cifs: print MIDs in decimal notation
Subsystems (2)
PATCH 1/4 cifs: print MIDs in decimal notation
The MIDs are mostly printed as decimal, so let's make it consistent.
--- fs/cifs/cifs_debug.c | 2 +- fs/cifs/connect.c | 4 ++-- fs/cifs/smb2misc.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/cifs/cifs_debug.c +1 -1
@@ -207,7 +207,7 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)from_kuid (&init_user_ns, cfile->uid), cfile->dentry);#ifdef CONFIG_CIFS_DEBUG2 -seq_printf (m," 0x%llx\n" , cfile->fid.mid); +seq_printf (m," %llu\n" , cfile->fid.mid);#else seq_printf (m,"\n" );#endif /* CIFS_DEBUG2 */
fs/cifs/connect.c +2 -2
@@ -741,7 +741,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)spin_lock (&GlobalMid_Lock);list_for_each_safe (tmp, tmp2, &server->pending_mid_q) { mid_entry = list_entry(tmp, struct mid_q_entry, qhead); -cifs_dbg (FYI ,"Clearing mid 0x%llx\n" , mid_entry->mid); +cifs_dbg (FYI ,"Clearing mid %llu\n" , mid_entry->mid);kref_get (&mid_entry->refcount); mid_entry->mid_state =MID_SHUTDOWN ;list_move (&mid_entry->qhead, &dispose_list);
@@ -752,7 +752,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)/* now walk dispose list and issue callbacks */ list_for_each_safe (tmp, tmp2, &dispose_list) { mid_entry = list_entry(tmp, struct mid_q_entry, qhead); -cifs_dbg (FYI ,"Callback mid 0x%llx\n" , mid_entry->mid); +cifs_dbg (FYI ,"Callback mid %llu\n" , mid_entry->mid);list_del_init (&mid_entry->qhead); mid_entry->callback (mid_entry);cifs_mid_q_entry_release (mid_entry);
fs/cifs/smb2misc.c +1 -1
@@ -767,7 +767,7 @@ smb2_cancelled_close_fid(struct work_struct *work)int rc;if (cancelled->mid) -cifs_tcon_dbg (VFS ,"Close unmatched open for MID:%llx\n" , +cifs_tcon_dbg (VFS ,"Close unmatched open for MID:%llu\n" , cancelled->mid);else cifs_tcon_dbg (VFS ,"Close interrupted close\n" );
Signature · 1 line
2.30.1
PATCH 2/4 cifs: change noisy error message to FYI
A customer has reported that their dmesg were being flooded by
CIFS: VFS: \\server Cancelling wait for mid xxx cmd: a
CIFS: VFS: \\server Cancelling wait for mid yyy cmd: b
CIFS: VFS: \\server Cancelling wait for mid zzz cmd: c
because some processes that were performing statfs(2) on the share had been interrupted due to their automount setup when certain users logged in and out.
Change it to FYI as they should be mostly informative rather than error messages.
--- fs/cifs/transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/transport.c +1 -1
@@ -1248,7 +1248,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, }if (rc !=0 ) {for (; i < num_rqst; i++) { -cifs_server_dbg (VFS ,"Cancelling wait for mid %llu cmd: %d\n" , +cifs_server_dbg (FYI ,"Cancelling wait for mid %llu cmd: %d\n" , midQ[i]->mid,le16_to_cpu (midQ[i]->command));send_cancel (server, &rqst[i], midQ[i]);spin_lock (&GlobalMid_Lock);
Signature · 1 line
2.30.1
Re: [PATCH 2/4] cifs: change noisy error message to FYI
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
ronnie sahlberg
reviewerRe: [PATCH 2/4] cifs: change noisy error message to FYI
In reply to Paulo Alcantarareviewed-by me
Quoted 35 lines · Paulo Alcantara
A customer has reported that their dmesg were being flooded by
CIFS: VFS: \\server Cancelling wait for mid xxx cmd: a
CIFS: VFS: \\server Cancelling wait for mid yyy cmd: b
CIFS: VFS: \\server Cancelling wait for mid zzz cmd: cbecause some processes that were performing statfs(2) on the share had been interrupted due to their automount setup when certain users logged in and out.
Change it to FYI as they should be mostly informative rather than error messages.
Signed-off-by Paulo Alcantara (SUSE) <[email protected]>--- fs/cifs/transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/transport.c +1
-2@@ -1248,7 +1248,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, }if (rc !=0 ) {for (; i < num_rqst; i++) { -cifs_server_dbg (VFS ,"Cancelling wait for mid %llu cmd: %d\n" , +cifs_server_dbg (FYI ,"Cancelling wait for mid %llu cmd: %d\n" , midQ[i]->mid,le16_to_cpu (midQ[i]->command));send_cancel (server, &rqst[i], midQ[i]);spin_lock (&GlobalMid_Lock); --2.30.1
PATCH 3/4 cifs: return proper error code in statfs(2)
In reply to Paulo AlcantaraIn cifs_statfs(), if server->ops->queryfs is not NULL, then we should use its return value rather than always returning 0. Instead, use rc variable as it is properly set to 0 in case there is no server->ops->queryfs.
--- fs/cifs/cifsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifsfs.c +1 -1
@@ -290,7 +290,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) rc = server->ops->queryfs (xid, tcon, cifs_sb, buf);free_xid (xid); -return 0 ; +return rc; }static long cifs_fallocate (struct file *file,int mode,loff_t off,loff_t len)
Signature · 1 line
2.30.1
Re: [PATCH 3/4] cifs: return proper error code in statfs(2)
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
Re: [PATCH 3/4] cifs: return proper error code in statfs(2)
In reply to Paulo AlcantaraQuoted 27 lines · Paulo Alcantara
In
cifs_statfs(), ifserver->ops->queryfsis not NULL, then we should use its return value rather than always returning 0. Instead, use rc variable as it is properly set to 0 in case there is noserver->ops->queryfs.Signed-off-by Paulo Alcantara (SUSE) <[email protected]>--- fs/cifs/cifsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/cifsfs.c +1
-2@@ -290,7 +290,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) rc = server->ops->queryfs (xid, tcon, cifs_sb, buf);free_xid (xid); -return 0 ; +return rc; }static long cifs_fallocate (struct file *file,int mode,loff_t off,loff_t len) --2.30.1
Signature · 3 lines
Thanks, Steve
Re: [PATCH 3/4] cifs: return proper error code in statfs(2)
Quoted 1 line · Steve French
cc stable?
Yes, please.
ronnie sahlberg
reviewerRe: [PATCH 3/4] cifs: return proper error code in statfs(2)
In reply to Paulo Alcantarareviewed-by me
Quoted 27 lines · Paulo Alcantara
In
cifs_statfs(), ifserver->ops->queryfsis not NULL, then we should use its return value rather than always returning 0. Instead, use rc variable as it is properly set to 0 in case there is noserver->ops->queryfs.Signed-off-by Paulo Alcantara (SUSE) <[email protected]>--- fs/cifs/cifsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/cifsfs.c +1
-2@@ -290,7 +290,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) rc = server->ops->queryfs (xid, tcon, cifs_sb, buf);free_xid (xid); -return 0 ; +return rc; }static long cifs_fallocate (struct file *file,int mode,loff_t off,loff_t len) --2.30.1
PATCH 4/4 cifs: do not send close in compound create+close requests
In reply to Paulo AlcantaraIn case of interrupted syscalls, prevent sending CLOSE commands for compound CREATE+CLOSE requests by introducing an CIFS_CP_CREATE_CLOSE_OP flag to indicate lower layers that it should not send a CLOSE command to the MIDs corresponding the compound CREATE+CLOSE request.
A simple reproducer:
#!/bin/bash
mount //server/share /mnt -o username=foo,password=*** tc qdisc add dev eth0 root netem delay 450ms stat -f /mnt &>/dev/null & pid=$!
sleep 0.01
kill $pid
tc qdisc del dev eth0 root
umount /mnt
Before patch:
...
6 0.256893470 192.168.122.2 → 192.168.122.15 SMB2 402 Create Request File: ;GetInfo Request FS_INFO/FileFsFullSizeInformation;Close Request
7 0.257144491 192.168.122.15 → 192.168.122.2 SMB2 498 Create Response File: ;GetInfo Response;Close Response
9 0.260798209 192.168.122.2 → 192.168.122.15 SMB2 146 Close Request File: 10 0.260841089 192.168.122.15 → 192.168.122.2 SMB2 130 Close Response, Error: STATUS_FILE_CLOSED
--- fs/cifs/cifsglob.h | 19 ++++++++++--------- fs/cifs/smb2inode.c | 1 + fs/cifs/smb2misc.c | 8 ++++---- fs/cifs/smb2ops.c | 10 +++++----- fs/cifs/smb2proto.h | 3 +-- fs/cifs/transport.c | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-)
fs/cifs/cifsglob.h +10 -9
@@ -257,7 +257,7 @@ struct smb_version_operations {/* verify the message */ int (*check_message)(char *,unsigned int ,struct TCP_Server_Info *);bool (*is_oplock_break)(char *,struct TCP_Server_Info *); -int (*handle_cancelled_mid)(char *,struct TCP_Server_Info *); +int (*handle_cancelled_mid)(struct mid_q_entry *,struct TCP_Server_Info *);void (*downgrade_oplock)(struct TCP_Server_Info *server,struct cifsInodeInfo *cinode,__u32 oplock,unsigned int epoch,bool *purge_cache);
@@ -1705,16 +1705,17 @@ static inline bool is_retryable_error(int error)#define CIFS_NO_RSP_BUF 0x040/* no response buffer required */ /* Type of request operation */ -#define CIFS_ECHO_OP 0x080/* echo request */ -#define CIFS_OBREAK_OP 0x0100/* oplock break request */ -#define CIFS_NEG_OP 0x0200/* negotiate request */ +#define CIFS_ECHO_OP 0x080/* echo request */ +#define CIFS_OBREAK_OP 0x0100/* oplock break request */ +#define CIFS_NEG_OP 0x0200/* negotiate request */ +#define CIFS_CP_CREATE_CLOSE_OP 0x0400/* compound create+close request */ /* Lower bitmask values are reserved by others below. */ -#define CIFS_SESS_OP 0x2000/* session setup request */ -#define CIFS_OP_MASK 0x2380/* mask request type */ +#define CIFS_SESS_OP 0x2000/* session setup request */ +#define CIFS_OP_MASK 0x2780/* mask request type */ -#define CIFS_HAS_CREDITS 0x0400/* already has credits */ -#define CIFS_TRANSFORM_REQ 0x0800/* transform request before sending */ -#define CIFS_NO_SRV_RSP 0x1000/* there is no server response */ +#define CIFS_HAS_CREDITS 0x0400/* already has credits */ +#define CIFS_TRANSFORM_REQ 0x0800/* transform request before sending */ +#define CIFS_NO_SRV_RSP 0x1000/* there is no server response */ /* Security Flags: indicate type of session setup needed */ #define CIFSSEC_MAY_SIGN 0x00001
fs/cifs/smb2inode.c +1 -0
@@ -358,6 +358,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,if (cfile) goto after_close;/* Close */ + flags |=CIFS_CP_CREATE_CLOSE_OP ; rqst[num_rqst].rq_iov = &vars->close_iov[0 ]; rqst[num_rqst].rq_nvec =1 ; rc = SMB2_close_init(tcon, server,
fs/cifs/smb2misc.c +4 -4
@@ -844,14 +844,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, }int -smb2_handle_cancelled_mid (char *buffer,struct TCP_Server_Info *server) +smb2_handle_cancelled_mid (struct mid_q_entry *mid,struct TCP_Server_Info *server) { -struct smb2_sync_hdr *sync_hdr = (struct smb2_sync_hdr *)buffer; -struct smb2_create_rsp *rsp = (struct smb2_create_rsp *)buffer; +struct smb2_sync_hdr *sync_hdr = mid->resp_buf; +struct smb2_create_rsp *rsp = mid->resp_buf;struct cifs_tcon *tcon;int rc; -if (sync_hdr->Command !=SMB2_CREATE || +if ((mid->optype &CIFS_CP_CREATE_CLOSE_OP ) || sync_hdr->Command !=SMB2_CREATE || sync_hdr->Status !=STATUS_SUCCESS )return 0 ;
fs/cifs/smb2ops.c +5 -5
@@ -1195,7 +1195,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,struct TCP_Server_Info *server =cifs_pick_channel (ses);__le16 *utf16_path =NULL ;int ea_name_len =strlen (ea_name); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;int len;struct smb_rqst rqst[3 ];int resp_buftype[3 ];
@@ -1573,7 +1573,7 @@ smb2_ioctl_query_info(const unsigned int xid,struct smb_query_info qi;struct smb_query_info __user *pqi;int rc =0 ; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb2_query_info_rsp *qi_rsp =NULL ;struct smb2_ioctl_rsp *io_rsp =NULL ;void *buffer =NULL ;
@@ -2577,7 +2577,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, {struct cifs_ses *ses = tcon->ses;struct TCP_Server_Info *server =cifs_pick_channel (ses); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];
@@ -2975,7 +2975,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,unsigned int sub_offset;unsigned int print_len;unsigned int print_offset; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];
@@ -3157,7 +3157,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,struct cifs_open_parms oparms;struct cifs_fid fid;struct TCP_Server_Info *server =cifs_pick_channel (tcon->ses); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];
fs/cifs/smb2proto.h +1 -2
@@ -246,8 +246,7 @@ extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,extern int smb2_handle_cancelled_close (struct cifs_tcon *tcon,__u64 persistent_fid,__u64 volatile_fid); -extern int smb2_handle_cancelled_mid (char *buffer, -struct TCP_Server_Info *server); +extern int smb2_handle_cancelled_mid (struct mid_q_entry *mid,struct TCP_Server_Info *server);void smb2_cancelled_close_fid (struct work_struct *work); extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id,
fs/cifs/transport.c +1 -1
@@ -109,7 +109,7 @@ static void _cifs_mid_q_entry_release(struct kref *refcount)if (midEntry->resp_buf && (midEntry->mid_flags &MID_WAIT_CANCELLED ) && midEntry->mid_state ==MID_RESPONSE_RECEIVED && server->ops->handle_cancelled_mid) - server->ops->handle_cancelled_mid (midEntry->resp_buf, server); + server->ops->handle_cancelled_mid (midEntry, server); midEntry->mid_state =MID_FREE ;atomic_dec (&midCount);
Signature · 1 line
2.30.1
Re: [PATCH 4/4] cifs: do not send close in compound create+close requests
Quoted 5 lines · Paulo Alcantara
In case of interrupted syscalls, prevent sending CLOSE commands for compound CREATE+CLOSE requests by introducing an
CIFS_CP_CREATE_CLOSE_OPflag to indicate lower layers that it should not send a CLOSE command to the MIDs corresponding the compound CREATE+CLOSE request.
Sounds and looks good to me, good catch!
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
Re: [PATCH 4/4] cifs: do not send close in compound create+close requests
In reply to Paulo Alcantarastable?
Quoted 190 lines · Paulo Alcantara
In case of interrupted syscalls, prevent sending CLOSE commands for compound CREATE+CLOSE requests by introducing an
CIFS_CP_CREATE_CLOSE_OPflag to indicate lower layers that it should not send a CLOSE command to the MIDs corresponding the compound CREATE+CLOSE request.A simple reproducer:
#!/bin/bash
mount //server/share /mnt -o username=foo,password=*** tc qdisc add dev eth0 root netem delay 450ms stat -f /mnt &>/dev/null & pid=$!
sleep 0.01
kill $pid
tc qdisc del dev eth0 root
umount /mntBefore patch:
... 6 0.256893470 192.168.122.2 → 192.168.122.15 SMB2 402 Create Request File: ;GetInfo Request FS_INFO/FileFsFullSizeInformation;Close Request 7 0.257144491 192.168.122.15 → 192.168.122.2 SMB2 498 Create Response File: ;GetInfo Response;Close Response 9 0.260798209 192.168.122.2 → 192.168.122.15 SMB2 146 Close Request File: 10 0.260841089 192.168.122.15 → 192.168.122.2 SMB2 130 Close Response, Error: STATUS_FILE_CLOSEDSigned-off-by Paulo Alcantara (SUSE) <[email protected]>--- fs/cifs/cifsglob.h | 19 ++++++++++--------- fs/cifs/smb2inode.c | 1 + fs/cifs/smb2misc.c | 8 ++++---- fs/cifs/smb2ops.c | 10 +++++----- fs/cifs/smb2proto.h | 3 +-- fs/cifs/transport.c | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-)fs/cifs/cifsglob.h +10
-9@@ -257,7 +257,7 @@ struct smb_version_operations {/* verify the message */ int (*check_message)(char *,unsigned int ,struct TCP_Server_Info *);bool (*is_oplock_break)(char *,struct TCP_Server_Info *); -int (*handle_cancelled_mid)(char *,struct TCP_Server_Info *); +int (*handle_cancelled_mid)(struct mid_q_entry *,struct TCP_Server_Info *);void (*downgrade_oplock)(struct TCP_Server_Info *server,struct cifsInodeInfo *cinode,__u32 oplock,unsigned int epoch,bool *purge_cache);@@ -1705,16 +1705,17 @@ static inline bool is_retryable_error(int error)#define CIFS_NO_RSP_BUF 0x040/* no response buffer required */ /* Type of request operation */ -#define CIFS_ECHO_OP 0x080/* echo request */ -#define CIFS_OBREAK_OP 0x0100/* oplock break request */ -#define CIFS_NEG_OP 0x0200/* negotiate request */ +#define CIFS_ECHO_OP 0x080/* echo request */ +#define CIFS_OBREAK_OP 0x0100/* oplock break request */ +#define CIFS_NEG_OP 0x0200/* negotiate request */ +#define CIFS_CP_CREATE_CLOSE_OP 0x0400/* compound create+close request */ /* Lower bitmask values are reserved by others below. */ -#define CIFS_SESS_OP 0x2000/* session setup request */ -#define CIFS_OP_MASK 0x2380/* mask request type */ +#define CIFS_SESS_OP 0x2000/* session setup request */ +#define CIFS_OP_MASK 0x2780/* mask request type */ -#define CIFS_HAS_CREDITS 0x0400/* already has credits */ -#define CIFS_TRANSFORM_REQ 0x0800/* transform request before sending */ -#define CIFS_NO_SRV_RSP 0x1000/* there is no server response */ +#define CIFS_HAS_CREDITS 0x0400/* already has credits */ +#define CIFS_TRANSFORM_REQ 0x0800/* transform request before sending */ +#define CIFS_NO_SRV_RSP 0x1000/* there is no server response */ /* Security Flags: indicate type of session setup needed */ #define CIFSSEC_MAY_SIGN 0x00001fs/cifs/smb2inode.c +1
-0@@ -358,6 +358,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,if (cfile) goto after_close;/* Close */ + flags |=CIFS_CP_CREATE_CLOSE_OP ; rqst[num_rqst].rq_iov = &vars->close_iov[0 ]; rqst[num_rqst].rq_nvec =1 ; rc = SMB2_close_init(tcon, server,fs/cifs/smb2misc.c +4
-4@@ -844,14 +844,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, }int -smb2_handle_cancelled_mid (char *buffer,struct TCP_Server_Info *server) +smb2_handle_cancelled_mid (struct mid_q_entry *mid,struct TCP_Server_Info *server) { -struct smb2_sync_hdr *sync_hdr = (struct smb2_sync_hdr *)buffer; -struct smb2_create_rsp *rsp = (struct smb2_create_rsp *)buffer; +struct smb2_sync_hdr *sync_hdr = mid->resp_buf; +struct smb2_create_rsp *rsp = mid->resp_buf;struct cifs_tcon *tcon;int rc; -if (sync_hdr->Command !=SMB2_CREATE || +if ((mid->optype &CIFS_CP_CREATE_CLOSE_OP ) || sync_hdr->Command !=SMB2_CREATE || sync_hdr->Status !=STATUS_SUCCESS )return 0 ;fs/cifs/smb2ops.c +5
-5@@ -1195,7 +1195,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,struct TCP_Server_Info *server =cifs_pick_channel (ses);__le16 *utf16_path =NULL ;int ea_name_len =strlen (ea_name); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;int len;struct smb_rqst rqst[3 ];int resp_buftype[3 ];@@ -1573,7 +1573,7 @@ smb2_ioctl_query_info(const unsigned int xid,struct smb_query_info qi;struct smb_query_info __user *pqi;int rc =0 ; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb2_query_info_rsp *qi_rsp =NULL ;struct smb2_ioctl_rsp *io_rsp =NULL ;void *buffer =NULL ;@@ -2577,7 +2577,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, {struct cifs_ses *ses = tcon->ses;struct TCP_Server_Info *server =cifs_pick_channel (ses); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];@@ -2975,7 +2975,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,unsigned int sub_offset;unsigned int print_len;unsigned int print_offset; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];@@ -3157,7 +3157,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,struct cifs_open_parms oparms;struct cifs_fid fid;struct TCP_Server_Info *server =cifs_pick_channel (tcon->ses); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];fs/cifs/smb2proto.h +1
-2@@ -246,8 +246,7 @@ extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,extern int smb2_handle_cancelled_close (struct cifs_tcon *tcon,__u64 persistent_fid,__u64 volatile_fid); -extern int smb2_handle_cancelled_mid (char *buffer, -struct TCP_Server_Info *server); +extern int smb2_handle_cancelled_mid (struct mid_q_entry *mid,struct TCP_Server_Info *server);void smb2_cancelled_close_fid (struct work_struct *work); extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id,fs/cifs/transport.c +1
-2@@ -109,7 +109,7 @@ static void _cifs_mid_q_entry_release(struct kref *refcount)if (midEntry->resp_buf && (midEntry->mid_flags &MID_WAIT_CANCELLED ) && midEntry->mid_state ==MID_RESPONSE_RECEIVED && server->ops->handle_cancelled_mid) - server->ops->handle_cancelled_mid (midEntry->resp_buf, server); + server->ops->handle_cancelled_mid (midEntry, server); midEntry->mid_state =MID_FREE ;atomic_dec (&midCount); --2.30.1
Signature · 3 lines
Thanks, Steve
Re: [PATCH 4/4] cifs: do not send close in compound create+close requests
Quoted 1 line · Steve French
stable?
Yes, please.
ronnie sahlberg
reviewerRe: [PATCH 4/4] cifs: do not send close in compound create+close requests
In reply to Paulo Alcantarareviewed-by me
Quoted 190 lines · Paulo Alcantara
In case of interrupted syscalls, prevent sending CLOSE commands for compound CREATE+CLOSE requests by introducing an
CIFS_CP_CREATE_CLOSE_OPflag to indicate lower layers that it should not send a CLOSE command to the MIDs corresponding the compound CREATE+CLOSE request.A simple reproducer:
#!/bin/bash
mount //server/share /mnt -o username=foo,password=*** tc qdisc add dev eth0 root netem delay 450ms stat -f /mnt &>/dev/null & pid=$!
sleep 0.01
kill $pid
tc qdisc del dev eth0 root
umount /mntBefore patch:
... 6 0.256893470 192.168.122.2 → 192.168.122.15 SMB2 402 Create Request File: ;GetInfo Request FS_INFO/FileFsFullSizeInformation;Close Request 7 0.257144491 192.168.122.15 → 192.168.122.2 SMB2 498 Create Response File: ;GetInfo Response;Close Response 9 0.260798209 192.168.122.2 → 192.168.122.15 SMB2 146 Close Request File: 10 0.260841089 192.168.122.15 → 192.168.122.2 SMB2 130 Close Response, Error: STATUS_FILE_CLOSEDSigned-off-by Paulo Alcantara (SUSE) <[email protected]>--- fs/cifs/cifsglob.h | 19 ++++++++++--------- fs/cifs/smb2inode.c | 1 + fs/cifs/smb2misc.c | 8 ++++---- fs/cifs/smb2ops.c | 10 +++++----- fs/cifs/smb2proto.h | 3 +-- fs/cifs/transport.c | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-)fs/cifs/cifsglob.h +10
-9@@ -257,7 +257,7 @@ struct smb_version_operations {/* verify the message */ int (*check_message)(char *,unsigned int ,struct TCP_Server_Info *);bool (*is_oplock_break)(char *,struct TCP_Server_Info *); -int (*handle_cancelled_mid)(char *,struct TCP_Server_Info *); +int (*handle_cancelled_mid)(struct mid_q_entry *,struct TCP_Server_Info *);void (*downgrade_oplock)(struct TCP_Server_Info *server,struct cifsInodeInfo *cinode,__u32 oplock,unsigned int epoch,bool *purge_cache);@@ -1705,16 +1705,17 @@ static inline bool is_retryable_error(int error)#define CIFS_NO_RSP_BUF 0x040/* no response buffer required */ /* Type of request operation */ -#define CIFS_ECHO_OP 0x080/* echo request */ -#define CIFS_OBREAK_OP 0x0100/* oplock break request */ -#define CIFS_NEG_OP 0x0200/* negotiate request */ +#define CIFS_ECHO_OP 0x080/* echo request */ +#define CIFS_OBREAK_OP 0x0100/* oplock break request */ +#define CIFS_NEG_OP 0x0200/* negotiate request */ +#define CIFS_CP_CREATE_CLOSE_OP 0x0400/* compound create+close request */ /* Lower bitmask values are reserved by others below. */ -#define CIFS_SESS_OP 0x2000/* session setup request */ -#define CIFS_OP_MASK 0x2380/* mask request type */ +#define CIFS_SESS_OP 0x2000/* session setup request */ +#define CIFS_OP_MASK 0x2780/* mask request type */ -#define CIFS_HAS_CREDITS 0x0400/* already has credits */ -#define CIFS_TRANSFORM_REQ 0x0800/* transform request before sending */ -#define CIFS_NO_SRV_RSP 0x1000/* there is no server response */ +#define CIFS_HAS_CREDITS 0x0400/* already has credits */ +#define CIFS_TRANSFORM_REQ 0x0800/* transform request before sending */ +#define CIFS_NO_SRV_RSP 0x1000/* there is no server response */ /* Security Flags: indicate type of session setup needed */ #define CIFSSEC_MAY_SIGN 0x00001fs/cifs/smb2inode.c +1
-0@@ -358,6 +358,7 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,if (cfile) goto after_close;/* Close */ + flags |=CIFS_CP_CREATE_CLOSE_OP ; rqst[num_rqst].rq_iov = &vars->close_iov[0 ]; rqst[num_rqst].rq_nvec =1 ; rc = SMB2_close_init(tcon, server,fs/cifs/smb2misc.c +4
-4@@ -844,14 +844,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, }int -smb2_handle_cancelled_mid (char *buffer,struct TCP_Server_Info *server) +smb2_handle_cancelled_mid (struct mid_q_entry *mid,struct TCP_Server_Info *server) { -struct smb2_sync_hdr *sync_hdr = (struct smb2_sync_hdr *)buffer; -struct smb2_create_rsp *rsp = (struct smb2_create_rsp *)buffer; +struct smb2_sync_hdr *sync_hdr = mid->resp_buf; +struct smb2_create_rsp *rsp = mid->resp_buf;struct cifs_tcon *tcon;int rc; -if (sync_hdr->Command !=SMB2_CREATE || +if ((mid->optype &CIFS_CP_CREATE_CLOSE_OP ) || sync_hdr->Command !=SMB2_CREATE || sync_hdr->Status !=STATUS_SUCCESS )return 0 ;fs/cifs/smb2ops.c +5
-5@@ -1195,7 +1195,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,struct TCP_Server_Info *server =cifs_pick_channel (ses);__le16 *utf16_path =NULL ;int ea_name_len =strlen (ea_name); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;int len;struct smb_rqst rqst[3 ];int resp_buftype[3 ];@@ -1573,7 +1573,7 @@ smb2_ioctl_query_info(const unsigned int xid,struct smb_query_info qi;struct smb_query_info __user *pqi;int rc =0 ; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb2_query_info_rsp *qi_rsp =NULL ;struct smb2_ioctl_rsp *io_rsp =NULL ;void *buffer =NULL ;@@ -2577,7 +2577,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, {struct cifs_ses *ses = tcon->ses;struct TCP_Server_Info *server =cifs_pick_channel (ses); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];@@ -2975,7 +2975,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,unsigned int sub_offset;unsigned int print_len;unsigned int print_offset; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];@@ -3157,7 +3157,7 @@ smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,struct cifs_open_parms oparms;struct cifs_fid fid;struct TCP_Server_Info *server =cifs_pick_channel (tcon->ses); -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;struct smb_rqst rqst[3 ];int resp_buftype[3 ];struct kvec rsp_iov[3 ];fs/cifs/smb2proto.h +1
-2@@ -246,8 +246,7 @@ extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,extern int smb2_handle_cancelled_close (struct cifs_tcon *tcon,__u64 persistent_fid,__u64 volatile_fid); -extern int smb2_handle_cancelled_mid (char *buffer, -struct TCP_Server_Info *server); +extern int smb2_handle_cancelled_mid (struct mid_q_entry *mid,struct TCP_Server_Info *server);void smb2_cancelled_close_fid (struct work_struct *work); extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id,fs/cifs/transport.c +1
-2@@ -109,7 +109,7 @@ static void _cifs_mid_q_entry_release(struct kref *refcount)if (midEntry->resp_buf && (midEntry->mid_flags &MID_WAIT_CANCELLED ) && midEntry->mid_state ==MID_RESPONSE_RECEIVED && server->ops->handle_cancelled_mid) - server->ops->handle_cancelled_mid (midEntry->resp_buf, server); + server->ops->handle_cancelled_mid (midEntry, server); midEntry->mid_state =MID_FREE ;atomic_dec (&midCount); --2.30.1
Quoted 1 line · Paulo Alcantara
The MIDs are mostly printed as decimal, so let's make it consistent.
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
ronnie sahlberg
reviewerreviewed-by me
Quoted 61 lines · Paulo Alcantara
The MIDs are mostly printed as decimal, so let's make it consistent.
Signed-off-by Paulo Alcantara (SUSE) <[email protected]>--- fs/cifs/cifs_debug.c | 2 +- fs/cifs/connect.c | 4 ++-- fs/cifs/smb2misc.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)fs/cifs/cifs_debug.c +1
-1@@ -207,7 +207,7 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)from_kuid (&init_user_ns, cfile->uid), cfile->dentry);#ifdef CONFIG_CIFS_DEBUG2 -seq_printf (m," 0x%llx\n" , cfile->fid.mid); +seq_printf (m," %llu\n" , cfile->fid.mid);#else seq_printf (m,"\n" );#endif /* CIFS_DEBUG2 */ fs/cifs/connect.c +2
-2@@ -741,7 +741,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)spin_lock (&GlobalMid_Lock);list_for_each_safe (tmp, tmp2, &server->pending_mid_q) { mid_entry = list_entry(tmp, struct mid_q_entry, qhead); -cifs_dbg (FYI ,"Clearing mid 0x%llx\n" , mid_entry->mid); +cifs_dbg (FYI ,"Clearing mid %llu\n" , mid_entry->mid);kref_get (&mid_entry->refcount); mid_entry->mid_state =MID_SHUTDOWN ;list_move (&mid_entry->qhead, &dispose_list);@@ -752,7 +752,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)/* now walk dispose list and issue callbacks */ list_for_each_safe (tmp, tmp2, &dispose_list) { mid_entry = list_entry(tmp, struct mid_q_entry, qhead); -cifs_dbg (FYI ,"Callback mid 0x%llx\n" , mid_entry->mid); +cifs_dbg (FYI ,"Callback mid %llu\n" , mid_entry->mid);list_del_init (&mid_entry->qhead); mid_entry->callback (mid_entry);cifs_mid_q_entry_release (mid_entry);fs/cifs/smb2misc.c +1
-2@@ -767,7 +767,7 @@ smb2_cancelled_close_fid(struct work_struct *work)int rc;if (cancelled->mid) -cifs_tcon_dbg (VFS ,"Close unmatched open for MID:%llx\n" , +cifs_tcon_dbg (VFS ,"Close unmatched open for MID:%llu\n" , cancelled->mid);else cifs_tcon_dbg (VFS ,"Close interrupted close\n" ); --2.30.1