Skip to contentSkip to conversation

cachefiles: Fix unset error when calling netfs_prepare_write_failed()

PATCH Applied David Howells 2 participants 2 messages Sep 30 – Oct 2

Subsystems (5)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

Fix cachefiles to set subreq->error before calling netfs_prepare_write_failed() otherwise netfslib will try (and fail) to retry the subrequest (it shouldn't retry writes to the cache, but rather abandon them). This causes it to hang waiting for the request to complete.

Fixes 1a9fe4b6e787 ("cachefiles: Don't rely on backing fs storage map for most use cases")
cc Paulo Alcantara <[email protected]>
cc Matthew Wilcox <[email protected]>
---
 fs/cachefiles/io.c     |    2 ++
 fs/netfs/write_issue.c |    1 +
 2 files changed, 3 insertions(+)
fs/cachefiles/io.c +2 -0
index 4f547d97356e..d05059822288 100644
@@ -528,10 +528,12 @@ static void cachefiles_prepare_write_subreq(struct netfs_io_subrequest *subreq)
 
 	if (!cachefiles_cres_file(cres)) {
 		if (!fscache_wait_for_operation(cres, FSCACHE_WANT_WRITE)) {
+			subreq->error = -ENOBUFS;
 			trace_netfs_sreq(subreq, netfs_sreq_trace_cache_waitfail);
 			return netfs_prepare_write_failed(subreq);
 		}
 		if (!cachefiles_cres_file(cres)) {
+			subreq->error = -ENOBUFS;
 			trace_netfs_sreq(subreq, netfs_sreq_trace_cache_nofile);
 			return netfs_prepare_write_failed(subreq);
 		}
fs/netfs/write_issue.c +1 -0
index 9de73c0edad2..b255a1167bb1 100644
@@ -148,6 +148,7 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping,
  */
 void netfs_prepare_write_failed(struct netfs_io_subrequest *subreq)
 {
+	WARN_ON_ONCE(!subreq->error);
 	__set_bit(NETFS_SREQ_FAILED, &subreq->flags);
 	trace_netfs_sreq(subreq, netfs_sreq_trace_prep_failed);
 }
maintainer Applied
#1 lore raw
Quoted 4 lines · David Howells

Fix cachefiles to set subreq->error before calling netfs_prepare_write_failed() otherwise netfslib will try (and fail) to retry the subrequest (it shouldn't retry writes to the cache, but rather abandon them). This causes it to hang waiting for the request to complete.

Applied to the vfs-7.4.netfs branch of the vfs/vfs.git tree. Patches in the vfs-7.4.netfs branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.4.netfs

[1/1] cachefiles: Fix unset error when calling netfs_prepare_write_failed()

      https://git.kernel.org/vfs/vfs/c/04b0415fa18a