cifs: remove superfluous inode_lock in cifs_{strict_}fsync [Linux 5.2]

cifs: remove superfluous inode_lock in cifs_{strict_}fsync [Linux 5.2]

This Linux kernel change "cifs: remove superfluous inode_lock in cifs_{strict_}fsync" is included in the Linux 5.2 release. This change is authored by Jeff Layton <jlayton [at] kernel.org> on Mon Apr 8 10:59:42 2019 -0400. The commit for this change in Linux stable tree is 0ae3fa4 (patch).

cifs: remove superfluous inode_lock in cifs_{strict_}fsync

Originally, filemap_write_and_wait took the i_mutex internally, but
commit 02c24a82187d pushed the mutex acquisition into the individual
fsync routines, leaving it up to the subsystem maintainers to remove
it if it wasn't needed.

For cifs, I see no reason to take the inode_lock here. All of the
operations inside that lock are protected in other ways.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Acked-by: Pavel Shilovsky <pshilov@microsoft.com>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/cifs/file.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 7037a13..ce9a5be 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2443,7 +2443,6 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
    rc = file_write_and_wait_range(file, start, end);
    if (rc)
        return rc;
-   inode_lock(inode);

    xid = get_xid();

@@ -2468,7 +2467,6 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
    }

    free_xid(xid);
-   inode_unlock(inode);
    return rc;
 }

@@ -2480,12 +2478,10 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
    struct TCP_Server_Info *server;
    struct cifsFileInfo *smbfile = file->private_data;
    struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
-   struct inode *inode = file->f_mapping->host;

    rc = file_write_and_wait_range(file, start, end);
    if (rc)
        return rc;
-   inode_lock(inode);

    xid = get_xid();

@@ -2502,7 +2498,6 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
    }

    free_xid(xid);
-   inode_unlock(inode);
    return rc;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *