Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SMB2 version specific operations |
| 3 | * |
| 4 | * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License v2 as published |
| 8 | * by the Free Software Foundation. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 13 | * the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public License |
| 16 | * along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
Pavel Shilovsky | 3a3bab5 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 20 | #include <linux/pagemap.h> |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 21 | #include <linux/vfs.h> |
Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 22 | #include "cifsglob.h" |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 23 | #include "smb2pdu.h" |
| 24 | #include "smb2proto.h" |
Pavel Shilovsky | 28ea529 | 2012-05-23 16:18:00 +0400 | [diff] [blame] | 25 | #include "cifsproto.h" |
| 26 | #include "cifs_debug.h" |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 27 | #include "smb2status.h" |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 28 | #include "smb2glob.h" |
Pavel Shilovsky | 28ea529 | 2012-05-23 16:18:00 +0400 | [diff] [blame] | 29 | |
| 30 | static int |
| 31 | change_conf(struct TCP_Server_Info *server) |
| 32 | { |
| 33 | server->credits += server->echo_credits + server->oplock_credits; |
| 34 | server->oplock_credits = server->echo_credits = 0; |
| 35 | switch (server->credits) { |
| 36 | case 0: |
| 37 | return -1; |
| 38 | case 1: |
| 39 | server->echoes = false; |
| 40 | server->oplocks = false; |
| 41 | cERROR(1, "disabling echoes and oplocks"); |
| 42 | break; |
| 43 | case 2: |
| 44 | server->echoes = true; |
| 45 | server->oplocks = false; |
| 46 | server->echo_credits = 1; |
| 47 | cFYI(1, "disabling oplocks"); |
| 48 | break; |
| 49 | default: |
| 50 | server->echoes = true; |
| 51 | server->oplocks = true; |
| 52 | server->echo_credits = 1; |
| 53 | server->oplock_credits = 1; |
| 54 | } |
| 55 | server->credits -= server->echo_credits + server->oplock_credits; |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | static void |
| 60 | smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add, |
| 61 | const int optype) |
| 62 | { |
| 63 | int *val, rc = 0; |
| 64 | spin_lock(&server->req_lock); |
| 65 | val = server->ops->get_credits_field(server, optype); |
| 66 | *val += add; |
| 67 | server->in_flight--; |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 68 | if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP) |
Pavel Shilovsky | 28ea529 | 2012-05-23 16:18:00 +0400 | [diff] [blame] | 69 | rc = change_conf(server); |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 70 | /* |
| 71 | * Sometimes server returns 0 credits on oplock break ack - we need to |
| 72 | * rebalance credits in this case. |
| 73 | */ |
| 74 | else if (server->in_flight > 0 && server->oplock_credits == 0 && |
| 75 | server->oplocks) { |
| 76 | if (server->credits > 1) { |
| 77 | server->credits--; |
| 78 | server->oplock_credits++; |
| 79 | } |
| 80 | } |
Pavel Shilovsky | 28ea529 | 2012-05-23 16:18:00 +0400 | [diff] [blame] | 81 | spin_unlock(&server->req_lock); |
| 82 | wake_up(&server->request_q); |
| 83 | if (rc) |
| 84 | cifs_reconnect(server); |
| 85 | } |
| 86 | |
| 87 | static void |
| 88 | smb2_set_credits(struct TCP_Server_Info *server, const int val) |
| 89 | { |
| 90 | spin_lock(&server->req_lock); |
| 91 | server->credits = val; |
| 92 | spin_unlock(&server->req_lock); |
| 93 | } |
| 94 | |
| 95 | static int * |
| 96 | smb2_get_credits_field(struct TCP_Server_Info *server, const int optype) |
| 97 | { |
| 98 | switch (optype) { |
| 99 | case CIFS_ECHO_OP: |
| 100 | return &server->echo_credits; |
| 101 | case CIFS_OBREAK_OP: |
| 102 | return &server->oplock_credits; |
| 103 | default: |
| 104 | return &server->credits; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | static unsigned int |
| 109 | smb2_get_credits(struct mid_q_entry *mid) |
| 110 | { |
| 111 | return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest); |
| 112 | } |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 113 | |
| 114 | static __u64 |
| 115 | smb2_get_next_mid(struct TCP_Server_Info *server) |
| 116 | { |
| 117 | __u64 mid; |
| 118 | /* for SMB2 we need the current value */ |
| 119 | spin_lock(&GlobalMid_Lock); |
| 120 | mid = server->CurrentMid++; |
| 121 | spin_unlock(&GlobalMid_Lock); |
| 122 | return mid; |
| 123 | } |
Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 124 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 125 | static struct mid_q_entry * |
| 126 | smb2_find_mid(struct TCP_Server_Info *server, char *buf) |
| 127 | { |
| 128 | struct mid_q_entry *mid; |
| 129 | struct smb2_hdr *hdr = (struct smb2_hdr *)buf; |
| 130 | |
| 131 | spin_lock(&GlobalMid_Lock); |
| 132 | list_for_each_entry(mid, &server->pending_mid_q, qhead) { |
| 133 | if ((mid->mid == hdr->MessageId) && |
| 134 | (mid->mid_state == MID_REQUEST_SUBMITTED) && |
| 135 | (mid->command == hdr->Command)) { |
| 136 | spin_unlock(&GlobalMid_Lock); |
| 137 | return mid; |
| 138 | } |
| 139 | } |
| 140 | spin_unlock(&GlobalMid_Lock); |
| 141 | return NULL; |
| 142 | } |
| 143 | |
| 144 | static void |
| 145 | smb2_dump_detail(void *buf) |
| 146 | { |
| 147 | #ifdef CONFIG_CIFS_DEBUG2 |
| 148 | struct smb2_hdr *smb = (struct smb2_hdr *)buf; |
| 149 | |
| 150 | cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d", |
| 151 | smb->Command, smb->Status, smb->Flags, smb->MessageId, |
| 152 | smb->ProcessId); |
| 153 | cERROR(1, "smb buf %p len %u", smb, smb2_calc_size(smb)); |
| 154 | #endif |
| 155 | } |
| 156 | |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 157 | static bool |
| 158 | smb2_need_neg(struct TCP_Server_Info *server) |
| 159 | { |
| 160 | return server->max_read == 0; |
| 161 | } |
| 162 | |
| 163 | static int |
| 164 | smb2_negotiate(const unsigned int xid, struct cifs_ses *ses) |
| 165 | { |
| 166 | int rc; |
| 167 | ses->server->CurrentMid = 0; |
| 168 | rc = SMB2_negotiate(xid, ses); |
| 169 | /* BB we probably don't need to retry with modern servers */ |
| 170 | if (rc == -EAGAIN) |
| 171 | rc = -EHOSTDOWN; |
| 172 | return rc; |
| 173 | } |
| 174 | |
Pavel Shilovsky | 3a3bab5 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 175 | static unsigned int |
| 176 | smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info) |
| 177 | { |
| 178 | struct TCP_Server_Info *server = tcon->ses->server; |
| 179 | unsigned int wsize; |
| 180 | |
| 181 | /* start with specified wsize, or default */ |
| 182 | wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE; |
| 183 | wsize = min_t(unsigned int, wsize, server->max_write); |
| 184 | /* |
| 185 | * limit write size to 2 ** 16, because we don't support multicredit |
| 186 | * requests now. |
| 187 | */ |
| 188 | wsize = min_t(unsigned int, wsize, 2 << 15); |
| 189 | |
Pavel Shilovsky | 3a3bab5 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 190 | return wsize; |
| 191 | } |
| 192 | |
| 193 | static unsigned int |
| 194 | smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info) |
| 195 | { |
| 196 | struct TCP_Server_Info *server = tcon->ses->server; |
| 197 | unsigned int rsize; |
| 198 | |
| 199 | /* start with specified rsize, or default */ |
| 200 | rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE; |
| 201 | rsize = min_t(unsigned int, rsize, server->max_read); |
| 202 | /* |
| 203 | * limit write size to 2 ** 16, because we don't support multicredit |
| 204 | * requests now. |
| 205 | */ |
| 206 | rsize = min_t(unsigned int, rsize, 2 << 15); |
| 207 | |
Pavel Shilovsky | 3a3bab5 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 208 | return rsize; |
| 209 | } |
| 210 | |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 211 | static int |
| 212 | smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, |
| 213 | struct cifs_sb_info *cifs_sb, const char *full_path) |
| 214 | { |
| 215 | int rc; |
| 216 | __u64 persistent_fid, volatile_fid; |
| 217 | __le16 *utf16_path; |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 218 | __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 219 | |
| 220 | utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb); |
| 221 | if (!utf16_path) |
| 222 | return -ENOMEM; |
| 223 | |
| 224 | rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 225 | FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL); |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 226 | if (rc) { |
| 227 | kfree(utf16_path); |
| 228 | return rc; |
| 229 | } |
| 230 | |
| 231 | rc = SMB2_close(xid, tcon, persistent_fid, volatile_fid); |
| 232 | kfree(utf16_path); |
| 233 | return rc; |
| 234 | } |
| 235 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 236 | static int |
| 237 | smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon, |
| 238 | struct cifs_sb_info *cifs_sb, const char *full_path, |
| 239 | u64 *uniqueid, FILE_ALL_INFO *data) |
| 240 | { |
| 241 | *uniqueid = le64_to_cpu(data->IndexNumber); |
| 242 | return 0; |
| 243 | } |
| 244 | |
Pavel Shilovsky | b7546bc | 2012-09-18 16:20:27 -0700 | [diff] [blame] | 245 | static int |
| 246 | smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon, |
| 247 | struct cifs_fid *fid, FILE_ALL_INFO *data) |
| 248 | { |
| 249 | int rc; |
| 250 | struct smb2_file_all_info *smb2_data; |
| 251 | |
| 252 | smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2, |
| 253 | GFP_KERNEL); |
| 254 | if (smb2_data == NULL) |
| 255 | return -ENOMEM; |
| 256 | |
| 257 | rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid, |
| 258 | smb2_data); |
| 259 | if (!rc) |
| 260 | move_smb2_info_to_cifs(data, smb2_data); |
| 261 | kfree(smb2_data); |
| 262 | return rc; |
| 263 | } |
| 264 | |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 265 | static bool |
| 266 | smb2_can_echo(struct TCP_Server_Info *server) |
| 267 | { |
| 268 | return server->echoes; |
| 269 | } |
| 270 | |
Pavel Shilovsky | d60622e | 2012-05-28 15:19:39 +0400 | [diff] [blame] | 271 | static void |
| 272 | smb2_clear_stats(struct cifs_tcon *tcon) |
| 273 | { |
| 274 | #ifdef CONFIG_CIFS_STATS |
| 275 | int i; |
| 276 | for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) { |
| 277 | atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0); |
| 278 | atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0); |
| 279 | } |
| 280 | #endif |
| 281 | } |
| 282 | |
| 283 | static void |
| 284 | smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon) |
| 285 | { |
| 286 | #ifdef CONFIG_CIFS_STATS |
| 287 | atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent; |
| 288 | atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed; |
| 289 | seq_printf(m, "\nNegotiates: %d sent %d failed", |
| 290 | atomic_read(&sent[SMB2_NEGOTIATE_HE]), |
| 291 | atomic_read(&failed[SMB2_NEGOTIATE_HE])); |
| 292 | seq_printf(m, "\nSessionSetups: %d sent %d failed", |
| 293 | atomic_read(&sent[SMB2_SESSION_SETUP_HE]), |
| 294 | atomic_read(&failed[SMB2_SESSION_SETUP_HE])); |
| 295 | #define SMB2LOGOFF 0x0002 /* trivial request/resp */ |
| 296 | seq_printf(m, "\nLogoffs: %d sent %d failed", |
| 297 | atomic_read(&sent[SMB2_LOGOFF_HE]), |
| 298 | atomic_read(&failed[SMB2_LOGOFF_HE])); |
| 299 | seq_printf(m, "\nTreeConnects: %d sent %d failed", |
| 300 | atomic_read(&sent[SMB2_TREE_CONNECT_HE]), |
| 301 | atomic_read(&failed[SMB2_TREE_CONNECT_HE])); |
| 302 | seq_printf(m, "\nTreeDisconnects: %d sent %d failed", |
| 303 | atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]), |
| 304 | atomic_read(&failed[SMB2_TREE_DISCONNECT_HE])); |
| 305 | seq_printf(m, "\nCreates: %d sent %d failed", |
| 306 | atomic_read(&sent[SMB2_CREATE_HE]), |
| 307 | atomic_read(&failed[SMB2_CREATE_HE])); |
| 308 | seq_printf(m, "\nCloses: %d sent %d failed", |
| 309 | atomic_read(&sent[SMB2_CLOSE_HE]), |
| 310 | atomic_read(&failed[SMB2_CLOSE_HE])); |
| 311 | seq_printf(m, "\nFlushes: %d sent %d failed", |
| 312 | atomic_read(&sent[SMB2_FLUSH_HE]), |
| 313 | atomic_read(&failed[SMB2_FLUSH_HE])); |
| 314 | seq_printf(m, "\nReads: %d sent %d failed", |
| 315 | atomic_read(&sent[SMB2_READ_HE]), |
| 316 | atomic_read(&failed[SMB2_READ_HE])); |
| 317 | seq_printf(m, "\nWrites: %d sent %d failed", |
| 318 | atomic_read(&sent[SMB2_WRITE_HE]), |
| 319 | atomic_read(&failed[SMB2_WRITE_HE])); |
| 320 | seq_printf(m, "\nLocks: %d sent %d failed", |
| 321 | atomic_read(&sent[SMB2_LOCK_HE]), |
| 322 | atomic_read(&failed[SMB2_LOCK_HE])); |
| 323 | seq_printf(m, "\nIOCTLs: %d sent %d failed", |
| 324 | atomic_read(&sent[SMB2_IOCTL_HE]), |
| 325 | atomic_read(&failed[SMB2_IOCTL_HE])); |
| 326 | seq_printf(m, "\nCancels: %d sent %d failed", |
| 327 | atomic_read(&sent[SMB2_CANCEL_HE]), |
| 328 | atomic_read(&failed[SMB2_CANCEL_HE])); |
| 329 | seq_printf(m, "\nEchos: %d sent %d failed", |
| 330 | atomic_read(&sent[SMB2_ECHO_HE]), |
| 331 | atomic_read(&failed[SMB2_ECHO_HE])); |
| 332 | seq_printf(m, "\nQueryDirectories: %d sent %d failed", |
| 333 | atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]), |
| 334 | atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE])); |
| 335 | seq_printf(m, "\nChangeNotifies: %d sent %d failed", |
| 336 | atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]), |
| 337 | atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE])); |
| 338 | seq_printf(m, "\nQueryInfos: %d sent %d failed", |
| 339 | atomic_read(&sent[SMB2_QUERY_INFO_HE]), |
| 340 | atomic_read(&failed[SMB2_QUERY_INFO_HE])); |
| 341 | seq_printf(m, "\nSetInfos: %d sent %d failed", |
| 342 | atomic_read(&sent[SMB2_SET_INFO_HE]), |
| 343 | atomic_read(&failed[SMB2_SET_INFO_HE])); |
| 344 | seq_printf(m, "\nOplockBreaks: %d sent %d failed", |
| 345 | atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]), |
| 346 | atomic_read(&failed[SMB2_OPLOCK_BREAK_HE])); |
| 347 | #endif |
| 348 | } |
| 349 | |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 350 | static void |
| 351 | smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) |
| 352 | { |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 353 | struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 354 | cfile->fid.persistent_fid = fid->persistent_fid; |
| 355 | cfile->fid.volatile_fid = fid->volatile_fid; |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 356 | smb2_set_oplock_level(cinode, oplock); |
Pavel Shilovsky | b140799 | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 357 | cinode->can_cache_brlcks = cinode->clientCanCacheAll; |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Pavel Shilovsky | 760ad0c | 2012-09-25 11:00:07 +0400 | [diff] [blame] | 360 | static void |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 361 | smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon, |
| 362 | struct cifs_fid *fid) |
| 363 | { |
Pavel Shilovsky | 760ad0c | 2012-09-25 11:00:07 +0400 | [diff] [blame] | 364 | SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid); |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 367 | static int |
| 368 | smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon, |
| 369 | struct cifs_fid *fid) |
| 370 | { |
| 371 | return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid); |
| 372 | } |
| 373 | |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 374 | static unsigned int |
| 375 | smb2_read_data_offset(char *buf) |
| 376 | { |
| 377 | struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf; |
| 378 | return rsp->DataOffset; |
| 379 | } |
| 380 | |
| 381 | static unsigned int |
| 382 | smb2_read_data_length(char *buf) |
| 383 | { |
| 384 | struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf; |
| 385 | return le32_to_cpu(rsp->DataLength); |
| 386 | } |
| 387 | |
Pavel Shilovsky | d8e0503 | 2012-09-18 16:20:30 -0700 | [diff] [blame] | 388 | |
| 389 | static int |
| 390 | smb2_sync_read(const unsigned int xid, struct cifsFileInfo *cfile, |
| 391 | struct cifs_io_parms *parms, unsigned int *bytes_read, |
| 392 | char **buf, int *buf_type) |
| 393 | { |
| 394 | parms->persistent_fid = cfile->fid.persistent_fid; |
| 395 | parms->volatile_fid = cfile->fid.volatile_fid; |
| 396 | return SMB2_read(xid, parms, bytes_read, buf, buf_type); |
| 397 | } |
| 398 | |
Pavel Shilovsky | 009d344 | 2012-09-18 16:20:30 -0700 | [diff] [blame] | 399 | static int |
| 400 | smb2_sync_write(const unsigned int xid, struct cifsFileInfo *cfile, |
| 401 | struct cifs_io_parms *parms, unsigned int *written, |
| 402 | struct kvec *iov, unsigned long nr_segs) |
| 403 | { |
| 404 | |
| 405 | parms->persistent_fid = cfile->fid.persistent_fid; |
| 406 | parms->volatile_fid = cfile->fid.volatile_fid; |
| 407 | return SMB2_write(xid, parms, written, iov, nr_segs); |
| 408 | } |
| 409 | |
Pavel Shilovsky | c839ff2 | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 410 | static int |
| 411 | smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon, |
| 412 | struct cifsFileInfo *cfile, __u64 size, bool set_alloc) |
| 413 | { |
| 414 | __le64 eof = cpu_to_le64(size); |
| 415 | return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, |
| 416 | cfile->fid.volatile_fid, cfile->pid, &eof); |
| 417 | } |
| 418 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 419 | static int |
| 420 | smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon, |
| 421 | const char *path, struct cifs_sb_info *cifs_sb, |
| 422 | struct cifs_fid *fid, __u16 search_flags, |
| 423 | struct cifs_search_info *srch_inf) |
| 424 | { |
| 425 | __le16 *utf16_path; |
| 426 | int rc; |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 427 | __u8 oplock = SMB2_OPLOCK_LEVEL_NONE; |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 428 | __u64 persistent_fid, volatile_fid; |
| 429 | |
| 430 | utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); |
| 431 | if (!utf16_path) |
| 432 | return -ENOMEM; |
| 433 | |
| 434 | rc = SMB2_open(xid, tcon, utf16_path, &persistent_fid, &volatile_fid, |
| 435 | FILE_READ_ATTRIBUTES | FILE_READ_DATA, FILE_OPEN, 0, 0, |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 436 | &oplock, NULL); |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 437 | kfree(utf16_path); |
| 438 | if (rc) { |
| 439 | cERROR(1, "open dir failed"); |
| 440 | return rc; |
| 441 | } |
| 442 | |
| 443 | srch_inf->entries_in_buffer = 0; |
| 444 | srch_inf->index_of_last_entry = 0; |
| 445 | fid->persistent_fid = persistent_fid; |
| 446 | fid->volatile_fid = volatile_fid; |
| 447 | |
| 448 | rc = SMB2_query_directory(xid, tcon, persistent_fid, volatile_fid, 0, |
| 449 | srch_inf); |
| 450 | if (rc) { |
| 451 | cERROR(1, "query directory failed"); |
| 452 | SMB2_close(xid, tcon, persistent_fid, volatile_fid); |
| 453 | } |
| 454 | return rc; |
| 455 | } |
| 456 | |
| 457 | static int |
| 458 | smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon, |
| 459 | struct cifs_fid *fid, __u16 search_flags, |
| 460 | struct cifs_search_info *srch_inf) |
| 461 | { |
| 462 | return SMB2_query_directory(xid, tcon, fid->persistent_fid, |
| 463 | fid->volatile_fid, 0, srch_inf); |
| 464 | } |
| 465 | |
| 466 | static int |
| 467 | smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon, |
| 468 | struct cifs_fid *fid) |
| 469 | { |
| 470 | return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid); |
| 471 | } |
| 472 | |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 473 | /* |
| 474 | * If we negotiate SMB2 protocol and get STATUS_PENDING - update |
| 475 | * the number of credits and return true. Otherwise - return false. |
| 476 | */ |
| 477 | static bool |
| 478 | smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length) |
| 479 | { |
| 480 | struct smb2_hdr *hdr = (struct smb2_hdr *)buf; |
| 481 | |
Steve French | 12e8a20 | 2012-09-19 09:19:39 -0700 | [diff] [blame] | 482 | if (hdr->Status != STATUS_PENDING) |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 483 | return false; |
| 484 | |
| 485 | if (!length) { |
| 486 | spin_lock(&server->req_lock); |
| 487 | server->credits += le16_to_cpu(hdr->CreditRequest); |
| 488 | spin_unlock(&server->req_lock); |
| 489 | wake_up(&server->request_q); |
| 490 | } |
| 491 | |
| 492 | return true; |
| 493 | } |
| 494 | |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 495 | static int |
| 496 | smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid, |
| 497 | struct cifsInodeInfo *cinode) |
| 498 | { |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 499 | if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) |
| 500 | return SMB2_lease_break(0, tcon, cinode->lease_key, |
| 501 | smb2_get_lease_state(cinode)); |
| 502 | |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 503 | return SMB2_oplock_break(0, tcon, fid->persistent_fid, |
| 504 | fid->volatile_fid, |
| 505 | cinode->clientCanCacheRead ? 1 : 0); |
| 506 | } |
| 507 | |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 508 | static int |
| 509 | smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon, |
| 510 | struct kstatfs *buf) |
| 511 | { |
| 512 | int rc; |
| 513 | u64 persistent_fid, volatile_fid; |
| 514 | __le16 srch_path = 0; /* Null - open root of share */ |
| 515 | u8 oplock = SMB2_OPLOCK_LEVEL_NONE; |
| 516 | |
| 517 | rc = SMB2_open(xid, tcon, &srch_path, &persistent_fid, &volatile_fid, |
| 518 | FILE_READ_ATTRIBUTES, FILE_OPEN, 0, 0, &oplock, NULL); |
| 519 | if (rc) |
| 520 | return rc; |
| 521 | buf->f_type = SMB2_MAGIC_NUMBER; |
| 522 | rc = SMB2_QFS_info(xid, tcon, persistent_fid, volatile_fid, buf); |
| 523 | SMB2_close(xid, tcon, persistent_fid, volatile_fid); |
| 524 | return rc; |
| 525 | } |
| 526 | |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 527 | static bool |
| 528 | smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2) |
| 529 | { |
| 530 | return ob1->fid.persistent_fid == ob2->fid.persistent_fid && |
| 531 | ob1->fid.volatile_fid == ob2->fid.volatile_fid; |
| 532 | } |
| 533 | |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 534 | static int |
| 535 | smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset, |
| 536 | __u64 length, __u32 type, int lock, int unlock, bool wait) |
| 537 | { |
| 538 | if (unlock && !lock) |
| 539 | type = SMB2_LOCKFLAG_UNLOCK; |
| 540 | return SMB2_lock(xid, tlink_tcon(cfile->tlink), |
| 541 | cfile->fid.persistent_fid, cfile->fid.volatile_fid, |
| 542 | current->tgid, length, offset, type, wait); |
| 543 | } |
| 544 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 545 | static void |
| 546 | smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid) |
| 547 | { |
| 548 | memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE); |
| 549 | } |
| 550 | |
| 551 | static void |
| 552 | smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid) |
| 553 | { |
| 554 | memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE); |
| 555 | } |
| 556 | |
| 557 | static void |
| 558 | smb2_new_lease_key(struct cifs_fid *fid) |
| 559 | { |
| 560 | get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE); |
| 561 | } |
| 562 | |
Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 563 | struct smb_version_operations smb21_operations = { |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 564 | .compare_fids = smb2_compare_fids, |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 565 | .setup_request = smb2_setup_request, |
Pavel Shilovsky | c95b8ee | 2012-07-11 14:45:28 +0400 | [diff] [blame] | 566 | .setup_async_request = smb2_setup_async_request, |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 567 | .check_receive = smb2_check_receive, |
Pavel Shilovsky | 28ea529 | 2012-05-23 16:18:00 +0400 | [diff] [blame] | 568 | .add_credits = smb2_add_credits, |
| 569 | .set_credits = smb2_set_credits, |
| 570 | .get_credits_field = smb2_get_credits_field, |
| 571 | .get_credits = smb2_get_credits, |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 572 | .get_next_mid = smb2_get_next_mid, |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 573 | .read_data_offset = smb2_read_data_offset, |
| 574 | .read_data_length = smb2_read_data_length, |
| 575 | .map_error = map_smb2_to_linux_error, |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 576 | .find_mid = smb2_find_mid, |
| 577 | .check_message = smb2_check_message, |
| 578 | .dump_detail = smb2_dump_detail, |
Pavel Shilovsky | d60622e | 2012-05-28 15:19:39 +0400 | [diff] [blame] | 579 | .clear_stats = smb2_clear_stats, |
| 580 | .print_stats = smb2_print_stats, |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 581 | .is_oplock_break = smb2_is_valid_oplock_break, |
Pavel Shilovsky | ec2e452 | 2011-12-27 16:12:43 +0400 | [diff] [blame] | 582 | .need_neg = smb2_need_neg, |
| 583 | .negotiate = smb2_negotiate, |
Pavel Shilovsky | 3a3bab5 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 584 | .negotiate_wsize = smb2_negotiate_wsize, |
| 585 | .negotiate_rsize = smb2_negotiate_rsize, |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 586 | .sess_setup = SMB2_sess_setup, |
| 587 | .logoff = SMB2_logoff, |
Pavel Shilovsky | faaf946 | 2011-12-27 16:04:00 +0400 | [diff] [blame] | 588 | .tree_connect = SMB2_tcon, |
| 589 | .tree_disconnect = SMB2_tdis, |
Pavel Shilovsky | 2503a0d | 2011-12-26 22:58:46 +0400 | [diff] [blame] | 590 | .is_path_accessible = smb2_is_path_accessible, |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 591 | .can_echo = smb2_can_echo, |
| 592 | .echo = SMB2_echo, |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 593 | .query_path_info = smb2_query_path_info, |
| 594 | .get_srv_inum = smb2_get_srv_inum, |
Pavel Shilovsky | b7546bc | 2012-09-18 16:20:27 -0700 | [diff] [blame] | 595 | .query_file_info = smb2_query_file_info, |
Pavel Shilovsky | c839ff2 | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 596 | .set_path_size = smb2_set_path_size, |
| 597 | .set_file_size = smb2_set_file_size, |
Pavel Shilovsky | 1feeaac | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 598 | .set_file_info = smb2_set_file_info, |
Pavel Shilovsky | a0e7318 | 2011-07-19 12:56:37 +0400 | [diff] [blame] | 599 | .mkdir = smb2_mkdir, |
| 600 | .mkdir_setinfo = smb2_mkdir_setinfo, |
Pavel Shilovsky | 1a500f0 | 2012-07-10 16:14:38 +0400 | [diff] [blame] | 601 | .rmdir = smb2_rmdir, |
Pavel Shilovsky | cbe6f43 | 2012-09-18 16:20:25 -0700 | [diff] [blame] | 602 | .unlink = smb2_unlink, |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 603 | .rename = smb2_rename_path, |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 604 | .create_hardlink = smb2_create_hardlink, |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 605 | .open = smb2_open_file, |
| 606 | .set_fid = smb2_set_fid, |
| 607 | .close = smb2_close_file, |
Pavel Shilovsky | 7a5cfb1 | 2012-09-18 16:20:28 -0700 | [diff] [blame] | 608 | .flush = smb2_flush_file, |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 609 | .async_readv = smb2_async_readv, |
Pavel Shilovsky | 3331914 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 610 | .async_writev = smb2_async_writev, |
Pavel Shilovsky | d8e0503 | 2012-09-18 16:20:30 -0700 | [diff] [blame] | 611 | .sync_read = smb2_sync_read, |
Pavel Shilovsky | 009d344 | 2012-09-18 16:20:30 -0700 | [diff] [blame] | 612 | .sync_write = smb2_sync_write, |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 613 | .query_dir_first = smb2_query_dir_first, |
| 614 | .query_dir_next = smb2_query_dir_next, |
| 615 | .close_dir = smb2_close_dir, |
| 616 | .calc_smb_size = smb2_calc_size, |
Pavel Shilovsky | 2e44b28 | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 617 | .is_status_pending = smb2_is_status_pending, |
Pavel Shilovsky | 983c88a | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 618 | .oplock_response = smb2_oplock_response, |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 619 | .queryfs = smb2_queryfs, |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 620 | .mand_lock = smb2_mand_lock, |
| 621 | .mand_unlock_range = smb2_unlock_range, |
Pavel Shilovsky | b140799 | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 622 | .push_mand_locks = smb2_push_mandatory_locks, |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 623 | .get_lease_key = smb2_get_lease_key, |
| 624 | .set_lease_key = smb2_set_lease_key, |
| 625 | .new_lease_key = smb2_new_lease_key, |
Steve French | 38107d4 | 2012-12-08 22:08:06 -0600 | [diff] [blame] | 626 | .calc_signature = smb2_calc_signature, |
| 627 | }; |
| 628 | |
| 629 | |
| 630 | struct smb_version_operations smb30_operations = { |
| 631 | .compare_fids = smb2_compare_fids, |
| 632 | .setup_request = smb2_setup_request, |
| 633 | .setup_async_request = smb2_setup_async_request, |
| 634 | .check_receive = smb2_check_receive, |
| 635 | .add_credits = smb2_add_credits, |
| 636 | .set_credits = smb2_set_credits, |
| 637 | .get_credits_field = smb2_get_credits_field, |
| 638 | .get_credits = smb2_get_credits, |
| 639 | .get_next_mid = smb2_get_next_mid, |
| 640 | .read_data_offset = smb2_read_data_offset, |
| 641 | .read_data_length = smb2_read_data_length, |
| 642 | .map_error = map_smb2_to_linux_error, |
| 643 | .find_mid = smb2_find_mid, |
| 644 | .check_message = smb2_check_message, |
| 645 | .dump_detail = smb2_dump_detail, |
| 646 | .clear_stats = smb2_clear_stats, |
| 647 | .print_stats = smb2_print_stats, |
| 648 | .is_oplock_break = smb2_is_valid_oplock_break, |
| 649 | .need_neg = smb2_need_neg, |
| 650 | .negotiate = smb2_negotiate, |
| 651 | .negotiate_wsize = smb2_negotiate_wsize, |
| 652 | .negotiate_rsize = smb2_negotiate_rsize, |
| 653 | .sess_setup = SMB2_sess_setup, |
| 654 | .logoff = SMB2_logoff, |
| 655 | .tree_connect = SMB2_tcon, |
| 656 | .tree_disconnect = SMB2_tdis, |
| 657 | .is_path_accessible = smb2_is_path_accessible, |
| 658 | .can_echo = smb2_can_echo, |
| 659 | .echo = SMB2_echo, |
| 660 | .query_path_info = smb2_query_path_info, |
| 661 | .get_srv_inum = smb2_get_srv_inum, |
| 662 | .query_file_info = smb2_query_file_info, |
| 663 | .set_path_size = smb2_set_path_size, |
| 664 | .set_file_size = smb2_set_file_size, |
| 665 | .set_file_info = smb2_set_file_info, |
| 666 | .mkdir = smb2_mkdir, |
| 667 | .mkdir_setinfo = smb2_mkdir_setinfo, |
| 668 | .rmdir = smb2_rmdir, |
| 669 | .unlink = smb2_unlink, |
| 670 | .rename = smb2_rename_path, |
| 671 | .create_hardlink = smb2_create_hardlink, |
| 672 | .open = smb2_open_file, |
| 673 | .set_fid = smb2_set_fid, |
| 674 | .close = smb2_close_file, |
| 675 | .flush = smb2_flush_file, |
| 676 | .async_readv = smb2_async_readv, |
| 677 | .async_writev = smb2_async_writev, |
| 678 | .sync_read = smb2_sync_read, |
| 679 | .sync_write = smb2_sync_write, |
| 680 | .query_dir_first = smb2_query_dir_first, |
| 681 | .query_dir_next = smb2_query_dir_next, |
| 682 | .close_dir = smb2_close_dir, |
| 683 | .calc_smb_size = smb2_calc_size, |
| 684 | .is_status_pending = smb2_is_status_pending, |
| 685 | .oplock_response = smb2_oplock_response, |
| 686 | .queryfs = smb2_queryfs, |
| 687 | .mand_lock = smb2_mand_lock, |
| 688 | .mand_unlock_range = smb2_unlock_range, |
| 689 | .push_mand_locks = smb2_push_mandatory_locks, |
| 690 | .get_lease_key = smb2_get_lease_key, |
| 691 | .set_lease_key = smb2_set_lease_key, |
| 692 | .new_lease_key = smb2_new_lease_key, |
| 693 | .calc_signature = smb3_calc_signature, |
Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 694 | }; |
| 695 | |
Steve French | dd446b1 | 2012-11-28 23:21:06 -0600 | [diff] [blame] | 696 | struct smb_version_values smb20_values = { |
| 697 | .version_string = SMB20_VERSION_STRING, |
| 698 | .protocol_id = SMB20_PROT_ID, |
| 699 | .req_capabilities = 0, /* MBZ */ |
| 700 | .large_lock_type = 0, |
| 701 | .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, |
| 702 | .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, |
| 703 | .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, |
| 704 | .header_size = sizeof(struct smb2_hdr), |
| 705 | .max_header_size = MAX_SMB2_HDR_SIZE, |
| 706 | .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, |
| 707 | .lock_cmd = SMB2_LOCK, |
| 708 | .cap_unix = 0, |
| 709 | .cap_nt_find = SMB2_NT_FIND, |
| 710 | .cap_large_files = SMB2_LARGE_FILES, |
Pavel Shilovsky | 63b7d3a | 2012-12-24 14:41:19 +0400 | [diff] [blame] | 711 | .oplock_read = SMB2_OPLOCK_LEVEL_II, |
Steve French | dd446b1 | 2012-11-28 23:21:06 -0600 | [diff] [blame] | 712 | }; |
| 713 | |
Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 714 | struct smb_version_values smb21_values = { |
| 715 | .version_string = SMB21_VERSION_STRING, |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 716 | .protocol_id = SMB21_PROT_ID, |
| 717 | .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */ |
| 718 | .large_lock_type = 0, |
| 719 | .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, |
| 720 | .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, |
| 721 | .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, |
| 722 | .header_size = sizeof(struct smb2_hdr), |
| 723 | .max_header_size = MAX_SMB2_HDR_SIZE, |
| 724 | .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, |
| 725 | .lock_cmd = SMB2_LOCK, |
| 726 | .cap_unix = 0, |
| 727 | .cap_nt_find = SMB2_NT_FIND, |
| 728 | .cap_large_files = SMB2_LARGE_FILES, |
Pavel Shilovsky | 63b7d3a | 2012-12-24 14:41:19 +0400 | [diff] [blame] | 729 | .oplock_read = SMB2_OPLOCK_LEVEL_II, |
Steve French | e4aa25e | 2012-10-01 12:26:22 -0500 | [diff] [blame] | 730 | }; |
| 731 | |
| 732 | struct smb_version_values smb30_values = { |
| 733 | .version_string = SMB30_VERSION_STRING, |
| 734 | .protocol_id = SMB30_PROT_ID, |
| 735 | .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU, |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 736 | .large_lock_type = 0, |
| 737 | .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK, |
| 738 | .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK, |
| 739 | .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK, |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 740 | .header_size = sizeof(struct smb2_hdr), |
| 741 | .max_header_size = MAX_SMB2_HDR_SIZE, |
Pavel Shilovsky | 09a4707 | 2012-09-18 16:20:29 -0700 | [diff] [blame] | 742 | .read_rsp_size = sizeof(struct smb2_read_rsp) - 1, |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 743 | .lock_cmd = SMB2_LOCK, |
Pavel Shilovsky | 29e20f9 | 2012-07-13 13:58:14 +0400 | [diff] [blame] | 744 | .cap_unix = 0, |
| 745 | .cap_nt_find = SMB2_NT_FIND, |
| 746 | .cap_large_files = SMB2_LARGE_FILES, |
Pavel Shilovsky | 067785c | 2013-03-06 19:38:36 +0400 | [diff] [blame] | 747 | .oplock_read = SMB2_OPLOCK_LEVEL_II, |
Steve French | 1080ef7 | 2011-02-24 18:07:19 +0000 | [diff] [blame] | 748 | }; |