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

Reviewed-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/ceph/locks.c

index 3e2843e86e2744486075519dfd87f9d39edc9ced..f3b461c708a8bea40554813ddc7287ba6bd7f428 100644 (file)
@@ -364,7 +364,7 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
        *fcntl_count = 0;
        *flock_count = 0;
 
-       ctx = inode->i_flctx;
+       ctx = locks_inode_context(inode);
        if (ctx) {
                spin_lock(&ctx->flc_lock);
                list_for_each_entry(lock, &ctx->flc_posix, fl_list)
@@ -418,7 +418,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
                                int num_fcntl_locks, int num_flock_locks)
 {
        struct file_lock *lock;
-       struct file_lock_context *ctx = inode->i_flctx;
+       struct file_lock_context *ctx = locks_inode_context(inode);
        int err = 0;
        int seen_fcntl = 0;
        int seen_flock = 0;