mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] erofs: add sysfs node to control cached decompression strategy
@ 2024-11-01 12:42 Chunhai Guo
  2024-11-11  2:28 ` Gao Xiang
  0 siblings, 1 reply; 4+ messages in thread
From: Chunhai Guo @ 2024-11-01 12:42 UTC (permalink / raw)
  To: xiang
  Cc: chao, huyue2, jefflexu, dhavale, linux-erofs, linux-kernel, Chunhai Guo

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@vivo.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@vivo.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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-12  1:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-01 12:42 [PATCH] erofs: add sysfs node to control cached decompression strategy Chunhai Guo
2024-11-11  2:28 ` Gao Xiang
2024-11-11 11:10   ` Chunhai Guo
2024-11-12  1:06     ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®