Commit 6ba0c4e5 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Simplify internal check for whether file is open for write

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 1db97eaa
...@@ -1328,19 +1328,11 @@ static bool nfs_file_has_writers(struct nfs_inode *nfsi) ...@@ -1328,19 +1328,11 @@ static bool nfs_file_has_writers(struct nfs_inode *nfsi)
{ {
struct inode *inode = &nfsi->vfs_inode; struct inode *inode = &nfsi->vfs_inode;
assert_spin_locked(&inode->i_lock);
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return false; return false;
if (list_empty(&nfsi->open_files)) if (list_empty(&nfsi->open_files))
return false; return false;
/* Note: This relies on nfsi->open_files being ordered with writers return inode_is_open_for_write(inode);
* being placed at the head of the list.
* See nfs_inode_attach_open_context()
*/
return (list_first_entry(&nfsi->open_files,
struct nfs_open_context,
list)->mode & FMODE_WRITE) == FMODE_WRITE;
} }
static bool nfs_file_has_buffered_writers(struct nfs_inode *nfsi) static bool nfs_file_has_buffered_writers(struct nfs_inode *nfsi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment