From: Mateusz Guzik <mjguzik@gmail.com>
To: brauner@kernel.org
Cc: viro@zeniv.linux.org.uk, jack@suse.cz,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Mateusz Guzik <mjguzik@gmail.com>
Subject: [PATCH v6 0/3] assorted ->i_count changes + extension of lockless handling
Date: Tue, 21 Apr 2026 20:25:35 +0200 [thread overview]
Message-ID: <20260421182538.1215894-1-mjguzik@gmail.com> (raw)
The stock kernel support partial lockless in handling in that iput() can
decrement any value > 1. Any ref acquire however requires the spinlock.
With this patchset ref acquires when the value was already at least 1
also become lockless. That is, only transitions 0->1 and 1->0 take the
lock.
I verified when nfs calls into the hash taking the lock is typically
avoided. Similarly, btrfs likes to igrab() and avoids the lock.
However, I have to fully admit I did not perform any benchmarks. While
cleaning stuff up I noticed lockless operation is almost readily
available so I went for it.
Clean-up wise, the icount_read_once() stuff lines up with inode_state_read_once().
The prefix is different but I opted to not change it due to igrab(), ihold() et al.
v6
- remove the DONTCACHE vs drop patch for the time being
- s/igrab_try_lockless/igrab_from_hash/
v5:
- reword some commentary
- add unlikely to the new icount check in iput_final()
v4:
- squash icount_read patches
- use icount_read_once in the new ihold assert, reported by syzbot
- squash lockless ref acquire patches, rewrite new comments
v3:
- tidy up ihold
- add lockless handling to the hash
Mateusz Guzik (3):
fs: add icount_read_once() and stop open-coding ->i_count loads
fs: relocate and tidy up ihold()
fs: allow lockless ->i_count bumps as long as it does not transition
0->1
arch/powerpc/platforms/cell/spufs/file.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/mds_client.c | 2 +-
fs/dcache.c | 4 +
fs/ext4/ialloc.c | 4 +-
fs/hpfs/inode.c | 2 +-
fs/inode.c | 96 ++++++++++++++++++++----
fs/nfs/inode.c | 4 +-
fs/smb/client/inode.c | 2 +-
fs/ubifs/super.c | 2 +-
fs/xfs/xfs_inode.c | 2 +-
fs/xfs/xfs_trace.h | 2 +-
include/linux/fs.h | 13 ++++
include/trace/events/filelock.h | 2 +-
security/landlock/fs.c | 2 +-
15 files changed, 112 insertions(+), 29 deletions(-)
--
2.48.1
next reply other threads:[~2026-04-21 18:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 18:25 Mateusz Guzik [this message]
2026-04-21 18:25 ` [PATCH v6 1/3] fs: add icount_read_once() and stop open-coding ->i_count loads Mateusz Guzik
2026-04-22 10:17 ` Jan Kara
2026-04-21 18:25 ` [PATCH v6 2/3] fs: relocate and tidy up ihold() Mateusz Guzik
2026-04-22 10:18 ` Jan Kara
2026-04-21 18:25 ` [PATCH v6 3/3] fs: allow lockless ->i_count bumps as long as it does not transition 0->1 Mateusz Guzik
2026-04-22 10:26 ` Jan Kara
2026-04-22 13:02 ` [PATCH v6 0/3] assorted ->i_count changes + extension of lockless handling Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260421182538.1215894-1-mjguzik@gmail.com \
--to=mjguzik@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox