diff options
| author | Mateusz Guzik <mjguzik@gmail.com> | 2026-04-21 20:25:38 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-05-11 23:12:29 +0200 |
| commit | c678577e8896829f9da08635d6075dddefbaf684 (patch) | |
| tree | 1b1ea799a4529c07e5046b69fbc988666c7c5d51 /include/linux | |
| parent | ac8bcfc07d0ba68721a4ff750e7df12d203ae6ac (diff) | |
| download | lwn-c678577e8896829f9da08635d6075dddefbaf684.tar.gz lwn-c678577e8896829f9da08635d6075dddefbaf684.zip | |
fs: allow lockless ->i_count bumps as long as it does not transition 0->1
With this change only 0->1 and 1->0 transitions need the lock.
I verified all places which look at the refcount either only care about
it staying 0 (and have the lock enforce it) or don't hold the inode lock
to begin with (making the above change irrelevant to their correcness or
lack thereof).
I also confirmed nfs and btrfs like to call into these a lot and now
avoid the lock in the common case, shaving off some atomics.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://patch.msgid.link/20260421182538.1215894-4-mjguzik@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/fs.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 61ce251ad83e..c5c31a6f7ed5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2227,8 +2227,8 @@ static inline int icount_read_once(const struct inode *inode) } /* - * returns the refcount on the inode. The lock guarantees no new references - * are added, but references can be dropped as long as the result is > 0. + * returns the refcount on the inode. The lock guarantees no 0->1 or 1->0 transitions + * of the count are going to take place, otherwise it changes arbitrarily. */ static inline int icount_read(const struct inode *inode) { |
