[dm-devel] dm: stop using bi_private
Mike Snitzer
snitzer at redhat.com
Wed Mar 12 20:56:18 UTC 2014
On Tue, Mar 04 2014 at 6:24pm -0500,
Mikulas Patocka <mpatocka at redhat.com> wrote:
> Device mapper uses the bi_private field as a pointer to dm_target_io or
> dm_rq_clone_bio_info. With current kernel, the bio structure is embedded
> in the structures dm_target_io and dm_rq_clone_bio_info, so the pointer to
> the structure that contains the bio can be found with the macro
> container_of.
>
> This patch removes the use of bi_private and uses container_of instead.
>
> Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
>
> ---
> drivers/md/dm.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> Index: linux-3.14-rc4/drivers/md/dm.c
> ===================================================================
> --- linux-3.14-rc4.orig/drivers/md/dm.c 2014-03-01 17:19:05.000000000 +0100
> +++ linux-3.14-rc4/drivers/md/dm.c 2014-03-01 17:23:31.000000000 +0100
> @@ -753,7 +753,7 @@ static void dec_pending(struct dm_io *io
> static void clone_endio(struct bio *bio, int error)
> {
> int r = 0;
> - struct dm_target_io *tio = bio->bi_private;
> + struct dm_target_io *tio = dm_per_bio_data(bio, 0);
> struct dm_io *io = tio->io;
> struct mapped_device *md = tio->io->md;
> dm_endio_fn endio = tio->ti->type->end_io;
FYI, I've picked this up for 3.15.
But I decided to use this instead:
struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);
While I understand dm_per_bio_data() with 0 accomplishes the same I
think it clearer to use container_of().
Mike
More information about the dm-devel
mailing list