linux-fsdevel.vger.kernel.org archive mirror
 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, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 5/9] erofs: set accurate anony inode size for page cache sharing
Date: Fri,  3 Feb 2023 11:01:39 +0800	[thread overview]
Message-ID: <20230203030143.73105-6-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20230203030143.73105-1-jefflexu@linux.alibaba.com>

In prep for the following support for readahead for page cache sharing,
we need accurate inode size of the anonymous inode, or the readahead
algorithm may exceed EOF of blobs if the inode size is OFFSET_MAX magic.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/fscache.c  | 9 +++++++++
 fs/erofs/internal.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index bed02b21978a..4fe7f23b022e 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -554,6 +554,15 @@ struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb,
 	mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
 	inode->i_private = ctx;
 
+	if (test_opt(&EROFS_SB(sb)->opt, SHARE_CACHE)) {
+		struct netfs_cache_resources cres;
+		ret = fscache_begin_read_operation(&cres, cookie);
+		if (ret)
+			goto err_cookie;
+		fscache_end_operation(&cres);
+		inode->i_size = cookie->object_size;
+	}
+
 	ctx->cookie = cookie;
 	ctx->inode = inode;
 	return ctx;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 7c6a7a2d9acf..60d14561fb46 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -181,6 +181,7 @@ struct erofs_sb_info {
 #define EROFS_MOUNT_POSIX_ACL		0x00000020
 #define EROFS_MOUNT_DAX_ALWAYS		0x00000040
 #define EROFS_MOUNT_DAX_NEVER		0x00000080
+#define EROFS_MOUNT_SHARE_CACHE		0x00000100
 
 #define clear_opt(opt, option)	((opt)->mount_opt &= ~EROFS_MOUNT_##option)
 #define set_opt(opt, option)	((opt)->mount_opt |= EROFS_MOUNT_##option)
-- 
2.19.1.6.gb485710b


  parent reply	other threads:[~2023-02-03  3:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03  3:01 [PATCH v3 0/9] erofs: support page cache sharing between EROFS images in fscache mode Jingbo Xu
2023-02-03  3:01 ` [PATCH v3 1/9] erofs: support readahead in meta routine Jingbo Xu
2023-02-03  3:01 ` [PATCH v3 2/9] erofs: remove unused device mapping in the " Jingbo Xu
2023-02-03  3:01 ` [PATCH v3 3/9] erofs: unify anonymous inodes for blob Jingbo Xu
2023-02-03  3:01 ` [PATCH v3 4/9] erofs: allocate anonymous file of blob for page cache sharing Jingbo Xu
2023-02-03  3:01 ` Jingbo Xu [this message]
2023-02-03  3:01 ` [PATCH v3 6/9] erofs: implement .read_iter " Jingbo Xu
2023-02-03  3:01 ` [PATCH v3 7/9] erofs: implement .mmap " Jingbo Xu
2023-02-03 15:12   ` kernel test robot
2023-02-03  3:01 ` [PATCH v3 8/9] erofs: add helper checking if page cache sharing shall be enabled Jingbo Xu
2023-02-03  3:01 ` [PATCH v3 9/9] erofs: introduce 'sharecache' mount option 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=20230203030143.73105-6-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-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).