Skip to contentSkip to conversation

: Add proper support for ISIDs in TransportID processing

PATCH New Nicholas A. Bellinger 1 participant 1 message Apr 13, 2010

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

PATCH 1/4 : Add proper support for ISIDs in TransportID processing

From: Nicholas Bellinger <[email protected]>

This patch updates TCM/PR to add proper support for processing SCSI Initiator Ports that contain an Initiator Session ID in a single TransportID. Note that iSCSI is the only fabric defined by SPC-4 that can function in this manner, where a iSCSI TransportID can be:

*) iSCSI IQN device (InitiatorName)
*) iSCSI Port Name (InitiatorName+ISID).

This patch to target_core_pr.c will check for the existence of the TCM fabric module call struct target_core_fabric_ops->sess_get_initiator_sid() (only expected to be set by iSCSI fabrics) to determine of ISIDs will be enforced, and will then save the received ISID (if present) for the local fabric port to t10_pr_registration_t->pr_reg_isid[] and sets PRF_ISID_PRESENT_AT_REG.

Note that this patch changes the default operation of TCM/PR to require the use of InitiatorName+ISID TransportIDs for iSCSI with the LIO-Target fabric module. This updates a number of PR functions to be ISID aware and to accept the optional fabric pointer to ISID for both SPC-3 PR and legacy SPC-2 reservations operation.

For the fast path in core_scsi3_pr_reservation_check() and core_scsi2_reservation_check(), a binary comparision is done on the registration/reservation time ISID against the local I_T Nexus if ISIDs are in use for the underlying TCM fabric module.

---
 drivers/target/target_core_configfs.c  |   24 ++-
 drivers/target/target_core_pr.c        |  299 +++++++++++++++++++++++++------
 include/target/target_core_base.h      |    4 +
 include/target/target_core_pr.h        |    2 +
 include/target/target_core_transport.h |    1 +
 5 files changed, 266 insertions(+), 64 deletions(-)
drivers/target/target_core_configfs.c +18 -6
index fc3ea81..acd7fcd 100644
@@ -864,6 +864,10 @@ static ssize_t target_core_dev_pr_show_spc3_res(
 {
 	se_node_acl_t *se_nacl;
 	t10_pr_registration_t *pr_reg;
+	char i_buf[PR_REG_ISID_ID_LEN];
+	int prf_isid;
+
+	memset(i_buf, 0, PR_REG_ISID_ID_LEN);
 
 	spin_lock(&dev->dev_reservation_lock);
 	pr_reg = dev->dev_pr_res_holder;
@@ -873,9 +877,12 @@ static ssize_t target_core_dev_pr_show_spc3_res(
 		return *len;
 	}
 	se_nacl = pr_reg->pr_reg_nacl;
-	*len += sprintf(page + *len, "SPC-3 Reservation: %s Initiator: %s\n",
+	prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
+				PR_REG_ISID_ID_LEN);
+
+	*len += sprintf(page + *len, "SPC-3 Reservation: %s Initiator: %s%s\n",
 		TPG_TFO(se_nacl->se_tpg)->get_fabric_name(),
-		se_nacl->initiatorname);
+		se_nacl->initiatorname, (prf_isid) ? &i_buf[0] : "");
 	spin_unlock(&dev->dev_reservation_lock);
 
 	return *len;
@@ -1053,8 +1060,9 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
 	struct target_core_fabric_ops *tfo;
 	t10_pr_registration_t *pr_reg;
 	unsigned char buf[384];
+	char i_buf[PR_REG_ISID_ID_LEN];
 	ssize_t len = 0;
-	int reg_count = 0;
+	int reg_count = 0, prf_isid;
 
 	if (!(su_dev->se_dev_ptr))
 		return -ENODEV;
@@ -1069,11 +1077,15 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
 			pr_reg_list) {
 
 		memset(buf, 0, 384);
+		memset(i_buf, 0, PR_REG_ISID_ID_LEN);
 		tfo = pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo;
-		sprintf(buf, "%s Node: %s Key: 0x%016Lx PRgen: 0x%08x\n",
+		prf_isid = core_pr_dump_initiator_port(pr_reg, &i_buf[0],
+					PR_REG_ISID_ID_LEN);
+		sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n",
 			tfo->get_fabric_name(),
-			pr_reg->pr_reg_nacl->initiatorname,
-			pr_reg->pr_res_key, pr_reg->pr_res_generation);
+			pr_reg->pr_reg_nacl->initiatorname, (prf_isid) ?
+			&i_buf[0] : "", pr_reg->pr_res_key,
+			pr_reg->pr_res_generation);
 
 		if ((len + strlen(buf) > PAGE_SIZE))
 			break;
drivers/target/target_core_pr.c +241 -58

673 lines not on this page · raw message

include/target/target_core_base.h +4 -0
index 7b49640..e4a860a 100644
@@ -363,6 +363,7 @@ typedef struct t10_pr_registration_s {
 	u32 pr_res_mapped_lun;
 	u32 pr_aptpl_target_lun;
 	u32 pr_res_generation;
+	u64 pr_reg_bin_isid;
 	u64 pr_res_key;
 	atomic_t pr_res_holders;
 	struct se_node_acl_s *pr_reg_nacl;
@@ -725,6 +726,7 @@ typedef struct se_dev_attrib_s {
 	int		emulate_tas;
 	int		emulate_reservations;
 	int		emulate_alua;
+	int		enforce_pr_isids;
 	u32		hw_block_size;
 	u32		block_size;
 	u32		hw_max_sectors;
@@ -797,6 +799,8 @@ typedef struct se_device_s {
 	u32			dev_tcq_window_closed;
 	/* Physical device queue depth */
 	u32			queue_depth;
+	/* 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 */
include/target/target_core_pr.h +2 -0
index 0fe3ee8..4281ede 100644
@@ -45,6 +45,8 @@
 
 extern struct kmem_cache *t10_pr_reg_cache;
 
+extern int core_pr_dump_initiator_port(struct t10_pr_registration_s *,
+			char *, u32);
 extern int core_scsi2_emulate_crh(struct se_cmd_s *);
 extern int core_scsi3_alloc_aptpl_registration(
 			struct t10_reservation_template_s *, u64,
include/target/target_core_transport.h +1 -0
index 87eb748..a049053 100644
@@ -96,6 +96,7 @@
 #define DF_READ_ONLY				0x00000040
 #define DF_SPC3_PERSISTENT_RESERVE		0x00000080
 #define DF_SPC2_RESERVATIONS			0x00000100
+#define DF_SPC2_RESERVATIONS_WITH_ISID		0x00000200
 
 /* se_dev_attrib_t sanity values */
 /* 10 Minutes, see transport_get_default_task_timeout()  */
Signature · 1 line
1.5.6.5