Skip to contentSkip to conversation

target: Convert transport_dev_end_lba() to ->get_blocks()

PATCH New Nicholas A. Bellinger 1 participant 1 message Nov 26, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target: Convert transport_dev_end_lba() to ->get_blocks()

From: Nicholas Bellinger <[email protected]>

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.

---
 drivers/target/target_core_transport.c |    5 +----
 include/target/target_core_base.h      |    1 -
 2 files changed, 1 insertions(+), 5 deletions(-)
drivers/target/target_core_transport.c +1 -4
index dbe5dbf..665eaac 100644
@@ -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)
include/target/target_core_base.h +0 -1
index 7ccde37..ba15644 100644
@@ -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;
Signature · 1 line
1.5.6.5