* [PATCH 1/2] btrfs: use mask for all RAID1* profiles in btrfs_calc_avail_data_space
2022-06-23 14:56 [PATCH 0/2] Profile mask and calculation cleanups David Sterba
@ 2022-06-23 14:57 ` David Sterba
2022-06-23 14:57 ` [PATCH 2/2] btrfs: merge calculations for simple striped profiles in btrfs_rmap_block David Sterba
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2022-06-23 14:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
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.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/super.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 41652dcd16f4..4c7089b1681b 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -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;
--
2.36.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] btrfs: merge calculations for simple striped profiles in btrfs_rmap_block
2022-06-23 14:56 [PATCH 0/2] Profile mask and calculation cleanups David Sterba
2022-06-23 14:57 ` [PATCH 1/2] btrfs: use mask for all RAID1* profiles in btrfs_calc_avail_data_space David Sterba
@ 2022-06-23 14:57 ` David Sterba
2022-06-23 15:31 ` [PATCH 0/2] Profile mask and calculation cleanups Nikolay Borisov
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2022-06-23 14:57 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use the same expression for stripe_nr for RAID0 (map->sub_stripes is 1)
and RAID10 (map->sub_stripes is 2), with equivalent results.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/block-group.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 13358fbc1629..e930749770ac 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -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
--
2.36.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Profile mask and calculation cleanups
2022-06-23 14:56 [PATCH 0/2] Profile mask and calculation cleanups David Sterba
2022-06-23 14:57 ` [PATCH 1/2] btrfs: use mask for all RAID1* profiles in btrfs_calc_avail_data_space David Sterba
2022-06-23 14:57 ` [PATCH 2/2] btrfs: merge calculations for simple striped profiles in btrfs_rmap_block David Sterba
@ 2022-06-23 15:31 ` Nikolay Borisov
2022-06-24 6:41 ` Johannes Thumshirn
2022-06-24 13:42 ` David Sterba
4 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2022-06-23 15:31 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 23.06.22 г. 17:56 ч., David Sterba wrote:
> 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(-)
>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Profile mask and calculation cleanups
2022-06-23 14:56 [PATCH 0/2] Profile mask and calculation cleanups David Sterba
` (2 preceding siblings ...)
2022-06-23 15:31 ` [PATCH 0/2] Profile mask and calculation cleanups Nikolay Borisov
@ 2022-06-24 6:41 ` Johannes Thumshirn
2022-06-24 13:42 ` David Sterba
4 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2022-06-24 6:41 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On 23.06.22 17:01, David Sterba wrote:
> 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(-)
>
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Profile mask and calculation cleanups
2022-06-23 14:56 [PATCH 0/2] Profile mask and calculation cleanups David Sterba
` (3 preceding siblings ...)
2022-06-24 6:41 ` Johannes Thumshirn
@ 2022-06-24 13:42 ` David Sterba
4 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2022-06-24 13:42 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs
On Thu, Jun 23, 2022 at 04:56:58PM +0200, David Sterba wrote:
> 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
Added to misc-next.
^ permalink raw reply [flat|nested] 6+ messages in thread