On Tue, Apr 01, 2025 at 10:44:34AM +0800, Herbert Xu wrote:
Thanks for the pointer, I wasn't aware of its existence. Yes
there should definitely be only one code path for this. So
what's stopping you from removing fscrypt right now? IOW what's
missing from blk-crypto?
Well, fscrypt (ext4/f2fs/ubifs/ceph encryption) wouldn't be removed; its
implementation would just change on ext4 and f2fs. Instead of providing a
choice of whether to use blk-crypto or fs-layer crypto for file contents
en/decryption, ext4 and f2fs would always use blk-crypto. Supporting code such
as fscrypt_decrypt_bio() that would become unused by that would be removed.
A few reasons I've waited so long:
- The fs-layer file contents en/decryption code was there first, and there
hasn't been a strong need to remove it yet
- Much of the file contents en/decryption code in fs/crypto/ would still be
needed, since ubifs and ceph still use it as they are not block-based
- It would make CONFIG_BLK_INLINE_ENCRYPTION, which adds a field to struct bio,
required on more systems
- It would add the overhead of keyslot management to software crypto
- blk-crypto currently always uses inline encryption hardware when it's
available; but, I'd like to preserve ext4's and f2fs's existing behavior where
the use of inline encryption hardware is opt-in via a mount option.
But I'm thinking it's finally time, especially with the conversions of
filesystems to operate on folios that's going on.
dm-crypt could of course use blk-crypto too, but the dm people haven't been
super comfortable so far with delegating en/decryption to the block layer.