mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org
Cc: huyue2@coolpad.com, zhujia.zj@bytedance.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] erofs: pass accurate blob size to prepare_ondemand_read()
Date: Tue, 21 Feb 2023 17:17:18 +0800	[thread overview]
Message-ID: <20230221091719.126127-2-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20230221091719.126127-1-jefflexu@linux.alibaba.com>

To make fscache mode support PAGE_SIZE larger than 4KB, the blob image
size may be small than the multiples of PAGE_SIZE (as erofs block size
is no larger than 4KB), while the file range of the blob requested to
read is multiples of PAGE_SIZE and may be larger than the blob image
size.

Therefore we need the accurate blob size, so that the EOF part could be
distinguished and zero-filled then.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 87ff35bff8d5..f7a1e147d0f4 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -125,7 +125,7 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 
 	DBG_BUGON(len > req->len - req->submitted);
 
-	ret = fscache_begin_read_operation(cres, cookie);
+	ret = fscache_begin_wait_operation(cres, cookie, FSCACHE_WANT_READ);
 	if (ret)
 		return ret;
 
@@ -134,8 +134,17 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 		size_t slen = len - done;
 		unsigned long flags = 1 << NETFS_SREQ_ONDEMAND;
 
+		if (sstart >= cookie->object_size) {
+			iov_iter_xarray(&iter, ITER_DEST, &req->mapping->i_pages,
+					lstart + done, slen);
+			iov_iter_zero(slen, &iter);
+			done += slen;
+			continue;
+		}
+
+		slen = min_t(size_t, slen, cookie->object_size - sstart);
 		source = cres->ops->prepare_ondemand_read(cres,
-				sstart, &slen, LLONG_MAX, &flags, 0);
+				sstart, &slen, cookie->object_size, &flags, 0);
 		if (WARN_ON(slen == 0))
 			source = NETFS_INVALID_READ;
 		if (source != NETFS_READ_FROM_CACHE) {
-- 
2.19.1.6.gb485710b


  reply	other threads:[~2023-02-21  9:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21  9:17 [PATCH 0/2] erofs: remove the constraint of 4KB blksize for fscache mode Jingbo Xu
2023-02-21  9:17 ` Jingbo Xu [this message]
2023-02-21  9:17 ` [PATCH 2/2] erofs: set blksize to on-disk " Jingbo Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230221091719.126127-2-jefflexu@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=chao@kernel.org \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    --cc=zhujia.zj@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®