All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: check the sector size of underlying device when verifying start
@ 2018-08-10 15:23 Mikulas Patocka
  2018-08-10 15:56 ` Mike Snitzer
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2018-08-10 15:23 UTC (permalink / raw)
  To: Mike Snitzer, Ondrej Kozina, Alasdair G. Kergon; +Cc: dm-devel

It was found out that these commands would fail:
# modprobe scsi_debug dev_size_mb=128 sector_size=512
# dmsetup create crypt0 --table "0 245752 crypt cipher_null-ecb - 0 /dev/sda 16385 1 sector_size:4096"
with the error
"device-mapper: table: 253:0: start=16385 not aligned to h/w logical block size 4096 of sda"

The logic incorrectly checks the starting sector offset on the underlying
device against the block size of the device that is being created.

This patch fixes it by checking the starting sector offset against the
block size of the underlying device, not the device that is being created.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org

---
 drivers/md/dm-table.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/md/dm-table.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-table.c	2018-08-10 15:18:31.410000000 +0200
+++ linux-2.6/drivers/md/dm-table.c	2018-08-10 15:18:31.410000000 +0200
@@ -356,7 +356,7 @@ static int device_area_is_invalid(struct
 	if (logical_block_size_sectors <= 1)
 		return 0;
 
-	if (start & (logical_block_size_sectors - 1)) {
+	if (start & (bdev_logical_block_size(dev->bdev) / 512 - 1)) {
 		DMWARN("%s: start=%llu not aligned to h/w "
 		       "logical block size %u of %s",
 		       dm_device_name(ti->table->md),

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

* Re: dm: check the sector size of underlying device when verifying start
  2018-08-10 15:23 [PATCH] dm: check the sector size of underlying device when verifying start Mikulas Patocka
@ 2018-08-10 15:56 ` Mike Snitzer
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2018-08-10 15:56 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: Ondrej Kozina, dm-devel, Alasdair G. Kergon

On Fri, Aug 10 2018 at 11:23am -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:

> It was found out that these commands would fail:
> # modprobe scsi_debug dev_size_mb=128 sector_size=512
> # dmsetup create crypt0 --table "0 245752 crypt cipher_null-ecb - 0 /dev/sda 16385 1 sector_size:4096"
> with the error
> "device-mapper: table: 253:0: start=16385 not aligned to h/w logical block size 4096 of sda"
> 
> The logic incorrectly checks the starting sector offset on the underlying
> device against the block size of the device that is being created.
> 
> This patch fixes it by checking the starting sector offset against the
> block size of the underlying device, not the device that is being created.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Cc: stable@vger.kernel.org

tweaked like we discussed and staged for 4.19 here:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.19&id=b2f9960fd34e6dddba7975133b84263a2f594a20

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

end of thread, other threads:[~2018-08-10 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-10 15:23 [PATCH] dm: check the sector size of underlying device when verifying start Mikulas Patocka
2018-08-10 15: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.