[PATCH 2/4] Support new fields in READ CAPACITY (16)

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

 



Enable setting Logical Blocks per Physical Block Exponent and
Lowest Aligned LBA. This is needed to expose underlying device
properties in the iscsi lun.

Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 usr/sbc.c  |    4 ++++
 usr/spc.c  |   11 +++++++++++
 usr/tgtd.h |    3 +++
 3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/usr/sbc.c b/usr/sbc.c
index f6f0dfd..9666801 100644
--- a/usr/sbc.c
+++ b/usr/sbc.c
@@ -229,6 +229,7 @@ static int sbc_service_action(int host_no, struct scsi_cmd *cmd)
 	unsigned int bshift;
 	uint64_t size;
 	int len = 32;
+	int val;
 
 	if (cmd->scb[1] != SAI_READ_CAPACITY_16)
 		goto sense;
@@ -247,6 +248,9 @@ static int sbc_service_action(int host_no, struct scsi_cmd *cmd)
 	*((uint64_t *)(data)) = __cpu_to_be64(size - 1);
 	data[2] = __cpu_to_be32(1UL << bshift);
 
+	val = (cmd->dev->attrs.lbppbe << 16) | cmd->dev->attrs.la_lba;
+	data[3] = __cpu_to_be32(val);
+
 overflow:
 	scsi_set_in_resid_by_actual(cmd, len);
 	return SAM_STAT_GOOD;
diff --git a/usr/spc.c b/usr/spc.c
index 62853bc..eba4857 100644
--- a/usr/spc.c
+++ b/usr/spc.c
@@ -1612,6 +1612,7 @@ enum {
 	Opt_scsi_id, Opt_scsi_sn,
 	Opt_vendor_id, Opt_product_id,
 	Opt_product_rev, Opt_sense_format,
+	Opt_lbppbe, Opt_la_lba,
 	Opt_optimal_xfer_gran, Opt_optimal_xfer_len,
 	Opt_removable, Opt_readonly, Opt_online,
 	Opt_mode_page,
@@ -1627,6 +1628,8 @@ static match_table_t tokens = {
 	{Opt_product_id, "product_id=%s"},
 	{Opt_product_rev, "product_rev=%s"},
 	{Opt_sense_format, "sense_format=%s"},
+	{Opt_lbppbe, "lbppbe=%s"},
+	{Opt_la_lba, "la_lba=%s"},
 	{Opt_optimal_xfer_gran, "optimal_xfer_gran=%s"},
 	{Opt_optimal_xfer_len, "optimal_xfer_len=%s"},
 	{Opt_removable, "removable=%s"},
@@ -1698,6 +1701,14 @@ int lu_config(struct scsi_lu *lu, char *params, match_fn_t *fn)
 			match_strncpy(buf, &args[0], sizeof(buf));
 			attrs->sense_format = atoi(buf);
 			break;
+		case Opt_lbppbe:
+			match_strncpy(buf, &args[0], sizeof(buf));
+			attrs->lbppbe = atoi(buf);
+			break;
+		case Opt_la_lba:
+			match_strncpy(buf, &args[0], sizeof(buf));
+			attrs->la_lba = atoi(buf);
+			break;
 		case Opt_optimal_xfer_gran:
 			match_strncpy(buf, &args[0], sizeof(buf));
 			update_b0_opt_xfer_gran(lu, atoi(buf));
diff --git a/usr/tgtd.h b/usr/tgtd.h
index c21287d..1805f3e 100644
--- a/usr/tgtd.h
+++ b/usr/tgtd.h
@@ -67,6 +67,9 @@ struct lu_phy_attr {
 	char readonly;          /* Read-Only media */
 	char online;		/* Logical Unit online */
 	char sense_format;	/* Descrptor format sense data supported */
+				/* For the following see READ CAPACITY (16) */
+	unsigned char lbppbe;	/* Logical blocks per physical block exponent */
+	uint16_t la_lba;	/* Lowest aligned LBA */
 
 	/* VPD pages 0x80 -> 0xff masked with 0x80*/
 	struct vpd *lu_vpd[1 << PCODE_SHIFT];
-- 
1.7.1

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


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux