Skip to contentSkip to conversation

f2fs: Advertise encrypted casefolding in sysfs

PATCH In review Jaegeuk Kim 3 participants 9 messages Jun 5, 2021 – Jun 10, 2021

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/3 f2fs: Advertise encrypted casefolding in sysfs

From: Daniel Rosenberg <[email protected]>

Older kernels don't support encryption with casefolding. This adds the sysfs entry encrypted_casefold to show support for those combined features. Support for this feature was originally added by commit 7ad08a58bf67 ("f2fs: Handle casefolding with Encryption")

Fixes 7ad08a58bf67 ("f2fs: Handle casefolding with Encryption")
Cc [email protected] # v5.11+
---
 fs/f2fs/sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/f2fs/sysfs.c +8 -0
index 62fbe4f20dd6..4daa6aeb200b 100644
@@ -583,6 +583,7 @@ enum feat_id {
 	FEAT_COMPRESSION,
 	FEAT_RO,
 	FEAT_TEST_DUMMY_ENCRYPTION_V2,
+	FEAT_ENCRYPTED_CASEFOLD,
 };
 
 static ssize_t f2fs_feature_show(struct f2fs_attr *a,
@@ -605,6 +606,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,
 	case FEAT_COMPRESSION:
 	case FEAT_RO:
 	case FEAT_TEST_DUMMY_ENCRYPTION_V2:
+	case FEAT_ENCRYPTED_CASEFOLD:
 		return sprintf(buf, "supported\n");
 	}
 	return 0;
@@ -709,7 +711,10 @@ F2FS_GENERAL_RO_ATTR(avg_vblocks);
 #ifdef CONFIG_FS_ENCRYPTION
 F2FS_FEATURE_RO_ATTR(encryption, FEAT_CRYPTO);
 F2FS_FEATURE_RO_ATTR(test_dummy_encryption_v2, FEAT_TEST_DUMMY_ENCRYPTION_V2);
+#ifdef CONFIG_UNICODE
+F2FS_FEATURE_RO_ATTR(encrypted_casefold, FEAT_ENCRYPTED_CASEFOLD);
 #endif
+#endif /* CONFIG_FS_ENCRYPTION */
 #ifdef CONFIG_BLK_DEV_ZONED
 F2FS_FEATURE_RO_ATTR(block_zoned, FEAT_BLKZONED);
 #endif
@@ -822,7 +827,10 @@ static struct attribute *f2fs_feat_attrs[] = {
 #ifdef CONFIG_FS_ENCRYPTION
 	ATTR_LIST(encryption),
 	ATTR_LIST(test_dummy_encryption_v2),
+#ifdef CONFIG_UNICODE
+	ATTR_LIST(encrypted_casefold),
 #endif
+#endif /* CONFIG_FS_ENCRYPTION */
 #ifdef CONFIG_BLK_DEV_ZONED
 	ATTR_LIST(block_zoned),
 #endif
Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
author maintainer
#1 lore raw

PATCH 2/3 f2fs: add pin_file in feature list

This patch adds missing pin_file feature supported by kernel.

Fixes f5a53edcf01e ("f2fs: support aligned pinned file")
---
 fs/f2fs/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/sysfs.c +2 -0
index 4daa6aeb200b..e4d5090b7cb3 100644
@@ -740,6 +740,7 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_written_block, compr_written_block);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_saved_block, compr_saved_block);
 F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_new_inode, compr_new_inode);
 #endif
+F2FS_FEATURE_RO_ATTR(pin_file);
 
 /* For ATGC */
 F2FS_RW_ATTR(ATGC_INFO, atgc_management, atgc_candidate_ratio, candidate_ratio);
@@ -853,6 +854,7 @@ static struct attribute *f2fs_feat_attrs[] = {
 #ifdef CONFIG_F2FS_FS_COMPRESSION
 	ATTR_LIST(compression),
 #endif
+	ATTR_LIST(pin_file),
 	NULL,
 };
 ATTRIBUTE_GROUPS(f2fs_feat);
Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
author maintainer
#3 lore raw

PATCH 3/3 f2fs: clean up /sys/fs/f2fs/<disk>/features

In reply to Jaegeuk Kim

Let's create /sys/fs/f2fs/<disk>/feature_list/ to meet sysfs rule.

Note that there are three feature list entries:
1) /sys/fs/f2fs/features
: shows runtime features supported by in-kernel f2fs along with Kconfig
- ref. F2FS_FEATURE_RO_ATTR()

2) /sys/fs/f2fs/$s_id/features <deprecated>
: shows on-disk features enabled by mkfs.f2fs, used for old kernels

3) /sys/fs/f2fs/$s_id/feature_list
: shows on-disk features enabled by mkfs.f2fs per instance.
this list covers old feature list provided by 2) and beyond
- ref. F2FS_SB_FEATURE_RO_ATTR()

---
 Documentation/ABI/testing/sysfs-fs-f2fs |  29 +++-
 fs/f2fs/f2fs.h                          |   3 +
 fs/f2fs/sysfs.c                         | 191 ++++++++++++++++--------
 3 files changed, 159 insertions(+), 64 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +28 -1
index 5088281e312e..0c40b3a5961c 100644
@@ -203,7 +203,34 @@ Description:	Shows total written kbytes issued to disk.
 What:		/sys/fs/f2fs/<disk>/features
 Date:		July 2017
 Contact:	"Jaegeuk Kim" <[email protected]>
-Description:	Shows all enabled features in current device.
+Description:	<deprecated: should use /sys/fs/f2fs/<disk>/feature_list/
+		Shows all enabled features in current device.
+		Supported features:
+		encryption, blkzoned, extra_attr, projquota, inode_checksum,
+		flexible_inline_xattr, quota_ino, inode_crtime, lost_found,
+		verity, sb_checksum, casefold, readonly, compression, pin_file.
+
+What:		/sys/fs/f2fs/<disk>/feature_list/
+Date:		June 2021
+Contact:	"Jaegeuk Kim" <[email protected]>
+Description:	Expand /sys/fs/f2fs/<disk>/features to meet sysfs rule.
+		Supported on-disk features:
+		encryption, block_zoned (aka blkzoned), extra_attr,
+		project_quota (aka projquota), inode_checksum,
+		flexible_inline_xattr, quota_ino, inode_crtime, lost_found,
+		verity, sb_checksum, casefold, readonly, compression.
+		Note that, pin_file is moved into /sys/fs/f2fs/features/.
+
+What:		/sys/fs/f2fs/feature/
+Date:		July 2017
+Contact:	"Jaegeuk Kim" <[email protected]>
+Description:	Shows all enabled kernel features.
+		Supported features:
+		encryption, block_zoned, extra_attr, project_quota,
+		inode_checksum, flexible_inline_xattr, quota_ino,
+		inode_crtime, lost_found, verity, sb_checksum,
+		casefold, readonly, compression, test_dummy_encryption_v2,
+		atomic_write, pin_file, encrypted_casefold.
 
 What:		/sys/fs/f2fs/<disk>/inject_rate
 Date:		May 2016
fs/f2fs/f2fs.h +3 -0
index 8903c43091f8..bbc36828a9d9 100644
@@ -1665,6 +1665,9 @@ struct f2fs_sb_info {
 	struct kobject s_stat_kobj;		/* /sys/fs/f2fs/<devname>/stat */
 	struct completion s_stat_kobj_unregister;
 
+	struct kobject s_feature_list_kobj;		/* /sys/fs/f2fs/<devname>/feature_list */
+	struct completion s_feature_list_kobj_unregister;
+
 	/* For shrinker support */
 	struct list_head s_list;
 	int s_ndevs;				/* number of devices */
fs/f2fs/sysfs.c +128 -63

254 lines not on this page · raw message

Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
#4 lore raw

Re: [f2fs-dev] [PATCH 3/3] f2fs: clean up /sys/fs/f2fs/<disk>/features

Quoted 1 line · Jaegeuk Kim

+What: /sys/fs/f2fs/feature/

features/, not feature/.

Quoted 6 lines

+/*
+ * Note that there are three feature list entries:
+ * 1) /sys/fs/f2fs/features
+ * : shows runtime features supported by in-kernel f2fs along with Kconfig
+ * - ref. F2FS_FEATURE_RO_ATTR()
+ *

Quoted 8 lines

+ * 2) /sys/fs/f2fs/$s_id/features <deprecated>
+ * : shows on-disk features enabled by mkfs.f2fs, used for old kernels
+ *
+ * 3) /sys/fs/f2fs/$s_id/feature_list
+ * : shows on-disk features enabled by mkfs.f2fs per instance.
+ * this list covers old feature list provided by 2) and beyond
+ * - ref. F2FS_SB_FEATURE_RO_ATTR()
+ */

It would be helpful to make it clear which of these use the one-feature-per-file convention and which use the comma-separated features convention. And also whether future features will be listed in both (2) and (3), or just in (3).

Otherwise this patch looks good -- thanks!

- Eric

author maintainer
#5 lore raw

Re: [PATCH 3/3 v2] f2fs: clean up /sys/fs/f2fs/<disk>/features

In reply to Jaegeuk Kim

Let's create /sys/fs/f2fs/<disk>/feature_list/ to meet sysfs rule.

Note that there are three feature list entries:
1) /sys/fs/f2fs/features
: shows runtime features supported by in-kernel f2fs along with Kconfig.
- ref. F2FS_FEATURE_RO_ATTR()

2) /sys/fs/f2fs/$s_id/features <deprecated>
: shows on-disk features enabled by mkfs.f2fs, used for old kernels. This
won't add new feature anymore, and thus, users should check entries in 3) instead of this 2).

3) /sys/fs/f2fs/$s_id/feature_list
: shows on-disk features enabled by mkfs.f2fs per instance, which follows
sysfs entry rule where each entry should expose single value. This list covers old feature list provided by 2) and beyond. Therefore, please add new on-disk feature in this list only.
- ref. F2FS_SB_FEATURE_RO_ATTR()

---

change log from v1:
- adjust Eric's comment

 Documentation/ABI/testing/sysfs-fs-f2fs |  29 +++-
 fs/f2fs/f2fs.h                          |   3 +
 fs/f2fs/sysfs.c                         | 196 ++++++++++++++++--------
 3 files changed, 163 insertions(+), 65 deletions(-)
Documentation/ABI/testing/sysfs-fs-f2fs +28 -1
index 5088281e312e..95155e4ec7fe 100644
@@ -203,7 +203,34 @@ Description:	Shows total written kbytes issued to disk.
 What:		/sys/fs/f2fs/<disk>/features
 Date:		July 2017
 Contact:	"Jaegeuk Kim" <[email protected]>
-Description:	Shows all enabled features in current device.
+Description:	<deprecated: should use /sys/fs/f2fs/<disk>/feature_list/
+		Shows all enabled features in current device.
+		Supported features:
+		encryption, blkzoned, extra_attr, projquota, inode_checksum,
+		flexible_inline_xattr, quota_ino, inode_crtime, lost_found,
+		verity, sb_checksum, casefold, readonly, compression, pin_file.
+
+What:		/sys/fs/f2fs/<disk>/feature_list/
+Date:		June 2021
+Contact:	"Jaegeuk Kim" <[email protected]>
+Description:	Expand /sys/fs/f2fs/<disk>/features to meet sysfs rule.
+		Supported on-disk features:
+		encryption, block_zoned (aka blkzoned), extra_attr,
+		project_quota (aka projquota), inode_checksum,
+		flexible_inline_xattr, quota_ino, inode_crtime, lost_found,
+		verity, sb_checksum, casefold, readonly, compression.
+		Note that, pin_file is moved into /sys/fs/f2fs/features/.
+
+What:		/sys/fs/f2fs/features/
+Date:		July 2017
+Contact:	"Jaegeuk Kim" <[email protected]>
+Description:	Shows all enabled kernel features.
+		Supported features:
+		encryption, block_zoned, extra_attr, project_quota,
+		inode_checksum, flexible_inline_xattr, quota_ino,
+		inode_crtime, lost_found, verity, sb_checksum,
+		casefold, readonly, compression, test_dummy_encryption_v2,
+		atomic_write, pin_file, encrypted_casefold.
 
 What:		/sys/fs/f2fs/<disk>/inject_rate
 Date:		May 2016
fs/f2fs/f2fs.h +3 -0
index 8903c43091f8..bbc36828a9d9 100644
@@ -1665,6 +1665,9 @@ struct f2fs_sb_info {
 	struct kobject s_stat_kobj;		/* /sys/fs/f2fs/<devname>/stat */
 	struct completion s_stat_kobj_unregister;
 
+	struct kobject s_feature_list_kobj;		/* /sys/fs/f2fs/<devname>/feature_list */
+	struct completion s_feature_list_kobj_unregister;
+
 	/* For shrinker support */
 	struct list_head s_list;
 	int s_ndevs;				/* number of devices */
fs/f2fs/sysfs.c +132 -64

258 lines not on this page · raw message

Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
maintainer Reviewed-by
#6 lore raw

Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: clean up /sys/fs/f2fs/<disk>/features

Quoted 12 lines · Jaegeuk Kim

Let's create /sys/fs/f2fs/<disk>/feature_list/ to meet sysfs rule.

Note that there are three feature list entries:
1) /sys/fs/f2fs/features
: shows runtime features supported by in-kernel f2fs along with Kconfig.
- ref. F2FS_FEATURE_RO_ATTR()

2) /sys/fs/f2fs/$s_id/features <deprecated>
: shows on-disk features enabled by mkfs.f2fs, used for old kernels. This
won't add new feature anymore, and thus, users should check entries in 3) instead of this 2).

Quoted 8 lines

3) /sys/fs/f2fs/$s_id/feature_list
: shows on-disk features enabled by mkfs.f2fs per instance, which follows
sysfs entry rule where each entry should expose single value. This list covers old feature list provided by 2) and beyond. Therefore, please add new on-disk feature in this list only.
- ref. F2FS_SB_FEATURE_RO_ATTR()

fs/f2fs/sysfs.c static struct kobj_type f2fs_stat_ktype = { · line 988

Quoted 7 lines
fs/f2fs/sysfs.c +7 -0
+static struct kobj_type f2fs_feature_list_ktype = {
+	.default_groups = f2fs_sb_feat_groups,
+	.sysfs_ops	= &f2fs_feature_list_attr_ops,
+	.release	= f2fs_feature_list_kobj_release,
+};
+
+

Nitpick, one redundant blank line.

Thanks,

author maintainer
#7 lore raw

Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: clean up /sys/fs/f2fs/<disk>/features

Quoted 24 lines · Chao Yu
Quoted 12 lines · Jaegeuk Kim

Let's create /sys/fs/f2fs/<disk>/feature_list/ to meet sysfs rule.

Note that there are three feature list entries:
1) /sys/fs/f2fs/features
: shows runtime features supported by in-kernel f2fs along with Kconfig.
- ref. F2FS_FEATURE_RO_ATTR()

2) /sys/fs/f2fs/$s_id/features <deprecated>
: shows on-disk features enabled by mkfs.f2fs, used for old kernels. This
won't add new feature anymore, and thus, users should check entries in 3) instead of this 2).

Quoted 8 lines

3) /sys/fs/f2fs/$s_id/feature_list
: shows on-disk features enabled by mkfs.f2fs per instance, which follows
sysfs entry rule where each entry should expose single value. This list covers old feature list provided by 2) and beyond. Therefore, please add new on-disk feature in this list only.
- ref. F2FS_SB_FEATURE_RO_ATTR()

Quoted 9 lines

fs/f2fs/sysfs.c static struct kobj_type f2fs_stat_ktype = { · line 988

Quoted 7 lines
fs/f2fs/sysfs.c +7 -0
+static struct kobj_type f2fs_feature_list_ktype = {
+	.default_groups = f2fs_sb_feat_groups,
+	.sysfs_ops	= &f2fs_feature_list_attr_ops,
+	.release	= f2fs_feature_list_kobj_release,
+};
+
+

Nitpick, one redundant blank line.

Done.

Quoted 2 lines

Thanks,

Reviewed-by
#8 lore raw

Re: [f2fs-dev] [PATCH 3/3 v2] f2fs: clean up /sys/fs/f2fs/<disk>/features

In reply to Jaegeuk Kim
Quoted 22 lines · Jaegeuk Kim

Let's create /sys/fs/f2fs/<disk>/feature_list/ to meet sysfs rule.

Note that there are three feature list entries:
1) /sys/fs/f2fs/features
: shows runtime features supported by in-kernel f2fs along with Kconfig.
- ref. F2FS_FEATURE_RO_ATTR()

2) /sys/fs/f2fs/$s_id/features <deprecated>
: shows on-disk features enabled by mkfs.f2fs, used for old kernels. This
won't add new feature anymore, and thus, users should check entries in 3) instead of this 2).

3) /sys/fs/f2fs/$s_id/feature_list
: shows on-disk features enabled by mkfs.f2fs per instance, which follows
sysfs entry rule where each entry should expose single value. This list covers old feature list provided by 2) and beyond. Therefore, please add new on-disk feature in this list only.
- ref. F2FS_SB_FEATURE_RO_ATTR()

---

Quoted 7 lines

change log from v1:
- adjust Eric's comment

 Documentation/ABI/testing/sysfs-fs-f2fs |  29 +++-
 fs/f2fs/f2fs.h                          |   3 +
 fs/f2fs/sysfs.c                         | 196 ++++++++++++++++--------
 3 files changed, 163 insertions(+), 65 deletions(-)

- Eric