Re: [RFC ONLY 2/8] btrfs: move btrfs_io_context to volumes.h

Qu Wenruo
2022-05-17T07:43:23Z

On 2022/5/16 22:31, Johannes Thumshirn wrote:
> In preparation for upcoming changes, move 'struct btrfs_io_context' to
> volumes.h, so we can use it outside of volumes.c

In fact I don't think the naming itself (from myself) is that good.

It maybe a good idea to also do a rename here.

I have some bad alternatives, but doesn't seem better than the current
generic naming either:

- btrfs_io_mapping
- btrfs_mapping_context

Thus I guess the current name is chosen mostly due to lack of better ones.

Thanks,
Qu

>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
> fs/btrfs/volumes.h | 90 +++++++++++++++++++++++-----------------------
> 1 file changed, 45 insertions(+), 45 deletions(-)
>
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index bd297f23d19e..894d289a3b50 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -32,6 +32,51 @@ struct btrfs_io_geometry {
> u64 raid56_stripe_offset;
> };
>
> +struct btrfs_io_stripe {
> + struct btrfs_device *dev;
> + u64 physical;
> + u64 length; /* only used for discard mappings */
> +};
> +
> +/*
> + * Context for IO subsmission for device stripe.
> + *
> + * - Track the unfinished mirrors for mirror based profiles
> + * Mirror based profiles are SINGLE/DUP/RAID1/RAID10.
> + *
> + * - Contain the logical -> physical mapping info
> + * Used by submit_stripe_bio() for mapping logical bio
> + * into physical device address.
> + *
> + * - Contain device replace info
> + * Used by handle_ops_on_dev_replace() to copy logical bios
> + * into the new device.
> + *
> + * - Contain RAID56 full stripe logical bytenrs
> + */
> +struct btrfs_io_context {
> + refcount_t refs;
> + atomic_t stripes_pending;
> + struct btrfs_fs_info *fs_info;
> + u64 map_type; /* get from map_lookup->type */
> + bio_end_io_t *end_io;
> + struct bio *orig_bio;
> + void *private;
> + atomic_t error;
> + int max_errors;
> + int num_stripes;
> + int mirror_num;
> + int num_tgtdevs;
> + int *tgtdev_map;
> + /*
> + * logical block numbers for the start of each stripe
> + * The last one or two are p/q. These are sorted,
> + * so raid_map[0] is the start of our full stripe
> + */
> + u64 *raid_map;
> + struct btrfs_io_stripe stripes[];
> +};
> +
> /*
> * Use sequence counter to get consistent device stat data on
> * 32-bit processors.
> @@ -354,51 +399,6 @@ static inline void btrfs_bio_free_csum(struct btrfs_bio *bbio)
> }
> }
>
> -struct btrfs_io_stripe {
> - struct btrfs_device *dev;
> - u64 physical;
> - u64 length; /* only used for discard mappings */
> -};
> -
> -/*
> - * Context for IO subsmission for device stripe.
> - *
> - * - Track the unfinished mirrors for mirror based profiles
> - * Mirror based profiles are SINGLE/DUP/RAID1/RAID10.
> - *
> - * - Contain the logical -> physical mapping info
> - * Used by submit_stripe_bio() for mapping logical bio
> - * into physical device address.
> - *
> - * - Contain device replace info
> - * Used by handle_ops_on_dev_replace() to copy logical bios
> - * into the new device.
> - *
> - * - Contain RAID56 full stripe logical bytenrs
> - */
> -struct btrfs_io_context {
> - refcount_t refs;
> - atomic_t stripes_pending;
> - struct btrfs_fs_info *fs_info;
> - u64 map_type; /* get from map_lookup->type */
> - bio_end_io_t *end_io;
> - struct bio *orig_bio;
> - void *private;
> - atomic_t error;
> - int max_errors;
> - int num_stripes;
> - int mirror_num;
> - int num_tgtdevs;
> - int *tgtdev_map;
> - /*
> - * logical block numbers for the start of each stripe
> - * The last one or two are p/q. These are sorted,
> - * so raid_map[0] is the start of our full stripe
> - */
> - u64 *raid_map;
> - struct btrfs_io_stripe stripes[];
> -};
> -
> struct btrfs_device_info {
> struct btrfs_device *dev;
> u64 dev_offset;