]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smb: enable reuse of deferred file handles for write operations
authorBharath SM <bharathsm@microsoft.com>
Fri, 13 Dec 2024 17:20:21 +0000 (22:50 +0530)
committerSteve French <stfrench@microsoft.com>
Mon, 23 Dec 2024 14:05:39 +0000 (08:05 -0600)
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 <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/file.c

index a58a3333ecc300ab1974c9ea85ab637af81d64e1..3b2d33291a7e6443552d67315e567935214029ba 100644 (file)
@@ -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;