]> www.infradead.org Git - users/jedix/linux-maple.git/commit
netfs: Fix missing wakeup after issuing writes
authorDavid Howells <dhowells@redhat.com>
Wed, 2 Oct 2024 14:45:50 +0000 (15:45 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 2 Oct 2024 14:56:15 +0000 (16:56 +0200)
commit1ca4169c391c370e0f3a92938df2862900575096
tree52f5ac9cffb0fb0011e5c6694575c87d7c3be569
parent59d39b9259e4d15b6e4c6da758ab318a76a10ca4
netfs: Fix missing wakeup after issuing writes

After dividing up a proposed write into subrequests, netfslib sets
NETFS_RREQ_ALL_QUEUED to indicate to the collector that it can move on to
the final cleanup once it has emptied the subrequest queues.

Now, whilst the collector will normally end up running at least once after
this bit is set just because it takes a while to process all the write
subrequests before the collector runs out of subrequests, there exists the
possibility that the issuing thread will be forced to sleep and the
collector thread will clean up all the subrequests before ALL_QUEUED gets
set.

In such a case, the collector thread will not get triggered again and will
never clear NETFS_RREQ_IN_PROGRESS thus leaving a request uncompleted and
causing a potential futute hang.

Fix this by scheduling the write collector if all the subrequest queues are
empty (and thus no writes pending issuance).

Note that we'd do this ideally before queuing the subrequest, but in the
case of buffered writeback, at least, we can't find out that we've run out
of folios until after we've called writeback_iter() and it has returned
NULL - at which point we might not actually have any subrequests still
under construction.

Fixes: 288ace2f57c9 ("netfs: New writeback implementation")
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/3317784.1727880350@warthog.procyon.org.uk
cc: Jeff Layton <jlayton@kernel.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/write_issue.c