diff mbox series

[RFC,10/19] netfs: refactor netfs_rreq_prepare_read

Message ID 20211210073619.21667-11-jefflexu@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series fscache,erofs: fscache-based demand-read semantics | expand

Commit Message

Jingbo Xu Dec. 10, 2021, 7:36 a.m. UTC
In demand-read mode, fs using fscache for demand-read doesn't know and
care the exact file size of the data blob file, and thus skip the file
size check in this case.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
 fs/netfs/read_helper.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c
index af12a7996672..ade1523fc180 100644
--- a/fs/netfs/read_helper.c
+++ b/fs/netfs/read_helper.c
@@ -776,14 +776,16 @@  netfs_rreq_prepare_read(struct netfs_read_request *rreq,
 		goto out;
 
 	if (source == NETFS_DOWNLOAD_FROM_SERVER) {
-		/* Call out to the netfs to let it shrink the request to fit
-		 * its own I/O sizes and boundaries.  If it shinks it here, it
-		 * will be called again to make simultaneous calls; if it wants
-		 * to make serial calls, it can indicate a short read and then
-		 * we will call it again.
-		 */
-		if (subreq->len > rreq->i_size - subreq->start)
-			subreq->len = rreq->i_size - subreq->start;
+		if (rreq->type == NETFS_TYPE_CACHE) {
+			/* Call out to the netfs to let it shrink the request to fit
+			 * its own I/O sizes and boundaries.  If it shinks it here, it
+			 * will be called again to make simultaneous calls; if it wants
+			 * to make serial calls, it can indicate a short read and then
+			 * we will call it again.
+			 */
+			if (subreq->len > rreq->i_size - subreq->start)
+				subreq->len = rreq->i_size - subreq->start;
+		}
 
 		if (rreq->netfs_ops->clamp_length &&
 		    !rreq->netfs_ops->clamp_length(subreq)) {