[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241101124241.3090642-1-guochunhai@vivo.com>
Date: Fri, 1 Nov 2024 06:42:41 -0600
From: Chunhai Guo <guochunhai@...o.com>
To: xiang@...nel.org
Cc: chao@...nel.org,
huyue2@...lpad.com,
jefflexu@...ux.alibaba.com,
dhavale@...gle.com,
linux-erofs@...ts.ozlabs.org,
linux-kernel@...r.kernel.org,
Chunhai Guo <guochunhai@...o.com>
Subject: [PATCH] erofs: add sysfs node to control cached decompression strategy
Add sysfs node to control cached decompression strategy, and all the
cache will be cleaned up when the strategy is set to
EROFS_ZIP_CACHE_DISABLED.
Signed-off-by: Chunhai Guo <guochunhai@...o.com>
---
Documentation/ABI/testing/sysfs-fs-erofs | 14 ++++++++++++++
fs/erofs/sysfs.c | 8 ++++++++
2 files changed, 22 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-fs-erofs b/Documentation/ABI/testing/sysfs-fs-erofs
index 284224d1b56f..194087bcbaea 100644
--- a/Documentation/ABI/testing/sysfs-fs-erofs
+++ b/Documentation/ABI/testing/sysfs-fs-erofs
@@ -16,3 +16,17 @@ Description: Control strategy of sync decompression:
readahead on atomic contexts only.
- 1 (force on): enable for readpage and readahead.
- 2 (force off): disable for all situations.
+
+What: /sys/fs/erofs/<disk>/cache_strategy
+Date: November 2024
+Contact: "Guo Chunhai" <guochunhai@...o.com>
+Description: Control strategy of cached decompression strategy
+
+ - 0 (disabled): In-place I/O decompression only.
+ - 1 (readahead): Cache the last incomplete compressed physical
+ cluster for further reading. It still does in-place I/O
+ decompression for the rest compressed physical clusters.
+ - 2 (default, readaround): Cache the both ends of incomplete
+ compressed physical clusters for further reading. It
+ still does in-place I/O decompression for the rest
+ compressed physical clusters.
diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
index 63cffd0fd261..2ee59eef3aa7 100644
--- a/fs/erofs/sysfs.c
+++ b/fs/erofs/sysfs.c
@@ -57,11 +57,13 @@ static struct erofs_attr erofs_attr_##_name = { \
#ifdef CONFIG_EROFS_FS_ZIP
EROFS_ATTR_RW_UI(sync_decompress, erofs_mount_opts);
+EROFS_ATTR_RW_UI(cache_strategy, erofs_mount_opts);
#endif
static struct attribute *erofs_attrs[] = {
#ifdef CONFIG_EROFS_FS_ZIP
ATTR_LIST(sync_decompress),
+ ATTR_LIST(cache_strategy),
#endif
NULL,
};
@@ -150,6 +152,12 @@ static ssize_t erofs_attr_store(struct kobject *kobj, struct attribute *attr,
if (!strcmp(a->attr.name, "sync_decompress") &&
(t > EROFS_SYNC_DECOMPRESS_FORCE_OFF))
return -EINVAL;
+ else if (!strcmp(a->attr.name, "cache_strategy")) {
+ if (t > EROFS_ZIP_CACHE_READAROUND)
+ return -EINVAL;
+ else if (t == EROFS_ZIP_CACHE_DISABLED)
+ z_erofs_shrink_scan(sbi, ~0UL);
+ }
#endif
*(unsigned int *)ptr = t;
return len;
--
2.25.1
Powered by blists - more mailing lists