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 if (server->in_flight == 0 && (optype & CIFS_OP_MASK) != CIFS_NEG_OP)
75 rc = change_conf(server);
77 * Sometimes server returns 0 credits on oplock break ack - we need to
78 * rebalance credits in this case.
80 else if (server->in_flight > 0 && server->oplock_credits == 0 &&
82 if (server->credits > 1) {
84 server->oplock_credits++;
87 spin_unlock(&server->req_lock);
88 wake_up(&server->request_q);
90 cifs_reconnect(server);
94 smb2_set_credits(struct TCP_Server_Info *server, const int val)
96 spin_lock(&server->req_lock);
97 server->credits = val;
98 spin_unlock(&server->req_lock);
102 smb2_get_credits_field(struct TCP_Server_Info *server, const int optype)
106 return &server->echo_credits;
108 return &server->oplock_credits;
110 return &server->credits;
115 smb2_get_credits(struct mid_q_entry *mid)
117 return le16_to_cpu(((struct smb2_hdr *)mid->resp_buf)->CreditRequest);
121 smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
122 unsigned int *num, unsigned int *credits)
125 unsigned int scredits;
127 spin_lock(&server->req_lock);
129 if (server->credits <= 0) {
130 spin_unlock(&server->req_lock);
131 cifs_num_waiters_inc(server);
132 rc = wait_event_killable(server->request_q,
133 has_credits(server, &server->credits));
134 cifs_num_waiters_dec(server);
137 spin_lock(&server->req_lock);
139 if (server->tcpStatus == CifsExiting) {
140 spin_unlock(&server->req_lock);
144 scredits = server->credits;
145 /* can deadlock with reopen */
147 *num = SMB2_MAX_BUFFER_SIZE;
152 /* leave one credit for a possible reopen */
154 *num = min_t(unsigned int, size,
155 scredits * SMB2_MAX_BUFFER_SIZE);
157 *credits = DIV_ROUND_UP(*num, SMB2_MAX_BUFFER_SIZE);
158 server->credits -= *credits;
163 spin_unlock(&server->req_lock);
168 smb2_get_next_mid(struct TCP_Server_Info *server)
171 /* for SMB2 we need the current value */
172 spin_lock(&GlobalMid_Lock);
173 mid = server->CurrentMid++;
174 spin_unlock(&GlobalMid_Lock);
178 static struct mid_q_entry *
179 smb2_find_mid(struct TCP_Server_Info *server, char *buf)
181 struct mid_q_entry *mid;
182 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
183 __u64 wire_mid = le64_to_cpu(hdr->MessageId);
185 spin_lock(&GlobalMid_Lock);
186 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
187 if ((mid->mid == wire_mid) &&
188 (mid->mid_state == MID_REQUEST_SUBMITTED) &&
189 (mid->command == hdr->Command)) {
190 spin_unlock(&GlobalMid_Lock);
194 spin_unlock(&GlobalMid_Lock);
199 smb2_dump_detail(void *buf)
201 #ifdef CONFIG_CIFS_DEBUG2
202 struct smb2_hdr *smb = (struct smb2_hdr *)buf;
204 cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
205 smb->Command, smb->Status, smb->Flags, smb->MessageId,
207 cifs_dbg(VFS, "smb buf %p len %u\n", smb, smb2_calc_size(smb));
212 smb2_need_neg(struct TCP_Server_Info *server)
214 return server->max_read == 0;
218 smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
221 ses->server->CurrentMid = 0;
222 rc = SMB2_negotiate(xid, ses);
223 /* BB we probably don't need to retry with modern servers */
230 smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
232 struct TCP_Server_Info *server = tcon->ses->server;
235 /* start with specified wsize, or default */
236 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
237 wsize = min_t(unsigned int, wsize, server->max_write);
239 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
240 wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
246 smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
248 struct TCP_Server_Info *server = tcon->ses->server;
251 /* start with specified rsize, or default */
252 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
253 rsize = min_t(unsigned int, rsize, server->max_read);
255 if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
256 rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
261 #ifdef CONFIG_CIFS_STATS2
263 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
266 unsigned int ret_data_len = 0;
267 struct network_interface_info_ioctl_rsp *out_buf;
269 rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
270 FSCTL_QUERY_NETWORK_INTERFACE_INFO, true /* is_fsctl */,
271 NULL /* no data input */, 0 /* no data input */,
272 (char **)&out_buf, &ret_data_len);
274 cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
275 else if (ret_data_len < sizeof(struct network_interface_info_ioctl_rsp)) {
276 cifs_dbg(VFS, "server returned bad net interface info buf\n");
279 /* Dump info on first interface */
280 cifs_dbg(FYI, "Adapter Capability 0x%x\t",
281 le32_to_cpu(out_buf->Capability));
282 cifs_dbg(FYI, "Link Speed %lld\n",
283 le64_to_cpu(out_buf->LinkSpeed));
291 smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
294 __le16 srch_path = 0; /* Null - open root of share */
295 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
296 struct cifs_open_parms oparms;
300 oparms.desired_access = FILE_READ_ATTRIBUTES;
301 oparms.disposition = FILE_OPEN;
302 oparms.create_options = 0;
304 oparms.reconnect = false;
306 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
310 #ifdef CONFIG_CIFS_STATS2
311 SMB3_request_interfaces(xid, tcon);
314 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
315 FS_ATTRIBUTE_INFORMATION);
316 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
317 FS_DEVICE_INFORMATION);
318 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
319 FS_SECTOR_SIZE_INFORMATION); /* SMB3 specific */
320 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
325 smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
328 __le16 srch_path = 0; /* Null - open root of share */
329 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
330 struct cifs_open_parms oparms;
334 oparms.desired_access = FILE_READ_ATTRIBUTES;
335 oparms.disposition = FILE_OPEN;
336 oparms.create_options = 0;
338 oparms.reconnect = false;
340 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
344 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
345 FS_ATTRIBUTE_INFORMATION);
346 SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
347 FS_DEVICE_INFORMATION);
348 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
353 smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
354 struct cifs_sb_info *cifs_sb, const char *full_path)
358 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
359 struct cifs_open_parms oparms;
362 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
367 oparms.desired_access = FILE_READ_ATTRIBUTES;
368 oparms.disposition = FILE_OPEN;
369 oparms.create_options = 0;
371 oparms.reconnect = false;
373 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
379 rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
385 smb2_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
386 struct cifs_sb_info *cifs_sb, const char *full_path,
387 u64 *uniqueid, FILE_ALL_INFO *data)
389 *uniqueid = le64_to_cpu(data->IndexNumber);
394 smb2_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
395 struct cifs_fid *fid, FILE_ALL_INFO *data)
398 struct smb2_file_all_info *smb2_data;
400 smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
402 if (smb2_data == NULL)
405 rc = SMB2_query_info(xid, tcon, fid->persistent_fid, fid->volatile_fid,
408 move_smb2_info_to_cifs(data, smb2_data);
414 smb2_can_echo(struct TCP_Server_Info *server)
416 return server->echoes;
420 smb2_clear_stats(struct cifs_tcon *tcon)
422 #ifdef CONFIG_CIFS_STATS
424 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
425 atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
426 atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
432 smb2_dump_share_caps(struct seq_file *m, struct cifs_tcon *tcon)
434 seq_puts(m, "\n\tShare Capabilities:");
435 if (tcon->capabilities & SMB2_SHARE_CAP_DFS)
436 seq_puts(m, " DFS,");
437 if (tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
438 seq_puts(m, " CONTINUOUS AVAILABILITY,");
439 if (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT)
440 seq_puts(m, " SCALEOUT,");
441 if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER)
442 seq_puts(m, " CLUSTER,");
443 if (tcon->capabilities & SMB2_SHARE_CAP_ASYMMETRIC)
444 seq_puts(m, " ASYMMETRIC,");
445 if (tcon->capabilities == 0)
446 seq_puts(m, " None");
447 if (tcon->ss_flags & SSINFO_FLAGS_ALIGNED_DEVICE)
448 seq_puts(m, " Aligned,");
449 if (tcon->ss_flags & SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE)
450 seq_puts(m, " Partition Aligned,");
451 if (tcon->ss_flags & SSINFO_FLAGS_NO_SEEK_PENALTY)
452 seq_puts(m, " SSD,");
453 if (tcon->ss_flags & SSINFO_FLAGS_TRIM_ENABLED)
454 seq_puts(m, " TRIM-support,");
456 seq_printf(m, "\tShare Flags: 0x%x", tcon->share_flags);
457 if (tcon->perf_sector_size)
458 seq_printf(m, "\tOptimal sector size: 0x%x",
459 tcon->perf_sector_size);
463 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
465 #ifdef CONFIG_CIFS_STATS
466 atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
467 atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
468 seq_printf(m, "\nNegotiates: %d sent %d failed",
469 atomic_read(&sent[SMB2_NEGOTIATE_HE]),
470 atomic_read(&failed[SMB2_NEGOTIATE_HE]));
471 seq_printf(m, "\nSessionSetups: %d sent %d failed",
472 atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
473 atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
474 seq_printf(m, "\nLogoffs: %d sent %d failed",
475 atomic_read(&sent[SMB2_LOGOFF_HE]),
476 atomic_read(&failed[SMB2_LOGOFF_HE]));
477 seq_printf(m, "\nTreeConnects: %d sent %d failed",
478 atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
479 atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
480 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
481 atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
482 atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
483 seq_printf(m, "\nCreates: %d sent %d failed",
484 atomic_read(&sent[SMB2_CREATE_HE]),
485 atomic_read(&failed[SMB2_CREATE_HE]));
486 seq_printf(m, "\nCloses: %d sent %d failed",
487 atomic_read(&sent[SMB2_CLOSE_HE]),
488 atomic_read(&failed[SMB2_CLOSE_HE]));
489 seq_printf(m, "\nFlushes: %d sent %d failed",
490 atomic_read(&sent[SMB2_FLUSH_HE]),
491 atomic_read(&failed[SMB2_FLUSH_HE]));
492 seq_printf(m, "\nReads: %d sent %d failed",
493 atomic_read(&sent[SMB2_READ_HE]),
494 atomic_read(&failed[SMB2_READ_HE]));
495 seq_printf(m, "\nWrites: %d sent %d failed",
496 atomic_read(&sent[SMB2_WRITE_HE]),
497 atomic_read(&failed[SMB2_WRITE_HE]));
498 seq_printf(m, "\nLocks: %d sent %d failed",
499 atomic_read(&sent[SMB2_LOCK_HE]),
500 atomic_read(&failed[SMB2_LOCK_HE]));
501 seq_printf(m, "\nIOCTLs: %d sent %d failed",
502 atomic_read(&sent[SMB2_IOCTL_HE]),
503 atomic_read(&failed[SMB2_IOCTL_HE]));
504 seq_printf(m, "\nCancels: %d sent %d failed",
505 atomic_read(&sent[SMB2_CANCEL_HE]),
506 atomic_read(&failed[SMB2_CANCEL_HE]));
507 seq_printf(m, "\nEchos: %d sent %d failed",
508 atomic_read(&sent[SMB2_ECHO_HE]),
509 atomic_read(&failed[SMB2_ECHO_HE]));
510 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
511 atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
512 atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
513 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
514 atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
515 atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
516 seq_printf(m, "\nQueryInfos: %d sent %d failed",
517 atomic_read(&sent[SMB2_QUERY_INFO_HE]),
518 atomic_read(&failed[SMB2_QUERY_INFO_HE]));
519 seq_printf(m, "\nSetInfos: %d sent %d failed",
520 atomic_read(&sent[SMB2_SET_INFO_HE]),
521 atomic_read(&failed[SMB2_SET_INFO_HE]));
522 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
523 atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
524 atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
529 smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
531 struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
532 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
534 cfile->fid.persistent_fid = fid->persistent_fid;
535 cfile->fid.volatile_fid = fid->volatile_fid;
536 server->ops->set_oplock_level(cinode, oplock, fid->epoch,
538 cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
539 memcpy(cfile->fid.create_guid, fid->create_guid, 16);
543 smb2_close_file(const unsigned int xid, struct cifs_tcon *tcon,
544 struct cifs_fid *fid)
546 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
550 SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon,
551 u64 persistent_fid, u64 volatile_fid,
552 struct copychunk_ioctl *pcchunk)
555 unsigned int ret_data_len;
556 struct resume_key_req *res_key;
558 rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid,
559 FSCTL_SRV_REQUEST_RESUME_KEY, true /* is_fsctl */,
560 NULL, 0 /* no input */,
561 (char **)&res_key, &ret_data_len);
564 cifs_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
565 goto req_res_key_exit;
567 if (ret_data_len < sizeof(struct resume_key_req)) {
568 cifs_dbg(VFS, "Invalid refcopy resume key length\n");
570 goto req_res_key_exit;
572 memcpy(pcchunk->SourceKey, res_key->ResumeKey, COPY_CHUNK_RES_KEY_SIZE);
580 smb2_clone_range(const unsigned int xid,
581 struct cifsFileInfo *srcfile,
582 struct cifsFileInfo *trgtfile, u64 src_off,
583 u64 len, u64 dest_off)
586 unsigned int ret_data_len;
587 struct copychunk_ioctl *pcchunk;
588 struct copychunk_ioctl_rsp *retbuf = NULL;
589 struct cifs_tcon *tcon;
590 int chunks_copied = 0;
591 bool chunk_sizes_updated = false;
593 pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
598 cifs_dbg(FYI, "in smb2_clone_range - about to call request res key\n");
599 /* Request a key from the server to identify the source of the copy */
600 rc = SMB2_request_res_key(xid, tlink_tcon(srcfile->tlink),
601 srcfile->fid.persistent_fid,
602 srcfile->fid.volatile_fid, pcchunk);
604 /* Note: request_res_key sets res_key null only if rc !=0 */
608 /* For now array only one chunk long, will make more flexible later */
609 pcchunk->ChunkCount = cpu_to_le32(1);
610 pcchunk->Reserved = 0;
611 pcchunk->Reserved2 = 0;
613 tcon = tlink_tcon(trgtfile->tlink);
616 pcchunk->SourceOffset = cpu_to_le64(src_off);
617 pcchunk->TargetOffset = cpu_to_le64(dest_off);
619 cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
621 /* Request server copy to target from src identified by key */
622 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
623 trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
624 true /* is_fsctl */, (char *)pcchunk,
625 sizeof(struct copychunk_ioctl), (char **)&retbuf,
629 sizeof(struct copychunk_ioctl_rsp)) {
630 cifs_dbg(VFS, "invalid cchunk response size\n");
634 if (retbuf->TotalBytesWritten == 0) {
635 cifs_dbg(FYI, "no bytes copied\n");
640 * Check if server claimed to write more than we asked
642 if (le32_to_cpu(retbuf->TotalBytesWritten) >
643 le32_to_cpu(pcchunk->Length)) {
644 cifs_dbg(VFS, "invalid copy chunk response\n");
648 if (le32_to_cpu(retbuf->ChunksWritten) != 1) {
649 cifs_dbg(VFS, "invalid num chunks written\n");
655 src_off += le32_to_cpu(retbuf->TotalBytesWritten);
656 dest_off += le32_to_cpu(retbuf->TotalBytesWritten);
657 len -= le32_to_cpu(retbuf->TotalBytesWritten);
659 cifs_dbg(FYI, "Chunks %d PartialChunk %d Total %d\n",
660 le32_to_cpu(retbuf->ChunksWritten),
661 le32_to_cpu(retbuf->ChunkBytesWritten),
662 le32_to_cpu(retbuf->TotalBytesWritten));
663 } else if (rc == -EINVAL) {
664 if (ret_data_len != sizeof(struct copychunk_ioctl_rsp))
667 cifs_dbg(FYI, "MaxChunks %d BytesChunk %d MaxCopy %d\n",
668 le32_to_cpu(retbuf->ChunksWritten),
669 le32_to_cpu(retbuf->ChunkBytesWritten),
670 le32_to_cpu(retbuf->TotalBytesWritten));
673 * Check if this is the first request using these sizes,
674 * (ie check if copy succeed once with original sizes
675 * and check if the server gave us different sizes after
676 * we already updated max sizes on previous request).
677 * if not then why is the server returning an error now
679 if ((chunks_copied != 0) || chunk_sizes_updated)
682 /* Check that server is not asking us to grow size */
683 if (le32_to_cpu(retbuf->ChunkBytesWritten) <
684 tcon->max_bytes_chunk)
685 tcon->max_bytes_chunk =
686 le32_to_cpu(retbuf->ChunkBytesWritten);
688 goto cchunk_out; /* server gave us bogus size */
690 /* No need to change MaxChunks since already set to 1 */
691 chunk_sizes_updated = true;
702 smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
703 struct cifs_fid *fid)
705 return SMB2_flush(xid, tcon, fid->persistent_fid, fid->volatile_fid);
709 smb2_read_data_offset(char *buf)
711 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
712 return rsp->DataOffset;
716 smb2_read_data_length(char *buf)
718 struct smb2_read_rsp *rsp = (struct smb2_read_rsp *)buf;
719 return le32_to_cpu(rsp->DataLength);
724 smb2_sync_read(const unsigned int xid, struct cifs_fid *pfid,
725 struct cifs_io_parms *parms, unsigned int *bytes_read,
726 char **buf, int *buf_type)
728 parms->persistent_fid = pfid->persistent_fid;
729 parms->volatile_fid = pfid->volatile_fid;
730 return SMB2_read(xid, parms, bytes_read, buf, buf_type);
734 smb2_sync_write(const unsigned int xid, struct cifs_fid *pfid,
735 struct cifs_io_parms *parms, unsigned int *written,
736 struct kvec *iov, unsigned long nr_segs)
739 parms->persistent_fid = pfid->persistent_fid;
740 parms->volatile_fid = pfid->volatile_fid;
741 return SMB2_write(xid, parms, written, iov, nr_segs);
744 /* Set or clear the SPARSE_FILE attribute based on value passed in setsparse */
745 static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,
746 struct cifsFileInfo *cfile, struct inode *inode, __u8 setsparse)
748 struct cifsInodeInfo *cifsi;
751 cifsi = CIFS_I(inode);
753 /* if file already sparse don't bother setting sparse again */
754 if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && setsparse)
755 return true; /* already sparse */
757 if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && !setsparse)
758 return true; /* already not sparse */
761 * Can't check for sparse support on share the usual way via the
762 * FS attribute info (FILE_SUPPORTS_SPARSE_FILES) on the share
763 * since Samba server doesn't set the flag on the share, yet
764 * supports the set sparse FSCTL and returns sparse correctly
765 * in the file attributes. If we fail setting sparse though we
766 * mark that server does not support sparse files for this share
767 * to avoid repeatedly sending the unsupported fsctl to server
768 * if the file is repeatedly extended.
770 if (tcon->broken_sparse_sup)
773 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
774 cfile->fid.volatile_fid, FSCTL_SET_SPARSE,
775 true /* is_fctl */, &setsparse, 1, NULL, NULL);
777 tcon->broken_sparse_sup = true;
778 cifs_dbg(FYI, "set sparse rc = %d\n", rc);
783 cifsi->cifsAttrs |= FILE_ATTRIBUTE_SPARSE_FILE;
785 cifsi->cifsAttrs &= (~FILE_ATTRIBUTE_SPARSE_FILE);
791 smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
792 struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
794 __le64 eof = cpu_to_le64(size);
798 * If extending file more than one page make sparse. Many Linux fs
799 * make files sparse by default when extending via ftruncate
801 inode = d_inode(cfile->dentry);
803 if (!set_alloc && (size > inode->i_size + 8192)) {
806 /* whether set sparse succeeds or not, extend the file */
807 smb2_set_sparse(xid, tcon, cfile, inode, set_sparse);
810 return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
811 cfile->fid.volatile_fid, cfile->pid, &eof, false);
815 smb2_duplicate_extents(const unsigned int xid,
816 struct cifsFileInfo *srcfile,
817 struct cifsFileInfo *trgtfile, u64 src_off,
818 u64 len, u64 dest_off)
821 unsigned int ret_data_len;
823 struct duplicate_extents_to_file dup_ext_buf;
824 struct cifs_tcon *tcon = tlink_tcon(trgtfile->tlink);
826 /* server fileays advertise duplicate extent support with this flag */
827 if ((le32_to_cpu(tcon->fsAttrInfo.Attributes) &
828 FILE_SUPPORTS_BLOCK_REFCOUNTING) == 0)
831 dup_ext_buf.VolatileFileHandle = srcfile->fid.volatile_fid;
832 dup_ext_buf.PersistentFileHandle = srcfile->fid.persistent_fid;
833 dup_ext_buf.SourceFileOffset = cpu_to_le64(src_off);
834 dup_ext_buf.TargetFileOffset = cpu_to_le64(dest_off);
835 dup_ext_buf.ByteCount = cpu_to_le64(len);
836 cifs_dbg(FYI, "duplicate extents: src off %lld dst off %lld len %lld",
837 src_off, dest_off, len);
839 rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
841 goto duplicate_extents_out;
843 rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
844 trgtfile->fid.volatile_fid,
845 FSCTL_DUPLICATE_EXTENTS_TO_FILE,
846 true /* is_fsctl */, (char *)&dup_ext_buf,
847 sizeof(struct duplicate_extents_to_file),
851 if (ret_data_len > 0)
852 cifs_dbg(FYI, "non-zero response length in duplicate extents");
854 duplicate_extents_out:
859 smb2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
860 struct cifsFileInfo *cfile)
862 return SMB2_set_compression(xid, tcon, cfile->fid.persistent_fid,
863 cfile->fid.volatile_fid);
867 smb3_set_integrity(const unsigned int xid, struct cifs_tcon *tcon,
868 struct cifsFileInfo *cfile)
870 struct fsctl_set_integrity_information_req integr_info;
872 unsigned int ret_data_len;
874 integr_info.ChecksumAlgorithm = cpu_to_le16(CHECKSUM_TYPE_UNCHANGED);
875 integr_info.Flags = 0;
876 integr_info.Reserved = 0;
878 return SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
879 cfile->fid.volatile_fid,
880 FSCTL_SET_INTEGRITY_INFORMATION,
881 true /* is_fsctl */, (char *)&integr_info,
882 sizeof(struct fsctl_set_integrity_information_req),
889 smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
890 const char *path, struct cifs_sb_info *cifs_sb,
891 struct cifs_fid *fid, __u16 search_flags,
892 struct cifs_search_info *srch_inf)
896 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
897 struct cifs_open_parms oparms;
899 utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
904 oparms.desired_access = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
905 oparms.disposition = FILE_OPEN;
906 oparms.create_options = 0;
908 oparms.reconnect = false;
910 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
913 cifs_dbg(VFS, "open dir failed\n");
917 srch_inf->entries_in_buffer = 0;
918 srch_inf->index_of_last_entry = 0;
920 rc = SMB2_query_directory(xid, tcon, fid->persistent_fid,
921 fid->volatile_fid, 0, srch_inf);
923 cifs_dbg(VFS, "query directory failed\n");
924 SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
930 smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
931 struct cifs_fid *fid, __u16 search_flags,
932 struct cifs_search_info *srch_inf)
934 return SMB2_query_directory(xid, tcon, fid->persistent_fid,
935 fid->volatile_fid, 0, srch_inf);
939 smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
940 struct cifs_fid *fid)
942 return SMB2_close(xid, tcon, fid->persistent_fid, fid->volatile_fid);
946 * If we negotiate SMB2 protocol and get STATUS_PENDING - update
947 * the number of credits and return true. Otherwise - return false.
950 smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length)
952 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
954 if (hdr->Status != STATUS_PENDING)
958 spin_lock(&server->req_lock);
959 server->credits += le16_to_cpu(hdr->CreditRequest);
960 spin_unlock(&server->req_lock);
961 wake_up(&server->request_q);
968 smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
969 struct cifsInodeInfo *cinode)
971 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
972 return SMB2_lease_break(0, tcon, cinode->lease_key,
973 smb2_get_lease_state(cinode));
975 return SMB2_oplock_break(0, tcon, fid->persistent_fid,
977 CIFS_CACHE_READ(cinode) ? 1 : 0);
981 smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
985 __le16 srch_path = 0; /* Null - open root of share */
986 u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
987 struct cifs_open_parms oparms;
991 oparms.desired_access = FILE_READ_ATTRIBUTES;
992 oparms.disposition = FILE_OPEN;
993 oparms.create_options = 0;
995 oparms.reconnect = false;
997 rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL);
1000 buf->f_type = SMB2_MAGIC_NUMBER;
1001 rc = SMB2_QFS_info(xid, tcon, fid.persistent_fid, fid.volatile_fid,
1003 SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
1008 smb2_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
1010 return ob1->fid.persistent_fid == ob2->fid.persistent_fid &&
1011 ob1->fid.volatile_fid == ob2->fid.volatile_fid;
1015 smb2_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
1016 __u64 length, __u32 type, int lock, int unlock, bool wait)
1018 if (unlock && !lock)
1019 type = SMB2_LOCKFLAG_UNLOCK;
1020 return SMB2_lock(xid, tlink_tcon(cfile->tlink),
1021 cfile->fid.persistent_fid, cfile->fid.volatile_fid,
1022 current->tgid, length, offset, type, wait);
1026 smb2_get_lease_key(struct inode *inode, struct cifs_fid *fid)
1028 memcpy(fid->lease_key, CIFS_I(inode)->lease_key, SMB2_LEASE_KEY_SIZE);
1032 smb2_set_lease_key(struct inode *inode, struct cifs_fid *fid)
1034 memcpy(CIFS_I(inode)->lease_key, fid->lease_key, SMB2_LEASE_KEY_SIZE);
1038 smb2_new_lease_key(struct cifs_fid *fid)
1040 get_random_bytes(fid->lease_key, SMB2_LEASE_KEY_SIZE);
1043 #define SMB2_SYMLINK_STRUCT_SIZE \
1044 (sizeof(struct smb2_err_rsp) - 1 + sizeof(struct smb2_symlink_err_rsp))
1047 smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
1048 const char *full_path, char **target_path,
1049 struct cifs_sb_info *cifs_sb)
1053 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
1054 struct cifs_open_parms oparms;
1055 struct cifs_fid fid;
1056 struct smb2_err_rsp *err_buf = NULL;
1057 struct smb2_symlink_err_rsp *symlink;
1058 unsigned int sub_len;
1059 unsigned int sub_offset;
1060 unsigned int print_len;
1061 unsigned int print_offset;
1063 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
1065 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
1070 oparms.desired_access = FILE_READ_ATTRIBUTES;
1071 oparms.disposition = FILE_OPEN;
1072 oparms.create_options = 0;
1074 oparms.reconnect = false;
1076 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
1078 if (!rc || !err_buf) {
1083 if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) ||
1084 get_rfc1002_length(err_buf) + 4 < SMB2_SYMLINK_STRUCT_SIZE) {
1089 /* open must fail on symlink - reset rc */
1091 symlink = (struct smb2_symlink_err_rsp *)err_buf->ErrorData;
1092 sub_len = le16_to_cpu(symlink->SubstituteNameLength);
1093 sub_offset = le16_to_cpu(symlink->SubstituteNameOffset);
1094 print_len = le16_to_cpu(symlink->PrintNameLength);
1095 print_offset = le16_to_cpu(symlink->PrintNameOffset);
1097 if (get_rfc1002_length(err_buf) + 4 <
1098 SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) {
1103 if (get_rfc1002_length(err_buf) + 4 <
1104 SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) {
1109 *target_path = cifs_strndup_from_utf16(
1110 (char *)symlink->PathBuffer + sub_offset,
1111 sub_len, true, cifs_sb->local_nls);
1112 if (!(*target_path)) {
1116 convert_delimiter(*target_path, '/');
1117 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
1122 static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
1123 loff_t offset, loff_t len, bool keep_size)
1125 struct inode *inode;
1126 struct cifsInodeInfo *cifsi;
1127 struct cifsFileInfo *cfile = file->private_data;
1128 struct file_zero_data_information fsctl_buf;
1134 inode = d_inode(cfile->dentry);
1135 cifsi = CIFS_I(inode);
1137 /* if file not oplocked can't be sure whether asking to extend size */
1138 if (!CIFS_CACHE_READ(cifsi))
1139 if (keep_size == false)
1143 * Must check if file sparse since fallocate -z (zero range) assumes
1144 * non-sparse allocation
1146 if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE))
1150 * need to make sure we are not asked to extend the file since the SMB3
1151 * fsctl does not change the file size. In the future we could change
1152 * this to zero the first part of the range then set the file size
1153 * which for a non sparse file would zero the newly extended range
1155 if (keep_size == false)
1156 if (i_size_read(inode) < offset + len)
1159 cifs_dbg(FYI, "offset %lld len %lld", offset, len);
1161 fsctl_buf.FileOffset = cpu_to_le64(offset);
1162 fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
1164 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
1165 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
1166 true /* is_fctl */, (char *)&fsctl_buf,
1167 sizeof(struct file_zero_data_information), NULL, NULL);
1172 static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
1173 loff_t offset, loff_t len)
1175 struct inode *inode;
1176 struct cifsInodeInfo *cifsi;
1177 struct cifsFileInfo *cfile = file->private_data;
1178 struct file_zero_data_information fsctl_buf;
1181 __u8 set_sparse = 1;
1185 inode = d_inode(cfile->dentry);
1186 cifsi = CIFS_I(inode);
1188 /* Need to make file sparse, if not already, before freeing range. */
1189 /* Consider adding equivalent for compressed since it could also work */
1190 if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse))
1193 cifs_dbg(FYI, "offset %lld len %lld", offset, len);
1195 fsctl_buf.FileOffset = cpu_to_le64(offset);
1196 fsctl_buf.BeyondFinalZero = cpu_to_le64(offset + len);
1198 rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
1199 cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
1200 true /* is_fctl */, (char *)&fsctl_buf,
1201 sizeof(struct file_zero_data_information), NULL, NULL);
1206 static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
1207 loff_t off, loff_t len, bool keep_size)
1209 struct inode *inode;
1210 struct cifsInodeInfo *cifsi;
1211 struct cifsFileInfo *cfile = file->private_data;
1212 long rc = -EOPNOTSUPP;
1217 inode = d_inode(cfile->dentry);
1218 cifsi = CIFS_I(inode);
1220 /* if file not oplocked can't be sure whether asking to extend size */
1221 if (!CIFS_CACHE_READ(cifsi))
1222 if (keep_size == false)
1226 * Files are non-sparse by default so falloc may be a no-op
1227 * Must check if file sparse. If not sparse, and not extending
1228 * then no need to do anything since file already allocated
1230 if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {
1231 if (keep_size == true)
1233 /* check if extending file */
1234 else if (i_size_read(inode) >= off + len)
1235 /* not extending file and already not sparse */
1237 /* BB: in future add else clause to extend file */
1242 if ((keep_size == true) || (i_size_read(inode) >= off + len)) {
1244 * Check if falloc starts within first few pages of file
1245 * and ends within a few pages of the end of file to
1246 * ensure that most of file is being forced to be
1247 * fallocated now. If so then setting whole file sparse
1248 * ie potentially making a few extra pages at the beginning
1249 * or end of the file non-sparse via set_sparse is harmless.
1251 if ((off > 8192) || (off + len + 8192 < i_size_read(inode)))
1254 rc = smb2_set_sparse(xid, tcon, cfile, inode, false);
1256 /* BB: else ... in future add code to extend file and set sparse */
1264 static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,
1265 loff_t off, loff_t len)
1267 /* KEEP_SIZE already checked for by do_fallocate */
1268 if (mode & FALLOC_FL_PUNCH_HOLE)
1269 return smb3_punch_hole(file, tcon, off, len);
1270 else if (mode & FALLOC_FL_ZERO_RANGE) {
1271 if (mode & FALLOC_FL_KEEP_SIZE)
1272 return smb3_zero_range(file, tcon, off, len, true);
1273 return smb3_zero_range(file, tcon, off, len, false);
1274 } else if (mode == FALLOC_FL_KEEP_SIZE)
1275 return smb3_simple_falloc(file, tcon, off, len, true);
1277 return smb3_simple_falloc(file, tcon, off, len, false);
1283 smb2_downgrade_oplock(struct TCP_Server_Info *server,
1284 struct cifsInodeInfo *cinode, bool set_level2)
1287 server->ops->set_oplock_level(cinode, SMB2_OPLOCK_LEVEL_II,
1290 server->ops->set_oplock_level(cinode, 0, 0, NULL);
1294 smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1295 unsigned int epoch, bool *purge_cache)
1298 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
1300 if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
1301 cinode->oplock = CIFS_CACHE_RHW_FLG;
1302 cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
1303 &cinode->vfs_inode);
1304 } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
1305 cinode->oplock = CIFS_CACHE_RW_FLG;
1306 cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
1307 &cinode->vfs_inode);
1308 } else if (oplock == SMB2_OPLOCK_LEVEL_II) {
1309 cinode->oplock = CIFS_CACHE_READ_FLG;
1310 cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
1311 &cinode->vfs_inode);
1317 smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1318 unsigned int epoch, bool *purge_cache)
1320 char message[5] = {0};
1323 if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
1327 if (oplock & SMB2_LEASE_READ_CACHING_HE) {
1328 cinode->oplock |= CIFS_CACHE_READ_FLG;
1329 strcat(message, "R");
1331 if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
1332 cinode->oplock |= CIFS_CACHE_HANDLE_FLG;
1333 strcat(message, "H");
1335 if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
1336 cinode->oplock |= CIFS_CACHE_WRITE_FLG;
1337 strcat(message, "W");
1339 if (!cinode->oplock)
1340 strcat(message, "None");
1341 cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
1342 &cinode->vfs_inode);
1346 smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
1347 unsigned int epoch, bool *purge_cache)
1349 unsigned int old_oplock = cinode->oplock;
1351 smb21_set_oplock_level(cinode, oplock, epoch, purge_cache);
1354 *purge_cache = false;
1355 if (old_oplock == CIFS_CACHE_READ_FLG) {
1356 if (cinode->oplock == CIFS_CACHE_READ_FLG &&
1357 (epoch - cinode->epoch > 0))
1358 *purge_cache = true;
1359 else if (cinode->oplock == CIFS_CACHE_RH_FLG &&
1360 (epoch - cinode->epoch > 1))
1361 *purge_cache = true;
1362 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
1363 (epoch - cinode->epoch > 1))
1364 *purge_cache = true;
1365 else if (cinode->oplock == 0 &&
1366 (epoch - cinode->epoch > 0))
1367 *purge_cache = true;
1368 } else if (old_oplock == CIFS_CACHE_RH_FLG) {
1369 if (cinode->oplock == CIFS_CACHE_RH_FLG &&
1370 (epoch - cinode->epoch > 0))
1371 *purge_cache = true;
1372 else if (cinode->oplock == CIFS_CACHE_RHW_FLG &&
1373 (epoch - cinode->epoch > 1))
1374 *purge_cache = true;
1376 cinode->epoch = epoch;
1381 smb2_is_read_op(__u32 oplock)
1383 return oplock == SMB2_OPLOCK_LEVEL_II;
1387 smb21_is_read_op(__u32 oplock)
1389 return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
1390 !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
1394 map_oplock_to_lease(u8 oplock)
1396 if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE)
1397 return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING;
1398 else if (oplock == SMB2_OPLOCK_LEVEL_II)
1399 return SMB2_LEASE_READ_CACHING;
1400 else if (oplock == SMB2_OPLOCK_LEVEL_BATCH)
1401 return SMB2_LEASE_HANDLE_CACHING | SMB2_LEASE_READ_CACHING |
1402 SMB2_LEASE_WRITE_CACHING;
1407 smb2_create_lease_buf(u8 *lease_key, u8 oplock)
1409 struct create_lease *buf;
1411 buf = kzalloc(sizeof(struct create_lease), GFP_KERNEL);
1415 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
1416 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
1417 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
1419 buf->ccontext.DataOffset = cpu_to_le16(offsetof
1420 (struct create_lease, lcontext));
1421 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context));
1422 buf->ccontext.NameOffset = cpu_to_le16(offsetof
1423 (struct create_lease, Name));
1424 buf->ccontext.NameLength = cpu_to_le16(4);
1425 /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
1434 smb3_create_lease_buf(u8 *lease_key, u8 oplock)
1436 struct create_lease_v2 *buf;
1438 buf = kzalloc(sizeof(struct create_lease_v2), GFP_KERNEL);
1442 buf->lcontext.LeaseKeyLow = cpu_to_le64(*((u64 *)lease_key));
1443 buf->lcontext.LeaseKeyHigh = cpu_to_le64(*((u64 *)(lease_key + 8)));
1444 buf->lcontext.LeaseState = map_oplock_to_lease(oplock);
1446 buf->ccontext.DataOffset = cpu_to_le16(offsetof
1447 (struct create_lease_v2, lcontext));
1448 buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
1449 buf->ccontext.NameOffset = cpu_to_le16(offsetof
1450 (struct create_lease_v2, Name));
1451 buf->ccontext.NameLength = cpu_to_le16(4);
1452 /* SMB2_CREATE_REQUEST_LEASE is "RqLs" */
1461 smb2_parse_lease_buf(void *buf, unsigned int *epoch)
1463 struct create_lease *lc = (struct create_lease *)buf;
1465 *epoch = 0; /* not used */
1466 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
1467 return SMB2_OPLOCK_LEVEL_NOCHANGE;
1468 return le32_to_cpu(lc->lcontext.LeaseState);
1472 smb3_parse_lease_buf(void *buf, unsigned int *epoch)
1474 struct create_lease_v2 *lc = (struct create_lease_v2 *)buf;
1476 *epoch = le16_to_cpu(lc->lcontext.Epoch);
1477 if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS)
1478 return SMB2_OPLOCK_LEVEL_NOCHANGE;
1479 return le32_to_cpu(lc->lcontext.LeaseState);
1483 smb2_wp_retry_size(struct inode *inode)
1485 return min_t(unsigned int, CIFS_SB(inode->i_sb)->wsize,
1486 SMB2_MAX_BUFFER_SIZE);
1490 smb2_dir_needs_close(struct cifsFileInfo *cfile)
1492 return !cfile->invalidHandle;
1495 struct smb_version_operations smb20_operations = {
1496 .compare_fids = smb2_compare_fids,
1497 .setup_request = smb2_setup_request,
1498 .setup_async_request = smb2_setup_async_request,
1499 .check_receive = smb2_check_receive,
1500 .add_credits = smb2_add_credits,
1501 .set_credits = smb2_set_credits,
1502 .get_credits_field = smb2_get_credits_field,
1503 .get_credits = smb2_get_credits,
1504 .wait_mtu_credits = cifs_wait_mtu_credits,
1505 .get_next_mid = smb2_get_next_mid,
1506 .read_data_offset = smb2_read_data_offset,
1507 .read_data_length = smb2_read_data_length,
1508 .map_error = map_smb2_to_linux_error,
1509 .find_mid = smb2_find_mid,
1510 .check_message = smb2_check_message,
1511 .dump_detail = smb2_dump_detail,
1512 .clear_stats = smb2_clear_stats,
1513 .print_stats = smb2_print_stats,
1514 .is_oplock_break = smb2_is_valid_oplock_break,
1515 .downgrade_oplock = smb2_downgrade_oplock,
1516 .need_neg = smb2_need_neg,
1517 .negotiate = smb2_negotiate,
1518 .negotiate_wsize = smb2_negotiate_wsize,
1519 .negotiate_rsize = smb2_negotiate_rsize,
1520 .sess_setup = SMB2_sess_setup,
1521 .logoff = SMB2_logoff,
1522 .tree_connect = SMB2_tcon,
1523 .tree_disconnect = SMB2_tdis,
1524 .qfs_tcon = smb2_qfs_tcon,
1525 .is_path_accessible = smb2_is_path_accessible,
1526 .can_echo = smb2_can_echo,
1528 .query_path_info = smb2_query_path_info,
1529 .get_srv_inum = smb2_get_srv_inum,
1530 .query_file_info = smb2_query_file_info,
1531 .set_path_size = smb2_set_path_size,
1532 .set_file_size = smb2_set_file_size,
1533 .set_file_info = smb2_set_file_info,
1534 .set_compression = smb2_set_compression,
1535 .mkdir = smb2_mkdir,
1536 .mkdir_setinfo = smb2_mkdir_setinfo,
1537 .rmdir = smb2_rmdir,
1538 .unlink = smb2_unlink,
1539 .rename = smb2_rename_path,
1540 .create_hardlink = smb2_create_hardlink,
1541 .query_symlink = smb2_query_symlink,
1542 .open = smb2_open_file,
1543 .set_fid = smb2_set_fid,
1544 .close = smb2_close_file,
1545 .flush = smb2_flush_file,
1546 .async_readv = smb2_async_readv,
1547 .async_writev = smb2_async_writev,
1548 .sync_read = smb2_sync_read,
1549 .sync_write = smb2_sync_write,
1550 .query_dir_first = smb2_query_dir_first,
1551 .query_dir_next = smb2_query_dir_next,
1552 .close_dir = smb2_close_dir,
1553 .calc_smb_size = smb2_calc_size,
1554 .is_status_pending = smb2_is_status_pending,
1555 .oplock_response = smb2_oplock_response,
1556 .queryfs = smb2_queryfs,
1557 .mand_lock = smb2_mand_lock,
1558 .mand_unlock_range = smb2_unlock_range,
1559 .push_mand_locks = smb2_push_mandatory_locks,
1560 .get_lease_key = smb2_get_lease_key,
1561 .set_lease_key = smb2_set_lease_key,
1562 .new_lease_key = smb2_new_lease_key,
1563 .calc_signature = smb2_calc_signature,
1564 .is_read_op = smb2_is_read_op,
1565 .set_oplock_level = smb2_set_oplock_level,
1566 .create_lease_buf = smb2_create_lease_buf,
1567 .parse_lease_buf = smb2_parse_lease_buf,
1568 .clone_range = smb2_clone_range,
1569 .wp_retry_size = smb2_wp_retry_size,
1570 .dir_needs_close = smb2_dir_needs_close,
1573 struct smb_version_operations smb21_operations = {
1574 .compare_fids = smb2_compare_fids,
1575 .setup_request = smb2_setup_request,
1576 .setup_async_request = smb2_setup_async_request,
1577 .check_receive = smb2_check_receive,
1578 .add_credits = smb2_add_credits,
1579 .set_credits = smb2_set_credits,
1580 .get_credits_field = smb2_get_credits_field,
1581 .get_credits = smb2_get_credits,
1582 .wait_mtu_credits = smb2_wait_mtu_credits,
1583 .get_next_mid = smb2_get_next_mid,
1584 .read_data_offset = smb2_read_data_offset,
1585 .read_data_length = smb2_read_data_length,
1586 .map_error = map_smb2_to_linux_error,
1587 .find_mid = smb2_find_mid,
1588 .check_message = smb2_check_message,
1589 .dump_detail = smb2_dump_detail,
1590 .clear_stats = smb2_clear_stats,
1591 .print_stats = smb2_print_stats,
1592 .is_oplock_break = smb2_is_valid_oplock_break,
1593 .downgrade_oplock = smb2_downgrade_oplock,
1594 .need_neg = smb2_need_neg,
1595 .negotiate = smb2_negotiate,
1596 .negotiate_wsize = smb2_negotiate_wsize,
1597 .negotiate_rsize = smb2_negotiate_rsize,
1598 .sess_setup = SMB2_sess_setup,
1599 .logoff = SMB2_logoff,
1600 .tree_connect = SMB2_tcon,
1601 .tree_disconnect = SMB2_tdis,
1602 .qfs_tcon = smb2_qfs_tcon,
1603 .is_path_accessible = smb2_is_path_accessible,
1604 .can_echo = smb2_can_echo,
1606 .query_path_info = smb2_query_path_info,
1607 .get_srv_inum = smb2_get_srv_inum,
1608 .query_file_info = smb2_query_file_info,
1609 .set_path_size = smb2_set_path_size,
1610 .set_file_size = smb2_set_file_size,
1611 .set_file_info = smb2_set_file_info,
1612 .set_compression = smb2_set_compression,
1613 .mkdir = smb2_mkdir,
1614 .mkdir_setinfo = smb2_mkdir_setinfo,
1615 .rmdir = smb2_rmdir,
1616 .unlink = smb2_unlink,
1617 .rename = smb2_rename_path,
1618 .create_hardlink = smb2_create_hardlink,
1619 .query_symlink = smb2_query_symlink,
1620 .query_mf_symlink = smb3_query_mf_symlink,
1621 .create_mf_symlink = smb3_create_mf_symlink,
1622 .open = smb2_open_file,
1623 .set_fid = smb2_set_fid,
1624 .close = smb2_close_file,
1625 .flush = smb2_flush_file,
1626 .async_readv = smb2_async_readv,
1627 .async_writev = smb2_async_writev,
1628 .sync_read = smb2_sync_read,
1629 .sync_write = smb2_sync_write,
1630 .query_dir_first = smb2_query_dir_first,
1631 .query_dir_next = smb2_query_dir_next,
1632 .close_dir = smb2_close_dir,
1633 .calc_smb_size = smb2_calc_size,
1634 .is_status_pending = smb2_is_status_pending,
1635 .oplock_response = smb2_oplock_response,
1636 .queryfs = smb2_queryfs,
1637 .mand_lock = smb2_mand_lock,
1638 .mand_unlock_range = smb2_unlock_range,
1639 .push_mand_locks = smb2_push_mandatory_locks,
1640 .get_lease_key = smb2_get_lease_key,
1641 .set_lease_key = smb2_set_lease_key,
1642 .new_lease_key = smb2_new_lease_key,
1643 .calc_signature = smb2_calc_signature,
1644 .is_read_op = smb21_is_read_op,
1645 .set_oplock_level = smb21_set_oplock_level,
1646 .create_lease_buf = smb2_create_lease_buf,
1647 .parse_lease_buf = smb2_parse_lease_buf,
1648 .clone_range = smb2_clone_range,
1649 .wp_retry_size = smb2_wp_retry_size,
1650 .dir_needs_close = smb2_dir_needs_close,
1653 struct smb_version_operations smb30_operations = {
1654 .compare_fids = smb2_compare_fids,
1655 .setup_request = smb2_setup_request,
1656 .setup_async_request = smb2_setup_async_request,
1657 .check_receive = smb2_check_receive,
1658 .add_credits = smb2_add_credits,
1659 .set_credits = smb2_set_credits,
1660 .get_credits_field = smb2_get_credits_field,
1661 .get_credits = smb2_get_credits,
1662 .wait_mtu_credits = smb2_wait_mtu_credits,
1663 .get_next_mid = smb2_get_next_mid,
1664 .read_data_offset = smb2_read_data_offset,
1665 .read_data_length = smb2_read_data_length,
1666 .map_error = map_smb2_to_linux_error,
1667 .find_mid = smb2_find_mid,
1668 .check_message = smb2_check_message,
1669 .dump_detail = smb2_dump_detail,
1670 .clear_stats = smb2_clear_stats,
1671 .print_stats = smb2_print_stats,
1672 .dump_share_caps = smb2_dump_share_caps,
1673 .is_oplock_break = smb2_is_valid_oplock_break,
1674 .downgrade_oplock = smb2_downgrade_oplock,
1675 .need_neg = smb2_need_neg,
1676 .negotiate = smb2_negotiate,
1677 .negotiate_wsize = smb2_negotiate_wsize,
1678 .negotiate_rsize = smb2_negotiate_rsize,
1679 .sess_setup = SMB2_sess_setup,
1680 .logoff = SMB2_logoff,
1681 .tree_connect = SMB2_tcon,
1682 .tree_disconnect = SMB2_tdis,
1683 .qfs_tcon = smb3_qfs_tcon,
1684 .is_path_accessible = smb2_is_path_accessible,
1685 .can_echo = smb2_can_echo,
1687 .query_path_info = smb2_query_path_info,
1688 .get_srv_inum = smb2_get_srv_inum,
1689 .query_file_info = smb2_query_file_info,
1690 .set_path_size = smb2_set_path_size,
1691 .set_file_size = smb2_set_file_size,
1692 .set_file_info = smb2_set_file_info,
1693 .set_compression = smb2_set_compression,
1694 .mkdir = smb2_mkdir,
1695 .mkdir_setinfo = smb2_mkdir_setinfo,
1696 .rmdir = smb2_rmdir,
1697 .unlink = smb2_unlink,
1698 .rename = smb2_rename_path,
1699 .create_hardlink = smb2_create_hardlink,
1700 .query_symlink = smb2_query_symlink,
1701 .query_mf_symlink = smb3_query_mf_symlink,
1702 .create_mf_symlink = smb3_create_mf_symlink,
1703 .open = smb2_open_file,
1704 .set_fid = smb2_set_fid,
1705 .close = smb2_close_file,
1706 .flush = smb2_flush_file,
1707 .async_readv = smb2_async_readv,
1708 .async_writev = smb2_async_writev,
1709 .sync_read = smb2_sync_read,
1710 .sync_write = smb2_sync_write,
1711 .query_dir_first = smb2_query_dir_first,
1712 .query_dir_next = smb2_query_dir_next,
1713 .close_dir = smb2_close_dir,
1714 .calc_smb_size = smb2_calc_size,
1715 .is_status_pending = smb2_is_status_pending,
1716 .oplock_response = smb2_oplock_response,
1717 .queryfs = smb2_queryfs,
1718 .mand_lock = smb2_mand_lock,
1719 .mand_unlock_range = smb2_unlock_range,
1720 .push_mand_locks = smb2_push_mandatory_locks,
1721 .get_lease_key = smb2_get_lease_key,
1722 .set_lease_key = smb2_set_lease_key,
1723 .new_lease_key = smb2_new_lease_key,
1724 .generate_signingkey = generate_smb3signingkey,
1725 .calc_signature = smb3_calc_signature,
1726 .set_integrity = smb3_set_integrity,
1727 .is_read_op = smb21_is_read_op,
1728 .set_oplock_level = smb3_set_oplock_level,
1729 .create_lease_buf = smb3_create_lease_buf,
1730 .parse_lease_buf = smb3_parse_lease_buf,
1731 .clone_range = smb2_clone_range,
1732 .duplicate_extents = smb2_duplicate_extents,
1733 .validate_negotiate = smb3_validate_negotiate,
1734 .wp_retry_size = smb2_wp_retry_size,
1735 .dir_needs_close = smb2_dir_needs_close,
1736 .fallocate = smb3_fallocate,
1739 #ifdef CONFIG_CIFS_SMB311
1740 struct smb_version_operations smb311_operations = {
1741 .compare_fids = smb2_compare_fids,
1742 .setup_request = smb2_setup_request,
1743 .setup_async_request = smb2_setup_async_request,
1744 .check_receive = smb2_check_receive,
1745 .add_credits = smb2_add_credits,
1746 .set_credits = smb2_set_credits,
1747 .get_credits_field = smb2_get_credits_field,
1748 .get_credits = smb2_get_credits,
1749 .wait_mtu_credits = smb2_wait_mtu_credits,
1750 .get_next_mid = smb2_get_next_mid,
1751 .read_data_offset = smb2_read_data_offset,
1752 .read_data_length = smb2_read_data_length,
1753 .map_error = map_smb2_to_linux_error,
1754 .find_mid = smb2_find_mid,
1755 .check_message = smb2_check_message,
1756 .dump_detail = smb2_dump_detail,
1757 .clear_stats = smb2_clear_stats,
1758 .print_stats = smb2_print_stats,
1759 .dump_share_caps = smb2_dump_share_caps,
1760 .is_oplock_break = smb2_is_valid_oplock_break,
1761 .downgrade_oplock = smb2_downgrade_oplock,
1762 .need_neg = smb2_need_neg,
1763 .negotiate = smb2_negotiate,
1764 .negotiate_wsize = smb2_negotiate_wsize,
1765 .negotiate_rsize = smb2_negotiate_rsize,
1766 .sess_setup = SMB2_sess_setup,
1767 .logoff = SMB2_logoff,
1768 .tree_connect = SMB2_tcon,
1769 .tree_disconnect = SMB2_tdis,
1770 .qfs_tcon = smb3_qfs_tcon,
1771 .is_path_accessible = smb2_is_path_accessible,
1772 .can_echo = smb2_can_echo,
1774 .query_path_info = smb2_query_path_info,
1775 .get_srv_inum = smb2_get_srv_inum,
1776 .query_file_info = smb2_query_file_info,
1777 .set_path_size = smb2_set_path_size,
1778 .set_file_size = smb2_set_file_size,
1779 .set_file_info = smb2_set_file_info,
1780 .set_compression = smb2_set_compression,
1781 .mkdir = smb2_mkdir,
1782 .mkdir_setinfo = smb2_mkdir_setinfo,
1783 .rmdir = smb2_rmdir,
1784 .unlink = smb2_unlink,
1785 .rename = smb2_rename_path,
1786 .create_hardlink = smb2_create_hardlink,
1787 .query_symlink = smb2_query_symlink,
1788 .query_mf_symlink = smb3_query_mf_symlink,
1789 .create_mf_symlink = smb3_create_mf_symlink,
1790 .open = smb2_open_file,
1791 .set_fid = smb2_set_fid,
1792 .close = smb2_close_file,
1793 .flush = smb2_flush_file,
1794 .async_readv = smb2_async_readv,
1795 .async_writev = smb2_async_writev,
1796 .sync_read = smb2_sync_read,
1797 .sync_write = smb2_sync_write,
1798 .query_dir_first = smb2_query_dir_first,
1799 .query_dir_next = smb2_query_dir_next,
1800 .close_dir = smb2_close_dir,
1801 .calc_smb_size = smb2_calc_size,
1802 .is_status_pending = smb2_is_status_pending,
1803 .oplock_response = smb2_oplock_response,
1804 .queryfs = smb2_queryfs,
1805 .mand_lock = smb2_mand_lock,
1806 .mand_unlock_range = smb2_unlock_range,
1807 .push_mand_locks = smb2_push_mandatory_locks,
1808 .get_lease_key = smb2_get_lease_key,
1809 .set_lease_key = smb2_set_lease_key,
1810 .new_lease_key = smb2_new_lease_key,
1811 .generate_signingkey = generate_smb3signingkey,
1812 .calc_signature = smb3_calc_signature,
1813 .set_integrity = smb3_set_integrity,
1814 .is_read_op = smb21_is_read_op,
1815 .set_oplock_level = smb3_set_oplock_level,
1816 .create_lease_buf = smb3_create_lease_buf,
1817 .parse_lease_buf = smb3_parse_lease_buf,
1818 .clone_range = smb2_clone_range,
1819 .duplicate_extents = smb2_duplicate_extents,
1820 /* .validate_negotiate = smb3_validate_negotiate, */ /* not used in 3.11 */
1821 .wp_retry_size = smb2_wp_retry_size,
1822 .dir_needs_close = smb2_dir_needs_close,
1823 .fallocate = smb3_fallocate,
1825 #endif /* CIFS_SMB311 */
1827 struct smb_version_values smb20_values = {
1828 .version_string = SMB20_VERSION_STRING,
1829 .protocol_id = SMB20_PROT_ID,
1830 .req_capabilities = 0, /* MBZ */
1831 .large_lock_type = 0,
1832 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1833 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1834 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1835 .header_size = sizeof(struct smb2_hdr),
1836 .max_header_size = MAX_SMB2_HDR_SIZE,
1837 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1838 .lock_cmd = SMB2_LOCK,
1840 .cap_nt_find = SMB2_NT_FIND,
1841 .cap_large_files = SMB2_LARGE_FILES,
1842 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1843 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1844 .create_lease_size = sizeof(struct create_lease),
1847 struct smb_version_values smb21_values = {
1848 .version_string = SMB21_VERSION_STRING,
1849 .protocol_id = SMB21_PROT_ID,
1850 .req_capabilities = 0, /* MBZ on negotiate req until SMB3 dialect */
1851 .large_lock_type = 0,
1852 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1853 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1854 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1855 .header_size = sizeof(struct smb2_hdr),
1856 .max_header_size = MAX_SMB2_HDR_SIZE,
1857 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1858 .lock_cmd = SMB2_LOCK,
1860 .cap_nt_find = SMB2_NT_FIND,
1861 .cap_large_files = SMB2_LARGE_FILES,
1862 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1863 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1864 .create_lease_size = sizeof(struct create_lease),
1867 struct smb_version_values smb30_values = {
1868 .version_string = SMB30_VERSION_STRING,
1869 .protocol_id = SMB30_PROT_ID,
1870 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES,
1871 .large_lock_type = 0,
1872 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1873 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1874 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1875 .header_size = sizeof(struct smb2_hdr),
1876 .max_header_size = MAX_SMB2_HDR_SIZE,
1877 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1878 .lock_cmd = SMB2_LOCK,
1880 .cap_nt_find = SMB2_NT_FIND,
1881 .cap_large_files = SMB2_LARGE_FILES,
1882 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1883 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1884 .create_lease_size = sizeof(struct create_lease_v2),
1887 struct smb_version_values smb302_values = {
1888 .version_string = SMB302_VERSION_STRING,
1889 .protocol_id = SMB302_PROT_ID,
1890 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES,
1891 .large_lock_type = 0,
1892 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1893 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1894 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1895 .header_size = sizeof(struct smb2_hdr),
1896 .max_header_size = MAX_SMB2_HDR_SIZE,
1897 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1898 .lock_cmd = SMB2_LOCK,
1900 .cap_nt_find = SMB2_NT_FIND,
1901 .cap_large_files = SMB2_LARGE_FILES,
1902 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1903 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1904 .create_lease_size = sizeof(struct create_lease_v2),
1907 #ifdef CONFIG_CIFS_SMB311
1908 struct smb_version_values smb311_values = {
1909 .version_string = SMB311_VERSION_STRING,
1910 .protocol_id = SMB311_PROT_ID,
1911 .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU | SMB2_GLOBAL_CAP_PERSISTENT_HANDLES,
1912 .large_lock_type = 0,
1913 .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
1914 .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
1915 .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
1916 .header_size = sizeof(struct smb2_hdr),
1917 .max_header_size = MAX_SMB2_HDR_SIZE,
1918 .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
1919 .lock_cmd = SMB2_LOCK,
1921 .cap_nt_find = SMB2_NT_FIND,
1922 .cap_large_files = SMB2_LARGE_FILES,
1923 .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
1924 .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
1925 .create_lease_size = sizeof(struct create_lease_v2),