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>
22 #include <linux/falloc.h>
25 #include "smb2proto.h"
26 #include "cifsproto.h"
27 #include "cifs_debug.h"
28 #include "cifs_unicode.h"
29 #include "smb2status.h"
33 change_conf(struct TCP_Server_Info *server)
35 server->credits += server->echo_credits + server->oplock_credits;
36 server->oplock_credits = server->echo_credits = 0;
37 switch (server->credits) {
41 server->echoes = false;
42 server->oplocks = false;
43 cifs_dbg(VFS, "disabling echoes and oplocks\n");
46 server->echoes = true;
47 server->oplocks = false;
48 server->echo_credits = 1;
49 cifs_dbg(FYI, "disabling oplocks\n");
52 server->echoes = true;
54 server->oplocks = true;
55 server->oplock_credits = 1;
57 server->oplocks = false;
59 server->echo_credits = 1;
61 server->credits -= server->echo_credits + server->oplock_credits;
66 smb2_add_credits(struct TCP_Server_Info *server, const unsigned int add,
70 spin_lock(&server->req_lock);
71 val = server->ops->get_credits_field(server, optype);
74 *val = 65000; /* Don't get near 64K credits, avoid srv bugs */
75 printk_once(KERN_WARNING "server overflowed SMB3 credits\n");
78 if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
79 rc = change_conf(server);
81 * Sometimes server returns 0 credits on oplock break ack - we need to
82 * rebalance credits in this case.
84 else if (server->in_flight > 0 && server->oplock_credits == 0 &&
86 if (server->credits > 1) {
88 server->oplock_credits++;
91 spin_unlock(&server->req_lock);
92 wake_up(&server->request_q);
94 cifs_reconnect(server);
98 smb2_set_credits(struct TCP_Server_Info *server, const int val)
100 spin_lock(&server->req_lock);
101 server->credits = val;
102 spin_unlock(&server->req_lock);
106 smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
110 return &server->echo_credits;
112 return &server->oplock_credits;
114 return &server->credits;
119 smb2_get_credits(struct mid_q_entry *mid)
121 return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
125 smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
126 unsigned int *num, unsigned int *credits)
129 unsigned int scredits;
131 spin_lock(&server->req_lock);
133 if (server->credits <= 0) {
134 spin_unlock(&server->req_lock);
135 cifs_num_waiters_inc(server);
136 rc = wait_event_killable(server->request_q,
137 has_credits(server, &server->credits));
138 cifs_num_waiters_dec(server);
141 spin_lock(&server->req_lock);
143 if (server->tcpStatus == CifsExiting) {
144 spin_unlock(&server->req_lock);
148 scredits = server->credits;
149 /* can deadlock with reopen */
151 *num = SMB2_MAX_BUFFER_SIZE;
156 /* leave one credit for a possible reopen */
158 *num = min_t(unsigned int, size,
159 scredits * SMB2_MAX_BUFFER_SIZE);
161 *credits = DIV_ROUND_UP(*num, SMB2_MAX_BUFFER_SIZE);
162 server->credits -= *credits;
167 spin_unlock(&server->req_lock);
172 smb2_get_next_mid(struct TCP_Server_Info *server)
175 /* for SMB2 we need the current value */
176 spin_lock(&GlobalMid_Lock);
177 mid = server->CurrentMid++;
178 spin_unlock(&GlobalMid_Lock);
182 static struct mid_q_entry *
183 smb2_find_mid(struct TCP_Server_Info *server, char *buf)
185 struct mid_q_entry *mid;
186 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
187 __u64 wire_mid = le64_to_cpu(hdr->MessageId);
189 if (hdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) {
190 cifs_dbg(VFS, "encrypted frame parsing not supported yet");
194 spin_lock(&GlobalMid_Lock);
195 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
196 if ((mid->mid == wire_mid) &&
197 (mid->mid_state == MID_REQUEST_SUBMITTED) &&
198 (mid->command == hdr->Command)) {
199 spin_unlock(&GlobalMid_Lock);
203 spin_unlock(&GlobalMid_Lock);
208 smb2_dump_detail(void *buf)
210 #ifdef CONFIG_CIFS_DEBUG2
211 struct smb2_hdr *smb = (struct smb2_hdr *)buf;
213 cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
214 smb->Command, smb->Status, smb->Flags, smb->MessageId,
216 cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
221 smb2_need_neg(struct TCP_Server_Info *server)
223 return server->max_read == 0;
227 smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
230 ses->server->CurrentMid = 0;
231 rc = SMB2_negotiate(xid, ses);
232 /* BB we probably don't need to retry with modern servers */
239 smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
241 struct TCP_Server_Info *server = tcon->ses->server;
244 /* start with specified wsize, or default */
245 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
246 wsize = min_t(unsigned int, wsize, server->max_write);
248 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
249 wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
255 smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
257 struct TCP_Server_Info *server = tcon->ses->server;
260 /* start with specified rsize, or default */
261 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
262 rsize = min_t(unsigned int, rsize, server->max_read);
264 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
265 rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
270 #ifdef CONFIG_CIFS_STATS2
272 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
275 unsigned int ret_data_len = 0;
276 struct network_interface_info_ioctl_rsp *out_buf;
278 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
279 FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */,
280 NULL /* no data input */, 0 /* no data input */,
281 (char **)&out_buf, &ret_data_len);
283 cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
284 else if (ret_data_len < sizeof(struct network_interface_info_ioctl_rsp)) {
285 cifs_dbg(VFS, "server returned bad net interface info buf\n");
288 /* Dump info on first interface */
289 cifs_dbg(FYI, "Adapter Capability 0x%x\t",
290 le32_to_cpu(out_buf->Capability));
291 cifs_dbg(FYI, "Link Speed %lld\n",
292 le64_to_cpu(out_buf->LinkSpeed));
300 smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
303 __le16 srch_path = 0; /* Null - open root of share */
304 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
305 struct cifs_open_parms oparms;
309 oparms.desired_access = FILE_READ_ATTRIBUTES;
310 oparms.disposition = FILE_OPEN;
311 oparms.create_options = 0;
313 oparms.reconnect = false;
315 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
319 #ifdef CONFIG_CIFS_STATS2
320 SMB3_request_interfaces(xid, tcon);
323 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
324 FS_ATTRIBUTE_INFORMATION);
325 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
326 FS_DEVICE_INFORMATION);
327 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
328 FS_SECTOR_SIZE_INFORMATION); /* SMB3 specific */
329 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
334 smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
337 __le16 srch_path = 0; /* Null - open root of share */
338 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
339 struct cifs_open_parms oparms;
343 oparms.desired_access = FILE_READ_ATTRIBUTES;
344 oparms.disposition = FILE_OPEN;
345 oparms.create_options = 0;
347 oparms.reconnect = false;
349 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
353 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
354 FS_ATTRIBUTE_INFORMATION);
355 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
356 FS_DEVICE_INFORMATION);
357 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
362 smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
363 struct cifs_sb_info *cifs_sb, const char *full_path)
367 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
368 struct cifs_open_parms oparms;
371 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
376 oparms.desired_access = FILE_READ_ATTRIBUTES;
377 oparms.disposition = FILE_OPEN;
378 oparms.create_options = 0;
380 oparms.reconnect = false;
382 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
388 rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
394 smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
395 struct cifs_sb_info *cifs_sb, const char *full_path,
396 u64 *uniqueid, FILE_ALL_INFO *data)
398 *uniqueid = le64_to_cpu(data->IndexNumber);
403 smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
404 struct cifs_fid *fid, FILE_ALL_INFO *data)
407 struct smb2_file_all_info *smb2_data;
409 smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
411 if (smb2_data == NULL)
414 rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
417 move_smb2_info_to_cifs(data, smb2_data);
423 smb2_can_echo(struct TCP_Server_Info *server)
425 return server->echoes;
429 smb2_clear_stats(struct cifs_tcon *tcon)
431 #ifdef CONFIG_CIFS_STATS
433 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
434 atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
435 atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
441 smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon)
443 seq_puts(m, "\n\tShare Capabilities:");
444 if (tcon->capabilities & SMB2_SHARE_CAP_DFS)
445 seq_puts(m, " DFS,");
446 if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
447 seq_puts(m, " CONTINUOUS AVAILABILITY,");
448 if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT)
449 seq_puts(m, " SCALEOUT,");
450 if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER)
451 seq_puts(m, " CLUSTER,");
452 if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC)
453 seq_puts(m, " ASYMMETRIC,");
454 if (tcon->capabilities == 0)
455 seq_puts(m, " None");
456 if (tcon->ss_flags & SSINFO_FLAGS_ALIGNED_DEVICE)
457 seq_puts(m, " Aligned,");
458 if (tcon->ss_flags & SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE)
459 seq_puts(m, " Partition Aligned,");
460 if (tcon->ss_flags & SSINFO_FLAGS_NO_SEEK_PENALTY)
461 seq_puts(m, " SSD,");
462 if (tcon->ss_flags & SSINFO_FLAGS_TRIM_ENABLED)
463 seq_puts(m, " TRIM-support,");
465 seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags);
466 if (tcon->perf_sector_size)
467 seq_printf(m, "\tOptimal sector size: 0x%x",
468 tcon->perf_sector_size);
472 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
474 #ifdef CONFIG_CIFS_STATS
475 atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
476 atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
477 seq_printf(m, "\nNegotiates: %d sent %d failed",
478 atomic_read(&sent[SMB2_NEGOTIATE_HE]),
479 atomic_read(&failed[SMB2_NEGOTIATE_HE]));
480 seq_printf(m, "\nSessionSetups: %d sent %d failed",
481 atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
482 atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
483 seq_printf(m, "\nLogoffs: %d sent %d failed",
484 atomic_read(&sent[SMB2_LOGOFF_HE]),
485 atomic_read(&failed[SMB2_LOGOFF_HE]));
486 seq_printf(m, "\nTreeConnects: %d sent %d failed",
487 atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
488 atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
489 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
490 atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
491 atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
492 seq_printf(m, "\nCreates: %d sent %d failed",
493 atomic_read(&sent[SMB2_CREATE_HE]),
494 atomic_read(&failed[SMB2_CREATE_HE]));
495 seq_printf(m, "\nCloses: %d sent %d failed",
496 atomic_read(&sent[SMB2_CLOSE_HE]),
497 atomic_read(&failed[SMB2_CLOSE_HE]));
498 seq_printf(m, "\nFlushes: %d sent %d failed",
499 atomic_read(&sent[SMB2_FLUSH_HE]),
500 atomic_read(&failed[SMB2_FLUSH_HE]));
501 seq_printf(m, "\nReads: %d sent %d failed",
502 atomic_read(&sent[SMB2_READ_HE]),
503 atomic_read(&failed[SMB2_READ_HE]));
504 seq_printf(m, "\nWrites: %d sent %d failed",
505 atomic_read(&sent[SMB2_WRITE_HE]),
506 atomic_read(&failed[SMB2_WRITE_HE]));
507 seq_printf(m, "\nLocks: %d sent %d failed",
508 atomic_read(&sent[SMB2_LOCK_HE]),
509 atomic_read(&failed[SMB2_LOCK_HE]));
510 seq_printf(m, "\nIOCTLs: %d sent %d failed",
511 atomic_read(&sent[SMB2_IOCTL_HE]),
512 atomic_read(&failed[SMB2_IOCTL_HE]));
513 seq_printf(m, "\nCancels: %d sent %d failed",
514 atomic_read(&sent[SMB2_CANCEL_HE]),
515 atomic_read(&failed[SMB2_CANCEL_HE]));
516 seq_printf(m, "\nEchos: %d sent %d failed",
517 atomic_read(&sent[SMB2_ECHO_HE]),
518 atomic_read(&failed[SMB2_ECHO_HE]));
519 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
520 atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
521 atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
522 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
523 atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
524 atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
525 seq_printf(m, "\nQueryInfos: %d sent %d failed",
526 atomic_read(&sent[SMB2_QUERY_INFO_HE]),
527 atomic_read(&failed[SMB2_QUERY_INFO_HE]));
528 seq_printf(m, "\nSetInfos: %d sent %d failed",
529 atomic_read(&sent[SMB2_SET_INFO_HE]),
530 atomic_read(&failed[SMB2_SET_INFO_HE]));
531 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
532 atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
533 atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
538 smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
540 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
541 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
543 cfile->fid.persistent_fid = fid->persistent_fid;
544 cfile->fid.volatile_fid = fid->volatile_fid;
545 server->ops->set_oplock_level(cinode, oplock, fid->epoch,
547 cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
548 memcpy(cfile->fid.create_guid, fid->create_guid, 16);
552 smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
553 struct cifs_fid *fid)
555 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
559 SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
560 u64 persistent_fid, u64 volatile_fid,
561 struct copychunk_ioctl *pcchunk)
564 unsigned int ret_data_len;
565 struct resume_key_req *res_key;
567 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
568 FSCTL_SRV_REQUEST_RESUME_KEY, true /* is_fsctl */,
569 NULL, 0 /* no input */,
570 (char **)&res_key, &ret_data_len);
573 cifs_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
574 goto req_res_key_exit;
576 if (ret_data_len < sizeof(struct resume_key_req)) {
577 cifs_dbg(VFS, "Invalid refcopy resume key length\n");
579 goto req_res_key_exit;
581 memcpy(pcchunk->SourceKey, res_key->ResumeKey, COPY_CHUNK_RES_KEY_SIZE);
589 smb2_clone_range(const unsigned int xid,
590 struct cifsFileInfo *srcfile,
591 struct cifsFileInfo *trgtfile, u64 src_off,
592 u64 len, u64 dest_off)
595 unsigned int ret_data_len;
596 struct copychunk_ioctl *pcchunk;
597 struct copychunk_ioctl_rsp *retbuf = NULL;
598 struct cifs_tcon *tcon;
599 int chunks_copied = 0;
600 bool chunk_sizes_updated = false;
602 pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
607 cifs_dbg(FYI, "in smb2_clone_range - about to call request res key\n");
608 /* Request a key from the server to identify the source of the copy */
609 rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink),
610 srcfile->fid.persistent_fid,
611 srcfile->fid.volatile_fid, pcchunk);
613 /* Note: request_res_key sets res_key null only if rc !=0 */
617 /* For now array only one chunk long, will make more flexible later */
618 pcchunk->ChunkCount = cpu_to_le32(1);
619 pcchunk->Reserved = 0;
620 pcchunk->Reserved2 = 0;
622 tcon = tlink_tcon(trgtfile->tlink);
625 pcchunk->SourceOffset = cpu_to_le64(src_off);
626 pcchunk->TargetOffset = cpu_to_le64(dest_off);
628 cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
630 /* Request server copy to target from src identified by key */
631 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
632 trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
633 true /* is_fsctl */, (char *)pcchunk,
634 sizeof(struct copychunk_ioctl), (char **)&retbuf,
638 sizeof(struct copychunk_ioctl_rsp)) {
639 cifs_dbg(VFS, "invalid cchunk response size\n");
643 if (retbuf->TotalBytesWritten == 0) {
644 cifs_dbg(FYI, "no bytes copied\n");
649 * Check if server claimed to write more than we asked
651 if (le32_to_cpu(retbuf->TotalBytesWritten) >
652 le32_to_cpu(pcchunk->Length)) {
653 cifs_dbg(VFS, "invalid copy chunk response\n");
657 if (le32_to_cpu(retbuf->ChunksWritten) != 1) {
658 cifs_dbg(VFS, "invalid num chunks written\n");
664 src_off += le32_to_cpu(retbuf->TotalBytesWritten);
665 dest_off += le32_to_cpu(retbuf->TotalBytesWritten);
666 len -= le32_to_cpu(retbuf->TotalBytesWritten);
668 cifs_dbg(FYI, "Chunks %d PartialChunk %d Total %d\n",
669 le32_to_cpu(retbuf->ChunksWritten),
670 le32_to_cpu(retbuf->ChunkBytesWritten),
671 le32_to_cpu(retbuf->TotalBytesWritten));
672 } else if (rc == -EINVAL) {
673 if (ret_data_len != sizeof(struct copychunk_ioctl_rsp))
676 cifs_dbg(FYI, "MaxChunks %d BytesChunk %d MaxCopy %d\n",
677 le32_to_cpu(retbuf->ChunksWritten),
678 le32_to_cpu(retbuf->ChunkBytesWritten),
679 le32_to_cpu(retbuf->TotalBytesWritten));
682 * Check if this is the first request using these sizes,
683 * (ie check if copy succeed once with original sizes
684 * and check if the server gave us different sizes after
685 * we already updated max sizes on previous request).
686 * if not then why is the server returning an error now
688 if ((chunks_copied != 0) || chunk_sizes_updated)
691 /* Check that server is not asking us to grow size */
692 if (le32_to_cpu(retbuf->ChunkBytesWritten) <
693 tcon->max_bytes_chunk)
694 tcon->max_bytes_chunk =
695 le32_to_cpu(retbuf->ChunkBytesWritten);
697 goto cchunk_out; /* server gave us bogus size */
699 /* No need to change MaxChunks since already set to 1 */
700 chunk_sizes_updated = true;
711 smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
712 struct cifs_fid *fid)
714 return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
718 smb2_read_data_offset(char *buf)
720 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
721 return rsp->DataOffset;
725 smb2_read_data_length(char *buf)
727 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
728 return le32_to_cpu(rsp->DataLength);
733 smb2_sync_read(const unsigned int xid, struct cifs_fid *pfid,
734 struct cifs_io_parms *parms, unsigned int *bytes_read,
735 char **buf, int *buf_type)
737 parms->persistent_fid = pfid->persistent_fid;
738 parms->volatile_fid = pfid->volatile_fid;
739 return SMB2_read(xid, parms, bytes_read, buf, buf_type);
743 smb2_sync_write(const unsigned int xid, struct cifs_fid *pfid,
744 struct cifs_io_parms *parms, unsigned int *written,
745 struct kvec *iov, unsigned long nr_segs)
748 parms->persistent_fid = pfid->persistent_fid;
749 parms->volatile_fid = pfid->volatile_fid;
750 return SMB2_write(xid, parms, written, iov, nr_segs);
753 /* Set or clear the SPARSE_FILE attribute based on value passed in setsparse */
754 static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,
755 struct cifsFileInfo *cfile, struct inode *inode, __u8 setsparse)
757 struct cifsInodeInfo *cifsi;
760 cifsi = CIFS_I(inode);
762 /* if file already sparse don't bother setting sparse again */
763 if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && setsparse)
764 return true; /* already sparse */
766 if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && !setsparse)
767 return true; /* already not sparse */
770 * Can't check for sparse support on share the usual way via the
771 * FS attribute info (FILE_SUPPORTS_SPARSE_FILES) on the share
772 * since Samba server doesn't set the flag on the share, yet
773 * supports the set sparse FSCTL and returns sparse correctly
774 * in the file attributes. If we fail setting sparse though we
775 * mark that server does not support sparse files for this share
776 * to avoid repeatedly sending the unsupported fsctl to server
777 * if the file is repeatedly extended.
779 if (tcon->broken_sparse_sup)
782 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
783 cfile->fid.volatile_fid, FSCTL_SET_SPARSE,
784 true /* is_fctl */, &setsparse, 1, NULL, NULL);
786 tcon->broken_sparse_sup = true;
787 cifs_dbg(FYI, "set sparse rc = %d\n", rc);
792 cifsi->cifsAttrs |= FILE_ATTRIBUTE_SPARSE_FILE;
794 cifsi->cifsAttrs &= (~FILE_ATTRIBUTE_SPARSE_FILE);
800 smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
801 struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
803 __le64 eof = cpu_to_le64(size);
807 * If extending file more than one page make sparse. Many Linux fs
808 * make files sparse by default when extending via ftruncate
810 inode = d_inode(cfile->dentry);
812 if (!set_alloc && (size > inode->i_size + 8192)) {
815 /* whether set sparse succeeds or not, extend the file */
816 smb2_set_sparse(xid, tcon, cfile, inode, set_sparse);
819 return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
820 cfile->fid.volatile_fid, cfile->pid, &eof, false);
824 smb2_duplicate_extents(const unsigned int xid,
825 struct cifsFileInfo *srcfile,
826 struct cifsFileInfo *trgtfile, u64 src_off,
827 u64 len, u64 dest_off)
830 unsigned int ret_data_len;
832 struct duplicate_extents_to_file dup_ext_buf;
833 struct cifs_tcon *tcon = tlink_tcon(trgtfile->tlink);
835 /* server fileays advertise duplicate extent support with this flag */
836 if ((le32_to_cpu(tcon->fsAttrInfo.Attributes) &
837 FILE_SUPPORTS_BLOCK_REFCOUNTING) == 0)
840 dup_ext_buf.VolatileFileHandle = srcfile->fid.volatile_fid;
841 dup_ext_buf.PersistentFileHandle = srcfile->fid.persistent_fid;
842 dup_ext_buf.SourceFileOffset = cpu_to_le64(src_off);
843 dup_ext_buf.TargetFileOffset = cpu_to_le64(dest_off);
844 dup_ext_buf.ByteCount = cpu_to_le64(len);
845 cifs_dbg(FYI, "duplicate extents: src off %lld dst off %lld len %lld",
846 src_off, dest_off, len);
848 rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
850 goto duplicate_extents_out;
852 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
853 trgtfile->fid.volatile_fid,
854 FSCTL_DUPLICATE_EXTENTS_TO_FILE,
855 true /* is_fsctl */, (char *)&dup_ext_buf,
856 sizeof(struct duplicate_extents_to_file),
860 if (ret_data_len > 0)
861 cifs_dbg(FYI, "non-zero response length in duplicate extents");
863 duplicate_extents_out:
868 smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
869 struct cifsFileInfo *cfile)
871 return SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid,
872 cfile->fid.volatile_fid);
876 smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon,
877 struct cifsFileInfo *cfile)
879 struct fsctl_set_integrity_information_req integr_info;
881 unsigned int ret_data_len;
883 integr_info.ChecksumAlgorithm = cpu_to_le16(CHECKSUM_TYPE_UNCHANGED);
884 integr_info.Flags = 0;
885 integr_info.Reserved = 0;
887 return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
888 cfile->fid.volatile_fid,
889 FSCTL_SET_INTEGRITY_INFORMATION,
890 true /* is_fsctl */, (char *)&integr_info,
891 sizeof(struct fsctl_set_integrity_information_req),
898 smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
899 const char *path, struct cifs_sb_info *cifs_sb,
900 struct cifs_fid *fid, __u16 search_flags,
901 struct cifs_search_info *srch_inf)
905 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
906 struct cifs_open_parms oparms;
908 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
913 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
914 oparms.disposition = FILE_OPEN;
915 oparms.create_options = 0;
917 oparms.reconnect = false;
919 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
922 cifs_dbg(VFS, "open dir failed\n");
926 srch_inf->entries_in_buffer = 0;
927 srch_inf->index_of_last_entry = 0;
929 rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
930 fid->volatile_fid, 0, srch_inf);
932 cifs_dbg(VFS, "query directory failed\n");
933 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
939 smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
940 struct cifs_fid *fid, __u16 search_flags,
941 struct cifs_search_info *srch_inf)
943 return SMB2_query_directory(xid, tcon, fid->persistent_fid,
944 fid->volatile_fid, 0, srch_inf);
948 smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
949 struct cifs_fid *fid)
951 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
955 * If we negotiate SMB2 protocol and get STATUS_PENDING - update
956 * the number of credits and return true. Otherwise - return false.
959 smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
961 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
963 if (hdr->Status != STATUS_PENDING)
967 spin_lock(&server->req_lock);
968 server->credits += le16_to_cpu(hdr->CreditRequest);
969 spin_unlock(&server->req_lock);
970 wake_up(&server->request_q);
977 smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
978 struct cifsInodeInfo *cinode)
980 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
981 return SMB2_lease_break(0, tcon, cinode->lease_key,
982 smb2_get_lease_state(cinode));
984 return SMB2_oplock_break(0, tcon, fid->persistent_fid,
986 CIFS_CACHE_READ(cinode) ? 1 : 0);
990 smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
994 __le16 srch_path = 0; /* Null - open root of share */
995 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
996 struct cifs_open_parms oparms;
1000 oparms.desired_access = FILE_READ_ATTRIBUTES;
1001 oparms.disposition = FILE_OPEN;
1002 oparms.create_options = 0;
1004 oparms.reconnect = false;
1006 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
1009 buf->f_type = SMB2_MAGIC_NUMBER;
1010 rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
1012 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
1017 smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
1019 return ob1->fid.persistent_fid == ob2->fid.persistent_fid &&
1020 ob1->fid.volatile_fid == ob2->fid.volatile_fid;
1024 smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
1025 __u64 length, __u32 type, int lock, int unlock, bool wait)
1027 if (unlock && !lock)
1028 type = SMB2_LOCKFLAG_UNLOCK;
1029 return SMB2_lock(xid, tlink_tcon(cfile->tlink),
1030 cfile->fid.persistent_fid, cfile->fid.volatile_fid,
1031 current->tgid, length, offset, type, wait);
1035 smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid)
1037 memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE);
1041 smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid)
1043 memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
1047 smb2_new_lease_key(struct cifs_fid *fid)
1049 generate_random_uuid(fid->lease_key);
1052 #define SMB2_SYMLINK_STRUCT_SIZE \
1053 (sizeof(struct smb2_err_rsp) - 1 + sizeof(struct smb2_symlink_err_rsp))
1056 smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
1057 const char *full_path, char **target_path,
1058 struct cifs_sb_info *cifs_sb)
1062 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
1063 struct cifs_open_parms oparms;
1064 struct cifs_fid fid;
1065 struct smb2_err_rsp *err_buf = NULL;
1066 struct smb2_symlink_err_rsp *symlink;
1067 unsigned int sub_len;
1068 unsigned int sub_offset;
1069 unsigned int print_len;
1070 unsigned int print_offset;
1072 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
1074 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
1079 oparms.desired_access = FILE_READ_ATTRIBUTES;
1080 oparms.disposition = FILE_OPEN;
1081 oparms.create_options = 0;
1083 oparms.reconnect = false;
1085 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
1087 if (!rc || !err_buf) {
1092 if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) ||
1093 get_rfc1002_length(err_buf) + 4 < SMB2_SYMLINK_STRUCT_SIZE) {
1098 /* open must fail on symlink - reset rc */
1100 symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;
1101 sub_len = le16_to_cpu(symlink->SubstituteNameLength);
1102 sub_offset = le16_to_cpu(symlink->SubstituteNameOffset);
1103 print_len = le16_to_cpu(symlink->PrintNameLength);
1104 print_offset = le16_to_cpu(symlink->PrintNameOffset);
1106 if (get_rfc1002_length(err_buf) + 4 <
1107 SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) {
1112 if (get_rfc1002_length(err_buf) + 4 <
1113 SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) {
1118 *target_path = cifs_strndup_from_utf16(
1119 (char *)symlink->PathBuffer + sub_offset,
1120 sub_len, true, cifs_sb->local_nls);
1121 if (!(*target_path)) {
1125 convert_delimiter(*target_path, '/');
1126 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
1131 static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
1132 loff_t offset, loff_t len, bool keep_size)
1134 struct inode *inode;
1135 struct cifsInodeInfo *cifsi;
1136 struct cifsFileInfo *cfile = file->private_data;
1137 struct file_zero_data_information fsctl_buf;
1143 inode = d_inode(cfile->dentry);
1144 cifsi = CIFS_I(inode);
1146 /* if file not oplocked can't be sure whether asking to extend size */
1147 if (!CIFS_CACHE_READ(cifsi))
1148 if (keep_size == false)
1152 * Must check if file sparse since fallocate -z (zero range) assumes
1153 * non-sparse allocation
1155 if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE))
1159 * need to make sure we are not asked to extend the file since the SMB3
1160 * fsctl does not change the file size. In the future we could change
1161 * this to zero the first part of the range then set the file size
1162 * which for a non sparse file would zero the newly extended range
1164 if (keep_size == false)
1165 if (i_size_read(inode) < offset + len)
1168 cifs_dbg(FYI, "offset %lld len %lld", offset, len);
1170 fsctl_buf.FileOffset = cpu_to_le64(offset);
1171 fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
1173 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
1174 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
1175 true /* is_fctl */, (char *)&fsctl_buf,
1176 sizeof(struct file_zero_data_information), NULL, NULL);
1181 static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
1182 loff_t offset, loff_t len)
1184 struct inode *inode;
1185 struct cifsInodeInfo *cifsi;
1186 struct cifsFileInfo *cfile = file->private_data;
1187 struct file_zero_data_information fsctl_buf;
1190 __u8 set_sparse = 1;
1194 inode = d_inode(cfile->dentry);
1195 cifsi = CIFS_I(inode);
1197 /* Need to make file sparse, if not already, before freeing range. */
1198 /* Consider adding equivalent for compressed since it could also work */
1199 if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse))
1202 cifs_dbg(FYI, "offset %lld len %lld", offset, len);
1204 fsctl_buf.FileOffset = cpu_to_le64(offset);
1205 fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
1207 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
1208 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
1209 true /* is_fctl */, (char *)&fsctl_buf,
1210 sizeof(struct file_zero_data_information), NULL, NULL);
1215 static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
1216 loff_t off, loff_t len, bool keep_size)
1218 struct inode *inode;
1219 struct cifsInodeInfo *cifsi;
1220 struct cifsFileInfo *cfile = file->private_data;
1221 long rc = -EOPNOTSUPP;
1226 inode = d_inode(cfile->dentry);
1227 cifsi = CIFS_I(inode);
1229 /* if file not oplocked can't be sure whether asking to extend size */
1230 if (!CIFS_CACHE_READ(cifsi))
1231 if (keep_size == false)
1235 * Files are non-sparse by default so falloc may be a no-op
1236 * Must check if file sparse. If not sparse, and not extending
1237 * then no need to do anything since file already allocated
1239 if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {
1240 if (keep_size == true)
1242 /* check if extending file */
1243 else if (i_size_read(inode) >= off + len)
1244 /* not extending file and already not sparse */
1246 /* BB: in future add else clause to extend file */
1251 if ((keep_size == true) || (i_size_read(inode) >= off + len)) {
1253 * Check if falloc starts within first few pages of file
1254 * and ends within a few pages of the end of file to
1255 * ensure that most of file is being forced to be
1256 * fallocated now. If so then setting whole file sparse
1257 * ie potentially making a few extra pages at the beginning
1258 * or end of the file non-sparse via set_sparse is harmless.
1260 if ((off > 8192) || (off + len + 8192 < i_size_read(inode)))
1263 rc = smb2_set_sparse(xid, tcon, cfile, inode, false);
1265 /* BB: else ... in future add code to extend file and set sparse */
1273 static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,
1274 loff_t off, loff_t len)
1276 /* KEEP_SIZE already checked for by do_fallocate */
1277 if (mode & FALLOC_FL_PUNCH_HOLE)
1278 return smb3_punch_hole(file, tcon, off, len);
1279 else if (mode & FALLOC_FL_ZERO_RANGE) {
1280 if (mode & FALLOC_FL_KEEP_SIZE)
1281 return smb3_zero_range(file, tcon, off, len, true);
1282 return smb3_zero_range(file, tcon, off, len, false);
1283 } else if (mode == FALLOC_FL_KEEP_SIZE)
1284 return smb3_simple_falloc(file, tcon, off, len, true);
1286 return smb3_simple_falloc(file, tcon, off, len, false);
1292 smb2_downgrade_oplock(struct TCP_Server_Info *server,
1293 struct cifsInodeInfo *cinode, bool set_level2)
1296 server->ops->set_oplock_level(cinode, SMB2_OPLOCK_LEVEL_II,
1299 server->ops->set_oplock_level(cinode, 0, 0, NULL);
1303 smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1304 unsigned int epoch, bool *purge_cache)
1307 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
1309 if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
1310 cinode->oplock = CIFS_CACHE_RHW_FLG;
1311 cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
1312 &cinode->vfs_inode);
1313 } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
1314 cinode->oplock = CIFS_CACHE_RW_FLG;
1315 cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
1316 &cinode->vfs_inode);
1317 } else if (oplock == SMB2_OPLOCK_LEVEL_II) {
1318 cinode->oplock = CIFS_CACHE_READ_FLG;
1319 cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
1320 &cinode->vfs_inode);
1326 smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1327 unsigned int epoch, bool *purge_cache)
1329 char message[5] = {0};
1332 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
1336 if (oplock & SMB2_LEASE_READ_CACHING_HE) {
1337 cinode->oplock |= CIFS_CACHE_READ_FLG;
1338 strcat(message, "R");
1340 if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
1341 cinode->oplock |= CIFS_CACHE_HANDLE_FLG;
1342 strcat(message, "H");
1344 if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
1345 cinode->oplock |= CIFS_CACHE_WRITE_FLG;
1346 strcat(message, "W");
1348 if (!cinode->oplock)
1349 strcat(message, "None");
1350 cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
1351 &cinode->vfs_inode);
1355 smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1356 unsigned int epoch, bool *purge_cache)
1358 unsigned int old_oplock = cinode->oplock;
1360 smb21_set_oplock_level(cinode, oplock, epoch, purge_cache);
1363 *purge_cache = false;
1364 if (old_oplock == CIFS_CACHE_READ_FLG) {
1365 if (cinode->oplock == CIFS_CACHE_READ_FLG &&
1366 (epoch - cinode->epoch > 0))
1367 *purge_cache = true;
1368 else if (cinode->oplock == CIFS_CACHE_RH_FLG &&
1369 (epoch - cinode->epoch > 1))
1370 *purge_cache = true;
1371 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
1372 (epoch - cinode->epoch > 1))
1373 *purge_cache = true;
1374 else if (cinode->oplock == 0 &&
1375 (epoch - cinode->epoch > 0))
1376 *purge_cache = true;
1377 } else if (old_oplock == CIFS_CACHE_RH_FLG) {
1378 if (cinode->oplock == CIFS_CACHE_RH_FLG &&
1379 (epoch - cinode->epoch > 0))
1380 *purge_cache = true;
1381 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
1382 (epoch - cinode->epoch > 1))
1383 *purge_cache = true;
1385 cinode->epoch = epoch;
1390 smb2_is_read_op(__u32 oplock)
1392 return oplock == SMB2_OPLOCK_LEVEL_II;
1396 smb21_is_read_op(__u32 oplock)
1398 return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
1399 !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
1403 map_oplock_to_lease(u8 oplock)
1405 if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE)
1406 return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING;
1407 else if (oplock == SMB2_OPLOCK_LEVEL_II)
1408 return SMB2_LEASE_READ_CACHING;
1409 else if (oplock == SMB2_OPLOCK_LEVEL_BATCH)
1410 return SMB2_LEASE_HANDLE_CACHING | SMB2_LEASE_READ_CACHING |
1411 SMB2_LEASE_WRITE_CACHING;
1416 smb2_create_lease_buf(u8 *lease_key, u8 oplock)
1418 struct create_lease *buf;
1420 buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
1424 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
1425 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
1426 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
1428 buf->ccontext.DataOffset = cpu_to_le16(offsetof
1429 (struct create_lease, lcontext));
1430 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context));
1431 buf->ccontext.NameOffset = cpu_to_le16(offsetof
1432 (struct create_lease, Name));
1433 buf->ccontext.NameLength = cpu_to_le16(4);
1434 /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
1443 smb3_create_lease_buf(u8 *lease_key, u8 oplock)
1445 struct create_lease_v2 *buf;
1447 buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL);
1451 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
1452 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
1453 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
1455 buf->ccontext.DataOffset = cpu_to_le16(offsetof
1456 (struct create_lease_v2, lcontext));
1457 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
1458 buf->ccontext.NameOffset = cpu_to_le16(offsetof
1459 (struct create_lease_v2, Name));
1460 buf->ccontext.NameLength = cpu_to_le16(4);
1461 /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
1470 smb2_parse_lease_buf(void *buf, unsigned int *epoch)
1472 struct create_lease *lc = (struct create_lease *)buf;
1474 *epoch = 0; /* not used */
1475 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
1476 return SMB2_OPLOCK_LEVEL_NOCHANGE;
1477 return le32_to_cpu(lc->lcontext.LeaseState);
1481 smb3_parse_lease_buf(void *buf, unsigned int *epoch)
1483 struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
1485 *epoch = le16_to_cpu(lc->lcontext.Epoch);
1486 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
1487 return SMB2_OPLOCK_LEVEL_NOCHANGE;
1488 return le32_to_cpu(lc->lcontext.LeaseState);
1492 smb2_wp_retry_size(struct inode *inode)
1494 return min_t(unsigned int, CIFS_SB(inode->i_sb)->wsize,
1495 SMB2_MAX_BUFFER_SIZE);
1499 smb2_dir_needs_close(struct cifsFileInfo *cfile)
1501 return !cfile->invalidHandle;
1504 struct smb_version_operations smb20_operations = {
1505 .compare_fids = smb2_compare_fids,
1506 .setup_request = smb2_setup_request,
1507 .setup_async_request = smb2_setup_async_request,
1508 .check_receive = smb2_check_receive,
1509 .add_credits = smb2_add_credits,
1510 .set_credits = smb2_set_credits,
1511 .get_credits_field = smb2_get_credits_field,
1512 .get_credits = smb2_get_credits,
1513 .wait_mtu_credits = cifs_wait_mtu_credits,
1514 .get_next_mid = smb2_get_next_mid,
1515 .read_data_offset = smb2_read_data_offset,
1516 .read_data_length = smb2_read_data_length,
1517 .map_error = map_smb2_to_linux_error,
1518 .find_mid = smb2_find_mid,
1519 .check_message = smb2_check_message,
1520 .dump_detail = smb2_dump_detail,
1521 .clear_stats = smb2_clear_stats,
1522 .print_stats = smb2_print_stats,
1523 .is_oplock_break = smb2_is_valid_oplock_break,
1524 .downgrade_oplock = smb2_downgrade_oplock,
1525 .need_neg = smb2_need_neg,
1526 .negotiate = smb2_negotiate,
1527 .negotiate_wsize = smb2_negotiate_wsize,
1528 .negotiate_rsize = smb2_negotiate_rsize,
1529 .sess_setup = SMB2_sess_setup,
1530 .logoff = SMB2_logoff,
1531 .tree_connect = SMB2_tcon,
1532 .tree_disconnect = SMB2_tdis,
1533 .qfs_tcon = smb2_qfs_tcon,
1534 .is_path_accessible = smb2_is_path_accessible,
1535 .can_echo = smb2_can_echo,
1537 .query_path_info = smb2_query_path_info,
1538 .get_srv_inum = smb2_get_srv_inum,
1539 .query_file_info = smb2_query_file_info,
1540 .set_path_size = smb2_set_path_size,
1541 .set_file_size = smb2_set_file_size,
1542 .set_file_info = smb2_set_file_info,
1543 .set_compression = smb2_set_compression,
1544 .mkdir = smb2_mkdir,
1545 .mkdir_setinfo = smb2_mkdir_setinfo,
1546 .rmdir = smb2_rmdir,
1547 .unlink = smb2_unlink,
1548 .rename = smb2_rename_path,
1549 .create_hardlink = smb2_create_hardlink,
1550 .query_symlink = smb2_query_symlink,
1551 .query_mf_symlink = smb3_query_mf_symlink,
1552 .create_mf_symlink = smb3_create_mf_symlink,
1553 .open = smb2_open_file,
1554 .set_fid = smb2_set_fid,
1555 .close = smb2_close_file,
1556 .flush = smb2_flush_file,
1557 .async_readv = smb2_async_readv,
1558 .async_writev = smb2_async_writev,
1559 .sync_read = smb2_sync_read,
1560 .sync_write = smb2_sync_write,
1561 .query_dir_first = smb2_query_dir_first,
1562 .query_dir_next = smb2_query_dir_next,
1563 .close_dir = smb2_close_dir,
1564 .calc_smb_size = smb2_calc_size,
1565 .is_status_pending = smb2_is_status_pending,
1566 .oplock_response = smb2_oplock_response,
1567 .queryfs = smb2_queryfs,
1568 .mand_lock = smb2_mand_lock,
1569 .mand_unlock_range = smb2_unlock_range,
1570 .push_mand_locks = smb2_push_mandatory_locks,
1571 .get_lease_key = smb2_get_lease_key,
1572 .set_lease_key = smb2_set_lease_key,
1573 .new_lease_key = smb2_new_lease_key,
1574 .calc_signature = smb2_calc_signature,
1575 .is_read_op = smb2_is_read_op,
1576 .set_oplock_level = smb2_set_oplock_level,
1577 .create_lease_buf = smb2_create_lease_buf,
1578 .parse_lease_buf = smb2_parse_lease_buf,
1579 .clone_range = smb2_clone_range,
1580 .wp_retry_size = smb2_wp_retry_size,
1581 .dir_needs_close = smb2_dir_needs_close,
1584 struct smb_version_operations smb21_operations = {
1585 .compare_fids = smb2_compare_fids,
1586 .setup_request = smb2_setup_request,
1587 .setup_async_request = smb2_setup_async_request,
1588 .check_receive = smb2_check_receive,
1589 .add_credits = smb2_add_credits,
1590 .set_credits = smb2_set_credits,
1591 .get_credits_field = smb2_get_credits_field,
1592 .get_credits = smb2_get_credits,
1593 .wait_mtu_credits = smb2_wait_mtu_credits,
1594 .get_next_mid = smb2_get_next_mid,
1595 .read_data_offset = smb2_read_data_offset,
1596 .read_data_length = smb2_read_data_length,
1597 .map_error = map_smb2_to_linux_error,
1598 .find_mid = smb2_find_mid,
1599 .check_message = smb2_check_message,
1600 .dump_detail = smb2_dump_detail,
1601 .clear_stats = smb2_clear_stats,
1602 .print_stats = smb2_print_stats,
1603 .is_oplock_break = smb2_is_valid_oplock_break,
1604 .downgrade_oplock = smb2_downgrade_oplock,
1605 .need_neg = smb2_need_neg,
1606 .negotiate = smb2_negotiate,
1607 .negotiate_wsize = smb2_negotiate_wsize,
1608 .negotiate_rsize = smb2_negotiate_rsize,
1609 .sess_setup = SMB2_sess_setup,
1610 .logoff = SMB2_logoff,
1611 .tree_connect = SMB2_tcon,
1612 .tree_disconnect = SMB2_tdis,
1613 .qfs_tcon = smb2_qfs_tcon,
1614 .is_path_accessible = smb2_is_path_accessible,
1615 .can_echo = smb2_can_echo,
1617 .query_path_info = smb2_query_path_info,
1618 .get_srv_inum = smb2_get_srv_inum,
1619 .query_file_info = smb2_query_file_info,
1620 .set_path_size = smb2_set_path_size,
1621 .set_file_size = smb2_set_file_size,
1622 .set_file_info = smb2_set_file_info,
1623 .set_compression = smb2_set_compression,
1624 .mkdir = smb2_mkdir,
1625 .mkdir_setinfo = smb2_mkdir_setinfo,
1626 .rmdir = smb2_rmdir,
1627 .unlink = smb2_unlink,
1628 .rename = smb2_rename_path,
1629 .create_hardlink = smb2_create_hardlink,
1630 .query_symlink = smb2_query_symlink,
1631 .query_mf_symlink = smb3_query_mf_symlink,
1632 .create_mf_symlink = smb3_create_mf_symlink,
1633 .open = smb2_open_file,
1634 .set_fid = smb2_set_fid,
1635 .close = smb2_close_file,
1636 .flush = smb2_flush_file,
1637 .async_readv = smb2_async_readv,
1638 .async_writev = smb2_async_writev,
1639 .sync_read = smb2_sync_read,
1640 .sync_write = smb2_sync_write,
1641 .query_dir_first = smb2_query_dir_first,
1642 .query_dir_next = smb2_query_dir_next,
1643 .close_dir = smb2_close_dir,
1644 .calc_smb_size = smb2_calc_size,
1645 .is_status_pending = smb2_is_status_pending,
1646 .oplock_response = smb2_oplock_response,
1647 .queryfs = smb2_queryfs,
1648 .mand_lock = smb2_mand_lock,
1649 .mand_unlock_range = smb2_unlock_range,
1650 .push_mand_locks = smb2_push_mandatory_locks,
1651 .get_lease_key = smb2_get_lease_key,
1652 .set_lease_key = smb2_set_lease_key,
1653 .new_lease_key = smb2_new_lease_key,
1654 .calc_signature = smb2_calc_signature,
1655 .is_read_op = smb21_is_read_op,
1656 .set_oplock_level = smb21_set_oplock_level,
1657 .create_lease_buf = smb2_create_lease_buf,
1658 .parse_lease_buf = smb2_parse_lease_buf,
1659 .clone_range = smb2_clone_range,
1660 .wp_retry_size = smb2_wp_retry_size,
1661 .dir_needs_close = smb2_dir_needs_close,
1664 struct smb_version_operations smb30_operations = {
1665 .compare_fids = smb2_compare_fids,
1666 .setup_request = smb2_setup_request,
1667 .setup_async_request = smb2_setup_async_request,
1668 .check_receive = smb2_check_receive,
1669 .add_credits = smb2_add_credits,
1670 .set_credits = smb2_set_credits,
1671 .get_credits_field = smb2_get_credits_field,
1672 .get_credits = smb2_get_credits,
1673 .wait_mtu_credits = smb2_wait_mtu_credits,
1674 .get_next_mid = smb2_get_next_mid,
1675 .read_data_offset = smb2_read_data_offset,
1676 .read_data_length = smb2_read_data_length,
1677 .map_error = map_smb2_to_linux_error,
1678 .find_mid = smb2_find_mid,
1679 .check_message = smb2_check_message,
1680 .dump_detail = smb2_dump_detail,
1681 .clear_stats = smb2_clear_stats,
1682 .print_stats = smb2_print_stats,
1683 .dump_share_caps = smb2_dump_share_caps,
1684 .is_oplock_break = smb2_is_valid_oplock_break,
1685 .downgrade_oplock = smb2_downgrade_oplock,
1686 .need_neg = smb2_need_neg,
1687 .negotiate = smb2_negotiate,
1688 .negotiate_wsize = smb2_negotiate_wsize,
1689 .negotiate_rsize = smb2_negotiate_rsize,
1690 .sess_setup = SMB2_sess_setup,
1691 .logoff = SMB2_logoff,
1692 .tree_connect = SMB2_tcon,
1693 .tree_disconnect = SMB2_tdis,
1694 .qfs_tcon = smb3_qfs_tcon,
1695 .is_path_accessible = smb2_is_path_accessible,
1696 .can_echo = smb2_can_echo,
1698 .query_path_info = smb2_query_path_info,
1699 .get_srv_inum = smb2_get_srv_inum,
1700 .query_file_info = smb2_query_file_info,
1701 .set_path_size = smb2_set_path_size,
1702 .set_file_size = smb2_set_file_size,
1703 .set_file_info = smb2_set_file_info,
1704 .set_compression = smb2_set_compression,
1705 .mkdir = smb2_mkdir,
1706 .mkdir_setinfo = smb2_mkdir_setinfo,
1707 .rmdir = smb2_rmdir,
1708 .unlink = smb2_unlink,
1709 .rename = smb2_rename_path,
1710 .create_hardlink = smb2_create_hardlink,
1711 .query_symlink = smb2_query_symlink,
1712 .query_mf_symlink = smb3_query_mf_symlink,
1713 .create_mf_symlink = smb3_create_mf_symlink,
1714 .open = smb2_open_file,
1715 .set_fid = smb2_set_fid,
1716 .close = smb2_close_file,
1717 .flush = smb2_flush_file,
1718 .async_readv = smb2_async_readv,
1719 .async_writev = smb2_async_writev,
1720 .sync_read = smb2_sync_read,
1721 .sync_write = smb2_sync_write,
1722 .query_dir_first = smb2_query_dir_first,
1723 .query_dir_next = smb2_query_dir_next,
1724 .close_dir = smb2_close_dir,
1725 .calc_smb_size = smb2_calc_size,
1726 .is_status_pending = smb2_is_status_pending,
1727 .oplock_response = smb2_oplock_response,
1728 .queryfs = smb2_queryfs,
1729 .mand_lock = smb2_mand_lock,
1730 .mand_unlock_range = smb2_unlock_range,
1731 .push_mand_locks = smb2_push_mandatory_locks,
1732 .get_lease_key = smb2_get_lease_key,
1733 .set_lease_key = smb2_set_lease_key,
1734 .new_lease_key = smb2_new_lease_key,
1735 .generate_signingkey = generate_smb30signingkey,
1736 .calc_signature = smb3_calc_signature,
1737 .set_integrity = smb3_set_integrity,
1738 .is_read_op = smb21_is_read_op,
1739 .set_oplock_level = smb3_set_oplock_level,
1740 .create_lease_buf = smb3_create_lease_buf,
1741 .parse_lease_buf = smb3_parse_lease_buf,
1742 .clone_range = smb2_clone_range,
1743 .duplicate_extents = smb2_duplicate_extents,
1744 .validate_negotiate = smb3_validate_negotiate,
1745 .wp_retry_size = smb2_wp_retry_size,
1746 .dir_needs_close = smb2_dir_needs_close,
1747 .fallocate = smb3_fallocate,
1750 #ifdef CONFIG_CIFS_SMB311
1751 struct smb_version_operations smb311_operations = {
1752 .compare_fids = smb2_compare_fids,
1753 .setup_request = smb2_setup_request,
1754 .setup_async_request = smb2_setup_async_request,
1755 .check_receive = smb2_check_receive,
1756 .add_credits = smb2_add_credits,
1757 .set_credits = smb2_set_credits,
1758 .get_credits_field = smb2_get_credits_field,
1759 .get_credits = smb2_get_credits,
1760 .wait_mtu_credits = smb2_wait_mtu_credits,
1761 .get_next_mid = smb2_get_next_mid,
1762 .read_data_offset = smb2_read_data_offset,
1763 .read_data_length = smb2_read_data_length,
1764 .map_error = map_smb2_to_linux_error,
1765 .find_mid = smb2_find_mid,
1766 .check_message = smb2_check_message,
1767 .dump_detail = smb2_dump_detail,
1768 .clear_stats = smb2_clear_stats,
1769 .print_stats = smb2_print_stats,
1770 .dump_share_caps = smb2_dump_share_caps,
1771 .is_oplock_break = smb2_is_valid_oplock_break,
1772 .downgrade_oplock = smb2_downgrade_oplock,
1773 .need_neg = smb2_need_neg,
1774 .negotiate = smb2_negotiate,
1775 .negotiate_wsize = smb2_negotiate_wsize,
1776 .negotiate_rsize = smb2_negotiate_rsize,
1777 .sess_setup = SMB2_sess_setup,
1778 .logoff = SMB2_logoff,
1779 .tree_connect = SMB2_tcon,
1780 .tree_disconnect = SMB2_tdis,
1781 .qfs_tcon = smb3_qfs_tcon,
1782 .is_path_accessible = smb2_is_path_accessible,
1783 .can_echo = smb2_can_echo,
1785 .query_path_info = smb2_query_path_info,
1786 .get_srv_inum = smb2_get_srv_inum,
1787 .query_file_info = smb2_query_file_info,
1788 .set_path_size = smb2_set_path_size,
1789 .set_file_size = smb2_set_file_size,
1790 .set_file_info = smb2_set_file_info,
1791 .set_compression = smb2_set_compression,
1792 .mkdir = smb2_mkdir,
1793 .mkdir_setinfo = smb2_mkdir_setinfo,
1794 .rmdir = smb2_rmdir,
1795 .unlink = smb2_unlink,
1796 .rename = smb2_rename_path,
1797 .create_hardlink = smb2_create_hardlink,
1798 .query_symlink = smb2_query_symlink,
1799 .query_mf_symlink = smb3_query_mf_symlink,
1800 .create_mf_symlink = smb3_create_mf_symlink,
1801 .open = smb2_open_file,
1802 .set_fid = smb2_set_fid,
1803 .close = smb2_close_file,
1804 .flush = smb2_flush_file,
1805 .async_readv = smb2_async_readv,
1806 .async_writev = smb2_async_writev,
1807 .sync_read = smb2_sync_read,
1808 .sync_write = smb2_sync_write,
1809 .query_dir_first = smb2_query_dir_first,
1810 .query_dir_next = smb2_query_dir_next,
1811 .close_dir = smb2_close_dir,
1812 .calc_smb_size = smb2_calc_size,
1813 .is_status_pending = smb2_is_status_pending,
1814 .oplock_response = smb2_oplock_response,
1815 .queryfs = smb2_queryfs,
1816 .mand_lock = smb2_mand_lock,
1817 .mand_unlock_range = smb2_unlock_range,
1818 .push_mand_locks = smb2_push_mandatory_locks,
1819 .get_lease_key = smb2_get_lease_key,
1820 .set_lease_key = smb2_set_lease_key,
1821 .new_lease_key = smb2_new_lease_key,
1822 .generate_signingkey = generate_smb311signingkey,
1823 .calc_signature = smb3_calc_signature,
1824 .set_integrity = smb3_set_integrity,
1825 .is_read_op = smb21_is_read_op,
1826 .set_oplock_level = smb3_set_oplock_level,
1827 .create_lease_buf = smb3_create_lease_buf,
1828 .parse_lease_buf = smb3_parse_lease_buf,
1829 .clone_range = smb2_clone_range,
1830 .duplicate_extents = smb2_duplicate_extents,
1831 /* .validate_negotiate = smb3_validate_negotiate, */ /* not used in 3.11 */
1832 .wp_retry_size = smb2_wp_retry_size,
1833 .dir_needs_close = smb2_dir_needs_close,
1834 .fallocate = smb3_fallocate,
1836 #endif /* CIFS_SMB311 */
1838 struct smb_version_values smb20_values = {
1839 .version_string = SMB20_VERSION_STRING,
1840 .protocol_id = SMB20_PROT_ID,
1841 .req_capabilities = 0, /* MBZ */
1842 .large_lock_type = 0,
1843 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1844 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1845 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1846 .header_size = sizeof(struct smb2_hdr),
1847 .max_header_size = MAX_SMB2_HDR_SIZE,
1848 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1849 .lock_cmd = SMB2_LOCK,
1851 .cap_nt_find = SMB2_NT_FIND,
1852 .cap_large_files = SMB2_LARGE_FILES,
1853 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1854 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1855 .create_lease_size = sizeof(struct create_lease),
1858 struct smb_version_values smb21_values = {
1859 .version_string = SMB21_VERSION_STRING,
1860 .protocol_id = SMB21_PROT_ID,
1861 .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */
1862 .large_lock_type = 0,
1863 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1864 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1865 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1866 .header_size = sizeof(struct smb2_hdr),
1867 .max_header_size = MAX_SMB2_HDR_SIZE,
1868 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1869 .lock_cmd = SMB2_LOCK,
1871 .cap_nt_find = SMB2_NT_FIND,
1872 .cap_large_files = SMB2_LARGE_FILES,
1873 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1874 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1875 .create_lease_size = sizeof(struct create_lease),
1878 struct smb_version_values smb30_values = {
1879 .version_string = SMB30_VERSION_STRING,
1880 .protocol_id = SMB30_PROT_ID,
1881 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION,
1882 .large_lock_type = 0,
1883 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1884 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1885 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1886 .header_size = sizeof(struct smb2_hdr),
1887 .max_header_size = MAX_SMB2_HDR_SIZE,
1888 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1889 .lock_cmd = SMB2_LOCK,
1891 .cap_nt_find = SMB2_NT_FIND,
1892 .cap_large_files = SMB2_LARGE_FILES,
1893 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1894 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1895 .create_lease_size = sizeof(struct create_lease_v2),
1898 struct smb_version_values smb302_values = {
1899 .version_string = SMB302_VERSION_STRING,
1900 .protocol_id = SMB302_PROT_ID,
1901 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES | SMB2_GLOBAL_CAP_ENCRYPTION,
1902 .large_lock_type = 0,
1903 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1904 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1905 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1906 .header_size = sizeof(struct smb2_hdr),
1907 .max_header_size = MAX_SMB2_HDR_SIZE,
1908 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1909 .lock_cmd = SMB2_LOCK,
1911 .cap_nt_find = SMB2_NT_FIND,
1912 .cap_large_files = SMB2_LARGE_FILES,
1913 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1914 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1915 .create_lease_size = sizeof(struct create_lease_v2),
1918 #ifdef CONFIG_CIFS_SMB311
1919 struct smb_version_values smb311_values = {
1920 .version_string = SMB311_VERSION_STRING,
1921 .protocol_id = SMB311_PROT_ID,
1922 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES,
1923 .large_lock_type = 0,
1924 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1925 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1926 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1927 .header_size = sizeof(struct smb2_hdr),
1928 .max_header_size = MAX_SMB2_HDR_SIZE,
1929 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1930 .lock_cmd = SMB2_LOCK,
1932 .cap_nt_find = SMB2_NT_FIND,
1933 .cap_large_files = SMB2_LARGE_FILES,
1934 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1935 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1936 .create_lease_size = sizeof(struct create_lease_v2),