Re: [PATCH 1/4] fscrypt: Cap data units at the page size

From: Eric Biggers

Date: Tue Nov 03 2026 - 17:42:29 EST


On Tue, Nov 03, 2026 at 11:31:29PM +0800, Baokun Li wrote:
> diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
> index e602c31b3844..0dc158563e71 100644
> --- a/fs/crypto/fscrypt_private.h
> +++ b/fs/crypto/fscrypt_private.h
> @@ -203,7 +203,9 @@ static inline int
> fscrypt_policy_v2_du_bits(const struct fscrypt_policy_v2 *policy,
> const struct inode *inode)
> {
> - return policy->log2_data_unit_size ?: inode->i_blkbits;
> + if (policy->log2_data_unit_size)
> + return policy->log2_data_unit_size;
> + return min_t(unsigned int, inode->i_blkbits, PAGE_SHIFT);
> }

This would make the interpretation of the default value
log2_data_unit_size=0 depend on the page size, which (unlike i_blkbits)
is not part of the filesystem's on-disk format.

I think that for a sub-block data unit size to be used, it should need
to continue to be explicitly specified. Otherwise the default would
become ambiguous.

- Eric