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 v2 1/7] erofs: remove unused device mapping in the meta routine
Date: Wed, 11 Jan 2023 16:31:52 +0800	[thread overview]
Message-ID: <20230111083158.23462-2-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20230111083158.23462-1-jefflexu@linux.alibaba.com>

Currently there're two anonymous inodes (inode and anon_inode in struct
erofs_fscache) may be used for each blob.  The former is only for
bootstrap and used as the address_space of page cache, while the latter
is used for both bootstrap and data blobs when share domain mode enabled
and behaves as a sentinel in the shared domain.

In prep for the following support for page cache sharing, following
patch will unify these two anonymous inodes.  That is, the unified
anonymous inode not only acts as the address_space of page cache, but
also a sentinel in share domain mode.

However the current meta routine can't work if above change applied.
Current meta routine will make a device mapping, and superblock of the
filesystem is required to do the device mapping.  Currently the
superblock is derived from the input meta folio, which is reasonable
since the anonymous inode (used for the address_space of page cache) is
always allocated from the filesystem's sb.  However after anonymous
inodes are unified, that is no longer always true.  For example, in
share domain mode, the unified anonymous inode will be allocated from
pseudo mnt, and the superblock derived from the folio is actually a
pseudo sb, which can't be used for the device mapping at all.

As for the meta routine itself, currently metadata is always on
bootstrap, which means device mapping is not needed so far.  After
removing the redundant device mapping logic, we can derive the required
fscache_ctx from anonymous inode's i_private.

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

diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index 014e20962376..03de4dc99302 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -164,18 +164,8 @@ static int erofs_fscache_read_folios_async(struct fscache_cookie *cookie,
 static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
 {
 	int ret;
-	struct super_block *sb = folio_mapping(folio)->host->i_sb;
+	struct erofs_fscache *ctx = folio_mapping(folio)->host->i_private;
 	struct erofs_fscache_request *req;
-	struct erofs_map_dev mdev = {
-		.m_deviceid = 0,
-		.m_pa = folio_pos(folio),
-	};
-
-	ret = erofs_map_dev(sb, &mdev);
-	if (ret) {
-		folio_unlock(folio);
-		return ret;
-	}
 
 	req = erofs_fscache_req_alloc(folio_mapping(folio),
 				folio_pos(folio), folio_size(folio));
@@ -184,8 +174,8 @@ static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
 		return PTR_ERR(req);
 	}
 
-	ret = erofs_fscache_read_folios_async(mdev.m_fscache->cookie,
-				req, mdev.m_pa, folio_size(folio));
+	ret = erofs_fscache_read_folios_async(ctx->cookie, req,
+				folio_pos(folio), folio_size(folio));
 	if (ret)
 		req->error = ret;
 
@@ -469,6 +459,7 @@ struct erofs_fscache *erofs_fscache_acquire_cookie(struct super_block *sb,
 		inode->i_size = OFFSET_MAX;
 		inode->i_mapping->a_ops = &erofs_fscache_meta_aops;
 		mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
+		inode->i_private = ctx;
 
 		ctx->inode = inode;
 	}
-- 
2.19.1.6.gb485710b


  reply	other threads:[~2023-01-11  8:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  8:31 [PATCH v2 0/7] erofs: support page cache sharing between EROFS images in fscache mode Jingbo Xu
2023-01-11  8:31 ` Jingbo Xu [this message]
2023-01-11  8:31 ` [PATCH v2 2/7] erofs: unify anonymous inodes for blob Jingbo Xu
2023-01-11  8:31 ` [PATCH v2 3/7] erofs: allocate anonymous file of blob for page cache sharing Jingbo Xu
2023-01-11  8:31 ` [PATCH v2 4/7] erofs: implement .read_iter " Jingbo Xu
2023-01-11  8:31 ` [PATCH v2 5/7] erofs: implement .mmap " Jingbo Xu
2023-01-11  8:31 ` [PATCH v2 6/7] erofs: add helper checking if page cache sharing shall be enabled Jingbo Xu
2023-01-11  8:31 ` [PATCH v2 7/7] 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=20230111083158.23462-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-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).