[PATCH v6 42/43] btrfs: disable encryption on RAID5/6
From: Daniel Vacek
Date: Fri Feb 06 2026 - 13:36:14 EST
From: Josef Bacik <josef@xxxxxxxxxxxxxx>
The RAID5/6 code will re-arrange bios and submit them through a
different mechanism. This is problematic with inline encryption as we
have to get the bio and csum it after it's been encrypted, and the
radi5/6 bio's don't have the btrfs_bio embedded, so we have no way to
get the csums put on disk.
This isn't an unsolvable problem, but would require a bit of reworking.
Since we discourage users from using this code currently simply don't
allow encryption on RAID5/6 setups. If there's sufficient demand in the
future we can add the support for this.
Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
Signed-off-by: Daniel Vacek <neelx@xxxxxxxx>
---
v5: https://lore.kernel.org/linux-btrfs/941f02bb923edadae1aea4ae3e5aa6ba05d1215a.1706116485.git.josef@xxxxxxxxxxxxxx/
* No changes since.
---
fs/btrfs/ioctl.c | 4 ++++
fs/btrfs/super.c | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a8adf99ad0a8..1bade8fea16e 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -5198,6 +5198,10 @@ long btrfs_ioctl(struct file *file, unsigned int
return -EOPNOTSUPP;
if (sb_rdonly(fs_info->sb))
return -EROFS;
+ if (btrfs_fs_incompat(fs_info, RAID56)) {
+ btrfs_warn(fs_info, "can't enable encryption with RAID5/6");
+ return -EINVAL;
+ }
/*
* If we crash before we commit, nothing encrypted could have
* been written so it doesn't matter whether the encrypted
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 4a2887147ead..aefcbe56e85a 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -734,6 +734,12 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
if (btrfs_check_mountopts_zoned(info, mount_opt))
ret = false;
+ if (btrfs_fs_incompat(info, RAID56) &&
+ btrfs_raw_test_opt(*mount_opt, TEST_DUMMY_ENCRYPTION)) {
+ btrfs_err(info, "cannot use test_dummy_encryption with RAID5/6");
+ ret = false;
+ }
+
if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) {
if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) {
btrfs_warn(info,
--
2.51.0