netfs.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] support query ondemand feature for erofs and cachefiles
@ 2024-06-21  6:18 Hongbo Li
  2024-06-21  6:18 ` [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface Hongbo Li
  2024-06-21  6:18 ` [PATCH 2/2] cachefiles: support query cachefiles ondemand feature Hongbo Li
  0 siblings, 2 replies; 12+ messages in thread
From: Hongbo Li @ 2024-06-21  6:18 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs, lihongbo22

Hi all!

These two patches is used to support query ondemand feature
for erofs and cachefiles modules. Since erofs over fscache
introduces CONFIG_EROFS_FS_ONDEMAND and CONFIG_CACHEFILES_ONDEMAND,
we cannot know whether the kernel supports this feature or not
in userspace. So we introduce the sysfs interface for users'
applications to obtain this.

Comments and questions are, as always, welcome.
Please let me know what you think.

Thanks,
Hongbo

Hongbo Li (2):
  erofs: support query erofs ondemand feature by sysfs interface
  cachefiles: support query cachefiles ondemand feature

 fs/cachefiles/Makefile   |   3 +-
 fs/cachefiles/internal.h |   7 +++
 fs/cachefiles/main.c     |   7 +++
 fs/cachefiles/sysfs.c    | 101 +++++++++++++++++++++++++++++++++++++++
 fs/erofs/sysfs.c         |   6 +++
 5 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 fs/cachefiles/sysfs.c

-- 
2.34.1


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

* [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface
  2024-06-21  6:18 [PATCH 0/2] support query ondemand feature for erofs and cachefiles Hongbo Li
@ 2024-06-21  6:18 ` Hongbo Li
  2024-06-21  9:16   ` Gao Xiang
  2024-06-21  6:18 ` [PATCH 2/2] cachefiles: support query cachefiles ondemand feature Hongbo Li
  1 sibling, 1 reply; 12+ messages in thread
From: Hongbo Li @ 2024-06-21  6:18 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs, lihongbo22

Erofs over fscache depands on the config CONFIG_EROFS_FS_ONDEMAND
in erofs. There is no way to check whether this feature is supported
or not in userspace. We introduce sysfs file `erofs_ondemand` for
user checking current features. Here is the example:

[Before]
$ cat /sys/fs/erofs/features/erofs_ondemand
cat: /sys/fs/erofs/features/erofs_ondemand: No such file or directory

[After]
$ cat /sys/fs/erofs/features/erofs_ondemand
supported

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 fs/erofs/sysfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
index 435e515c0792..1b3d77583f76 100644
--- a/fs/erofs/sysfs.c
+++ b/fs/erofs/sysfs.c
@@ -78,6 +78,9 @@ EROFS_ATTR_FEATURE(sb_chksum);
 EROFS_ATTR_FEATURE(ztailpacking);
 EROFS_ATTR_FEATURE(fragments);
 EROFS_ATTR_FEATURE(dedupe);
+#if IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND)
+EROFS_ATTR_FEATURE(erofs_ondemand);
+#endif
 
 static struct attribute *erofs_feat_attrs[] = {
 	ATTR_LIST(zero_padding),
@@ -90,6 +93,9 @@ static struct attribute *erofs_feat_attrs[] = {
 	ATTR_LIST(ztailpacking),
 	ATTR_LIST(fragments),
 	ATTR_LIST(dedupe),
+#if IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND)
+	ATTR_LIST(erofs_ondemand),
+#endif
 	NULL,
 };
 ATTRIBUTE_GROUPS(erofs_feat);
-- 
2.34.1


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

* [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-21  6:18 [PATCH 0/2] support query ondemand feature for erofs and cachefiles Hongbo Li
  2024-06-21  6:18 ` [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface Hongbo Li
@ 2024-06-21  6:18 ` Hongbo Li
  2024-06-21  9:14   ` Gao Xiang
  1 sibling, 1 reply; 12+ messages in thread
From: Hongbo Li @ 2024-06-21  6:18 UTC (permalink / raw)
  To: xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs, lihongbo22

Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
module. We cannot know whether it is supported from userspace, so
we export this feature to user by sysfs interface.

[Before]
$ cat /sys/fs/cachefiles/features/cachefiles_ondemand
cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file or directory

[After]
$ cat /sys/fs/cachefiles/features/cachefiles_ondemand
supported

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 fs/cachefiles/Makefile   |   3 +-
 fs/cachefiles/internal.h |   7 +++
 fs/cachefiles/main.c     |   7 +++
 fs/cachefiles/sysfs.c    | 101 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 fs/cachefiles/sysfs.c

diff --git a/fs/cachefiles/Makefile b/fs/cachefiles/Makefile
index c37a7a9af10b..e5d9dd27f94f 100644
--- a/fs/cachefiles/Makefile
+++ b/fs/cachefiles/Makefile
@@ -13,7 +13,8 @@ cachefiles-y := \
 	namei.o \
 	security.o \
 	volume.o \
-	xattr.o
+	xattr.o \
+	sysfs.o
 
 cachefiles-$(CONFIG_CACHEFILES_ERROR_INJECTION) += error_inject.o
 cachefiles-$(CONFIG_CACHEFILES_ONDEMAND) += ondemand.o
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 6845a90cdfcc..4926684b3044 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -419,6 +419,13 @@ extern void cachefiles_prepare_to_write(struct fscache_cookie *cookie);
 extern bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume);
 extern int cachefiles_check_volume_xattr(struct cachefiles_volume *volume);
 
+/*
+ * sysfs.c
+ */
+
+int __init cachefiles_init_sysfs(void);
+void cachefiles_exit_sysfs(void);
+
 /*
  * Error handling
  */
diff --git a/fs/cachefiles/main.c b/fs/cachefiles/main.c
index 3f369c6f816d..0dcad6bb4b1f 100644
--- a/fs/cachefiles/main.c
+++ b/fs/cachefiles/main.c
@@ -64,9 +64,15 @@ static int __init cachefiles_init(void)
 		goto error_object_jar;
 	}
 
+	ret = cachefiles_init_sysfs();
+	if (ret)
+		goto sysfs_err;
+
 	pr_info("Loaded\n");
 	return 0;
 
+sysfs_err:
+	kmem_cache_destroy(cachefiles_object_jar);
 error_object_jar:
 	misc_deregister(&cachefiles_dev);
 error_dev:
@@ -85,6 +91,7 @@ static void __exit cachefiles_exit(void)
 {
 	pr_info("Unloading\n");
 
+	cachefiles_exit_sysfs();
 	kmem_cache_destroy(cachefiles_object_jar);
 	misc_deregister(&cachefiles_dev);
 	cachefiles_unregister_error_injection();
diff --git a/fs/cachefiles/sysfs.c b/fs/cachefiles/sysfs.c
new file mode 100644
index 000000000000..adfb260df59c
--- /dev/null
+++ b/fs/cachefiles/sysfs.c
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <linux/sysfs.h>
+#include <linux/kobject.h>
+
+#include "internal.h"
+
+enum {
+	attr_feature,
+};
+
+struct cachefiles_attr {
+	struct attribute attr;
+	short attr_id;
+};
+
+#define CACHEFILES_ATTR(_name, _mode, _id)				\
+static struct cachefiles_attr cachefiles_attr_##_name = {		\
+	.attr = {.name = __stringify(_name), .mode = _mode },		\
+	.attr_id = attr_##_id,						\
+}
+
+#define CACHEFILES_ATTR_FEATURE(_name) CACHEFILES_ATTR(_name, 0444, feature)
+
+#define ATTR_LIST(name) (&cachefiles_attr_##name.attr)
+
+/* supported features of cachefiles */
+#if IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)
+CACHEFILES_ATTR_FEATURE(cachefiles_ondemand);
+#endif
+
+static struct attribute *cachefiles_feat_attrs[] = {
+#if IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)
+	ATTR_LIST(cachefiles_ondemand),
+	NULL,
+#endif
+};
+
+ATTRIBUTE_GROUPS(cachefiles_feat);
+
+static ssize_t cachefiles_attr_show(struct kobject *kobj,
+				struct attribute *attr, char *buf)
+{
+	struct cachefiles_attr *a = container_of(attr, struct cachefiles_attr, attr);
+
+	switch (a->attr_id) {
+	case attr_feature:
+		return sysfs_emit(buf, "supported\n");
+	}
+
+	return 0;
+};
+
+static const struct sysfs_ops cachefiles_attr_ops = {
+	.show = cachefiles_attr_show,
+};
+
+static const struct kobj_type cachefiles_ktype = {
+	.sysfs_ops	= &cachefiles_attr_ops,
+};
+
+static struct kset cachefiles_root = {
+	.kobj	= {.ktype = &cachefiles_ktype},
+};
+
+static const struct kobj_type cachefiles_feat_ktype = {
+	.default_groups = cachefiles_feat_groups,
+	.sysfs_ops	= &cachefiles_attr_ops,
+};
+
+static struct kobject cachefiles_feat = {
+	.kset	= &cachefiles_root,
+};
+
+int __init cachefiles_init_sysfs(void)
+{
+	int ret;
+
+	kobject_set_name(&cachefiles_root.kobj, "cachefiles");
+	cachefiles_root.kobj.parent = fs_kobj;
+	ret = kset_register(&cachefiles_root);
+	if (ret)
+		goto root_err;
+
+	ret = kobject_init_and_add(&cachefiles_feat, &cachefiles_feat_ktype,
+				   NULL, "features");
+	if (ret)
+		goto feat_err;
+	return ret;
+
+feat_err:
+	kobject_put(&cachefiles_feat);
+	kset_unregister(&cachefiles_root);
+root_err:
+	return ret;
+}
+
+void cachefiles_exit_sysfs(void)
+{
+	kobject_put(&cachefiles_feat);
+	kset_unregister(&cachefiles_root);
+}
-- 
2.34.1


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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-21  6:18 ` [PATCH 2/2] cachefiles: support query cachefiles ondemand feature Hongbo Li
@ 2024-06-21  9:14   ` Gao Xiang
  2024-06-21  9:37     ` Hongbo Li
  0 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2024-06-21  9:14 UTC (permalink / raw)
  To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/21 14:18, Hongbo Li wrote:
> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
> module. We cannot know whether it is supported from userspace, so
> we export this feature to user by sysfs interface.
> 
> [Before]
> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file or directory
> 
> [After]
> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
> supported
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

I don't think such sysfs is needed, you could just use
`bind ondemand` to check if it is supported:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780


Thanks,
Gao Xiang

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

* Re: [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface
  2024-06-21  6:18 ` [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface Hongbo Li
@ 2024-06-21  9:16   ` Gao Xiang
  2024-06-21  9:28     ` Gao Xiang
  0 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2024-06-21  9:16 UTC (permalink / raw)
  To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/21 14:18, Hongbo Li wrote:
> Erofs over fscache depands on the config CONFIG_EROFS_FS_ONDEMAND
> in erofs. There is no way to check whether this feature is supported
> or not in userspace. We introduce sysfs file `erofs_ondemand` for
> user checking current features. Here is the example:
> 
> [Before]
> $ cat /sys/fs/erofs/features/erofs_ondemand
> cat: /sys/fs/erofs/features/erofs_ondemand: No such file or directory
> 
> [After]
> $ cat /sys/fs/erofs/features/erofs_ondemand
> supported
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

Similar here, I guess you could pass in any `fsid` mount
option and check the return value instead.

Thanks,
Gao Xiang

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

* Re: [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface
  2024-06-21  9:16   ` Gao Xiang
@ 2024-06-21  9:28     ` Gao Xiang
  0 siblings, 0 replies; 12+ messages in thread
From: Gao Xiang @ 2024-06-21  9:28 UTC (permalink / raw)
  To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/21 17:16, Gao Xiang wrote:
> 
> 
> On 2024/6/21 14:18, Hongbo Li wrote:
>> Erofs over fscache depands on the config CONFIG_EROFS_FS_ONDEMAND
>> in erofs. There is no way to check whether this feature is supported
>> or not in userspace. We introduce sysfs file `erofs_ondemand` for
>> user checking current features. Here is the example:
>>
>> [Before]
>> $ cat /sys/fs/erofs/features/erofs_ondemand
>> cat: /sys/fs/erofs/features/erofs_ondemand: No such file or directory
>>
>> [After]
>> $ cat /sys/fs/erofs/features/erofs_ondemand
>> supported
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> 
> Similar here, I guess you could pass in any `fsid` mount
> option and check the return value instead.

Add some words, currently I don't tend to add any sysfs for
new feautures since you could always use golden test images
or test programs to test if any on-disk/runtime feature is
really supported.

Maintaining sysfs files for these causes unnecessary burden
(and could cause unexpected inconsistency). Maybe in the
future I will deprecate all these sysfs files.

Thanks,
Gao Xiang

> 
> Thanks,
> Gao Xiang

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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-21  9:14   ` Gao Xiang
@ 2024-06-21  9:37     ` Hongbo Li
  2024-06-21 10:06       ` Gao Xiang
  0 siblings, 1 reply; 12+ messages in thread
From: Hongbo Li @ 2024-06-21  9:37 UTC (permalink / raw)
  To: Gao Xiang, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/21 17:14, Gao Xiang wrote:
> 
> 
> On 2024/6/21 14:18, Hongbo Li wrote:
>> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
>> module. We cannot know whether it is supported from userspace, so
>> we export this feature to user by sysfs interface.
>>
>> [Before]
>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file or 
>> directory
>>
>> [After]
>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>> supported
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> 
> I don't think such sysfs is needed, you could just use
> `bind ondemand` to check if it is supported:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780
> 
Thanks for reply!
`bind ondemand` can check if it is supported, but it requires a more 
complicated procedure for user to implement. For example, a serial of 
system call (open, ioctl, close) are need.The containerd snapshotter 
daemon relies on these feature, only use a simple check method is usable 
in product environment. The snapshotter developers may know how 
cachefiles works, but for snapshotter users, a simple way to check 
whether snapshotter can be launched is useful. Even though they do not 
know how cachefiles works.

Thanks,
Hongbo
> 
> Thanks,
> Gao Xiang

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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-21  9:37     ` Hongbo Li
@ 2024-06-21 10:06       ` Gao Xiang
  2024-06-21 10:42         ` Gao Xiang
  0 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2024-06-21 10:06 UTC (permalink / raw)
  To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/21 17:37, Hongbo Li wrote:
> 
> 
> On 2024/6/21 17:14, Gao Xiang wrote:
>>
>>
>> On 2024/6/21 14:18, Hongbo Li wrote:
>>> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
>>> module. We cannot know whether it is supported from userspace, so
>>> we export this feature to user by sysfs interface.
>>>
>>> [Before]
>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file or directory
>>>
>>> [After]
>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>> supported
>>>
>>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>>
>> I don't think such sysfs is needed, you could just use
>> `bind ondemand` to check if it is supported:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780
>>
> Thanks for reply!
> `bind ondemand` can check if it is supported, but it requires a more complicated procedure for user to implement. For example, a serial of system call (open, ioctl, close) are need.The containerd snapshotter daemon relies on these feature, only use a simple check method is usable in product environment. The snapshotter developers may know how cachefiles works, but for snapshotter users, a simple way to check whether snapshotter can be launched is useful. Even though they do not know how cachefiles works.

I don't think it needs to be considered as long as userspace
has a way to check since you could wrap up these as a helper
(I will do in the official erofs-utils later or if you have
some interest you could help too) and even some erofs-utils
binary for this.

sysfs maintainence just for some random feature doesn't
sound good to me (similar to ext4/xfs on-disk features) and
even if works, you cannot use this way for 5.19~6.10
upstream kernels.

Thanks,
Gao Xiang

> 
> Thanks,
> Hongbo
>>
>> Thanks,
>> Gao Xiang

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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-21 10:06       ` Gao Xiang
@ 2024-06-21 10:42         ` Gao Xiang
  2024-06-24 11:58           ` Hongbo Li
  0 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2024-06-21 10:42 UTC (permalink / raw)
  To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs

Hi,

On 2024/6/21 18:06, Gao Xiang wrote:
> 
> 
> On 2024/6/21 17:37, Hongbo Li wrote:
>>
>>
>> On 2024/6/21 17:14, Gao Xiang wrote:
>>>
>>>
>>> On 2024/6/21 14:18, Hongbo Li wrote:
>>>> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
>>>> module. We cannot know whether it is supported from userspace, so
>>>> we export this feature to user by sysfs interface.
>>>>
>>>> [Before]
>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file or directory
>>>>
>>>> [After]
>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>> supported
>>>>
>>>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>>>
>>> I don't think such sysfs is needed, you could just use
>>> `bind ondemand` to check if it is supported:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780
>>>
>> Thanks for reply!
>> `bind ondemand` can check if it is supported, but it requires a more complicated procedure for user to implement. For example, a serial of system call (open, ioctl, close) are need.The containerd snapshotter daemon relies on these feature, only use a simple check method is usable in product environment. The snapshotter developers may know how cachefiles works, but for snapshotter users, a simple way to check whether snapshotter can be launched is useful. Even though they do not know how cachefiles works.
> 
> I don't think it needs to be considered as long as userspace
> has a way to check since you could wrap up these as a helper
> (I will do in the official erofs-utils later or if you have
> some interest you could help too) and even some erofs-utils
> binary for this.
> 
> sysfs maintainence just for some random feature doesn't
> sound good to me (similar to ext4/xfs on-disk features) and
> even if works, you cannot use this way for 5.19~6.10
> upstream kernels.

Anyway, I know userspace folks always would like to have a
simple kernel way to check if a feature is supported for a
kernel, but (many years later) my current thought is that
the simplist way to check this is to introduce a simple
helper to try.  You cannot list every kernel features you
concerned as some sysfs file and in time properly, or you
could cause some inconsistency.

Anyway, that is my personal thought, having another detailed
list for all features users care about along with the real
implementaions seems unnecessary.

Thanks,
Gao Xiang

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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-21 10:42         ` Gao Xiang
@ 2024-06-24 11:58           ` Hongbo Li
  2024-06-24 12:58             ` Gao Xiang
  0 siblings, 1 reply; 12+ messages in thread
From: Hongbo Li @ 2024-06-24 11:58 UTC (permalink / raw)
  To: Gao Xiang, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/21 18:42, Gao Xiang wrote:
> Hi,
> 
> On 2024/6/21 18:06, Gao Xiang wrote:
>>
>>
>> On 2024/6/21 17:37, Hongbo Li wrote:
>>>
>>>
>>> On 2024/6/21 17:14, Gao Xiang wrote:
>>>>
>>>>
>>>> On 2024/6/21 14:18, Hongbo Li wrote:
>>>>> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
>>>>> module. We cannot know whether it is supported from userspace, so
>>>>> we export this feature to user by sysfs interface.
>>>>>
>>>>> [Before]
>>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>>> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file 
>>>>> or directory
>>>>>
>>>>> [After]
>>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>>> supported
>>>>>
>>>>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>>>>
>>>> I don't think such sysfs is needed, you could just use
>>>> `bind ondemand` to check if it is supported:
>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780
>>>>
>>> Thanks for reply!
>>> `bind ondemand` can check if it is supported, but it requires a more 
>>> complicated procedure for user to implement. For example, a serial of 
>>> system call (open, ioctl, close) are need.The containerd snapshotter 
>>> daemon relies on these feature, only use a simple check method is 
>>> usable in product environment. The snapshotter developers may know 
>>> how cachefiles works, but for snapshotter users, a simple way to 
>>> check whether snapshotter can be launched is useful. Even though they 
>>> do not know how cachefiles works.
>>
>> I don't think it needs to be considered as long as userspace
>> has a way to check since you could wrap up these as a helper
>> (I will do in the official erofs-utils later or if you have
>> some interest you could help too) and even some erofs-utils
>> binary for this.
>>
>> sysfs maintainence just for some random feature doesn't
>> sound good to me (similar to ext4/xfs on-disk features) and
>> even if works, you cannot use this way for 5.19~6.10
>> upstream kernels.
> 
> Anyway, I know userspace folks always would like to have a
> simple kernel way to check if a feature is supported for a
> kernel, but (many years later) my current thought is that
> the simplist way to check this is to introduce a simple
> helper to try.  You cannot list every kernel features you
> concerned as some sysfs file and in time properly, or you
> could cause some inconsistency.
> 
> Anyway, that is my personal thought, having another detailed
> list for all features users care about along with the real
> implementaions seems unnecessary.
Thanks for explaining!
Maybe the way of showing the features in erofs now seems not
quite reasonable. It only output the "supported" string from
sysfs. What suggestions do you have for this?

Thanks,
Hongbo
> 
> Thanks,
> Gao Xiang

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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-24 11:58           ` Hongbo Li
@ 2024-06-24 12:58             ` Gao Xiang
  2024-06-27 12:02               ` Hongbo Li
  0 siblings, 1 reply; 12+ messages in thread
From: Gao Xiang @ 2024-06-24 12:58 UTC (permalink / raw)
  To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/24 19:58, Hongbo Li wrote:
> 
> 
> On 2024/6/21 18:42, Gao Xiang wrote:
>> Hi,
>>
>> On 2024/6/21 18:06, Gao Xiang wrote:
>>>
>>>
>>> On 2024/6/21 17:37, Hongbo Li wrote:
>>>>
>>>>
>>>> On 2024/6/21 17:14, Gao Xiang wrote:
>>>>>
>>>>>
>>>>> On 2024/6/21 14:18, Hongbo Li wrote:
>>>>>> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
>>>>>> module. We cannot know whether it is supported from userspace, so
>>>>>> we export this feature to user by sysfs interface.
>>>>>>
>>>>>> [Before]
>>>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>>>> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such file or directory
>>>>>>
>>>>>> [After]
>>>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>>>> supported
>>>>>>
>>>>>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>>>>>
>>>>> I don't think such sysfs is needed, you could just use
>>>>> `bind ondemand` to check if it is supported:
>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780
>>>>>
>>>> Thanks for reply!
>>>> `bind ondemand` can check if it is supported, but it requires a more complicated procedure for user to implement. For example, a serial of system call (open, ioctl, close) are need.The containerd snapshotter daemon relies on these feature, only use a simple check method is usable in product environment. The snapshotter developers may know how cachefiles works, but for snapshotter users, a simple way to check whether snapshotter can be launched is useful. Even though they do not know how cachefiles works.
>>>
>>> I don't think it needs to be considered as long as userspace
>>> has a way to check since you could wrap up these as a helper
>>> (I will do in the official erofs-utils later or if you have
>>> some interest you could help too) and even some erofs-utils
>>> binary for this.
>>>
>>> sysfs maintainence just for some random feature doesn't
>>> sound good to me (similar to ext4/xfs on-disk features) and
>>> even if works, you cannot use this way for 5.19~6.10
>>> upstream kernels.
>>
>> Anyway, I know userspace folks always would like to have a
>> simple kernel way to check if a feature is supported for a
>> kernel, but (many years later) my current thought is that
>> the simplist way to check this is to introduce a simple
>> helper to try.  You cannot list every kernel features you
>> concerned as some sysfs file and in time properly, or you
>> could cause some inconsistency.
>>
>> Anyway, that is my personal thought, having another detailed
>> list for all features users care about along with the real
>> implementaions seems unnecessary.
> Thanks for explaining!
> Maybe the way of showing the features in erofs now seems not
> quite reasonable. It only output the "supported" string from
> sysfs. What suggestions do you have for this?

As I said, just using "bind ondemand" and "mount fsid" to check
if erofs over fscache is supported is enough.

If userspace folks don't like the internals, these logic could
be wrapped up in erofs-utils or whatever libraries.

Thanks,
Gao Xiang

> 
> Thanks,
> Hongbo
>>
>> Thanks,
>> Gao Xiang

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

* Re: [PATCH 2/2] cachefiles: support query cachefiles ondemand feature
  2024-06-24 12:58             ` Gao Xiang
@ 2024-06-27 12:02               ` Hongbo Li
  0 siblings, 0 replies; 12+ messages in thread
From: Hongbo Li @ 2024-06-27 12:02 UTC (permalink / raw)
  To: Gao Xiang, xiang, chao, huyue2, jefflexu, dhavale, dhowells
  Cc: linux-erofs, netfs



On 2024/6/24 20:58, Gao Xiang wrote:
> 
> 
> On 2024/6/24 19:58, Hongbo Li wrote:
>>
>>
>> On 2024/6/21 18:42, Gao Xiang wrote:
>>> Hi,
>>>
>>> On 2024/6/21 18:06, Gao Xiang wrote:
>>>>
>>>>
>>>> On 2024/6/21 17:37, Hongbo Li wrote:
>>>>>
>>>>>
>>>>> On 2024/6/21 17:14, Gao Xiang wrote:
>>>>>>
>>>>>>
>>>>>> On 2024/6/21 14:18, Hongbo Li wrote:
>>>>>>> Erofs over fscache need CONFIG_CACHEFILES_ONDEMAND in cachefiles
>>>>>>> module. We cannot know whether it is supported from userspace, so
>>>>>>> we export this feature to user by sysfs interface.
>>>>>>>
>>>>>>> [Before]
>>>>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>>>>> cat: /sys/fs/cachefiles/features/cachefiles_ondemand: No such 
>>>>>>> file or directory
>>>>>>>
>>>>>>> [After]
>>>>>>> $ cat /sys/fs/cachefiles/features/cachefiles_ondemand
>>>>>>> supported
>>>>>>>
>>>>>>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>>>>>>
>>>>>> I don't think such sysfs is needed, you could just use
>>>>>> `bind ondemand` to check if it is supported:
>>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/cachefiles/daemon.c?h=v6.9#n780
>>>>>>
>>>>> Thanks for reply!
>>>>> `bind ondemand` can check if it is supported, but it requires a 
>>>>> more complicated procedure for user to implement. For example, a 
>>>>> serial of system call (open, ioctl, close) are need.The containerd 
>>>>> snapshotter daemon relies on these feature, only use a simple check 
>>>>> method is usable in product environment. The snapshotter developers 
>>>>> may know how cachefiles works, but for snapshotter users, a simple 
>>>>> way to check whether snapshotter can be launched is useful. Even 
>>>>> though they do not know how cachefiles works.
>>>>
>>>> I don't think it needs to be considered as long as userspace
>>>> has a way to check since you could wrap up these as a helper
>>>> (I will do in the official erofs-utils later or if you have
>>>> some interest you could help too) and even some erofs-utils
>>>> binary for this.
>>>>
>>>> sysfs maintainence just for some random feature doesn't
>>>> sound good to me (similar to ext4/xfs on-disk features) and
>>>> even if works, you cannot use this way for 5.19~6.10
>>>> upstream kernels.
>>>
>>> Anyway, I know userspace folks always would like to have a
>>> simple kernel way to check if a feature is supported for a
>>> kernel, but (many years later) my current thought is that
>>> the simplist way to check this is to introduce a simple
>>> helper to try.  You cannot list every kernel features you
>>> concerned as some sysfs file and in time properly, or you
>>> could cause some inconsistency.
>>>
>>> Anyway, that is my personal thought, having another detailed
>>> list for all features users care about along with the real
>>> implementaions seems unnecessary.
>> Thanks for explaining!
>> Maybe the way of showing the features in erofs now seems not
>> quite reasonable. It only output the "supported" string from
>> sysfs. What suggestions do you have for this?
> 
> As I said, just using "bind ondemand" and "mount fsid" to check
> if erofs over fscache is supported is enough.
> 
> If userspace folks don't like the internals, these logic could
> be wrapped up in erofs-utils or whatever libraries.
> 
ok, thank you!
> Thanks,
> Gao Xiang
> 
>>
>> Thanks,
>> Hongbo
>>>
>>> Thanks,
>>> Gao Xiang

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

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

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-21  6:18 [PATCH 0/2] support query ondemand feature for erofs and cachefiles Hongbo Li
2024-06-21  6:18 ` [PATCH 1/2] erofs: support query erofs ondemand feature by sysfs interface Hongbo Li
2024-06-21  9:16   ` Gao Xiang
2024-06-21  9:28     ` Gao Xiang
2024-06-21  6:18 ` [PATCH 2/2] cachefiles: support query cachefiles ondemand feature Hongbo Li
2024-06-21  9:14   ` Gao Xiang
2024-06-21  9:37     ` Hongbo Li
2024-06-21 10:06       ` Gao Xiang
2024-06-21 10:42         ` Gao Xiang
2024-06-24 11:58           ` Hongbo Li
2024-06-24 12:58             ` Gao Xiang
2024-06-27 12:02               ` Hongbo Li

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).