From: Bharath SM Date: Fri, 13 Dec 2024 17:20:21 +0000 (+0530) Subject: smb: enable reuse of deferred file handles for write operations X-Git-Tag: v6.13-rc5~11^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8ea3b1ff544b47c1d64a22860f33b755638164e;p=thirdparty%2Flinux.git smb: enable reuse of deferred file handles for write operations Previously, deferred file handles were reused only for read operations, this commit extends to reusing deferred handles for write operations. By reusing these handles we can reduce the need for open/close operations over the wire. Signed-off-by: Bharath SM Signed-off-by: Steve French --- diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index a58a3333ecc30..3b2d33291a7e6 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -990,7 +990,11 @@ int cifs_open(struct inode *inode, struct file *file) } /* Get the cached handle as SMB2 close is deferred */ - rc = cifs_get_readable_path(tcon, full_path, &cfile); + if (OPEN_FMODE(file->f_flags) & FMODE_WRITE) { + rc = cifs_get_writable_path(tcon, full_path, FIND_WR_FSUID_ONLY, &cfile); + } else { + rc = cifs_get_readable_path(tcon, full_path, &cfile); + } if (rc == 0) { if (file->f_flags == cfile->f_flags) { file->private_data = cfile;