summaryrefslogtreecommitdiff
path: root/fs/netfs/read_helper.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2022-01-21 00:55:46 +0300
committerDavid Howells <dhowells@redhat.com>2022-03-18 12:24:00 +0300
commit2de160417315b8d64455fe03e9bb7d3308ac3281 (patch)
treefe7a61cba73b3f0e025e859c2bb7609818086da3 /fs/netfs/read_helper.c
parent663dfb65c3b3ea4b8e1944680352992d58f3aa22 (diff)
downloadlinux-2de160417315b8d64455fe03e9bb7d3308ac3281.tar.xz
netfs: Change ->init_request() to return an error code
Change the request initialisation function to return an error code so that the network filesystem can return a failure (ENOMEM, for example). This will also allow ceph to abort a ->readahead() op if the server refuses to give it a cap allowing local caching from within the netfslib framework (errors aren't passed back through ->readahead(), so returning, say, -ENOBUFS will cause the op to be aborted). Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/164678212401.1200972.16537041523832944934.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/164692905398.2099075.5238033621684646524.stgit@warthog.procyon.org.uk/ # v3
Diffstat (limited to 'fs/netfs/read_helper.c')
-rw-r--r--fs/netfs/read_helper.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
index dea085715286..b5176f4320f4 100644
--- a/fs/netfs/read_helper.c
+++ b/fs/netfs/read_helper.c
@@ -768,7 +768,7 @@ void netfs_readahead(struct readahead_control *ractl,
readahead_pos(ractl),
readahead_length(ractl),
NETFS_READAHEAD);
- if (!rreq)
+ if (IS_ERR(rreq))
goto cleanup;
if (ops->begin_cache_operation) {
@@ -842,11 +842,9 @@ int netfs_readpage(struct file *file,
rreq = netfs_alloc_request(folio->mapping, file, ops, netfs_priv,
folio_file_pos(folio), folio_size(folio),
NETFS_READPAGE);
- if (!rreq) {
- if (netfs_priv)
- ops->cleanup(folio_file_mapping(folio), netfs_priv);
- folio_unlock(folio);
- return -ENOMEM;
+ if (IS_ERR(rreq)) {
+ ret = PTR_ERR(rreq);
+ goto alloc_error;
}
if (ops->begin_cache_operation) {
@@ -887,6 +885,11 @@ int netfs_readpage(struct file *file,
out:
netfs_put_request(rreq, false, netfs_rreq_trace_put_hold);
return ret;
+alloc_error:
+ if (netfs_priv)
+ ops->cleanup(folio_file_mapping(folio), netfs_priv);
+ folio_unlock(folio);
+ return ret;
}
EXPORT_SYMBOL(netfs_readpage);
@@ -1007,12 +1010,13 @@ retry:
goto have_folio_no_wait;
}
- ret = -ENOMEM;
rreq = netfs_alloc_request(mapping, file, ops, netfs_priv,
folio_file_pos(folio), folio_size(folio),
NETFS_READ_FOR_WRITE);
- if (!rreq)
+ if (IS_ERR(rreq)) {
+ ret = PTR_ERR(rreq);
goto error;
+ }
rreq->no_unlock_folio = folio_index(folio);
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
netfs_priv = NULL;