[PATCH] target: Convert transport_dev_end_lba() to ->get_blocks()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>

This patch converts transport_get_sectors() -> transport_dev_end_lba() to use
dev->transport->get_blocks(dev) directly instead of the dev->dev_sectors_total
assignment in transport_add_device_to_core_hba().

This fixes a bug where backend struct block_devices like (Linux/LVM w/ IBLOCK)
could change their effective size reported by ->get_blocks(), but the original
dev->dev_sectors_total was still be enforced by transport_dev_end_lba().

Tested with IBLOCK, FILEIO, RAMDISK_DR and pSCSI LUNs of TYPE_DISK.

Signed-off-by: Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx>
---
 drivers/target/target_core_transport.c |    5 +----
 include/target/target_core_base.h      |    1 -
 2 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index dbe5dbf..665eaac 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1715,9 +1715,6 @@ struct se_device *transport_add_device_to_core_hba(
 	}
 	scsi_dump_inquiry(dev);
 
-	if (TRANSPORT(dev)->get_device_type(dev) == TYPE_DISK)
-		dev->dev_sectors_total = dev->transport->get_blocks(dev);
-
 out:
 	if (!ret)
 		return dev;
@@ -4248,7 +4245,7 @@ EXPORT_SYMBOL(transport_generic_map_mem_to_cmd);
 
 static inline long long transport_dev_end_lba(struct se_device *dev)
 {
-	return dev->dev_sectors_total + 1;
+	return dev->transport->get_blocks(dev) + 1;
 }
 
 static int transport_get_sectors(struct se_cmd *cmd)
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 7ccde37..ba15644 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -731,7 +731,6 @@ struct se_device {
 	/* Used for SPC-2 reservations enforce of ISIDs */
 	u64			dev_res_bin_isid;
 	t10_task_attr_index_t	dev_task_attr_type;
-	unsigned long long	dev_sectors_total;
 	/* Pointer to transport specific device structure */
 	void 			*dev_ptr;
 	u32			dev_index;
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux