Skip to content

Commit 78d9aff

Browse files
committed
Merge tag '5.2-smb3' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "CIFS/SMB3 changes: - three fixes for stable - add fiemap support - improve zero-range support - various RDMA (smb direct fixes) I have an additional set of fixes (for improved handling of sparse files, mode bits, POSIX extensions) that are still being tested that are not included in this pull request but I expect to send in the next week" * tag '5.2-smb3' of git://git.samba.org/sfrench/cifs-2.6: (29 commits) cifs: update module internal version number SMB3: Clean up query symlink when reparse point cifs: fix strcat buffer overflow and reduce raciness in smb21_set_oplock_level() Negotiate and save preferred compression algorithms cifs: rename and clarify CIFS_ASYNC_OP and CIFS_NO_RESP cifs: fix credits leak for SMB1 oplock breaks smb3: Add protocol structs for change notify support cifs: fix smb3_zero_range for Azure cifs: zero-range does not require the file is sparse Add new flag on SMB3.1.1 read cifs: add fiemap support SMB3: Add defines for new negotiate contexts cifs: fix bi-directional fsctl passthrough calls cifs: smbd: take an array of reqeusts when sending upper layer data SMB3: Add handling for different FSCTL access flags cifs: Add support for FSCTL passthrough that write data to the server cifs: remove superfluous inode_lock in cifs_{strict_}fsync cifs: Call MID callback before destroying transport cifs: smbd: Retry on memory registration failure cifs: smbd: Indicate to retry on transport sending failure ...
2 parents 8c79f4c + cb4f7bf commit 78d9aff

21 files changed

Lines changed: 2582 additions & 2184 deletions

‎fs/cifs/cifs_debug.c‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,10 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
312312
atomic_read(&server->smbd_conn->send_credits),
313313
atomic_read(&server->smbd_conn->receive_credits),
314314
server->smbd_conn->receive_credit_target);
315-
seq_printf(m, "\nPending send_pending: %x send_payload_pending:"
316-
" %x smbd_send_pending: %x smbd_recv_pending: %x",
315+
seq_printf(m, "\nPending send_pending: %x "
316+
"send_payload_pending: %x",
317317
atomic_read(&server->smbd_conn->send_pending),
318-
atomic_read(&server->smbd_conn->send_payload_pending),
319-
server->smbd_conn->smbd_send_pending,
320-
server->smbd_conn->smbd_recv_pending);
318+
atomic_read(&server->smbd_conn->send_payload_pending));
321319
seq_printf(m, "\nReceive buffers count_receive_queue: %x "
322320
"count_empty_packet_queue: %x",
323321
server->smbd_conn->count_receive_queue,
@@ -334,6 +332,12 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
334332
#endif
335333
seq_printf(m, "\nNumber of credits: %d Dialect 0x%x",
336334
server->credits, server->dialect);
335+
if (server->compress_algorithm == SMB3_COMPRESS_LZNT1)
336+
seq_printf(m, " COMPRESS_LZNT1");
337+
else if (server->compress_algorithm == SMB3_COMPRESS_LZ77)
338+
seq_printf(m, " COMPRESS_LZ77");
339+
else if (server->compress_algorithm == SMB3_COMPRESS_LZ77_HUFF)
340+
seq_printf(m, " COMPRESS_LZ77_HUFF");
337341
if (server->sign)
338342
seq_printf(m, " signed");
339343
if (server->posix_ext_supported)
@@ -462,8 +466,13 @@ static ssize_t cifs_stats_proc_write(struct file *file,
462466
server = list_entry(tmp1, struct TCP_Server_Info,
463467
tcp_ses_list);
464468
#ifdef CONFIG_CIFS_STATS2
465-
for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++)
469+
for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
470+
atomic_set(&server->num_cmds[i], 0);
466471
atomic_set(&server->smb2slowcmd[i], 0);
472+
server->time_per_cmd[i] = 0;
473+
server->slowest_cmd[i] = 0;
474+
server->fastest_cmd[0] = 0;
475+
}
467476
#endif /* CONFIG_CIFS_STATS2 */
468477
list_for_each(tmp2, &server->smb_ses_list) {
469478
ses = list_entry(tmp2, struct cifs_ses,
@@ -531,9 +540,19 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
531540
server = list_entry(tmp1, struct TCP_Server_Info,
532541
tcp_ses_list);
533542
#ifdef CONFIG_CIFS_STATS2
543+
seq_puts(m, "\nTotal time spent processing by command. Time ");
544+
seq_printf(m, "units are jiffies (%d per second)\n", HZ);
545+
seq_puts(m, " SMB3 CMD\tNumber\tTotal Time\tFastest\tSlowest\n");
546+
seq_puts(m, " --------\t------\t----------\t-------\t-------\n");
547+
for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
548+
seq_printf(m, " %d\t\t%d\t%llu\t\t%u\t%u\n", j,
549+
atomic_read(&server->num_cmds[j]),
550+
server->time_per_cmd[j],
551+
server->fastest_cmd[j],
552+
server->slowest_cmd[j]);
534553
for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
535554
if (atomic_read(&server->smb2slowcmd[j]))
536-
seq_printf(m, "%d slow responses from %s for command %d\n",
555+
seq_printf(m, " %d slow responses from %s for command %d\n",
537556
atomic_read(&server->smb2slowcmd[j]),
538557
server->hostname, j);
539558
#endif /* STATS2 */

‎fs/cifs/cifsfs.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
483483
seq_puts(s, ",seal");
484484
if (tcon->nocase)
485485
seq_puts(s, ",nocase");
486+
if (tcon->local_lease)
487+
seq_puts(s, ",locallease");
486488
if (tcon->retry)
487489
seq_puts(s, ",hard");
488490
else
@@ -984,6 +986,7 @@ const struct inode_operations cifs_file_inode_ops = {
984986
.getattr = cifs_getattr,
985987
.permission = cifs_permission,
986988
.listxattr = cifs_listxattr,
989+
.fiemap = cifs_fiemap,
987990
};
988991

989992
const struct inode_operations cifs_symlink_inode_ops = {

‎fs/cifs/cifsfs.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ extern int cifs_revalidate_mapping(struct inode *inode);
8484
extern int cifs_zap_mapping(struct inode *inode);
8585
extern int cifs_getattr(const struct path *, struct kstat *, u32, unsigned int);
8686
extern int cifs_setattr(struct dentry *, struct iattr *);
87+
extern int cifs_fiemap(struct inode *, struct fiemap_extent_info *, u64 start,
88+
u64 len);
8789

8890
extern const struct inode_operations cifs_file_inode_ops;
8991
extern const struct inode_operations cifs_symlink_inode_ops;
@@ -150,5 +152,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
150152
extern const struct export_operations cifs_export_ops;
151153
#endif /* CONFIG_CIFS_NFSD_EXPORT */
152154

153-
#define CIFS_VERSION "2.19"
155+
#define CIFS_VERSION "2.20"
154156
#endif /* _CIFSFS_H */

‎fs/cifs/cifsglob.h‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ struct smb_version_operations {
355355
struct cifs_sb_info *);
356356
/* query symlink target */
357357
int (*query_symlink)(const unsigned int, struct cifs_tcon *,
358-
const char *, char **, struct cifs_sb_info *);
358+
struct cifs_sb_info *, const char *,
359+
char **, bool);
359360
/* open a file for non-posix mounts */
360361
int (*open)(const unsigned int, struct cifs_open_parms *,
361362
__u32 *, FILE_ALL_INFO *);
@@ -493,6 +494,9 @@ struct smb_version_operations {
493494
char *full_path,
494495
umode_t mode,
495496
dev_t device_number);
497+
/* version specific fiemap implementation */
498+
int (*fiemap)(struct cifs_tcon *tcon, struct cifsFileInfo *,
499+
struct fiemap_extent_info *, u64, u64);
496500
};
497501

498502
struct smb_version_values {
@@ -596,6 +600,10 @@ struct smb_vol {
596600
unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
597601
};
598602

603+
/**
604+
* CIFS superblock mount flags (mnt_cifs_flags) to consider when
605+
* trying to reuse existing superblock for a new mount
606+
*/
599607
#define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \
600608
CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \
601609
CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \
@@ -606,8 +614,13 @@ struct smb_vol {
606614
CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \
607615
CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \
608616
CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
609-
CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID)
617+
CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID | \
618+
CIFS_MOUNT_NO_DFS)
610619

620+
/**
621+
* Generic VFS superblock mount flags (s_flags) to consider when
622+
* trying to reuse existing superblock for a new mount
623+
*/
611624
#define CIFS_MS_MASK (SB_RDONLY | SB_MANDLOCK | SB_NOEXEC | SB_NOSUID | \
612625
SB_NODEV | SB_SYNCHRONOUS)
613626

@@ -714,10 +727,15 @@ struct TCP_Server_Info {
714727
#ifdef CONFIG_CIFS_STATS2
715728
atomic_t in_send; /* requests trying to send */
716729
atomic_t num_waiters; /* blocked waiting to get in sendrecv */
730+
atomic_t num_cmds[NUMBER_OF_SMB2_COMMANDS]; /* total requests by cmd */
717731
atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */
732+
__u64 time_per_cmd[NUMBER_OF_SMB2_COMMANDS]; /* total time per cmd */
733+
__u32 slowest_cmd[NUMBER_OF_SMB2_COMMANDS];
734+
__u32 fastest_cmd[NUMBER_OF_SMB2_COMMANDS];
718735
#endif /* STATS2 */
719736
unsigned int max_read;
720737
unsigned int max_write;
738+
__le16 compress_algorithm;
721739
__le16 cipher_type;
722740
/* save initital negprot hash */
723741
__u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
@@ -1673,11 +1691,11 @@ static inline bool is_retryable_error(int error)
16731691

16741692
/* Type of Request to SendReceive2 */
16751693
#define CIFS_BLOCKING_OP 1 /* operation can block */
1676-
#define CIFS_ASYNC_OP 2 /* do not wait for response */
1694+
#define CIFS_NON_BLOCKING 2 /* do not block waiting for credits */
16771695
#define CIFS_TIMEOUT_MASK 0x003 /* only one of above set in req */
16781696
#define CIFS_LOG_ERROR 0x010 /* log NT STATUS if non-zero */
16791697
#define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */
1680-
#define CIFS_NO_RESP 0x040 /* no response buffer required */
1698+
#define CIFS_NO_RSP_BUF 0x040 /* no response buffer required */
16811699

16821700
/* Type of request operation */
16831701
#define CIFS_ECHO_OP 0x080 /* echo request */
@@ -1687,6 +1705,7 @@ static inline bool is_retryable_error(int error)
16871705

16881706
#define CIFS_HAS_CREDITS 0x0400 /* already has credits */
16891707
#define CIFS_TRANSFORM_REQ 0x0800 /* transform request before sending */
1708+
#define CIFS_NO_SRV_RSP 0x1000 /* there is no server response */
16901709

16911710
/* Security Flags: indicate type of session setup needed */
16921711
#define CIFSSEC_MAY_SIGN 0x00001

‎fs/cifs/cifsproto.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,21 @@ extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
526526
const struct nls_table *codepage);
527527
extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
528528
unsigned char *p24);
529+
530+
extern int
531+
cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data,
532+
const char *devname, bool is_smb3);
529533
extern void
530534
cifs_cleanup_volume_info_contents(struct smb_vol *volume_info);
531535

532536
extern struct TCP_Server_Info *
533537
cifs_find_tcp_session(struct smb_vol *vol);
534538

539+
extern void cifs_put_smb_ses(struct cifs_ses *ses);
540+
541+
extern struct cifs_ses *
542+
cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info);
543+
535544
void cifs_readdata_release(struct kref *refcount);
536545
int cifs_async_readv(struct cifs_readdata *rdata);
537546
int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid);

‎fs/cifs/cifssmb.c‎

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
860860
iov[1].iov_base = (char *)smb + 4;
861861

862862
rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
863-
server, CIFS_ASYNC_OP | CIFS_ECHO_OP, NULL);
863+
server, CIFS_NON_BLOCKING | CIFS_ECHO_OP, NULL);
864864
if (rc)
865865
cifs_dbg(FYI, "Echo request failed: %d\n", rc);
866866

@@ -2508,8 +2508,8 @@ int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
25082508
iov[1].iov_len = (num_unlock + num_lock) * sizeof(LOCKING_ANDX_RANGE);
25092509

25102510
cifs_stats_inc(&tcon->stats.cifs_stats.num_locks);
2511-
rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, CIFS_NO_RESP,
2512-
&rsp_iov);
2511+
rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type,
2512+
CIFS_NO_RSP_BUF, &rsp_iov);
25132513
cifs_small_buf_release(pSMB);
25142514
if (rc)
25152515
cifs_dbg(FYI, "Send error in cifs_lockv = %d\n", rc);
@@ -2540,7 +2540,7 @@ CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
25402540

25412541
if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
25422542
/* no response expected */
2543-
flags = CIFS_ASYNC_OP | CIFS_OBREAK_OP;
2543+
flags = CIFS_NO_SRV_RSP | CIFS_NON_BLOCKING | CIFS_OBREAK_OP;
25442544
pSMB->Timeout = 0;
25452545
} else if (waitFlag) {
25462546
flags = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
@@ -6567,93 +6567,3 @@ CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
65676567
return rc;
65686568
}
65696569
#endif
6570-
6571-
#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* BB unused temporarily */
6572-
/*
6573-
* Years ago the kernel added a "dnotify" function for Samba server,
6574-
* to allow network clients (such as Windows) to display updated
6575-
* lists of files in directory listings automatically when
6576-
* files are added by one user when another user has the
6577-
* same directory open on their desktop. The Linux cifs kernel
6578-
* client hooked into the kernel side of this interface for
6579-
* the same reason, but ironically when the VFS moved from
6580-
* "dnotify" to "inotify" it became harder to plug in Linux
6581-
* network file system clients (the most obvious use case
6582-
* for notify interfaces is when multiple users can update
6583-
* the contents of the same directory - exactly what network
6584-
* file systems can do) although the server (Samba) could
6585-
* still use it. For the short term we leave the worker
6586-
* function ifdeffed out (below) until inotify is fixed
6587-
* in the VFS to make it easier to plug in network file
6588-
* system clients. If inotify turns out to be permanently
6589-
* incompatible for network fs clients, we could instead simply
6590-
* expose this config flag by adding a future cifs (and smb2) notify ioctl.
6591-
*/
6592-
int CIFSSMBNotify(const unsigned int xid, struct cifs_tcon *tcon,
6593-
const int notify_subdirs, const __u16 netfid,
6594-
__u32 filter, struct file *pfile, int multishot,
6595-
const struct nls_table *nls_codepage)
6596-
{
6597-
int rc = 0;
6598-
struct smb_com_transaction_change_notify_req *pSMB = NULL;
6599-
struct smb_com_ntransaction_change_notify_rsp *pSMBr = NULL;
6600-
struct dir_notify_req *dnotify_req;
6601-
int bytes_returned;
6602-
6603-
cifs_dbg(FYI, "In CIFSSMBNotify for file handle %d\n", (int)netfid);
6604-
rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB,
6605-
(void **) &pSMBr);
6606-
if (rc)
6607-
return rc;
6608-
6609-
pSMB->TotalParameterCount = 0 ;
6610-
pSMB->TotalDataCount = 0;
6611-
pSMB->MaxParameterCount = cpu_to_le32(2);
6612-
pSMB->MaxDataCount = cpu_to_le32(CIFSMaxBufSize & 0xFFFFFF00);
6613-
pSMB->MaxSetupCount = 4;
6614-
pSMB->Reserved = 0;
6615-
pSMB->ParameterOffset = 0;
6616-
pSMB->DataCount = 0;
6617-
pSMB->DataOffset = 0;
6618-
pSMB->SetupCount = 4; /* single byte does not need le conversion */
6619-
pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
6620-
pSMB->ParameterCount = pSMB->TotalParameterCount;
6621-
if (notify_subdirs)
6622-
pSMB->WatchTree = 1; /* one byte - no le conversion needed */
6623-
pSMB->Reserved2 = 0;
6624-
pSMB->CompletionFilter = cpu_to_le32(filter);
6625-
pSMB->Fid = netfid; /* file handle always le */
6626-
pSMB->ByteCount = 0;
6627-
6628-
rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
6629-
(struct smb_hdr *)pSMBr, &bytes_returned,
6630-
CIFS_ASYNC_OP);
6631-
if (rc) {
6632-
cifs_dbg(FYI, "Error in Notify = %d\n", rc);
6633-
} else {
6634-
/* Add file to outstanding requests */
6635-
/* BB change to kmem cache alloc */
6636-
dnotify_req = kmalloc(
6637-
sizeof(struct dir_notify_req),
6638-
GFP_KERNEL);
6639-
if (dnotify_req) {
6640-
dnotify_req->Pid = pSMB->hdr.Pid;
6641-
dnotify_req->PidHigh = pSMB->hdr.PidHigh;
6642-
dnotify_req->Mid = pSMB->hdr.Mid;
6643-
dnotify_req->Tid = pSMB->hdr.Tid;
6644-
dnotify_req->Uid = pSMB->hdr.Uid;
6645-
dnotify_req->netfid = netfid;
6646-
dnotify_req->pfile = pfile;
6647-
dnotify_req->filter = filter;
6648-
dnotify_req->multishot = multishot;
6649-
spin_lock(&GlobalMid_Lock);
6650-
list_add_tail(&dnotify_req->lhead,
6651-
&GlobalDnotifyReqList);
6652-
spin_unlock(&GlobalMid_Lock);
6653-
} else
6654-
rc = -ENOMEM;
6655-
}
6656-
cifs_buf_release(pSMB);
6657-
return rc;
6658-
}
6659-
#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */

0 commit comments

Comments
 (0)