]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
netfs: Replace wb_lock with a bit lock for asynchronicity
authorDavid Howells <dhowells@redhat.com>
Thu, 25 Jun 2026 14:06:29 +0000 (15:06 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 1 Jul 2026 13:26:29 +0000 (15:26 +0200)
commit41376400c4717fed43490030902f9e4c9062b285
tree51c2f36294347e57da98c7e834d6929119fc13bf
parentfa746e23d1094f9a68afe5973746b0e32078fd8b
netfs: Replace wb_lock with a bit lock for asynchronicity

The netfs_inode::wb_lock mutex is used to prevent multiple simultaneous
writebacks from fighting each other (a writeback thread will write multiple
discontiguous regions within the same request).  The mutex, however, only
serialises the issuing of subrequests; it doesn't serialise the collection
of results, and, in particular, the updating of file size information and
fscache populatedness data.

Unfortunately, the mutex cannot be held around the entire process as it has
to be unlocked in the same thread in which it is locked - and we don't want
to hold up the allocator whilst we complete the writeback.

Fix this by replacing the mutex with a bit flag and a list of lock waiters
so that the lock can be dropped in the collector thread after collection is
complete.

Link: https://sashiko.dev/#/patchset/20260608145432.681865-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260625140640.3116900-12-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/afs/symlink.c
fs/netfs/locking.c
fs/netfs/write_collect.c
fs/netfs/write_issue.c
include/linux/netfs.h