]> git.ipfire.org Git - thirdparty/linux.git/commit
netfs: Fix unbuffered/DIO writes to dispatch subrequests in strict sequence
authorDavid Howells <dhowells@redhat.com>
Thu, 26 Feb 2026 13:32:33 +0000 (13:32 +0000)
committerChristian Brauner <brauner@kernel.org>
Thu, 26 Feb 2026 13:44:32 +0000 (14:44 +0100)
commita0b4c7a49137ed21279f354eb59f49ddae8dffc2
tree2743ad55a3900515aead3c38aaebf4d14db9b35c
parent28aaa9c39945b7925a1cc1d513c8f21ed38f5e4f
netfs: Fix unbuffered/DIO writes to dispatch subrequests in strict sequence

Fix netfslib such that when it's making an unbuffered or DIO write, to make
sure that it sends each subrequest strictly sequentially, waiting till the
previous one is 'committed' before sending the next so that we don't have
pieces landing out of order and potentially leaving a hole if an error
occurs (ENOSPC for example).

This is done by copying in just those bits of issuing, collecting and
retrying subrequests that are necessary to do one subrequest at a time.
Retrying, in particular, is simpler because if the current subrequest needs
retrying, the source iterator can just be copied again and the subrequest
prepped and issued again without needing to be concerned about whether it
needs merging with the previous or next in the sequence.

Note that the issuing loop waits for a subrequest to complete right after
issuing it, but this wait could be moved elsewhere allowing preparatory
steps to be performed whilst the subrequest is in progress.  In particular,
once content encryption is available in netfslib, that could be done whilst
waiting, as could cleanup of buffers that have been completed.

Fixes: 153a9961b551 ("netfs: Implement unbuffered/DIO write support")
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/58526.1772112753@warthog.procyon.org.uk
Tested-by: Steve French <sfrench@samba.org>
Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/direct_write.c
fs/netfs/internal.h
fs/netfs/write_collect.c
fs/netfs/write_issue.c
include/trace/events/netfs.h