From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org, Chao Yu <yuchao0@huawei.com>,
Chao Yu <chao@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 3/4] erofs: introduce on-disk lz4 fs configurations
Date: Mon, 29 Mar 2021 09:23:07 +0800 [thread overview]
Message-ID: <20210329012308.28743-4-hsiangkao@aol.com> (raw)
In-Reply-To: <20210329012308.28743-1-hsiangkao@aol.com>
From: Gao Xiang <hsiangkao@redhat.com>
Introduce z_erofs_lz4_cfgs to store all lz4 configurations.
Currently it's only max_distance, but will be used for new
features later.
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
fs/erofs/decompressor.c | 15 +++++++++++++--
fs/erofs/erofs_fs.h | 6 ++++++
fs/erofs/internal.h | 8 +++++---
fs/erofs/super.c | 2 +-
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 93411e9df9b6..97538ff24a19 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -29,9 +29,20 @@ struct z_erofs_decompressor {
};
int z_erofs_load_lz4_config(struct super_block *sb,
- struct erofs_super_block *dsb)
+ struct erofs_super_block *dsb,
+ struct z_erofs_lz4_cfgs *lz4, int size)
{
- u16 distance = le16_to_cpu(dsb->lz4_max_distance);
+ u16 distance;
+
+ if (lz4) {
+ if (size < sizeof(struct z_erofs_lz4_cfgs)) {
+ erofs_err(sb, "invalid lz4 cfgs, size=%u", size);
+ return -EINVAL;
+ }
+ distance = le16_to_cpu(lz4->max_distance);
+ } else {
+ distance = le16_to_cpu(dsb->lz4_max_distance);
+ }
EROFS_SB(sb)->lz4.max_distance_pages = distance ?
DIV_ROUND_UP(distance, PAGE_SIZE) + 1 :
diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 43467624ae3b..e0f3c0db1f82 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -197,6 +197,12 @@ enum {
Z_EROFS_COMPRESSION_MAX
};
+/* 14 bytes (+ length field = 16 bytes) */
+struct z_erofs_lz4_cfgs {
+ __le16 max_distance;
+ u8 reserved[12];
+} __packed;
+
/*
* bit 0 : COMPACTED_2B indexes (0 - off; 1 - on)
* e.g. for 4k logical cluster size, 4B if compacted 2B is off;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 1de60992c3dd..46b977f348eb 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -441,7 +441,8 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
int erofs_try_to_free_cached_page(struct address_space *mapping,
struct page *page);
int z_erofs_load_lz4_config(struct super_block *sb,
- struct erofs_super_block *dsb);
+ struct erofs_super_block *dsb,
+ struct z_erofs_lz4_cfgs *lz4, int len);
#else
static inline void erofs_shrinker_register(struct super_block *sb) {}
static inline void erofs_shrinker_unregister(struct super_block *sb) {}
@@ -450,9 +451,10 @@ static inline void erofs_exit_shrinker(void) {}
static inline int z_erofs_init_zip_subsystem(void) { return 0; }
static inline void z_erofs_exit_zip_subsystem(void) {}
static inline int z_erofs_load_lz4_config(struct super_block *sb,
- struct erofs_super_block *dsb)
+ struct erofs_super_block *dsb,
+ struct z_erofs_lz4_cfgs *lz4, int len)
{
- if (dsb->lz4_max_distance) {
+ if (lz4 || dsb->lz4_max_distance) {
erofs_err(sb, "lz4 algorithm isn't enabled");
return -EINVAL;
}
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 3212e4f73f85..1ca8da3f2125 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -189,7 +189,7 @@ static int erofs_read_superblock(struct super_block *sb)
}
/* parse on-disk compression configurations */
- ret = z_erofs_load_lz4_config(sb, dsb);
+ ret = z_erofs_load_lz4_config(sb, dsb, NULL, 0);
out:
kunmap(page);
put_page(page);
--
2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Gao Xiang <hsiangkao@aol.com>
To: linux-erofs@lists.ozlabs.org, Chao Yu <yuchao0@huawei.com>,
Chao Yu <chao@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Gao Xiang <hsiangkao@redhat.com>
Subject: [PATCH v2 3/4] erofs: introduce on-disk lz4 fs configurations
Date: Mon, 29 Mar 2021 09:23:07 +0800 [thread overview]
Message-ID: <20210329012308.28743-4-hsiangkao@aol.com> (raw)
In-Reply-To: <20210329012308.28743-1-hsiangkao@aol.com>
From: Gao Xiang <hsiangkao@redhat.com>
Introduce z_erofs_lz4_cfgs to store all lz4 configurations.
Currently it's only max_distance, but will be used for new
features later.
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
fs/erofs/decompressor.c | 15 +++++++++++++--
fs/erofs/erofs_fs.h | 6 ++++++
fs/erofs/internal.h | 8 +++++---
fs/erofs/super.c | 2 +-
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 93411e9df9b6..97538ff24a19 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -29,9 +29,20 @@ struct z_erofs_decompressor {
};
int z_erofs_load_lz4_config(struct super_block *sb,
- struct erofs_super_block *dsb)
+ struct erofs_super_block *dsb,
+ struct z_erofs_lz4_cfgs *lz4, int size)
{
- u16 distance = le16_to_cpu(dsb->lz4_max_distance);
+ u16 distance;
+
+ if (lz4) {
+ if (size < sizeof(struct z_erofs_lz4_cfgs)) {
+ erofs_err(sb, "invalid lz4 cfgs, size=%u", size);
+ return -EINVAL;
+ }
+ distance = le16_to_cpu(lz4->max_distance);
+ } else {
+ distance = le16_to_cpu(dsb->lz4_max_distance);
+ }
EROFS_SB(sb)->lz4.max_distance_pages = distance ?
DIV_ROUND_UP(distance, PAGE_SIZE) + 1 :
diff --git a/fs/erofs/erofs_fs.h b/fs/erofs/erofs_fs.h
index 43467624ae3b..e0f3c0db1f82 100644
--- a/fs/erofs/erofs_fs.h
+++ b/fs/erofs/erofs_fs.h
@@ -197,6 +197,12 @@ enum {
Z_EROFS_COMPRESSION_MAX
};
+/* 14 bytes (+ length field = 16 bytes) */
+struct z_erofs_lz4_cfgs {
+ __le16 max_distance;
+ u8 reserved[12];
+} __packed;
+
/*
* bit 0 : COMPACTED_2B indexes (0 - off; 1 - on)
* e.g. for 4k logical cluster size, 4B if compacted 2B is off;
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 1de60992c3dd..46b977f348eb 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -441,7 +441,8 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi,
int erofs_try_to_free_cached_page(struct address_space *mapping,
struct page *page);
int z_erofs_load_lz4_config(struct super_block *sb,
- struct erofs_super_block *dsb);
+ struct erofs_super_block *dsb,
+ struct z_erofs_lz4_cfgs *lz4, int len);
#else
static inline void erofs_shrinker_register(struct super_block *sb) {}
static inline void erofs_shrinker_unregister(struct super_block *sb) {}
@@ -450,9 +451,10 @@ static inline void erofs_exit_shrinker(void) {}
static inline int z_erofs_init_zip_subsystem(void) { return 0; }
static inline void z_erofs_exit_zip_subsystem(void) {}
static inline int z_erofs_load_lz4_config(struct super_block *sb,
- struct erofs_super_block *dsb)
+ struct erofs_super_block *dsb,
+ struct z_erofs_lz4_cfgs *lz4, int len)
{
- if (dsb->lz4_max_distance) {
+ if (lz4 || dsb->lz4_max_distance) {
erofs_err(sb, "lz4 algorithm isn't enabled");
return -EINVAL;
}
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 3212e4f73f85..1ca8da3f2125 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -189,7 +189,7 @@ static int erofs_read_superblock(struct super_block *sb)
}
/* parse on-disk compression configurations */
- ret = z_erofs_load_lz4_config(sb, dsb);
+ ret = z_erofs_load_lz4_config(sb, dsb, NULL, 0);
out:
kunmap(page);
put_page(page);
--
2.20.1
next prev parent reply other threads:[~2021-03-29 1:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210329012308.28743-1-hsiangkao.ref@aol.com>
2021-03-29 1:23 ` [PATCH v2 0/4] erofs: introduce on-disk compression configurations Gao Xiang via Linux-erofs
2021-03-29 1:23 ` Gao Xiang
2021-03-29 1:23 ` [PATCH v2 1/4] erofs: introduce erofs_sb_has_xxx() helpers Gao Xiang via Linux-erofs
2021-03-29 1:23 ` Gao Xiang
2021-03-29 1:23 ` [PATCH v2 2/4] erofs: support adjust lz4 history window size Gao Xiang via Linux-erofs
2021-03-29 1:23 ` Gao Xiang
2021-03-29 1:23 ` Gao Xiang via Linux-erofs [this message]
2021-03-29 1:23 ` [PATCH v2 3/4] erofs: introduce on-disk lz4 fs configurations Gao Xiang
2021-03-29 1:23 ` [PATCH v2 4/4] erofs: add on-disk compression configurations Gao Xiang via Linux-erofs
2021-03-29 1:23 ` Gao Xiang
2021-03-29 6:26 ` Chao Yu
2021-03-29 6:26 ` Chao Yu
2021-03-29 6:36 ` Gao Xiang
2021-03-29 6:36 ` Gao Xiang
2021-03-29 6:43 ` Chao Yu
2021-03-29 6:43 ` Chao Yu
2021-03-29 6:55 ` Gao Xiang
2021-03-29 6:55 ` Gao Xiang
2021-03-29 7:52 ` Chao Yu
2021-03-29 7:52 ` Chao Yu
2021-03-29 10:00 ` [PATCH v3 " Gao Xiang via Linux-erofs
2021-03-29 10:00 ` 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=20210329012308.28743-4-hsiangkao@aol.com \
--to=linux-erofs@lists.ozlabs.org \
--cc=chao@kernel.org \
--cc=hsiangkao@aol.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.