Skip to contentSkip to conversation

: Move core se_port_t logic to target_core_device.c

PATCH New Nicholas A. Bellinger 1 participant 1 message Feb 2, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 : Move core se_port_t logic to target_core_device.c

Quoted 1 line

From 12ba78888935ebf41ee769f57aced3e3599c7a8c Mon Sep 17 00:00:00 2001

From: Nicholas Bellinger <[email protected]>
Date: Sun, 1 Feb 2009 21:29:03 -0800
Subject: [PATCH 1/4] [Target_Core_Mod]: Move core se_port_t logic to target_core_device.c

This patch adds core_alloc_port(), core_export_port() and core_release_port() and adds their usage in dev_obj_export() and dev_obj_unexport().

Also, in core_alloc_port() the RELATIVE TARGET PORT IDENTIFER gets set to a unique 16-bit value per se_device_t using se_device_t->dev_rpti_counter. This value now replaces previous SCSI MIB SCSI_PORT_INDEX usage with se_port_t->sep_rtpi for SCSI MIB se_port_t->sep_index value assignment.

Here is what it looks like with active LIO-Target v3.0 iSCSI Target ports, the RELATIVE TARGET PORT IDENTIFER is displayed under the port_index column:

The first two rows are for a single Target_Core_Mod/IBLOCK storage object that is exported across two different iSCSI Target Endports (TargetName+TPGT):

target:# cat /proc/scsi_target/mib/scsi_tgt_port
inst device indx name port_index in_cmds write_mbytes read_mbytes hs_in_cmds 1 1 0 iSCSIPort#0 iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0+t+1 20 0 0 0 1 1 1 iSCSIPort#1 iqn.2003-01.org.linux-iscsi.target.i686:sn.cff3eedbd2fd+t+1 9 0 0 0 2 2 0 iSCSIPort#0 iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0+t+1 0 0 0 0 3 3 0 iSCSIPort#0 iqn.2003-01.org.linux-iscsi.target.i686:sn.e475ed6fcdd0+t+1 0 0 0 0

---
 drivers/lio-core/target_core_base.h   |    4 +-
 drivers/lio-core/target_core_device.c |   66 +++++++++++++++++++++++++++++++++
 drivers/lio-core/target_core_device.h |    3 +
 drivers/lio-core/target_core_mib.h    |    1 -
 drivers/lio-core/target_core_seobj.c  |   33 +++-------------
 5 files changed, 78 insertions(+), 29 deletions(-)
drivers/lio-core/target_core_base.h +3 -1
index c900517..5e979ff 100644
@@ -536,7 +536,9 @@ typedef struct se_device_s {
 	u8			type;		/* Type of disk transport used for device */
 	u8			thread_active;	/* Set to 1 if thread is NOT sleeping on thread_sem */
 	u8			dev_status_timer_flags;
+	u16			dev_rpti_counter; /* RELATIVE TARGET PORT IDENTIFER Counter */
 	u32			dev_flags;
+	u32			dev_port_count;
 	u32			dev_status;
 	u32			dev_tcq_window_closed;
 	u32			queue_depth;	/* Physical device queue depth */
@@ -544,7 +546,6 @@ typedef struct se_device_s {
 	void 			*dev_ptr; 	/* Pointer to transport specific device structure */
 #ifdef SNMP_SUPPORT
 	u32			dev_index;
-	u32			dev_port_count;
 	u64			creation_time;
 	u32			num_resets;
 	u64			num_cmds;
@@ -653,6 +654,7 @@ typedef struct se_lun_s {
 #define LUN_OBJ_API(lun)	((struct se_obj_lun_type_s *)(lun)->lun_obj_api)
 
 typedef struct se_port_s {
+	u16		sep_rtpi; /* RELATIVE TARGET PORT IDENTIFER */
 #ifdef SNMP_SUPPORT
         u32             sep_index;
         scsi_port_stats_t sep_stats;
drivers/lio-core/target_core_device.c +66 -0

72 lines not on this page · raw message

drivers/lio-core/target_core_device.h +3 -0
index c2d4b12..eff0c0a 100644
@@ -40,6 +40,9 @@ extern void core_dec_lacl_count (struct se_node_acl_s *, struct se_cmd_s *);
 extern void core_update_device_list_access (u32, u32, se_node_acl_t *);
 extern void core_update_device_list_for_node (se_lun_t *lun, u32, u32, se_node_acl_t *, se_portal_group_t *, int);
 extern void core_clear_lun_from_tpg (se_lun_t *, se_portal_group_t *);
+extern struct se_port_s *core_alloc_port (struct se_device_s *);
+extern void core_export_port (struct se_device_s *, struct se_portal_group_s *, struct se_port_s *, struct se_lun_s *);
+extern void core_release_port (struct se_device_s *, struct se_port_s *);
 extern int transport_core_report_lun_response (se_cmd_t *);
 extern void se_release_device_for_hba (se_device_t *);
 extern void se_release_evpd_for_dev (se_device_t *);
drivers/lio-core/target_core_mib.h +0 -1
index d4a9d31..127d113 100644
@@ -30,7 +30,6 @@
 typedef enum {
 	SCSI_INST_INDEX,
 	SCSI_DEVICE_INDEX,
-	SCSI_PORT_INDEX,
 	SCSI_AUTH_INTR_INDEX,
 	SCSI_INDEX_TYPE_MAX
 } scsi_index_t;
drivers/lio-core/target_core_seobj.c +6 -27
index 182a016..643659c 100644
@@ -185,45 +185,28 @@ extern void dev_put_obj (void *p)
 extern int dev_obj_export (void *p, se_portal_group_t *tpg, se_lun_t *lun)
 {
 	se_device_t *dev  = (se_device_t *)p;
-	se_port_t *sep;
+	se_port_t *port;
 
-	if (!(sep = kmalloc(sizeof(se_port_t), GFP_KERNEL))) {
-		TRACE_ERROR("Unable to allocate se_port_t\n");
+	if (!(port = core_alloc_port(dev)))
 		return(-1);
-	}
-	memset(sep, 0, sizeof(se_port_t));
-	INIT_LIST_HEAD(&sep->sep_list);
 
 	lun->se_dev = dev;
 	if (DEV_OBJ_API(dev)->activate(p) < 0) {
 		lun->se_dev = NULL;
-		kfree(sep);
+		kfree(port);
 		return(-1);
 	}
 
 	DEV_OBJ_API(dev)->inc_count(&dev->dev_export_obj);
 
-	spin_lock(&dev->se_port_lock);
-	spin_lock(&lun->lun_sep_lock);
-	sep->sep_tpg = tpg;
-	sep->sep_lun = lun;
-	lun->lun_sep = sep;
-	spin_unlock(&lun->lun_sep_lock);
-
-	list_add_tail(&sep->sep_list, &dev->dev_sep_list);
-	spin_unlock(&dev->se_port_lock);
-#ifdef SNMP_SUPPORT
-	dev->dev_port_count++;
-	sep->sep_index = scsi_get_new_index(SCSI_PORT_INDEX);
-#endif
-
+	core_export_port(dev, tpg, port, lun);
 	return(0);
 }
 
 extern void dev_obj_unexport (void *p, se_portal_group_t *tpg, se_lun_t *lun)
 {
 	se_device_t *dev  = (se_device_t *)p;
-	se_port_t *sep = lun->lun_sep;
+	se_port_t *port = lun->lun_sep;
 
 	spin_lock(&dev->se_port_lock);
 	spin_lock(&lun->lun_sep_lock);
@@ -236,12 +219,8 @@ extern void dev_obj_unexport (void *p, se_portal_group_t *tpg, se_lun_t *lun)
 
 	DEV_OBJ_API(dev)->dec_count(&dev->dev_export_obj);
 
-	list_del(&sep->sep_list);
+	core_release_port(dev, port);
 	spin_unlock(&dev->se_port_lock);
-#ifdef SNMP_SUPPORT
-	dev->dev_port_count--;
-#endif  
-	kfree(sep);
 
 	DEV_OBJ_API(dev)->deactivate(p);
 	lun->se_dev = NULL;
Signature · 1 line
1.5.4.1