btrfs-progs: mkfs: allow degenerate raid0/raid10

Kernel patch b2f78e88052bc0bee ("btrfs: allow degenerate raid0/raid10")
in
5.15 will allow mounting and converting to single device raid0 or two
device raid10.  Let mkfs create such filesystem.

"The motivation is to allow to preserve the profile type as long as it
 possible for some intermediate state (device removal, conversion), or
 when there are disks of different size, with raid0 the otherwise
 unusable space of the last device will be used too.  Similarly for
 raid10, though the two largest devices would need to be the same."

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-07-23 00:49:16 +02:00
parent b199123b33
commit a177ef7dd4
4 changed files with 10 additions and 7 deletions

View File

@ -317,11 +317,11 @@ There are the following block group types available:
^.^h| Copies ^.^h| Parity ^.<h| Striping
| single | 1 | | | 100% | 1/any
| DUP | 2 / 1 device | | | 50% | 1/any ^(see note 1)^
| RAID0 | | | 1 to N | 100% | 2/any
| RAID0 | | | 1 to N | 100% | 1/any ^(see note 5)^
| RAID1 | 2 | | | 50% | 2/any
| RAID1C3 | 3 | | | 33% | 3/any
| RAID1C4 | 4 | | | 25% | 4/any
| RAID10 | 2 | | 1 to N | 50% | 4/any
| RAID10 | 2 | | 1 to N | 50% | 2/any ^(see note 5)^
| RAID5 | 1 | 1 | 2 to N-1 | (N-1)/N | 2/any ^(see note 2)^
| RAID6 | 1 | 2 | 3 to N-2 | (N-2)/N | 3/any ^(see note 3)^
|=============================================================
@ -344,6 +344,9 @@ want to get effectively 3 copies in a RAID1-like manner (but not exactly that).
'Note 4:' Since kernel 5.5 it's possible to use RAID1C3 as replacement for
RAID6, higher space cost but reliable.
'Note 5:' Since kernel 5.15 it's possible to use (mount, convert profiles)
RAID0 on one device and RAID10 on two devices.
PROFILE LAYOUT
~~~~~~~~~~~~~~

View File

@ -731,10 +731,10 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
/* fallthrough */
case 2:
allowed |= BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
BTRFS_BLOCK_GROUP_RAID5;
BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID10;
/* fallthrough */
case 1:
allowed |= BTRFS_BLOCK_GROUP_DUP;
allowed |= BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID0;
}
if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) {

View File

@ -803,7 +803,7 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
case BTRFS_ERROR_DEV_RAID1C4_MIN_NOT_MET:
return "unable to go below four devices on raid1c4";
case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET:
return "unable to go below four devices on raid10";
return "unable to go below four/two devices on raid10";
case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET:
return "unable to go below two devices on raid5";
case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET:

View File

@ -36,7 +36,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.sub_stripes = 2,
.dev_stripes = 1,
.devs_max = 0, /* 0 == as many as possible */
.devs_min = 4,
.devs_min = 2,
.tolerated_failures = 1,
.devs_increment = 2,
.ncopies = 2,
@ -101,7 +101,7 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
.sub_stripes = 1,
.dev_stripes = 1,
.devs_max = 0,
.devs_min = 2,
.devs_min = 1,
.tolerated_failures = 0,
.devs_increment = 1,
.ncopies = 1,