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

From: Eric Biggers
Date: Fri Jun 04 2021 - 01:10:52 EST


On Thu, Jun 03, 2021 at 09:42:08PM -0700, Jaegeuk Kim wrote:
> enum feat_id {
> FEAT_CRYPTO = 0,
> FEAT_BLKZONED,
> @@ -587,6 +601,7 @@ enum feat_id {
> FEAT_RO,
> FEAT_TEST_DUMMY_ENCRYPTION_V2,
> FEAT_ENCRYPTED_CASEFOLD,
> + FEAT_PIN_FILE,
> };
>
> static ssize_t f2fs_feature_show(struct f2fs_attr *a,
> @@ -610,6 +625,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,
> case FEAT_RO:
> case FEAT_TEST_DUMMY_ENCRYPTION_V2:
> case FEAT_ENCRYPTED_CASEFOLD:
> + case FEAT_PIN_FILE:
> return sprintf(buf, "supported\n");
> }
> return 0;

There's no need for the feat_id enum to exist. If f2fs_feature_show() just
always printed "supported\n", it will do the right thing.

Also, adding pin_file probably should be a separate patch. That seems to be a
bug fix, as pin_file was mistakenly added to the per-sb feature list instead of
to the kernel feature list?

> +static ssize_t f2fs_sb_feature_show(struct f2fs_attr *a,
> + struct f2fs_sb_info *sbi, char *buf)
> +{
> + if (F2FS_MATCH_FEATURE(sbi, a->id))
> + return sprintf(buf, "supported\n");
> + return sprintf(buf, "unsupported\n");
> +}

This can just use F2FS_HAS_FEATURE(), provided that encrypted_casefold isn't
included here, which it shouldn't be (as discussed elsewhere).

- Eric