2 * SMB2 version specific operations
4 * Copyright (c) 2012, Jeff Layton <jlayton@redhat.com>
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.
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.
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
20 #include <linux/pagemap.h>
21 #include <linux/vfs.h>
24 #include "smb2proto.h"
25 #include "cifsproto.h"
26 #include "cifs_debug.h"
27 #include "cifs_unicode.h"
28 #include "smb2status.h"
32 change_conf(struct TCP_Server_Info *server)
34 server->credits += server->echo_credits + server->oplock_credits;
35 server->oplock_credits = server->echo_credits = 0;
36 switch (server->credits) {
40 server->echoes = false;
41 server->oplocks = false;
42 cifs_dbg(VFS, "disabling echoes and oplocks\n");
45 server->echoes = true;
46 server->oplocks = false;
47 server->echo_credits = 1;
48 cifs_dbg(FYI, "disabling oplocks\n");
51 server->echoes = true;
52 server->oplocks = true;
53 server->echo_credits = 1;
54 server->oplock_credits = 1;
56 server->credits -= server->echo_credits + server->oplock_credits;
61 smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
65 spin_lock(&server->req_lock);
66 val = server->ops->get_credits_field(server, optype);
69 if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
70 rc = change_conf(server);
72 * Sometimes server returns 0 credits on oplock break ack - we need to
73 * rebalance credits in this case.
75 else if (server->in_flight > 0 && server->oplock_credits == 0 &&
77 if (server->credits > 1) {
79 server->oplock_credits++;
82 spin_unlock(&server->req_lock);
83 wake_up(&server->request_q);
85 cifs_reconnect(server);
89 smb2_set_credits(struct TCP_Server_Info *server, const int val)
91 spin_lock(&server->req_lock);
92 server->credits = val;
93 spin_unlock(&server->req_lock);
97 smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
101 return &server->echo_credits;
103 return &server->oplock_credits;
105 return &server->credits;
110 smb2_get_credits(struct mid_q_entry *mid)
112 return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
116 smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
117 unsigned int *num, unsigned int *credits)
120 unsigned int scredits;
122 spin_lock(&server->req_lock);
124 if (server->credits <= 0) {
125 spin_unlock(&server->req_lock);
126 cifs_num_waiters_inc(server);
127 rc = wait_event_killable(server->request_q,
128 has_credits(server, &server->credits));
129 cifs_num_waiters_dec(server);
132 spin_lock(&server->req_lock);
134 if (server->tcpStatus == CifsExiting) {
135 spin_unlock(&server->req_lock);
139 scredits = server->credits;
140 /* can deadlock with reopen */
142 *num = SMB2_MAX_BUFFER_SIZE;
147 /* leave one credit for a possible reopen */
149 *num = min_t(unsigned int, size,
150 scredits * SMB2_MAX_BUFFER_SIZE);
152 *credits = DIV_ROUND_UP(*num, SMB2_MAX_BUFFER_SIZE);
153 server->credits -= *credits;
158 spin_unlock(&server->req_lock);
163 smb2_get_next_mid(struct TCP_Server_Info *server)
166 /* for SMB2 we need the current value */
167 spin_lock(&GlobalMid_Lock);
168 mid = server->CurrentMid++;
169 spin_unlock(&GlobalMid_Lock);
173 static struct mid_q_entry *
174 smb2_find_mid(struct TCP_Server_Info *server, char *buf)
176 struct mid_q_entry *mid;
177 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
179 spin_lock(&GlobalMid_Lock);
180 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
181 if ((mid->mid == hdr->MessageId) &&
182 (mid->mid_state == MID_REQUEST_SUBMITTED) &&
183 (mid->command == hdr->Command)) {
184 spin_unlock(&GlobalMid_Lock);
188 spin_unlock(&GlobalMid_Lock);
193 smb2_dump_detail(void *buf)
195 #ifdef CONFIG_CIFS_DEBUG2
196 struct smb2_hdr *smb = (struct smb2_hdr *)buf;
198 cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
199 smb->Command, smb->Status, smb->Flags, smb->MessageId,
201 cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
206 smb2_need_neg(struct TCP_Server_Info *server)
208 return server->max_read == 0;
212 smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
215 ses->server->CurrentMid = 0;
216 rc = SMB2_negotiate(xid, ses);
217 /* BB we probably don't need to retry with modern servers */
224 smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
226 struct TCP_Server_Info *server = tcon->ses->server;
229 /* start with specified wsize, or default */
230 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
231 wsize = min_t(unsigned int, wsize, server->max_write);
233 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
234 wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
240 smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
242 struct TCP_Server_Info *server = tcon->ses->server;
245 /* start with specified rsize, or default */
246 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
247 rsize = min_t(unsigned int, rsize, server->max_read);
248 /* set it to the maximum buffer size value we can send with 1 credit */
249 rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
254 #ifdef CONFIG_CIFS_STATS2
256 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
259 unsigned int ret_data_len = 0;
260 struct network_interface_info_ioctl_rsp *out_buf;
262 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
263 FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */,
264 NULL /* no data input */, 0 /* no data input */,
265 (char **)&out_buf, &ret_data_len);
267 if ((rc == 0) && (ret_data_len > 0)) {
268 /* Dump info on first interface */
269 cifs_dbg(FYI, "Adapter Capability 0x%x\t",
270 le32_to_cpu(out_buf->Capability));
271 cifs_dbg(FYI, "Link Speed %lld\n",
272 le64_to_cpu(out_buf->LinkSpeed));
274 cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
281 smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
284 __le16 srch_path = 0; /* Null - open root of share */
285 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
286 struct cifs_open_parms oparms;
290 oparms.desired_access = FILE_READ_ATTRIBUTES;
291 oparms.disposition = FILE_OPEN;
292 oparms.create_options = 0;
294 oparms.reconnect = false;
296 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
300 #ifdef CONFIG_CIFS_STATS2
301 SMB3_request_interfaces(xid, tcon);
304 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
305 FS_ATTRIBUTE_INFORMATION);
306 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
307 FS_DEVICE_INFORMATION);
308 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
309 FS_SECTOR_SIZE_INFORMATION); /* SMB3 specific */
310 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
315 smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
318 __le16 srch_path = 0; /* Null - open root of share */
319 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
320 struct cifs_open_parms oparms;
324 oparms.desired_access = FILE_READ_ATTRIBUTES;
325 oparms.disposition = FILE_OPEN;
326 oparms.create_options = 0;
328 oparms.reconnect = false;
330 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
334 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
335 FS_ATTRIBUTE_INFORMATION);
336 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
337 FS_DEVICE_INFORMATION);
338 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
343 smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
344 struct cifs_sb_info *cifs_sb, const char *full_path)
348 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
349 struct cifs_open_parms oparms;
352 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
357 oparms.desired_access = FILE_READ_ATTRIBUTES;
358 oparms.disposition = FILE_OPEN;
359 oparms.create_options = 0;
361 oparms.reconnect = false;
363 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
369 rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
375 smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
376 struct cifs_sb_info *cifs_sb, const char *full_path,
377 u64 *uniqueid, FILE_ALL_INFO *data)
379 *uniqueid = le64_to_cpu(data->IndexNumber);
384 smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
385 struct cifs_fid *fid, FILE_ALL_INFO *data)
388 struct smb2_file_all_info *smb2_data;
390 smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + MAX_NAME * 2,
392 if (smb2_data == NULL)
395 rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
398 move_smb2_info_to_cifs(data, smb2_data);
404 smb2_can_echo(struct TCP_Server_Info *server)
406 return server->echoes;
410 smb2_clear_stats(struct cifs_tcon *tcon)
412 #ifdef CONFIG_CIFS_STATS
414 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
415 atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
416 atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
422 smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon)
424 seq_puts(m, "\n\tShare Capabilities:");
425 if (tcon->capabilities & SMB2_SHARE_CAP_DFS)
426 seq_puts(m, " DFS,");
427 if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
428 seq_puts(m, " CONTINUOUS AVAILABILITY,");
429 if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT)
430 seq_puts(m, " SCALEOUT,");
431 if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER)
432 seq_puts(m, " CLUSTER,");
433 if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC)
434 seq_puts(m, " ASYMMETRIC,");
435 if (tcon->capabilities == 0)
436 seq_puts(m, " None");
437 if (tcon->ss_flags & SSINFO_FLAGS_ALIGNED_DEVICE)
438 seq_puts(m, " Aligned,");
439 if (tcon->ss_flags & SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE)
440 seq_puts(m, " Partition Aligned,");
441 if (tcon->ss_flags & SSINFO_FLAGS_NO_SEEK_PENALTY)
442 seq_puts(m, " SSD,");
443 if (tcon->ss_flags & SSINFO_FLAGS_TRIM_ENABLED)
444 seq_puts(m, " TRIM-support,");
446 seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags);
447 if (tcon->perf_sector_size)
448 seq_printf(m, "\tOptimal sector size: 0x%x",
449 tcon->perf_sector_size);
453 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
455 #ifdef CONFIG_CIFS_STATS
456 atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
457 atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
458 seq_printf(m, "\nNegotiates: %d sent %d failed",
459 atomic_read(&sent[SMB2_NEGOTIATE_HE]),
460 atomic_read(&failed[SMB2_NEGOTIATE_HE]));
461 seq_printf(m, "\nSessionSetups: %d sent %d failed",
462 atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
463 atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
464 seq_printf(m, "\nLogoffs: %d sent %d failed",
465 atomic_read(&sent[SMB2_LOGOFF_HE]),
466 atomic_read(&failed[SMB2_LOGOFF_HE]));
467 seq_printf(m, "\nTreeConnects: %d sent %d failed",
468 atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
469 atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
470 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
471 atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
472 atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
473 seq_printf(m, "\nCreates: %d sent %d failed",
474 atomic_read(&sent[SMB2_CREATE_HE]),
475 atomic_read(&failed[SMB2_CREATE_HE]));
476 seq_printf(m, "\nCloses: %d sent %d failed",
477 atomic_read(&sent[SMB2_CLOSE_HE]),
478 atomic_read(&failed[SMB2_CLOSE_HE]));
479 seq_printf(m, "\nFlushes: %d sent %d failed",
480 atomic_read(&sent[SMB2_FLUSH_HE]),
481 atomic_read(&failed[SMB2_FLUSH_HE]));
482 seq_printf(m, "\nReads: %d sent %d failed",
483 atomic_read(&sent[SMB2_READ_HE]),
484 atomic_read(&failed[SMB2_READ_HE]));
485 seq_printf(m, "\nWrites: %d sent %d failed",
486 atomic_read(&sent[SMB2_WRITE_HE]),
487 atomic_read(&failed[SMB2_WRITE_HE]));
488 seq_printf(m, "\nLocks: %d sent %d failed",
489 atomic_read(&sent[SMB2_LOCK_HE]),
490 atomic_read(&failed[SMB2_LOCK_HE]));
491 seq_printf(m, "\nIOCTLs: %d sent %d failed",
492 atomic_read(&sent[SMB2_IOCTL_HE]),
493 atomic_read(&failed[SMB2_IOCTL_HE]));
494 seq_printf(m, "\nCancels: %d sent %d failed",
495 atomic_read(&sent[SMB2_CANCEL_HE]),
496 atomic_read(&failed[SMB2_CANCEL_HE]));
497 seq_printf(m, "\nEchos: %d sent %d failed",
498 atomic_read(&sent[SMB2_ECHO_HE]),
499 atomic_read(&failed[SMB2_ECHO_HE]));
500 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
501 atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
502 atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
503 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
504 atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
505 atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
506 seq_printf(m, "\nQueryInfos: %d sent %d failed",
507 atomic_read(&sent[SMB2_QUERY_INFO_HE]),
508 atomic_read(&failed[SMB2_QUERY_INFO_HE]));
509 seq_printf(m, "\nSetInfos: %d sent %d failed",
510 atomic_read(&sent[SMB2_SET_INFO_HE]),
511 atomic_read(&failed[SMB2_SET_INFO_HE]));
512 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
513 atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
514 atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
519 smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
521 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
522 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
524 cfile->fid.persistent_fid = fid->persistent_fid;
525 cfile->fid.volatile_fid = fid->volatile_fid;
526 server->ops->set_oplock_level(cinode, oplock, fid->epoch,
528 cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
532 smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
533 struct cifs_fid *fid)
535 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
539 SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
540 u64 persistent_fid, u64 volatile_fid,
541 struct copychunk_ioctl *pcchunk)
544 unsigned int ret_data_len;
545 struct resume_key_req *res_key;
547 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
548 FSCTL_SRV_REQUEST_RESUME_KEY, true /* is_fsctl */,
549 NULL, 0 /* no input */,
550 (char **)&res_key, &ret_data_len);
553 cifs_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
554 goto req_res_key_exit;
556 if (ret_data_len < sizeof(struct resume_key_req)) {
557 cifs_dbg(VFS, "Invalid refcopy resume key length\n");
559 goto req_res_key_exit;
561 memcpy(pcchunk->SourceKey, res_key->ResumeKey, COPY_CHUNK_RES_KEY_SIZE);
569 smb2_clone_range(const unsigned int xid,
570 struct cifsFileInfo *srcfile,
571 struct cifsFileInfo *trgtfile, u64 src_off,
572 u64 len, u64 dest_off)
575 unsigned int ret_data_len;
576 struct copychunk_ioctl *pcchunk;
577 struct copychunk_ioctl_rsp *retbuf = NULL;
578 struct cifs_tcon *tcon;
579 int chunks_copied = 0;
580 bool chunk_sizes_updated = false;
582 pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
587 cifs_dbg(FYI, "in smb2_clone_range - about to call request res key\n");
588 /* Request a key from the server to identify the source of the copy */
589 rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink),
590 srcfile->fid.persistent_fid,
591 srcfile->fid.volatile_fid, pcchunk);
593 /* Note: request_res_key sets res_key null only if rc !=0 */
597 /* For now array only one chunk long, will make more flexible later */
598 pcchunk->ChunkCount = __constant_cpu_to_le32(1);
599 pcchunk->Reserved = 0;
600 pcchunk->Reserved2 = 0;
602 tcon = tlink_tcon(trgtfile->tlink);
605 pcchunk->SourceOffset = cpu_to_le64(src_off);
606 pcchunk->TargetOffset = cpu_to_le64(dest_off);
608 cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
610 /* Request server copy to target from src identified by key */
611 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
612 trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
613 true /* is_fsctl */, (char *)pcchunk,
614 sizeof(struct copychunk_ioctl), (char **)&retbuf,
618 sizeof(struct copychunk_ioctl_rsp)) {
619 cifs_dbg(VFS, "invalid cchunk response size\n");
623 if (retbuf->TotalBytesWritten == 0) {
624 cifs_dbg(FYI, "no bytes copied\n");
629 * Check if server claimed to write more than we asked
631 if (le32_to_cpu(retbuf->TotalBytesWritten) >
632 le32_to_cpu(pcchunk->Length)) {
633 cifs_dbg(VFS, "invalid copy chunk response\n");
637 if (le32_to_cpu(retbuf->ChunksWritten) != 1) {
638 cifs_dbg(VFS, "invalid num chunks written\n");
644 src_off += le32_to_cpu(retbuf->TotalBytesWritten);
645 dest_off += le32_to_cpu(retbuf->TotalBytesWritten);
646 len -= le32_to_cpu(retbuf->TotalBytesWritten);
648 cifs_dbg(FYI, "Chunks %d PartialChunk %d Total %d\n",
649 le32_to_cpu(retbuf->ChunksWritten),
650 le32_to_cpu(retbuf->ChunkBytesWritten),
651 le32_to_cpu(retbuf->TotalBytesWritten));
652 } else if (rc == -EINVAL) {
653 if (ret_data_len != sizeof(struct copychunk_ioctl_rsp))
656 cifs_dbg(FYI, "MaxChunks %d BytesChunk %d MaxCopy %d\n",
657 le32_to_cpu(retbuf->ChunksWritten),
658 le32_to_cpu(retbuf->ChunkBytesWritten),
659 le32_to_cpu(retbuf->TotalBytesWritten));
662 * Check if this is the first request using these sizes,
663 * (ie check if copy succeed once with original sizes
664 * and check if the server gave us different sizes after
665 * we already updated max sizes on previous request).
666 * if not then why is the server returning an error now
668 if ((chunks_copied != 0) || chunk_sizes_updated)
671 /* Check that server is not asking us to grow size */
672 if (le32_to_cpu(retbuf->ChunkBytesWritten) <
673 tcon->max_bytes_chunk)
674 tcon->max_bytes_chunk =
675 le32_to_cpu(retbuf->ChunkBytesWritten);
677 goto cchunk_out; /* server gave us bogus size */
679 /* No need to change MaxChunks since already set to 1 */
680 chunk_sizes_updated = true;
690 smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
691 struct cifs_fid *fid)
693 return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
697 smb2_read_data_offset(char *buf)
699 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
700 return rsp->DataOffset;
704 smb2_read_data_length(char *buf)
706 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
707 return le32_to_cpu(rsp->DataLength);
712 smb2_sync_read(const unsigned int xid, struct cifsFileInfo *cfile,
713 struct cifs_io_parms *parms, unsigned int *bytes_read,
714 char **buf, int *buf_type)
716 parms->persistent_fid = cfile->fid.persistent_fid;
717 parms->volatile_fid = cfile->fid.volatile_fid;
718 return SMB2_read(xid, parms, bytes_read, buf, buf_type);
722 smb2_sync_write(const unsigned int xid, struct cifsFileInfo *cfile,
723 struct cifs_io_parms *parms, unsigned int *written,
724 struct kvec *iov, unsigned long nr_segs)
727 parms->persistent_fid = cfile->fid.persistent_fid;
728 parms->volatile_fid = cfile->fid.volatile_fid;
729 return SMB2_write(xid, parms, written, iov, nr_segs);
733 smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
734 struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
736 __le64 eof = cpu_to_le64(size);
737 return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
738 cfile->fid.volatile_fid, cfile->pid, &eof);
742 smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
743 struct cifsFileInfo *cfile)
745 return SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid,
746 cfile->fid.volatile_fid);
750 smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
751 const char *path, struct cifs_sb_info *cifs_sb,
752 struct cifs_fid *fid, __u16 search_flags,
753 struct cifs_search_info *srch_inf)
757 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
758 struct cifs_open_parms oparms;
760 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
765 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
766 oparms.disposition = FILE_OPEN;
767 oparms.create_options = 0;
769 oparms.reconnect = false;
771 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
774 cifs_dbg(VFS, "open dir failed\n");
778 srch_inf->entries_in_buffer = 0;
779 srch_inf->index_of_last_entry = 0;
781 rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
782 fid->volatile_fid, 0, srch_inf);
784 cifs_dbg(VFS, "query directory failed\n");
785 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
791 smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
792 struct cifs_fid *fid, __u16 search_flags,
793 struct cifs_search_info *srch_inf)
795 return SMB2_query_directory(xid, tcon, fid->persistent_fid,
796 fid->volatile_fid, 0, srch_inf);
800 smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
801 struct cifs_fid *fid)
803 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
807 * If we negotiate SMB2 protocol and get STATUS_PENDING - update
808 * the number of credits and return true. Otherwise - return false.
811 smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
813 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
815 if (hdr->Status != STATUS_PENDING)
819 spin_lock(&server->req_lock);
820 server->credits += le16_to_cpu(hdr->CreditRequest);
821 spin_unlock(&server->req_lock);
822 wake_up(&server->request_q);
829 smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
830 struct cifsInodeInfo *cinode)
832 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
833 return SMB2_lease_break(0, tcon, cinode->lease_key,
834 smb2_get_lease_state(cinode));
836 return SMB2_oplock_break(0, tcon, fid->persistent_fid,
838 CIFS_CACHE_READ(cinode) ? 1 : 0);
842 smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
846 __le16 srch_path = 0; /* Null - open root of share */
847 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
848 struct cifs_open_parms oparms;
852 oparms.desired_access = FILE_READ_ATTRIBUTES;
853 oparms.disposition = FILE_OPEN;
854 oparms.create_options = 0;
856 oparms.reconnect = false;
858 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
861 buf->f_type = SMB2_MAGIC_NUMBER;
862 rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
864 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
869 smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
871 return ob1->fid.persistent_fid == ob2->fid.persistent_fid &&
872 ob1->fid.volatile_fid == ob2->fid.volatile_fid;
876 smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
877 __u64 length, __u32 type, int lock, int unlock, bool wait)
880 type = SMB2_LOCKFLAG_UNLOCK;
881 return SMB2_lock(xid, tlink_tcon(cfile->tlink),
882 cfile->fid.persistent_fid, cfile->fid.volatile_fid,
883 current->tgid, length, offset, type, wait);
887 smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid)
889 memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE);
893 smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid)
895 memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
899 smb2_new_lease_key(struct cifs_fid *fid)
901 get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE);
905 smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
906 const char *full_path, char **target_path,
907 struct cifs_sb_info *cifs_sb)
911 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
912 struct cifs_open_parms oparms;
914 struct smb2_err_rsp *err_buf = NULL;
915 struct smb2_symlink_err_rsp *symlink;
916 unsigned int sub_len, sub_offset;
918 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
920 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
925 oparms.desired_access = FILE_READ_ATTRIBUTES;
926 oparms.disposition = FILE_OPEN;
927 oparms.create_options = 0;
929 oparms.reconnect = false;
931 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
933 if (!rc || !err_buf) {
937 /* open must fail on symlink - reset rc */
939 symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;
940 sub_len = le16_to_cpu(symlink->SubstituteNameLength);
941 sub_offset = le16_to_cpu(symlink->SubstituteNameOffset);
942 *target_path = cifs_strndup_from_utf16(
943 (char *)symlink->PathBuffer + sub_offset,
944 sub_len, true, cifs_sb->local_nls);
945 if (!(*target_path)) {
949 convert_delimiter(*target_path, '/');
950 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
956 smb2_downgrade_oplock(struct TCP_Server_Info *server,
957 struct cifsInodeInfo *cinode, bool set_level2)
960 server->ops->set_oplock_level(cinode, SMB2_OPLOCK_LEVEL_II,
963 server->ops->set_oplock_level(cinode, 0, 0, NULL);
967 smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
968 unsigned int epoch, bool *purge_cache)
971 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
973 if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
974 cinode->oplock = CIFS_CACHE_RHW_FLG;
975 cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
977 } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
978 cinode->oplock = CIFS_CACHE_RW_FLG;
979 cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
981 } else if (oplock == SMB2_OPLOCK_LEVEL_II) {
982 cinode->oplock = CIFS_CACHE_READ_FLG;
983 cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
990 smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
991 unsigned int epoch, bool *purge_cache)
993 char message[5] = {0};
996 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
1000 if (oplock & SMB2_LEASE_READ_CACHING_HE) {
1001 cinode->oplock |= CIFS_CACHE_READ_FLG;
1002 strcat(message, "R");
1004 if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
1005 cinode->oplock |= CIFS_CACHE_HANDLE_FLG;
1006 strcat(message, "H");
1008 if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
1009 cinode->oplock |= CIFS_CACHE_WRITE_FLG;
1010 strcat(message, "W");
1012 if (!cinode->oplock)
1013 strcat(message, "None");
1014 cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
1015 &cinode->vfs_inode);
1019 smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1020 unsigned int epoch, bool *purge_cache)
1022 unsigned int old_oplock = cinode->oplock;
1024 smb21_set_oplock_level(cinode, oplock, epoch, purge_cache);
1027 *purge_cache = false;
1028 if (old_oplock == CIFS_CACHE_READ_FLG) {
1029 if (cinode->oplock == CIFS_CACHE_READ_FLG &&
1030 (epoch - cinode->epoch > 0))
1031 *purge_cache = true;
1032 else if (cinode->oplock == CIFS_CACHE_RH_FLG &&
1033 (epoch - cinode->epoch > 1))
1034 *purge_cache = true;
1035 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
1036 (epoch - cinode->epoch > 1))
1037 *purge_cache = true;
1038 else if (cinode->oplock == 0 &&
1039 (epoch - cinode->epoch > 0))
1040 *purge_cache = true;
1041 } else if (old_oplock == CIFS_CACHE_RH_FLG) {
1042 if (cinode->oplock == CIFS_CACHE_RH_FLG &&
1043 (epoch - cinode->epoch > 0))
1044 *purge_cache = true;
1045 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
1046 (epoch - cinode->epoch > 1))
1047 *purge_cache = true;
1049 cinode->epoch = epoch;
1054 smb2_is_read_op(__u32 oplock)
1056 return oplock == SMB2_OPLOCK_LEVEL_II;
1060 smb21_is_read_op(__u32 oplock)
1062 return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
1063 !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
1067 map_oplock_to_lease(u8 oplock)
1069 if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE)
1070 return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING;
1071 else if (oplock == SMB2_OPLOCK_LEVEL_II)
1072 return SMB2_LEASE_READ_CACHING;
1073 else if (oplock == SMB2_OPLOCK_LEVEL_BATCH)
1074 return SMB2_LEASE_HANDLE_CACHING | SMB2_LEASE_READ_CACHING |
1075 SMB2_LEASE_WRITE_CACHING;
1080 smb2_create_lease_buf(u8 *lease_key, u8 oplock)
1082 struct create_lease *buf;
1084 buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
1088 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
1089 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
1090 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
1092 buf->ccontext.DataOffset = cpu_to_le16(offsetof
1093 (struct create_lease, lcontext));
1094 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context));
1095 buf->ccontext.NameOffset = cpu_to_le16(offsetof
1096 (struct create_lease, Name));
1097 buf->ccontext.NameLength = cpu_to_le16(4);
1098 /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
1107 smb3_create_lease_buf(u8 *lease_key, u8 oplock)
1109 struct create_lease_v2 *buf;
1111 buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL);
1115 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
1116 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
1117 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
1119 buf->ccontext.DataOffset = cpu_to_le16(offsetof
1120 (struct create_lease_v2, lcontext));
1121 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
1122 buf->ccontext.NameOffset = cpu_to_le16(offsetof
1123 (struct create_lease_v2, Name));
1124 buf->ccontext.NameLength = cpu_to_le16(4);
1125 /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
1134 smb2_parse_lease_buf(void *buf, unsigned int *epoch)
1136 struct create_lease *lc = (struct create_lease *)buf;
1138 *epoch = 0; /* not used */
1139 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
1140 return SMB2_OPLOCK_LEVEL_NOCHANGE;
1141 return le32_to_cpu(lc->lcontext.LeaseState);
1145 smb3_parse_lease_buf(void *buf, unsigned int *epoch)
1147 struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
1149 *epoch = le16_to_cpu(lc->lcontext.Epoch);
1150 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
1151 return SMB2_OPLOCK_LEVEL_NOCHANGE;
1152 return le32_to_cpu(lc->lcontext.LeaseState);
1156 smb2_wp_retry_size(struct inode *inode)
1158 return min_t(unsigned int, CIFS_SB(inode->i_sb)->wsize,
1159 SMB2_MAX_BUFFER_SIZE);
1162 struct smb_version_operations smb20_operations = {
1163 .compare_fids = smb2_compare_fids,
1164 .setup_request = smb2_setup_request,
1165 .setup_async_request = smb2_setup_async_request,
1166 .check_receive = smb2_check_receive,
1167 .add_credits = smb2_add_credits,
1168 .set_credits = smb2_set_credits,
1169 .get_credits_field = smb2_get_credits_field,
1170 .get_credits = smb2_get_credits,
1171 .wait_mtu_credits = cifs_wait_mtu_credits,
1172 .get_next_mid = smb2_get_next_mid,
1173 .read_data_offset = smb2_read_data_offset,
1174 .read_data_length = smb2_read_data_length,
1175 .map_error = map_smb2_to_linux_error,
1176 .find_mid = smb2_find_mid,
1177 .check_message = smb2_check_message,
1178 .dump_detail = smb2_dump_detail,
1179 .clear_stats = smb2_clear_stats,
1180 .print_stats = smb2_print_stats,
1181 .is_oplock_break = smb2_is_valid_oplock_break,
1182 .downgrade_oplock = smb2_downgrade_oplock,
1183 .need_neg = smb2_need_neg,
1184 .negotiate = smb2_negotiate,
1185 .negotiate_wsize = smb2_negotiate_wsize,
1186 .negotiate_rsize = smb2_negotiate_rsize,
1187 .sess_setup = SMB2_sess_setup,
1188 .logoff = SMB2_logoff,
1189 .tree_connect = SMB2_tcon,
1190 .tree_disconnect = SMB2_tdis,
1191 .qfs_tcon = smb2_qfs_tcon,
1192 .is_path_accessible = smb2_is_path_accessible,
1193 .can_echo = smb2_can_echo,
1195 .query_path_info = smb2_query_path_info,
1196 .get_srv_inum = smb2_get_srv_inum,
1197 .query_file_info = smb2_query_file_info,
1198 .set_path_size = smb2_set_path_size,
1199 .set_file_size = smb2_set_file_size,
1200 .set_file_info = smb2_set_file_info,
1201 .set_compression = smb2_set_compression,
1202 .mkdir = smb2_mkdir,
1203 .mkdir_setinfo = smb2_mkdir_setinfo,
1204 .rmdir = smb2_rmdir,
1205 .unlink = smb2_unlink,
1206 .rename = smb2_rename_path,
1207 .create_hardlink = smb2_create_hardlink,
1208 .query_symlink = smb2_query_symlink,
1209 .open = smb2_open_file,
1210 .set_fid = smb2_set_fid,
1211 .close = smb2_close_file,
1212 .flush = smb2_flush_file,
1213 .async_readv = smb2_async_readv,
1214 .async_writev = smb2_async_writev,
1215 .sync_read = smb2_sync_read,
1216 .sync_write = smb2_sync_write,
1217 .query_dir_first = smb2_query_dir_first,
1218 .query_dir_next = smb2_query_dir_next,
1219 .close_dir = smb2_close_dir,
1220 .calc_smb_size = smb2_calc_size,
1221 .is_status_pending = smb2_is_status_pending,
1222 .oplock_response = smb2_oplock_response,
1223 .queryfs = smb2_queryfs,
1224 .mand_lock = smb2_mand_lock,
1225 .mand_unlock_range = smb2_unlock_range,
1226 .push_mand_locks = smb2_push_mandatory_locks,
1227 .get_lease_key = smb2_get_lease_key,
1228 .set_lease_key = smb2_set_lease_key,
1229 .new_lease_key = smb2_new_lease_key,
1230 .calc_signature = smb2_calc_signature,
1231 .is_read_op = smb2_is_read_op,
1232 .set_oplock_level = smb2_set_oplock_level,
1233 .create_lease_buf = smb2_create_lease_buf,
1234 .parse_lease_buf = smb2_parse_lease_buf,
1235 .clone_range = smb2_clone_range,
1236 .wp_retry_size = smb2_wp_retry_size,
1239 struct smb_version_operations smb21_operations = {
1240 .compare_fids = smb2_compare_fids,
1241 .setup_request = smb2_setup_request,
1242 .setup_async_request = smb2_setup_async_request,
1243 .check_receive = smb2_check_receive,
1244 .add_credits = smb2_add_credits,
1245 .set_credits = smb2_set_credits,
1246 .get_credits_field = smb2_get_credits_field,
1247 .get_credits = smb2_get_credits,
1248 .wait_mtu_credits = smb2_wait_mtu_credits,
1249 .get_next_mid = smb2_get_next_mid,
1250 .read_data_offset = smb2_read_data_offset,
1251 .read_data_length = smb2_read_data_length,
1252 .map_error = map_smb2_to_linux_error,
1253 .find_mid = smb2_find_mid,
1254 .check_message = smb2_check_message,
1255 .dump_detail = smb2_dump_detail,
1256 .clear_stats = smb2_clear_stats,
1257 .print_stats = smb2_print_stats,
1258 .is_oplock_break = smb2_is_valid_oplock_break,
1259 .downgrade_oplock = smb2_downgrade_oplock,
1260 .need_neg = smb2_need_neg,
1261 .negotiate = smb2_negotiate,
1262 .negotiate_wsize = smb2_negotiate_wsize,
1263 .negotiate_rsize = smb2_negotiate_rsize,
1264 .sess_setup = SMB2_sess_setup,
1265 .logoff = SMB2_logoff,
1266 .tree_connect = SMB2_tcon,
1267 .tree_disconnect = SMB2_tdis,
1268 .qfs_tcon = smb2_qfs_tcon,
1269 .is_path_accessible = smb2_is_path_accessible,
1270 .can_echo = smb2_can_echo,
1272 .query_path_info = smb2_query_path_info,
1273 .get_srv_inum = smb2_get_srv_inum,
1274 .query_file_info = smb2_query_file_info,
1275 .set_path_size = smb2_set_path_size,
1276 .set_file_size = smb2_set_file_size,
1277 .set_file_info = smb2_set_file_info,
1278 .set_compression = smb2_set_compression,
1279 .mkdir = smb2_mkdir,
1280 .mkdir_setinfo = smb2_mkdir_setinfo,
1281 .rmdir = smb2_rmdir,
1282 .unlink = smb2_unlink,
1283 .rename = smb2_rename_path,
1284 .create_hardlink = smb2_create_hardlink,
1285 .query_symlink = smb2_query_symlink,
1286 .open = smb2_open_file,
1287 .set_fid = smb2_set_fid,
1288 .close = smb2_close_file,
1289 .flush = smb2_flush_file,
1290 .async_readv = smb2_async_readv,
1291 .async_writev = smb2_async_writev,
1292 .sync_read = smb2_sync_read,
1293 .sync_write = smb2_sync_write,
1294 .query_dir_first = smb2_query_dir_first,
1295 .query_dir_next = smb2_query_dir_next,
1296 .close_dir = smb2_close_dir,
1297 .calc_smb_size = smb2_calc_size,
1298 .is_status_pending = smb2_is_status_pending,
1299 .oplock_response = smb2_oplock_response,
1300 .queryfs = smb2_queryfs,
1301 .mand_lock = smb2_mand_lock,
1302 .mand_unlock_range = smb2_unlock_range,
1303 .push_mand_locks = smb2_push_mandatory_locks,
1304 .get_lease_key = smb2_get_lease_key,
1305 .set_lease_key = smb2_set_lease_key,
1306 .new_lease_key = smb2_new_lease_key,
1307 .calc_signature = smb2_calc_signature,
1308 .is_read_op = smb21_is_read_op,
1309 .set_oplock_level = smb21_set_oplock_level,
1310 .create_lease_buf = smb2_create_lease_buf,
1311 .parse_lease_buf = smb2_parse_lease_buf,
1312 .clone_range = smb2_clone_range,
1313 .wp_retry_size = smb2_wp_retry_size,
1316 struct smb_version_operations smb30_operations = {
1317 .compare_fids = smb2_compare_fids,
1318 .setup_request = smb2_setup_request,
1319 .setup_async_request = smb2_setup_async_request,
1320 .check_receive = smb2_check_receive,
1321 .add_credits = smb2_add_credits,
1322 .set_credits = smb2_set_credits,
1323 .get_credits_field = smb2_get_credits_field,
1324 .get_credits = smb2_get_credits,
1325 .wait_mtu_credits = smb2_wait_mtu_credits,
1326 .get_next_mid = smb2_get_next_mid,
1327 .read_data_offset = smb2_read_data_offset,
1328 .read_data_length = smb2_read_data_length,
1329 .map_error = map_smb2_to_linux_error,
1330 .find_mid = smb2_find_mid,
1331 .check_message = smb2_check_message,
1332 .dump_detail = smb2_dump_detail,
1333 .clear_stats = smb2_clear_stats,
1334 .print_stats = smb2_print_stats,
1335 .dump_share_caps = smb2_dump_share_caps,
1336 .is_oplock_break = smb2_is_valid_oplock_break,
1337 .downgrade_oplock = smb2_downgrade_oplock,
1338 .need_neg = smb2_need_neg,
1339 .negotiate = smb2_negotiate,
1340 .negotiate_wsize = smb2_negotiate_wsize,
1341 .negotiate_rsize = smb2_negotiate_rsize,
1342 .sess_setup = SMB2_sess_setup,
1343 .logoff = SMB2_logoff,
1344 .tree_connect = SMB2_tcon,
1345 .tree_disconnect = SMB2_tdis,
1346 .qfs_tcon = smb3_qfs_tcon,
1347 .is_path_accessible = smb2_is_path_accessible,
1348 .can_echo = smb2_can_echo,
1350 .query_path_info = smb2_query_path_info,
1351 .get_srv_inum = smb2_get_srv_inum,
1352 .query_file_info = smb2_query_file_info,
1353 .set_path_size = smb2_set_path_size,
1354 .set_file_size = smb2_set_file_size,
1355 .set_file_info = smb2_set_file_info,
1356 .set_compression = smb2_set_compression,
1357 .mkdir = smb2_mkdir,
1358 .mkdir_setinfo = smb2_mkdir_setinfo,
1359 .rmdir = smb2_rmdir,
1360 .unlink = smb2_unlink,
1361 .rename = smb2_rename_path,
1362 .create_hardlink = smb2_create_hardlink,
1363 .query_symlink = smb2_query_symlink,
1364 .open = smb2_open_file,
1365 .set_fid = smb2_set_fid,
1366 .close = smb2_close_file,
1367 .flush = smb2_flush_file,
1368 .async_readv = smb2_async_readv,
1369 .async_writev = smb2_async_writev,
1370 .sync_read = smb2_sync_read,
1371 .sync_write = smb2_sync_write,
1372 .query_dir_first = smb2_query_dir_first,
1373 .query_dir_next = smb2_query_dir_next,
1374 .close_dir = smb2_close_dir,
1375 .calc_smb_size = smb2_calc_size,
1376 .is_status_pending = smb2_is_status_pending,
1377 .oplock_response = smb2_oplock_response,
1378 .queryfs = smb2_queryfs,
1379 .mand_lock = smb2_mand_lock,
1380 .mand_unlock_range = smb2_unlock_range,
1381 .push_mand_locks = smb2_push_mandatory_locks,
1382 .get_lease_key = smb2_get_lease_key,
1383 .set_lease_key = smb2_set_lease_key,
1384 .new_lease_key = smb2_new_lease_key,
1385 .generate_signingkey = generate_smb3signingkey,
1386 .calc_signature = smb3_calc_signature,
1387 .is_read_op = smb21_is_read_op,
1388 .set_oplock_level = smb3_set_oplock_level,
1389 .create_lease_buf = smb3_create_lease_buf,
1390 .parse_lease_buf = smb3_parse_lease_buf,
1391 .clone_range = smb2_clone_range,
1392 .validate_negotiate = smb3_validate_negotiate,
1393 .wp_retry_size = smb2_wp_retry_size,
1396 struct smb_version_values smb20_values = {
1397 .version_string = SMB20_VERSION_STRING,
1398 .protocol_id = SMB20_PROT_ID,
1399 .req_capabilities = 0, /* MBZ */
1400 .large_lock_type = 0,
1401 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1402 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1403 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1404 .header_size = sizeof(struct smb2_hdr),
1405 .max_header_size = MAX_SMB2_HDR_SIZE,
1406 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1407 .lock_cmd = SMB2_LOCK,
1409 .cap_nt_find = SMB2_NT_FIND,
1410 .cap_large_files = SMB2_LARGE_FILES,
1411 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1412 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1413 .create_lease_size = sizeof(struct create_lease),
1416 struct smb_version_values smb21_values = {
1417 .version_string = SMB21_VERSION_STRING,
1418 .protocol_id = SMB21_PROT_ID,
1419 .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */
1420 .large_lock_type = 0,
1421 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1422 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1423 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1424 .header_size = sizeof(struct smb2_hdr),
1425 .max_header_size = MAX_SMB2_HDR_SIZE,
1426 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1427 .lock_cmd = SMB2_LOCK,
1429 .cap_nt_find = SMB2_NT_FIND,
1430 .cap_large_files = SMB2_LARGE_FILES,
1431 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1432 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1433 .create_lease_size = sizeof(struct create_lease),
1436 struct smb_version_values smb30_values = {
1437 .version_string = SMB30_VERSION_STRING,
1438 .protocol_id = SMB30_PROT_ID,
1439 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
1440 .large_lock_type = 0,
1441 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1442 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1443 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1444 .header_size = sizeof(struct smb2_hdr),
1445 .max_header_size = MAX_SMB2_HDR_SIZE,
1446 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1447 .lock_cmd = SMB2_LOCK,
1449 .cap_nt_find = SMB2_NT_FIND,
1450 .cap_large_files = SMB2_LARGE_FILES,
1451 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1452 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1453 .create_lease_size = sizeof(struct create_lease_v2),
1456 struct smb_version_values smb302_values = {
1457 .version_string = SMB302_VERSION_STRING,
1458 .protocol_id = SMB302_PROT_ID,
1459 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
1460 .large_lock_type = 0,
1461 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1462 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1463 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1464 .header_size = sizeof(struct smb2_hdr),
1465 .max_header_size = MAX_SMB2_HDR_SIZE,
1466 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1467 .lock_cmd = SMB2_LOCK,
1469 .cap_nt_find = SMB2_NT_FIND,
1470 .cap_large_files = SMB2_LARGE_FILES,
1471 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1472 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1473 .create_lease_size = sizeof(struct create_lease_v2),