]> git.hungrycats.org Git - linux/commitdiff
btrfs: introduce extra limits on btrfs_chunk::stripe_len
authorQu Wenruo <wqu@suse.com>
Wed, 21 Oct 2026 03:39:43 +0000 (14:09 +1030)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Oct 2026 20:36:18 +0000 (21:36 +0100)
The new limits are:

- Stripe_len must be no smaller than sectorsize
  As sectorsize is still the minimal unit.

- Stripe_len must be no larger than BTRFS_STRIPE_LEN
  We still have a lot of things requiring on BTRFS_STRIPE_LEN alignment,
  e.g. dev extent and chunk allocation.
  A stripe_len larger than BTRFS_STRIPE_LEN will cause problems for the
  existing chunk allocator.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-checker.c

index 503b6be90ddadbc64f3d0be1118fc3cb03613943..61ea8f42c9f23baedd24be7d2190f501d9a3897a 100644 (file)
@@ -1044,7 +1044,18 @@ int btrfs_check_chunk_valid(const struct btrfs_fs_info *fs_info,
                          logical, length);
                return -EUCLEAN;
        }
-       if (unlikely(!is_power_of_2(stripe_len) || stripe_len != BTRFS_STRIPE_LEN)) {
+
+       /*
+        * For now the "stripe_len != BTRFS_STRIPE_LEN" will cover all cases,
+        * but the power_of_2 and stripe_len >= sectorsize and
+        * stripe_len <= BTRFS_STRIPE_LEN are the requirements for future
+        * stripe_len support.
+        *
+        * In the future, "stripe_len != BTRFS_STRIPE_LEN" will be removed.
+        */
+       if (unlikely(stripe_len != BTRFS_STRIPE_LEN ||
+                    !is_power_of_2(stripe_len) || stripe_len < sectorsize ||
+                    stripe_len > BTRFS_STRIPE_LEN)) {
                chunk_err(fs_info, leaf, chunk, logical,
                          "invalid chunk stripe length: %llu",
                          stripe_len);