Re: [PATCH v2 2/2] f2fs: Advertise encrypted casefolding in sysfs

From: Eric Biggers
Date: Thu Jun 03 2021 - 14:26:30 EST


On Thu, Jun 03, 2021 at 09:50:38AM +0000, Daniel Rosenberg wrote:
> 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: stable@xxxxxxxxxxxxxxx # v5.11+
> Signed-off-by: Daniel Rosenberg <drosen@xxxxxxxxxx>
> ---
> fs/f2fs/sysfs.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index 09e3f258eb52..6604291a3cdf 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -161,6 +161,9 @@ static ssize_t features_show(struct f2fs_attr *a,
> if (f2fs_sb_has_compression(sbi))
> len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
> len ? ", " : "", "compression");
> + if (f2fs_sb_has_casefold(sbi) && f2fs_sb_has_encrypt(sbi))
> + len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
> + len ? ", " : "", "encrypted_casefold");
> len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
> len ? ", " : "", "pin_file");
> len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
> @@ -579,6 +582,7 @@ enum feat_id {
> FEAT_CASEFOLD,
> FEAT_COMPRESSION,
> FEAT_TEST_DUMMY_ENCRYPTION_V2,
> + FEAT_ENCRYPTED_CASEFOLD,
> };
>
> static ssize_t f2fs_feature_show(struct f2fs_attr *a,
> @@ -600,6 +604,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,
> case FEAT_CASEFOLD:
> case FEAT_COMPRESSION:
> case FEAT_TEST_DUMMY_ENCRYPTION_V2:
> + case FEAT_ENCRYPTED_CASEFOLD:
> return sprintf(buf, "supported\n");
> }
> return 0;
> @@ -704,7 +709,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);
> -#endif
> +#ifdef CONFIG_UNICODE
> +F2FS_FEATURE_RO_ATTR(encrypted_casefold, FEAT_ENCRYPTED_CASEFOLD);
> +#endif /* CONFIG_UNICODE */
> +#endif /* CONFIG_FS_ENCRYPTION */

I had only asked for the #endif comment for CONFIG_FS_ENCRYPTION, since that is
a longer block. #endif comments aren't helpful for single-line blocks.
See Documentation/process/coding-style.rst:

At the end of any non-trivial #if or #ifdef block (more than a few lines),
place a comment after the #endif on the same line, noting the conditional
expression used.

Anyway, doesn't matter much...

Reviewed-by: Eric Biggers <ebiggers@xxxxxxxxxx>

- Eric