From: Jeffle Xu <jefflexu@linux.alibaba.com>
To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org,
chao@kernel.org, linux-erofs@lists.ozlabs.org
Cc: linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com,
bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com,
gerry@linux.alibaba.com, eguan@linux.alibaba.com,
linux-kernel@vger.kernel.org
Subject: [RFC 14/19] erofs: introduce fscache support
Date: Fri, 10 Dec 2021 15:36:14 +0800 [thread overview]
Message-ID: <20211210073619.21667-15-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20211210073619.21667-1-jefflexu@linux.alibaba.com>
This patch only handles the volume cookie and data file cookie for
bootstrap. The corresponding IO path is remained to be implemented in
the following patch.
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
fs/erofs/Makefile | 2 +-
fs/erofs/fscache.c | 37 +++++++++++++++++++++++++++++++++++++
fs/erofs/internal.h | 8 ++++++++
fs/erofs/super.c | 5 +++++
4 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 fs/erofs/fscache.c
diff --git a/fs/erofs/Makefile b/fs/erofs/Makefile
index 756fe2d65272..f9a3609625aa 100644
--- a/fs/erofs/Makefile
+++ b/fs/erofs/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_EROFS_FS) += erofs.o
-erofs-objs := super.o inode.o data.o namei.o dir.o utils.o pcpubuf.o
+erofs-objs := super.o inode.o data.o namei.o dir.o utils.o pcpubuf.o fscache.o
erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o
erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o
erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.o
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
new file mode 100644
index 000000000000..cf550fdedd1e
--- /dev/null
+++ b/fs/erofs/fscache.c
@@ -0,0 +1,37 @@
+#include "internal.h"
+
+int erofs_fscache_init(struct erofs_sb_info *sbi, char *bootstrap_path)
+{
+ sbi->volume = fscache_acquire_volume("erofs", NULL, 0);
+ if (!sbi->volume) {
+ printk("fscache_acquire_volume() failed\n");
+ return -EINVAL;
+ }
+
+ /*
+ * TODO: @object_size is 0 since erofs can not get size of bootstrap
+ * file.
+ */
+ sbi->bootstrap = fscache_acquire_cookie(sbi->volume, 0,
+ bootstrap_path, strlen(bootstrap_path),
+ NULL, 0,
+ 1 /*TODO: we don't want FSCACHE_COOKIE_NO_DATA_TO_READ set */
+ );
+
+ if (!sbi->bootstrap) {
+ printk("fscache_acquire_cookie() for bootstrap failed\n");
+ /* cleanup for sbi->volume is delayed to erofs_fscache_cleanup() */
+ return -EINVAL;
+ }
+
+ fscache_use_cookie(sbi->bootstrap, false);
+
+ return 0;
+}
+
+void erofs_fscache_cleanup(struct erofs_sb_info *sbi)
+{
+ fscache_unuse_cookie(sbi->bootstrap, NULL, NULL);
+ fscache_relinquish_cookie(sbi->bootstrap, false);
+ fscache_relinquish_volume(sbi->volume, 0, false);
+}
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index cf69d9c9cbed..8136ec63a9de 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -17,6 +17,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/iomap.h>
+#include <linux/fscache.h>
#include "erofs_fs.h"
/* redefine pr_fmt "erofs: " */
@@ -106,6 +107,9 @@ struct erofs_sb_info {
/* pseudo inode to manage cached pages */
struct inode *managed_cache;
+ struct fscache_volume *volume;
+ struct fscache_cookie *bootstrap;
+
struct erofs_sb_lz4_info lz4;
#endif /* CONFIG_EROFS_FS_ZIP */
struct erofs_dev_context *devs;
@@ -569,6 +573,10 @@ static inline int z_erofs_load_lzma_config(struct super_block *sb,
}
#endif /* !CONFIG_EROFS_FS_ZIP */
+/* fscache.c */
+int erofs_fscache_init(struct erofs_sb_info *sbi, char *bootstrap_path);
+void erofs_fscache_cleanup(struct erofs_sb_info *sbi);
+
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
#endif /* __EROFS_INTERNAL_H */
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 51695f6d4449..f2a5f4cd53fd 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -665,6 +665,10 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
else
sbi->dax_dev = NULL;
+ err = erofs_fscache_init(sbi, ctx->opt.bootstrap_path);
+ if (err)
+ return err;
+
err = erofs_read_superblock(sb);
if (err)
return err;
@@ -823,6 +827,7 @@ static void erofs_kill_sb(struct super_block *sb)
erofs_free_dev_context(sbi->devs);
fs_put_dax(sbi->dax_dev);
+ erofs_fscache_cleanup(sbi);
kfree(sbi);
sb->s_fs_info = NULL;
}
--
2.27.0
next prev parent reply other threads:[~2021-12-10 7:36 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 7:36 [RFC 00/19] fscache,erofs: fscache-based demand-read semantics Jeffle Xu
2021-12-10 7:36 ` [RFC 01/19] cachefiles: add mode command Jeffle Xu
2021-12-10 7:36 ` [RFC 02/19] cachefiles: implement key scheme for demand-read mode Jeffle Xu
2021-12-10 7:36 ` [RFC 03/19] cachefiles: refactor cachefiles_adjust_size() Jeffle Xu
2021-12-10 7:36 ` [RFC 04/19] netfs: make ops->init_rreq() optional Jeffle Xu
2021-12-10 7:36 ` [RFC 05/19] netfs: refactor netfs_alloc_read_request Jeffle Xu
2021-12-10 7:36 ` [RFC 06/19] netfs: add type field to struct netfs_read_request Jeffle Xu
2021-12-10 7:36 ` [RFC 07/19] netfs: add netfs_readpage_demand() Jeffle Xu
2021-12-10 7:36 ` [RFC 08/19] netfs: refactor netfs_clear_unread() Jeffle Xu
2021-12-10 7:36 ` [RFC 09/19] netfs: refactor netfs_rreq_unlock() Jeffle Xu
2021-12-10 7:36 ` [RFC 10/19] netfs: refactor netfs_rreq_prepare_read Jeffle Xu
2021-12-10 7:36 ` [RFC 11/19] cachefiles: refactor cachefiles_prepare_read Jeffle Xu
2021-12-10 7:36 ` [RFC 12/19] erofs: export erofs_map_blocks Jeffle Xu
2021-12-10 7:36 ` [RFC 13/19] erofs: add bootstrap_path mount option Jeffle Xu
2021-12-10 7:36 ` Jeffle Xu [this message]
2021-12-10 7:36 ` [RFC 15/19] erofs: implement fscache-based metadata read Jeffle Xu
2021-12-10 7:36 ` [RFC 16/19] erofs: implement fscache-based data read Jeffle Xu
2021-12-10 7:36 ` [RFC 17/19] netfs: support on demand read Jeffle Xu
2021-12-10 7:36 ` [RFC 18/19] cachefiles: " Jeffle Xu
2021-12-10 7:36 ` [RFC 19/19] erofs: " Jeffle Xu
2021-12-10 11:04 ` [RFC 02/19] cachefiles: implement key scheme for demand-read mode David Howells
2021-12-11 5:32 ` JeffleXu
2021-12-10 11:05 ` [RFC 01/19] cachefiles: add mode command David Howells
2021-12-11 5:23 ` JeffleXu
2021-12-10 15:41 ` [RFC 09/19] netfs: refactor netfs_rreq_unlock() David Howells
2021-12-11 5:23 ` JeffleXu
2021-12-11 5:44 ` [Linux-cachefs] " JeffleXu
2021-12-11 6:57 ` Gao Xiang
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=20211210073619.21667-15-jefflexu@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=bo.liu@linux.alibaba.com \
--cc=chao@kernel.org \
--cc=dhowells@redhat.com \
--cc=eguan@linux.alibaba.com \
--cc=gerry@linux.alibaba.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tao.peng@linux.alibaba.com \
--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).