nfs: use locks_inode_context helper
authorJeff Layton <jlayton@kernel.org>
Wed, 16 Nov 2022 14:55:36 +0000 (09:55 -0500)
committerJeff Layton <jlayton@kernel.org>
Wed, 30 Nov 2022 10:08:10 +0000 (05:08 -0500)
nfs currently doesn't access i_flctx safely. This requires a
smp_load_acquire, as the pointer is set via cmpxchg (a release
operation).

Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Anna Schumaker <anna@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/nfs/delegation.c
fs/nfs/nfs4state.c
fs/nfs/pagelist.c
fs/nfs/write.c

index ead8a0e06abf9abdc179601f61ee3a3fe2c4736c..cf7365581031b5c4442956a6643572580abc9abc 100644 (file)
@@ -146,7 +146,7 @@ static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_state
 {
        struct inode *inode = state->inode;
        struct file_lock *fl;
-       struct file_lock_context *flctx = inode->i_flctx;
+       struct file_lock_context *flctx = locks_inode_context(inode);
        struct list_head *list;
        int status = 0;
 
index a2d2d5d1b088895aba558358368d57d2ded0b13c..dd18344648f3cf017b666093c4d69a9a455fbd89 100644 (file)
@@ -1501,7 +1501,7 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
        struct file_lock *fl;
        struct nfs4_lock_state *lsp;
        int status = 0;
-       struct file_lock_context *flctx = inode->i_flctx;
+       struct file_lock_context *flctx = locks_inode_context(inode);
        struct list_head *list;
 
        if (flctx == NULL)
index 317cedfa52bf6d760093ffa6579023c26a4e3947..16be6dae524f99c946a277aedde9c8d42f9332d8 100644 (file)
@@ -1055,7 +1055,7 @@ static unsigned int nfs_coalesce_size(struct nfs_page *prev,
        if (prev) {
                if (!nfs_match_open_context(nfs_req_openctx(req), nfs_req_openctx(prev)))
                        return 0;
-               flctx = d_inode(nfs_req_openctx(req)->dentry)->i_flctx;
+               flctx = locks_inode_context(d_inode(nfs_req_openctx(req)->dentry));
                if (flctx != NULL &&
                    !(list_empty_careful(&flctx->flc_posix) &&
                      list_empty_careful(&flctx->flc_flock)) &&
index f41d24b54fd1f8b19a3e34e8cfad1bdb7b5ff206..80c240e50952217df66bda308787f02bd1eada15 100644 (file)
@@ -1185,7 +1185,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
 {
        struct nfs_open_context *ctx = nfs_file_open_context(file);
        struct nfs_lock_context *l_ctx;
-       struct file_lock_context *flctx = file_inode(file)->i_flctx;
+       struct file_lock_context *flctx = locks_inode_context(file_inode(file));
        struct nfs_page *req;
        int do_flush, status;
        /*
@@ -1321,7 +1321,7 @@ static int nfs_can_extend_write(struct file *file, struct page *page,
                                struct inode *inode, unsigned int pagelen)
 {
        int ret;
-       struct file_lock_context *flctx = inode->i_flctx;
+       struct file_lock_context *flctx = locks_inode_context(inode);
        struct file_lock *fl;
 
        if (file->f_flags & O_DSYNC)