smb/client: improve change notify support
Subsystems (2)
ChenXiaoSong
reviewercover smb/client: improve change notify support
From: ChenXiaoSong <[email protected]>
This patchset improves support for SMB client's notify feature, including the following two improvements:
1. Support for notify cancellation.
2. Support for receiving all action notifications from the server. 2.1. Before this patchset, when an operation on the server triggered multiple actions, the client received only one action notification. 2.2. After this patchset, the client can receive all action notifications.
Example:
smbinfo notify /mnt
# server: touch /export/file1
Notifications received, returned data_len is 24
Action: 0x00000001, FileName: file1
Notifications received, returned data_len is 24
Action: 0x00000003, FileName: file1
# server: mv /export/file1 /export/file2
Notifications received, returned data_len is 48
Action: 0x00000004, FileName: file1
Action: 0x00000005, FileName: file2
Notifications received, returned data_len is 24
Action: 0x00000003, FileName: file2
Notifications received, returned data_len is 24
Action: 0x00000002, FileName: file1
Then press Ctrl+C to exit smbinfo notify command. The following packets can be captured using tcpdump:
- client: Cancel Request
- server: Notify Response, Error: STATUS_CANCELLED
ChenXiaoSong (9):
smb/client: factor out cifs_new_dir_fileinfo() smb/client: close cached notify handles on closedir smb/client: prepare notify ioctl per-open state smb/client: cache SMB3 change notify handles smb/client: retry change notify after invalid cached handle smb/client: add helpers for sending cancel requests smb/client: remember async ids from SMB2 pending responses smb/client: send SMB2 cancel requests
smb/client: make SMB2 change notify interruptible
fs/smb/client/cifsglob.h | 6 ++ fs/smb/client/cifsproto.h | 4 + fs/smb/client/file.c | 54 +++++++++++++ fs/smb/client/readdir.c | 14 ++-- fs/smb/client/smb2ops.c | 148 ++++++++++++++++++++++++++-------- fs/smb/client/smb2pdu.c | 1 + fs/smb/client/smb2proto.h | 3 + fs/smb/client/smb2transport.c | 105 ++++++++++++++++++++++++ fs/smb/client/transport.c | 49 ++++++++--- 9 files changed, 332 insertions(+), 52 deletions(-)
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 1/9 smb/client: factor out cifs_new_dir_fileinfo()
From: ChenXiaoSong <[email protected]>
This patch was split out to make it easier to review.
Both readdir and notify can need directory private data before a search handle exists. Move the common cifsFileInfo allocation and initialization into a helper so those paths share the same setup.
--- fs/smb/client/cifsproto.h | 2 ++ fs/smb/client/file.c | 24 ++++++++++++++++++++++++ fs/smb/client/readdir.c | 14 ++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-)
fs/smb/client/cifsproto.h +2 -0
@@ -267,6 +267,8 @@ void cifs_close_all_deferred_files(struct cifs_tcon *tcon);void cifs_close_all_deferred_files_sb (struct cifs_sb_info *cifs_sb);void cifs_close_deferred_file_under_dentry (struct cifs_tcon *tcon,struct dentry *dentry); +struct cifsFileInfo *cifs_new_dir_fileinfo (struct file *file, +struct tcon_link *tlink);void cifs_mark_open_handles_for_deleted_file (struct inode *inode,const char *path);
fs/smb/client/file.c +24 -0
@@ -660,6 +660,30 @@ cifs_down_write(struct rw_semaphore *sem)static void cifsFileInfo_put_work (struct work_struct *work);void serverclose_work (struct work_struct *work); +struct cifsFileInfo *cifs_new_dir_fileinfo (struct file *file, +struct tcon_link *tlink) +{ +struct cifsFileInfo *cfile, *old; + + cfile = kzalloc_obj(struct cifsFileInfo); +if (!cfile) +return NULL ; + +spin_lock_init (&cfile->file_info_lock); +mutex_init (&cfile->fh_mutex); + cfile->invalidHandle = true; + cfile->tlink =cifs_get_tlink (tlink); + + old =cmpxchg (&file->private_data,NULL , cfile); +if (old) { +cifs_put_tlink (cfile->tlink); +kfree (cfile); +return old; + } + +return cfile; +} +struct cifsFileInfo *cifs_new_fileinfo (struct cifs_fid *fid,struct file *file,struct tcon_link *tlink,__u32 oplock,const char *symlink_target)
fs/smb/client/readdir.c +6 -8
@@ -355,20 +355,17 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,__u16 search_flags;int rc =0 ; -if (file->private_data ==NULL ) { +if (!file->private_data) { tlink =cifs_sb_tlink (cifs_sb);if (IS_ERR (tlink))return PTR_ERR (tlink); - cifsFile = kzalloc_obj(struct cifsFileInfo); -if (cifsFile ==NULL ) { + cifsFile =cifs_new_dir_fileinfo (file, tlink); +if (!cifsFile) { rc = -ENOMEM ; goto error_exit; } -spin_lock_init (&cifsFile->file_info_lock); - file->private_data = cifsFile; - cifsFile->tlink =cifs_get_tlink (tlink); - tcon =tlink_tcon (tlink); + tcon =tlink_tcon (cifsFile->tlink); }else { cifsFile = file->private_data; tcon =tlink_tcon (cifsFile->tlink);
@@ -1125,7 +1122,8 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)* Ensure FindFirst doesn't fail before doing filldir() for '.' and * '..'. Otherwise we won't be able to notify VFS in case of failure. */ -if (file->private_data ==NULL ) { + cifsFile = file->private_data; +if (!cifsFile || cifsFile->invalidHandle) { rc =initiate_cifs_search (xid, file, full_path);cifs_dbg (FYI ,"initiate cifs search rc %d\n" , rc);if (rc)
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 2/9 smb/client: close cached notify handles on closedir
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
This patch was split out to make it easier to review.
Add storage for a change-notify FID in cifsFileInfo and close it from the directory release path. This gives notify users a per-open lifetime for the extra handle without changing how smb3_notify opens it yet.
--- fs/smb/client/cifsglob.h | 4 ++++ fs/smb/client/file.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+)
fs/smb/client/cifsglob.h +4 -0
@@ -1459,6 +1459,10 @@ struct cifsFileInfo {int count;spinlock_t file_info_lock;/* protects four flag/count fields above */ struct mutex fh_mutex;/* prevents reopen race after dead ses*/ +struct mutex notify_fid_mutex; +struct cifs_fid notify_fid; +struct tcon_link *notify_tlink; + bool has_notify_fid:1;struct cifs_search_info srch_inf;struct work_struct oplock_break;/* work for oplock breaks */ struct work_struct put;/* work for the final part of _put */
fs/smb/client/file.c +30 -0
@@ -671,6 +671,7 @@ struct cifsFileInfo *cifs_new_dir_fileinfo(struct file *file,spin_lock_init (&cfile->file_info_lock);mutex_init (&cfile->fh_mutex); +mutex_init (&cfile->notify_fid_mutex); cfile->invalidHandle = true; cfile->tlink =cifs_get_tlink (tlink);
@@ -733,6 +734,7 @@ struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,INIT_WORK (&cfile->serverclose, serverclose_work);INIT_DELAYED_WORK (&cfile->deferred, smb2_deferred_work_close);mutex_init (&cfile->fh_mutex); +mutex_init (&cfile->notify_fid_mutex);spin_lock_init (&cfile->file_info_lock);/*
@@ -1548,6 +1550,32 @@ cifs_reopen_persistent_handles(struct cifs_tcon *tcon) } } +static void cifs_close_notify_fid (unsigned int xid,struct cifsFileInfo *cfile) +{ +struct cifs_tcon *tcon; +struct TCP_Server_Info *server; +int rc =0 ; + +mutex_lock (&cfile->notify_fid_mutex); +if (!cfile->has_notify_fid) + goto unlock; + + tcon =tlink_tcon (cfile->notify_tlink); + server = tcon->ses->server; +if (server->ops->close_dir) + rc = server->ops->close_dir (xid, tcon, &cfile->notify_fid); +else if (server->ops->close) + rc = server->ops->close (xid, tcon, &cfile->notify_fid); + +cifs_dbg (FYI ,"Closing cached notify handle with rc %d\n" , rc); + cfile->has_notify_fid = false; +cifs_put_tlink (cfile->notify_tlink); + cfile->notify_tlink =NULL ; + +unlock: +mutex_unlock (&cfile->notify_fid_mutex); +} +int cifs_closedir (struct inode *inode,struct file *file) {int rc =0 ;
@@ -1567,6 +1595,8 @@ int cifs_closedir(struct inode *inode, struct file *file) server = tcon->ses->server;cifs_dbg (FYI ,"Freeing private data in close dir\n" ); +cifs_close_notify_fid (xid, cfile); +spin_lock (&cfile->file_info_lock);if (server->ops->dir_needs_close (cfile)) { cfile->invalidHandle = true;
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 3/9 smb/client: prepare notify ioctl per-open state
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
This patch was split out to make it easier to review.
Ensure smb3_notify() has directory private data before requests. This gives later changes a per-open state container while preserving the existing per-notify SMB2_open/SMB2_close behavior.
--- fs/smb/client/smb2ops.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
fs/smb/client/smb2ops.c +16 -0
@@ -2376,9 +2376,11 @@ smb3_notify(const unsigned int xid, struct file *pfile,struct dentry *dentry = pfile->f_path.dentry;struct inode *inode =file_inode (pfile);struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); +struct cifsFileInfo *cfile;struct cifs_open_parms oparms;struct cifs_fid fid;struct cifs_tcon *tcon; +struct tcon_link *tlink;const unsigned char *path;char *returned_ioctl_info =NULL ;void *page =alloc_dentry_path ();
@@ -2412,6 +2414,20 @@ smb3_notify(const unsigned int xid, struct file *pfile, notify.data_len =0 ; } +if (!pfile->private_data) { + tlink =cifs_sb_tlink (cifs_sb); +if (IS_ERR (tlink)) { + rc =PTR_ERR (tlink); + goto notify_exit; + } + cfile =cifs_new_dir_fileinfo (pfile, tlink); +cifs_put_tlink (tlink); +if (!cfile) { + rc = -ENOMEM ; + goto notify_exit; + } + } + tcon =cifs_sb_master_tcon (cifs_sb); oparms = (struct cifs_open_parms ) { .tcon = tcon,
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 4/9 smb/client: cache SMB3 change notify handles
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
Keep the SMB3 change-notify FID in the per-open cifsFileInfo state. Subsequent notify calls reuse the saved FID and the handle is closed later from the directory release path.
--- fs/smb/client/smb2ops.c | 82 +++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 31 deletions(-)
fs/smb/client/smb2ops.c +51 -31
@@ -2378,29 +2378,17 @@ smb3_notify(const unsigned int xid, struct file *pfile,struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct cifsFileInfo *cfile;struct cifs_open_parms oparms; -struct cifs_fid fid; -struct cifs_tcon *tcon; -struct tcon_link *tlink; +struct cifs_fid fid = {}; +struct cifs_tcon *tcon =NULL ; +struct tcon_link *tlink =NULL ;const unsigned char *path;char *returned_ioctl_info =NULL ; -void *page =alloc_dentry_path (); +void *page =NULL ;__le16 *utf16_path =NULL ;u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;int rc =0 ;__u32 ret_len =0 ; - path =build_path_from_dentry (dentry, page); -if (IS_ERR (path)) { - rc =PTR_ERR (path); - goto notify_exit; - } - - utf16_path =cifs_convert_path_to_utf16 (path, cifs_sb); -if (utf16_path ==NULL ) { - rc = -ENOMEM ; - goto notify_exit; - } -if (return_changes) {if (copy_from_user (¬ify, ioc_buf,sizeof (struct smb3_notify_info ))) { rc = -EFAULT ;
@@ -2426,20 +2414,54 @@ smb3_notify(const unsigned int xid, struct file *pfile, rc = -ENOMEM ; goto notify_exit; } + }else { + cfile = pfile->private_data; } - tcon =cifs_sb_master_tcon (cifs_sb); - oparms = (struct cifs_open_parms ) { - .tcon = tcon, - .path = path, - .desired_access =FILE_READ_ATTRIBUTES |FILE_READ_DATA , - .disposition =FILE_OPEN , - .create_options =cifs_create_options (cifs_sb,0 ), - .fid = &fid, - }; +mutex_lock (&cfile->notify_fid_mutex); +if (!cfile->has_notify_fid) { + page =alloc_dentry_path (); + path =build_path_from_dentry (dentry, page); +if (IS_ERR (path)) { + rc =PTR_ERR (path); + goto notify_unlock; + } - rc =SMB2_open (xid, &oparms, utf16_path, &oplock,NULL ,NULL ,NULL , -NULL ); + utf16_path =cifs_convert_path_to_utf16 (path, cifs_sb); +if (!utf16_path) { + rc = -ENOMEM ; + goto notify_unlock; + } + + cfile->notify_tlink =cifs_get_tlink (cifs_sb_master_tlink (cifs_sb)); +if (IS_ERR_OR_NULL (cfile->notify_tlink)) { + rc = cfile->notify_tlink ?PTR_ERR (cfile->notify_tlink) : -EIO ; + cfile->notify_tlink =NULL ; + goto notify_unlock; + } + tcon =tlink_tcon (cfile->notify_tlink); + oparms = (struct cifs_open_parms ) { + .tcon = tcon, + .path = path, + .desired_access =FILE_READ_ATTRIBUTES |FILE_READ_DATA , + .disposition =FILE_OPEN , + .create_options =cifs_create_options (cifs_sb,0 ), + .fid = &cfile->notify_fid, + }; + + rc =SMB2_open (xid, &oparms, utf16_path, &oplock,NULL ,NULL ,NULL , +NULL ); +if (rc) { +cifs_put_tlink (cfile->notify_tlink); + cfile->notify_tlink =NULL ; + goto notify_unlock; + } + cfile->has_notify_fid = true; + } + fid = cfile->notify_fid; + tcon =tlink_tcon (cfile->notify_tlink); +notify_unlock: +mutex_unlock (&cfile->notify_fid_mutex);if (rc) goto notify_exit;
@@ -2447,9 +2469,7 @@ smb3_notify(const unsigned int xid, struct file *pfile, notify.watch_tree, notify.completion_filter, notify.data_len, &returned_ioctl_info, &ret_len); -SMB2_close (xid, tcon, fid.persistent_fid, fid.volatile_fid); - -cifs_dbg (FYI ,"change notify for path %s rc %d\n" , path, rc); +cifs_dbg (FYI ,"change notify for %pd rc %d\n" , dentry, rc);if (return_changes && (ret_len >0 ) && (notify.data_len >0 )) {if (ret_len > notify.data_len) ret_len = notify.data_len;
@@ -2459,8 +2479,8 @@ smb3_notify(const unsigned int xid, struct file *pfile,else if (copy_to_user (&pnotify_buf->data_len, &ret_len,sizeof (ret_len))) rc = -EFAULT ; } -kfree (returned_ioctl_info); notify_exit: +kfree (returned_ioctl_info);free_dentry_path (page);kfree (utf16_path);return rc;
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 5/9 smb/client: retry change notify after invalid cached handle
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
The notify ioctl caches a separate FID in cifsFileInfo. That handle is not reopened by cifs_reopen_file(), so it can become stale across reconnects. If the server returns STATUS_INVALID_HANDLE for the cached FID, SMB2_change_notify() maps it to -EBADF, but smb3_notify() kept reusing the bad handle.
Invalidate the cached notify FID on -EBADF and retry once so the next attempt opens a fresh handle. Clear only if the cached FID still matches the failed one to avoid racing with another thread that reopened it.
--- fs/smb/client/smb2ops.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
fs/smb/client/smb2ops.c +34 -2
@@ -2365,7 +2365,21 @@ smb3_enum_snapshots(const unsigned int xid, struct cifs_tcon *tcon,return rc; } - +static void +smb3_notify_invalidate_fid (struct cifsFileInfo *cfile, +const struct cifs_fid *fid) +{ +mutex_lock (&cfile->notify_fid_mutex); +if (cfile->has_notify_fid && + cfile->notify_fid.persistent_fid == fid->persistent_fid && + cfile->notify_fid.volatile_fid == fid->volatile_fid) { + cfile->has_notify_fid = false; +memset (&cfile->notify_fid,0 ,sizeof (cfile->notify_fid)); +cifs_put_tlink (cfile->notify_tlink); + cfile->notify_tlink =NULL ; + } +mutex_unlock (&cfile->notify_fid_mutex); +} static int smb3_notify(const unsigned int xid, struct file *pfile,
@@ -2388,6 +2402,7 @@ smb3_notify(const unsigned int xid, struct file *pfile,u8 oplock =SMB2_OPLOCK_LEVEL_NONE ;int rc =0 ;__u32 ret_len =0 ; +bool retry = false;if (return_changes) {if (copy_from_user (¬ify, ioc_buf,sizeof (struct smb3_notify_info ))) {
@@ -2418,6 +2433,7 @@ smb3_notify(const unsigned int xid, struct file *pfile, cfile = pfile->private_data; } +retry_notify:mutex_lock (&cfile->notify_fid_mutex);if (!cfile->has_notify_fid) { page =alloc_dentry_path ();
@@ -2468,7 +2484,23 @@ smb3_notify(const unsigned int xid, struct file *pfile, rc =SMB2_change_notify (xid, tcon, fid.persistent_fid, fid.volatile_fid, notify.watch_tree, notify.completion_filter, notify.data_len, &returned_ioctl_info, &ret_len); - +if (rc == -EBADF ) { +smb3_notify_invalidate_fid (cfile, &fid); +if (retry) + goto notify_done; + +kfree (returned_ioctl_info); + returned_ioctl_info =NULL ; +free_dentry_path (page); + page =NULL ; +kfree (utf16_path); + utf16_path =NULL ; + ret_len =0 ; + retry = true; + goto retry_notify; + } + +notify_done:cifs_dbg (FYI ,"change notify for %pd rc %d\n" , dentry, rc);if (return_changes && (ret_len >0 ) && (notify.data_len >0 )) {if (ret_len > notify.data_len)
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 6/9 smb/client: add helpers for sending cancel requests
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
SMB cancel requests are sent after the waiter has already been interrupted, so they need to get onto the wire even when the current task has a pending signal.
Split the low-level send path so normal requests keep the existing blocking and signal checks, while cancel requests can ignore the pre-send fatal signal check and force non-blocking socket sends.
--- fs/smb/client/cifsproto.h | 2 ++ fs/smb/client/transport.c | 49 +++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 12 deletions(-)
fs/smb/client/cifsproto.h +2 -0
@@ -109,6 +109,8 @@ int cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server);int __smb_send_rqst (struct TCP_Server_Info *server,int num_rqst,struct smb_rqst *rqst); +int __smb_send_cancel_rqst (struct TCP_Server_Info *server,int num_rqst, +struct smb_rqst *rqst);int wait_for_free_request (struct TCP_Server_Info *server,const int flags,unsigned int *instance); int cifs_wait_mtu_credits(struct TCP_Server_Info *server, size_t size,
fs/smb/client/transport.c +37 -12
109 lines not on this page · raw message
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 7/9 smb/client: remember async ids from SMB2 pending responses
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
SMB2 servers may turn a request into an asynchronous command by replying with STATUS_PENDING and SMB2_FLAGS_ASYNC_COMMAND. A later SMB2_CANCEL must target the async id from that pending response rather than only the original message id fields.
Store that async id in the mid entry when processing STATUS_PENDING so the cancel path can build the correct header.
--- fs/smb/client/cifsglob.h | 2 ++ fs/smb/client/smb2ops.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)
fs/smb/client/cifsglob.h +2 -0
@@ -1713,6 +1713,7 @@ struct mid_q_entry {struct list_head qhead;/* mids waiting on reply from this server */ refcount_t refcount;__u64 mid;/* multiplex id */ +__u64 async_id;/* async id if server returned STATUS_PENDING */ __u16 credits;/* number of credits consumed by this mid */ __u16 credits_received;/* number of credits from the response */ __u32 pid;/* process id */
@@ -1742,6 +1743,7 @@ struct mid_q_entry { bool multiRsp:1; /* multiple trans2 responses for one request */ bool multiEnd:1; /* both received */ bool decrypted:1; /* decrypted entry */ + bool async_cmd:1; /* server returned an async id for this request */ };struct close_cancelled_open {
fs/smb/client/smb2ops.c +12 -0
@@ -2684,11 +2684,23 @@ static bool smb2_is_status_pending(char *buf, struct TCP_Server_Info *server) {struct smb2_hdr *shdr = (struct smb2_hdr *)buf; +struct mid_q_entry *mid;int scredits, in_flight;if (shdr->Status !=STATUS_PENDING )return false; +if (shdr->Flags &SMB2_FLAGS_ASYNC_COMMAND ) { + mid =__smb2_find_mid (server, buf, false); +if (mid) { +spin_lock (&mid->mid_lock); + mid->async_cmd = true; + mid->async_id =le64_to_cpu (shdr->Id.AsyncId); +spin_unlock (&mid->mid_lock); +release_mid (server, mid); + } + } +if (shdr->CreditRequest) {spin_lock (&server->req_lock); server->credits +=le16_to_cpu (shdr->CreditRequest);
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 8/9 smb/client: send SMB2 cancel requests
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
Wire up the generic cancel callback for SMB2 and later dialects. When a synchronous wait is interrupted, the client can now send SMB2_CANCEL for the outstanding mid instead of only marking the mid as cancelled locally.
Build cancel requests from the original request header so the message id, session id, tree id, signing state, and any saved async id target the request that is being abandoned. Encrypted shares wrap the cancel in a transform request before sending it.
--- fs/smb/client/smb2ops.c | 4 ++ fs/smb/client/smb2proto.h | 3 + fs/smb/client/smb2transport.c | 105 ++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+)
fs/smb/client/smb2ops.c +4 -0
@@ -5484,6 +5484,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY struct smb_version_operations smb20_operations = { + .send_cancel = smb2_send_cancel, .compare_fids = smb2_compare_fids, .setup_request = smb2_setup_request, .setup_async_request = smb2_setup_async_request,
@@ -5586,6 +5587,7 @@ struct smb_version_operations smb20_operations = {#endif /* CIFS_ALLOW_INSECURE_LEGACY */ struct smb_version_operations smb21_operations = { + .send_cancel = smb2_send_cancel, .compare_fids = smb2_compare_fids, .setup_request = smb2_setup_request, .setup_async_request = smb2_setup_async_request,
@@ -5690,6 +5692,7 @@ struct smb_version_operations smb21_operations = { };struct smb_version_operations smb30_operations = { + .send_cancel = smb2_send_cancel, .compare_fids = smb2_compare_fids, .setup_request = smb2_setup_request, .setup_async_request = smb2_setup_async_request,
@@ -5806,6 +5809,7 @@ struct smb_version_operations smb30_operations = { };struct smb_version_operations smb311_operations = { + .send_cancel = smb2_send_cancel, .compare_fids = smb2_compare_fids, .setup_request = smb2_setup_request, .setup_async_request = smb2_setup_async_request,
fs/smb/client/smb2proto.h +3 -0
@@ -40,6 +40,9 @@ int smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server);int smb2_check_receive (struct mid_q_entry *mid,struct TCP_Server_Info *server,bool log_error); +int smb2_send_cancel (struct cifs_ses *ses,struct TCP_Server_Info *server, +struct smb_rqst *rqst,struct mid_q_entry *mid, +unsigned int xid);struct mid_q_entry *smb2_setup_request (struct cifs_ses *ses,struct TCP_Server_Info *server,struct smb_rqst *rqst);
fs/smb/client/smb2transport.c +105 -0
111 lines not on this page · raw message
Signature · 1 line
2.54.0
ChenXiaoSong
reviewerPATCH 9/9 smb/client: make SMB2 change notify interruptible
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
SMB2 change notify can block indefinitely while waiting for directory changes. Mark the request as interruptible so userspace can stop the wait with a normal signal.
The interrupted wait now uses the SMB2 cancel callback added earlier in the series to notify the server about the abandoned request.
--- fs/smb/client/smb2pdu.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/client/smb2pdu.c +1 -0
@@ -4127,6 +4127,7 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,if (smb3_encryption_required (tcon)) flags |=CIFS_TRANSFORM_REQ ; + flags |=CIFS_INTERRUPTIBLE_WAIT ;memset (&rqst,0 ,sizeof (struct smb_rqst ));memset (&iov,0 ,sizeof (iov));
Signature · 1 line
2.54.0