All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: stop using bi_private
@ 2014-03-04 23:24 Mikulas Patocka
  2014-03-12 20:56 ` Mike Snitzer
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2014-03-04 23:24 UTC (permalink / raw)
  To: Mike Snitzer, Alasdair G. Kergon, dm-devel

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@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;
@@ -787,7 +787,8 @@ static void clone_endio(struct bio *bio,
  */
 static void end_clone_bio(struct bio *clone, int error)
 {
-	struct dm_rq_clone_bio_info *info = clone->bi_private;
+	struct dm_rq_clone_bio_info *info =
+			container_of(clone, struct dm_rq_clone_bio_info, clone);
 	struct dm_rq_target_io *tio = info->tio;
 	struct bio *bio = info->orig;
 	unsigned int nr_bytes = info->orig->bi_iter.bi_size;
@@ -1113,7 +1114,6 @@ static void __map_bio(struct dm_target_i
 	struct dm_target *ti = tio->ti;
 
 	clone->bi_end_io = clone_endio;
-	clone->bi_private = tio;
 
 	/*
 	 * Map the clone.  If r == 0 we don't need to do
@@ -1529,7 +1529,6 @@ static int dm_rq_bio_constructor(struct 
 	info->orig = bio_orig;
 	info->tio = tio;
 	bio->bi_end_io = end_clone_bio;
-	bio->bi_private = info;
 
 	return 0;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dm: stop using bi_private
  2014-03-04 23:24 [PATCH] dm: stop using bi_private Mikulas Patocka
@ 2014-03-12 20:56 ` Mike Snitzer
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2014-03-12 20:56 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: dm-devel, Alasdair G. Kergon

On Tue, Mar 04 2014 at  6:24pm -0500,
Mikulas Patocka <mpatocka@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@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-12 20:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-04 23:24 [PATCH] dm: stop using bi_private Mikulas Patocka
2014-03-12 20:56 ` Mike Snitzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.