Profile mask and calculation cleanups
David Sterba
maintainercover Profile mask and calculation cleanups
There are still some instances of hardcoded values repeating what we have in the raid attr table or using a similar expresion to calculate things that can be simplified.
David Sterba (2):
btrfs: use mask for all RAID1* profiles in btrfs_calc_avail_data_space
btrfs: merge calculations for simple striped profiles in
btrfs_rmap_block
fs/btrfs/block-group.c | 5 ++--- fs/btrfs/super.c | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-)
Signature · 1 line
2.36.1
David Sterba
maintainerPATCH 1/2 btrfs: use mask for all RAID1* profiles in btrfs_calc_avail_data_space
There's a sequence of hard coded values for RAID1 profiles that are already stored in the raid_attr table that should be used instead.
--- fs/btrfs/super.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/btrfs/super.c +2 -6
@@ -2243,12 +2243,8 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,if (type &BTRFS_BLOCK_GROUP_RAID0 ) num_stripes = nr_devices; -else if (type &BTRFS_BLOCK_GROUP_RAID1 ) - num_stripes =2 ; -else if (type &BTRFS_BLOCK_GROUP_RAID1C3 ) - num_stripes =3 ; -else if (type &BTRFS_BLOCK_GROUP_RAID1C4 ) - num_stripes =4 ; +else if (type &BTRFS_BLOCK_GROUP_RAID1_MASK ) + num_stripes = rattr->ncopies;else if (type &BTRFS_BLOCK_GROUP_RAID10 ) num_stripes =4 ;
Signature · 1 line
2.36.1
David Sterba
maintainerPATCH 2/2 btrfs: merge calculations for simple striped profiles in btrfs_rmap_block
In reply to David SterbaUse the same expression for stripe_nr for RAID0 (map->sub_stripes is 1) and RAID10 (map->sub_stripes is 2), with equivalent results.
--- fs/btrfs/block-group.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/block-group.c +2 -3
@@ -1816,11 +1816,10 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start, stripe_nr = physical - map->stripes[i].physical; stripe_nr =div64_u64_rem (stripe_nr, map->stripe_len, &offset); -if (map->type &BTRFS_BLOCK_GROUP_RAID10 ) { +if (map->type & (BTRFS_BLOCK_GROUP_RAID0 | +BTRFS_BLOCK_GROUP_RAID10 )) { stripe_nr = stripe_nr * map->num_stripes + i; stripe_nr =div_u64 (stripe_nr, map->sub_stripes); - }else if (map->type &BTRFS_BLOCK_GROUP_RAID0 ) { - stripe_nr = stripe_nr * map->num_stripes + i; }/* * The remaining case would be for RAID56, multiply by
Signature · 1 line
2.36.1
Quoted 4 lines · David Sterba
There are still some instances of hardcoded values repeating what we have in the raid attr table or using a similar expresion to calculate things that can be simplified.
Quoted 9 lines
David Sterba (2):
btrfs: use mask for all RAID1* profiles inbtrfs_calc_avail_data_space
btrfs: merge calculations for simple striped profiles in
btrfs_rmap_blockfs/btrfs/block-group.c | 5 ++--- fs/btrfs/super.c | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-)
Quoted 4 lines · David Sterba
There are still some instances of hardcoded values repeating what we have in the raid attr table or using a similar expresion to calculate things that can be simplified.
Quoted 9 lines
David Sterba (2):
btrfs: use mask for all RAID1* profiles inbtrfs_calc_avail_data_space
btrfs: merge calculations for simple striped profiles in
btrfs_rmap_blockfs/btrfs/block-group.c | 5 ++--- fs/btrfs/super.c | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-)
Looks good,
Quoted 8 lines · David Sterba
There are still some instances of hardcoded values repeating what we have in the raid attr table or using a similar expresion to calculate things that can be simplified.
David Sterba (2):
btrfs: use mask for all RAID1* profiles inbtrfs_calc_avail_data_space
btrfs: merge calculations for simple striped profiles in
btrfs_rmap_block
Added to misc-next.