* [PATCH] btrfs: Always initialize btrfs_bio::tgtdev_map/raid_map pointers
@ 2020-06-29 14:16 Nikolay Borisov
2020-06-30 8:03 ` Nikolay Borisov
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Borisov @ 2020-06-29 14:16 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
Since btrfs_bio always contains the extra space for the tgtdev_map and
raid_maps it's pointless to make the assignment iff specific conditions
are met. Instead, always assign the pointers to their correct value at
allocation time.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/volumes.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index cb9883c7f8b7..1b1fc1485a41 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5522,6 +5522,9 @@ static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes)
atomic_set(&bbio->error, 0);
refcount_set(&bbio->refs, 1);
+ bbio->tgtdev_map = (int *)(bbio->stripes + total_stripes);
+ bbio->raid_map = (u64 *)(bbio->tgtdev_map + real_stripes);
+
return bbio;
}
@@ -6144,8 +6147,6 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
ret = -ENOMEM;
goto out;
}
- if (dev_replace_is_ongoing && dev_replace->tgtdev != NULL)
- bbio->tgtdev_map = (int *)(bbio->stripes + num_alloc_stripes);
/* build raid_map */
if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK && need_raid_map &&
@@ -6153,10 +6154,6 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
u64 tmp;
unsigned rot;
- bbio->raid_map = (u64 *)((void *)bbio->stripes +
- sizeof(struct btrfs_bio_stripe) *
- num_alloc_stripes +
- sizeof(int) * tgtdev_indexes);
/* Work out the disk rotation on this stripe-set */
div_u64_rem(stripe_nr, num_stripes, &rot);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: Always initialize btrfs_bio::tgtdev_map/raid_map pointers
2020-06-29 14:16 [PATCH] btrfs: Always initialize btrfs_bio::tgtdev_map/raid_map pointers Nikolay Borisov
@ 2020-06-30 8:03 ` Nikolay Borisov
0 siblings, 0 replies; 2+ messages in thread
From: Nikolay Borisov @ 2020-06-30 8:03 UTC (permalink / raw)
To: linux-btrfs
On 29.06.20 г. 17:16 ч., Nikolay Borisov wrote:
> Since btrfs_bio always contains the extra space for the tgtdev_map and
> raid_maps it's pointless to make the assignment iff specific conditions
> are met. Instead, always assign the pointers to their correct value at
> allocation time.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> fs/btrfs/volumes.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index cb9883c7f8b7..1b1fc1485a41 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -5522,6 +5522,9 @@ static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes)
> atomic_set(&bbio->error, 0);
> refcount_set(&bbio->refs, 1);
>
> + bbio->tgtdev_map = (int *)(bbio->stripes + total_stripes);
> + bbio->raid_map = (u64 *)(bbio->tgtdev_map + real_stripes);
> +
> return bbio;
> }
>
> @@ -6144,8 +6147,6 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
> ret = -ENOMEM;
> goto out;
> }
> - if (dev_replace_is_ongoing && dev_replace->tgtdev != NULL)
> - bbio->tgtdev_map = (int *)(bbio->stripes + num_alloc_stripes);
>
> /* build raid_map */
> if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK && need_raid_map &&
> @@ -6153,10 +6154,6 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
> u64 tmp;
> unsigned rot;
>
> - bbio->raid_map = (u64 *)((void *)bbio->stripes +
> - sizeof(struct btrfs_bio_stripe) *
> - num_alloc_stripes +
> - sizeof(int) * tgtdev_indexes);
>
> /* Work out the disk rotation on this stripe-set */
> div_u64_rem(stripe_nr, num_stripes, &rot);
>
This patch is not complete since the presence of raid_map now means that
the sort parityu function in __btrfs_map_block will always be invoked,
which is not what we want. I'll send a fixed v2 later.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-30 8:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 14:16 [PATCH] btrfs: Always initialize btrfs_bio::tgtdev_map/raid_map pointers Nikolay Borisov
2020-06-30 8:03 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).