]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfsd: use locks_inode_context helper
authorJeff Layton <jlayton@kernel.org>
Wed, 16 Nov 2022 14:36:07 +0000 (09:36 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:21 +0000 (16:19 +0200)
[ Upstream commit 77c67530e1f95ac25c7075635f32f04367380894 ]

nfsd currently doesn't access i_flctx safely everywhere. This requires a
smp_load_acquire, as the pointer is set via cmpxchg (a release
operation).

Acked-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c

index 7cfc92aa2a2362dad68cc905b4f529fd161dd34f..dbcdb74e9ff6fdcbba5ae5faa0f818a5f460c988 100644 (file)
@@ -4773,7 +4773,7 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
 
 static bool nfsd4_deleg_present(const struct inode *inode)
 {
-       struct file_lock_context *ctx = smp_load_acquire(&inode->i_flctx);
+       struct file_lock_context *ctx = locks_inode_context(inode);
 
        return ctx && !list_empty_careful(&ctx->flc_lease);
 }
@@ -5912,7 +5912,7 @@ nfs4_lockowner_has_blockers(struct nfs4_lockowner *lo)
 
        list_for_each_entry(stp, &lo->lo_owner.so_stateids, st_perstateowner) {
                nf = stp->st_stid.sc_file;
-               ctx = nf->fi_inode->i_flctx;
+               ctx = locks_inode_context(nf->fi_inode);
                if (!ctx)
                        continue;
                if (locks_owner_has_blockers(ctx, lo))
@@ -7726,7 +7726,7 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner)
        }
 
        inode = locks_inode(nf->nf_file);
-       flctx = inode->i_flctx;
+       flctx = locks_inode_context(inode);
 
        if (flctx && !list_empty_careful(&flctx->flc_posix)) {
                spin_lock(&flctx->flc_lock);