target: fix discard alignment on partitions
authorChristoph Hellwig <hch@lst.de>
Fri, 15 Apr 2022 04:52:34 +0000 (06:52 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Apr 2022 01:49:58 +0000 (19:49 -0600)
Use the proper bdev_discard_alignment helper that accounts for partition
offsets.

Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220415045258.199825-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/target/target_core_device.c

index 3a1ec70..16e775b 100644 (file)
@@ -849,8 +849,8 @@ bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
         */
        attrib->max_unmap_block_desc_count = 1;
        attrib->unmap_granularity = q->limits.discard_granularity / block_size;
-       attrib->unmap_granularity_alignment = q->limits.discard_alignment /
-                                                               block_size;
+       attrib->unmap_granularity_alignment =
+               bdev_discard_alignment(bdev) / block_size;
        return true;
 }
 EXPORT_SYMBOL(target_configure_unmap_from_queue);