All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-4.12] block, dm: use __blk_integrity_register to properly setup integrity profile
@ 2017-04-21 22:28 Mike Snitzer
  2017-04-21 22:43 ` Martin K. Petersen
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Snitzer @ 2017-04-21 22:28 UTC (permalink / raw)
  To: Jens Axboe; +Cc: dm-devel, linux-block, Mikulas Patocka

From: Mikulas Patocka <mpatocka@redhat.com>

When registering integrity profile on a DM device, the logical block
size of the underlying device with integrity support must be used, not
the logical block size of the stacked device we are creating.

Introduce __blk_integrity_register() to allow users more precise control
over the logical block size used to register the integrity profile.
blk_integrity_register() now calls __blk_integrity_register().

DM core's use of __blk_integrity_register() fixes a long-standing DM
linear target bug where it cannot pass integrity data to the underlying
device if its logical block size conflicts with the underlying device's
logical block size.

Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 block/blk-integrity.c  | 14 +++++++++++---
 drivers/md/dm-table.c  |  6 ++++--
 include/linux/blkdev.h |  2 ++
 3 files changed, 17 insertions(+), 5 deletions(-)

NOTE: Jens, I'd like to get this staged in linux-dm.git for 4.12
because the dm-inegrity target depends on it, doing so would avoid
some awkward coordination between block and DM trees.  SO if you're OK
with this patch, and with me sending it to Linus as part of the DM
pull, please provide your Ack. Thanks!

diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 9f0ff5b..d2a36e3 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -396,9 +396,10 @@ static struct blk_integrity_profile nop_profile = {
 };
 
 /**
- * blk_integrity_register - Register a gendisk as being integrity-capable
+ * __blk_integrity_register - Register a gendisk as being integrity-capable
  * @disk:	struct gendisk pointer to make integrity-aware
  * @template:	block integrity profile to register
+ * @logical_block_size:	block size - integrity tag exists for each block
  *
  * Description: When a device needs to advertise itself as being able to
  * send/receive integrity metadata it must use this function to register
@@ -406,19 +407,26 @@ static struct blk_integrity_profile nop_profile = {
  * struct with values appropriate for the underlying hardware. See
  * Documentation/block/data-integrity.txt.
  */
-void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
+void __blk_integrity_register(struct gendisk *disk, struct blk_integrity *template,
+			      unsigned logical_block_size)
 {
 	struct blk_integrity *bi = &disk->queue->integrity;
 
 	bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE |
 		template->flags;
-	bi->interval_exp = ilog2(queue_logical_block_size(disk->queue));
+	bi->interval_exp = ilog2(logical_block_size);
 	bi->profile = template->profile ? template->profile : &nop_profile;
 	bi->tuple_size = template->tuple_size;
 	bi->tag_size = template->tag_size;
 
 	blk_integrity_revalidate(disk);
 }
+EXPORT_SYMBOL(__blk_integrity_register);
+
+void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template)
+{
+	__blk_integrity_register(disk, template, queue_logical_block_size(disk->queue));
+}
 EXPORT_SYMBOL(blk_integrity_register);
 
 /**
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index b060084..b7a5843 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1181,13 +1181,15 @@ static int dm_table_register_integrity(struct dm_table *t)
 		return 0;
 
 	if (!integrity_profile_exists(dm_disk(md))) {
+		struct blk_integrity *integrity = blk_get_integrity(template_disk);
+
 		t->integrity_supported = true;
 		/*
 		 * Register integrity profile during table load; we can do
 		 * this because the final profile must match during resume.
 		 */
-		blk_integrity_register(dm_disk(md),
-				       blk_get_integrity(template_disk));
+		__blk_integrity_register(dm_disk(md), integrity,
+					 1U << integrity->interval_exp);
 		return 0;
 	}
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 796016e..353400c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1778,6 +1778,8 @@ struct blk_integrity_profile {
 	const char			*name;
 };
 
+extern void __blk_integrity_register(struct gendisk *, struct blk_integrity *,
+				     unsigned);
 extern void blk_integrity_register(struct gendisk *, struct blk_integrity *);
 extern void blk_integrity_unregister(struct gendisk *);
 extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
-- 
2.10.1

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

* Re: [PATCH for-4.12] block, dm: use __blk_integrity_register to properly setup integrity profile
  2017-04-21 22:28 [PATCH for-4.12] block, dm: use __blk_integrity_register to properly setup integrity profile Mike Snitzer
@ 2017-04-21 22:43 ` Martin K. Petersen
  2017-04-22 15:10   ` Mike Snitzer
  0 siblings, 1 reply; 6+ messages in thread
From: Martin K. Petersen @ 2017-04-21 22:43 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: Jens Axboe, dm-devel, linux-block, Mikulas Patocka


Mike/Mikulas,

> Introduce __blk_integrity_register() to allow users more precise control
> over the logical block size used to register the integrity profile.
> blk_integrity_register() now calls __blk_integrity_register().

This seems a bit kludgy. It would be cleaner having the integrity
interval be explicitly specified in the integrity template for all
callers. Maybe with a fallback to qlbs if it's set to 0.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH for-4.12] block, dm: use __blk_integrity_register to properly setup integrity profile
  2017-04-21 22:43 ` Martin K. Petersen
@ 2017-04-22 15:10   ` Mike Snitzer
  2017-04-22 21:22     ` [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0 Mike Snitzer
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Snitzer @ 2017-04-22 15:10 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Jens Axboe, dm-devel, linux-block, Mikulas Patocka

On Fri, Apr 21 2017 at  6:43pm -0400,
Martin K. Petersen <martin.petersen@oracle.com> wrote:

> 
> Mike/Mikulas,
> 
> > Introduce __blk_integrity_register() to allow users more precise control
> > over the logical block size used to register the integrity profile.
> > blk_integrity_register() now calls __blk_integrity_register().
> 
> This seems a bit kludgy. It would be cleaner having the integrity
> interval be explicitly specified in the integrity template for all
> callers. Maybe with a fallback to qlbs if it's set to 0.

Fair enough, I'll revise and send v2 shortly.  Thanks.

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

* [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0
  2017-04-22 15:10   ` Mike Snitzer
@ 2017-04-22 21:22     ` Mike Snitzer
  2017-04-23 18:42       ` Martin K. Petersen
  2017-04-23 19:00       ` Jens Axboe
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Snitzer @ 2017-04-22 21:22 UTC (permalink / raw)
  To: Jens Axboe, Martin K. Petersen; +Cc: dm-devel, linux-block, Mikulas Patocka

When registering an integrity profile: if the template's interval_exp is
not 0 use it, otherwise use the ilog2() of logical block size of the
provided gendisk.

This fixes a long-standing DM linear target bug where it cannot pass
integrity data to the underlying device if its logical block size
conflicts with the underlying device's logical block size.

Cc: stable@vger.kernel.org
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 block/blk-integrity.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Jens, please feel free to pick this up for 4.12 and I'll just make the
dm-integrity commit Depends-on it once you've staged it.

diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 9f0ff5b..d6e1b9a 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -412,7 +412,8 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
 
 	bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE |
 		template->flags;
-	bi->interval_exp = ilog2(queue_logical_block_size(disk->queue));
+	bi->interval_exp = template->interval_exp ? :
+		ilog2(queue_logical_block_size(disk->queue));
 	bi->profile = template->profile ? template->profile : &nop_profile;
 	bi->tuple_size = template->tuple_size;
 	bi->tag_size = template->tag_size;
-- 
2.10.1

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

* Re: [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0
  2017-04-22 21:22     ` [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0 Mike Snitzer
@ 2017-04-23 18:42       ` Martin K. Petersen
  2017-04-23 19:00       ` Jens Axboe
  1 sibling, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2017-04-23 18:42 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: Jens Axboe, Martin K. Petersen, dm-devel, linux-block, Mikulas Patocka


Mike,

> When registering an integrity profile: if the template's interval_exp is
> not 0 use it, otherwise use the ilog2() of logical block size of the
> provided gendisk.
>
> This fixes a long-standing DM linear target bug where it cannot pass
> integrity data to the underlying device if its logical block size
> conflicts with the underlying device's logical block size.

Looks good!

Acked-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0
  2017-04-22 21:22     ` [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0 Mike Snitzer
  2017-04-23 18:42       ` Martin K. Petersen
@ 2017-04-23 19:00       ` Jens Axboe
  1 sibling, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2017-04-23 19:00 UTC (permalink / raw)
  To: Mike Snitzer, Martin K. Petersen; +Cc: dm-devel, linux-block, Mikulas Patocka

On 04/22/2017 03:22 PM, Mike Snitzer wrote:
> When registering an integrity profile: if the template's interval_exp is
> not 0 use it, otherwise use the ilog2() of logical block size of the
> provided gendisk.
> 
> This fixes a long-standing DM linear target bug where it cannot pass
> integrity data to the underlying device if its logical block size
> conflicts with the underlying device's logical block size.
> 
> Cc: stable@vger.kernel.org
> Reported-by: Mikulas Patocka <mpatocka@redhat.com>
> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
> ---
>  block/blk-integrity.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> Jens, please feel free to pick this up for 4.12 and I'll just make the
> dm-integrity commit Depends-on it once you've staged it.

OK, I'll commit it. I'll send out my pull request as soon as the merge
window opens, so you should not have any delays.

-- 
Jens Axboe

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

end of thread, other threads:[~2017-04-23 19:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 22:28 [PATCH for-4.12] block, dm: use __blk_integrity_register to properly setup integrity profile Mike Snitzer
2017-04-21 22:43 ` Martin K. Petersen
2017-04-22 15:10   ` Mike Snitzer
2017-04-22 21:22     ` [PATCH v2 for-4.12] block: fix blk_integrity_register to use template's interval_exp if not 0 Mike Snitzer
2017-04-23 18:42       ` Martin K. Petersen
2017-04-23 19:00       ` Jens Axboe

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.