* [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
* Re: [PATCH] erofs: add sysfs node to control cached decompression strategy
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
0 siblings, 1 reply; 4+ messages in thread
From: Gao Xiang @ 2024-11-11 2:28 UTC (permalink / raw)
To: Chunhai Guo, xiang
Cc: chao, huyue2, jefflexu, dhavale, linux-erofs, linux-kernel
Hi Chunhai,
On 2024/11/1 20:42, Chunhai Guo wrote:
> 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>
I guess remount could also change the decompression strategy?
Or there are some other concern that remount is not usable
for your use cases?
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: add sysfs node to control cached decompression strategy
2024-11-11 2:28 ` Gao Xiang
@ 2024-11-11 11:10 ` Chunhai Guo
2024-11-12 1:06 ` Gao Xiang
0 siblings, 1 reply; 4+ messages in thread
From: Chunhai Guo @ 2024-11-11 11:10 UTC (permalink / raw)
To: Gao Xiang, Chunhai Guo, xiang
Cc: chao, huyue2, jefflexu, dhavale, linux-erofs, linux-kernel
在 2024/11/11 10:28, Gao Xiang 写道:
> Hi Chunhai,
>
> On 2024/11/1 20:42, Chunhai Guo wrote:
>> 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>
> I guess remount could also change the decompression strategy?
> Or there are some other concern that remount is not usable
> for your use cases?
Yes, remount can change the strategy. However, the cache will not be
cleaned when the strategy is changed to EROFS_ZIP_CACHE_DISABLED. I will
make another patch to address this during remount. Thank you for your
suggestion.
>
> Thanks,
> Gao Xiang
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: add sysfs node to control cached decompression strategy
2024-11-11 11:10 ` Chunhai Guo
@ 2024-11-12 1:06 ` Gao Xiang
0 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2024-11-12 1:06 UTC (permalink / raw)
To: Chunhai Guo, xiang
Cc: chao, huyue2, jefflexu, dhavale, linux-erofs, linux-kernel
On 2024/11/11 19:10, Chunhai Guo wrote:
> 在 2024/11/11 10:28, Gao Xiang 写道:
>> Hi Chunhai,
>>
>> On 2024/11/1 20:42, Chunhai Guo wrote:
>>> 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>
>> I guess remount could also change the decompression strategy?
>> Or there are some other concern that remount is not usable
>> for your use cases?
> Yes, remount can change the strategy. However, the cache will not be
> cleaned when the strategy is changed to EROFS_ZIP_CACHE_DISABLED. I will
> make another patch to address this during remount. Thank you for your
> suggestion.
Sounds good to me.
Thanks,
Gao Xiang
^ 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®