diff options
author | Jeff Layton <jlayton@kernel.org> | 2022-11-16 09:02:30 -0500 |
---|---|---|
committer | Jeff Layton <jlayton@kernel.org> | 2022-11-30 05:08:10 -0500 |
commit | 401a8b8fd5acd51582b15238d72a8d0edd580e9f (patch) | |
tree | 7b8c736ac196067e55416586ad2e5a7b99216b6d /include/linux/fs.h | |
parent | ab1ddef98a715eddb65309ffa83267e4e84a571e (diff) | |
download | linux-401a8b8fd5acd51582b15238d72a8d0edd580e9f.tar.gz linux-401a8b8fd5acd51582b15238d72a8d0edd580e9f.tar.bz2 linux-401a8b8fd5acd51582b15238d72a8d0edd580e9f.zip |
filelock: add a new locks_inode_context accessor function
There are a number of places in the kernel that are accessing the
inode->i_flctx field without smp_load_acquire. This is required to
ensure that the caller doesn't see a partially-initialized structure.
Add a new accessor function for it to make this clear and convert all of
the relevant accesses in locks.c to use it. Also, convert
locks_free_lock_context to use the helper as well instead of just doing
a "bare" assignment.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 6165c6245347..fd0a79511fd8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1187,6 +1187,13 @@ extern void show_fd_locks(struct seq_file *f, struct file *filp, struct files_struct *files); extern bool locks_owner_has_blockers(struct file_lock_context *flctx, fl_owner_t owner); + +static inline struct file_lock_context * +locks_inode_context(const struct inode *inode) +{ + return smp_load_acquire(&inode->i_flctx); +} + #else /* !CONFIG_FILE_LOCKING */ static inline int fcntl_getlk(struct file *file, unsigned int cmd, struct flock __user *user) @@ -1332,6 +1339,13 @@ static inline bool locks_owner_has_blockers(struct file_lock_context *flctx, { return false; } + +static inline struct file_lock_context * +locks_inode_context(const struct inode *inode) +{ + return NULL; +} + #endif /* !CONFIG_FILE_LOCKING */ static inline struct inode *file_inode(const struct file *f) |