Skip to contentSkip to conversation

target: Updates for .38-rc4

PATCH New Nicholas A. Bellinger 1 participant 13 messages Feb 4, 2011

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

cover target: Updates for .38-rc4

From: Nicholas Bellinger <[email protected]>

Hi James and Co,

Please consider the following patch series for mainline target code. It consists of predominately configfs bugfixes uncovered with recent SLUB poison testing, and proper removal of legacy procfs target_core_mib.c code. Note that the complete set of fabric independent statistics (SCSI MIBs) and fabric dependent statistics will be included as native configfs group context 'per value' attribute series during the .39 time frame.

Note this series is expected to be applied on top of the 24 patch series from scsi-post-merge-2.6.git/for-38-rc3-v2 here:

[PATCH 00/24] target updates for .38-rc3 (v2)
http://marc.info/?l=linux-scsi&m=129632617326015&w=2

This patch series is against the following commit with the above series applied:

commit ebf53826e105f488f4f628703a108e98940d1dc5
Author: Linus Torvalds <[email protected]>
Date: Tue Feb 1 13:05:49 2011 +1000

       Linux 2.6.38-rc3

This series is also availible for a direct PULL from here:

git://git.kernel.org/pub/scm/linux/kernel/git/nab/scsi-post-merge-2.6.git for-38-rc4

Please review and apply for mainline.

Thanks!

Jesper Juhl (1):
target: Avoid mem leak and needless work in transport_generic_get_mem

Nicholas Bellinger (11):
target: Fix top-level configfs_subsystem default_group shutdown
breakage
target: Move core_delete_hba() into ->release() callback
target: Move subdev release logic into ->release() callback
target: Move core_alua_free_lu_gp() into ->release() callback
target: Move core_alua_free_tg_pt_gp() into ->release() callback
target: Move fabric dependent struct se_wwn free into ->release()
callback
target: Move fabric dependent se_portal_group free into ->release()
callback
target: Move fabric dependent se_node_acl free into ->release
callback()
target: Move fabric dependent struct se_tpg_np free into ->release()
callback
target: Move fabric independent se_lun_acl free into ->release()
callback
target: Remove procfs based target_core_mib.c code

 drivers/target/Makefile                      |    1 -
 drivers/target/target_core_configfs.c        |  149 ++--
 drivers/target/target_core_device.c          |    3 -
 drivers/target/target_core_fabric_configfs.c |   92 ++-
 drivers/target/target_core_hba.c             |    1 -
 drivers/target/target_core_mib.c             | 1098 --------------------------
 drivers/target/target_core_mib.h             |   21 -
 drivers/target/target_core_tpg.c             |   10 -
 drivers/target/target_core_transport.c       |   52 +-
 include/target/target_core_base.h            |   21 +-
 include/target/target_core_transport.h       |    2 +
 11 files changed, 207 insertions(+), 1243 deletions(-)
 delete mode 100644 drivers/target/target_core_mib.c
 delete mode 100644 drivers/target/target_core_mib.h
Signature · 1 line
1.7.4
#1 lore raw

PATCH 1/12 target: Avoid mem leak and needless work in transport_generic_get_mem

From: Jesper Juhl <[email protected]>

In drivers/target/target_core_transport.c::transport_generic_get_mem() there are a few potential memory leaks in the error paths. This patch makes sure that we free previously allocated memory when other allocations fail. It also moves some work (INIT_LIST_HEAD() and assignment to se_mem->se_len) below all the allocations so that if something fails we don't do the work at all.

---
 drivers/target/target_core_transport.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/target/target_core_transport.c +6 -3
index ddc1f7f..04f6115 100644
@@ -4333,11 +4333,9 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size)
 			printk(KERN_ERR "Unable to allocate struct se_mem\n");
 			goto out;
 		}
-		INIT_LIST_HEAD(&se_mem->se_list);
-		se_mem->se_len = (length > dma_size) ? dma_size : length;
 
 /* #warning FIXME Allocate contigous pages for struct se_mem elements */
-		se_mem->se_page = (struct page *) alloc_pages(GFP_KERNEL, 0);
+		se_mem->se_page = alloc_pages(GFP_KERNEL, 0);
 		if (!(se_mem->se_page)) {
 			printk(KERN_ERR "alloc_pages() failed\n");
 			goto out;
@@ -4348,6 +4346,8 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size)
 			printk(KERN_ERR "kmap_atomic() failed\n");
 			goto out;
 		}
+		INIT_LIST_HEAD(&se_mem->se_list);
+		se_mem->se_len = (length > dma_size) ? dma_size : length;
 		memset(buf, 0, se_mem->se_len);
 		kunmap_atomic(buf, KM_IRQ0);
 
@@ -4366,6 +4366,9 @@ transport_generic_get_mem(struct se_cmd *cmd, u32 length, u32 dma_size)
 
 	return 0;
 out:
+	if (se_mem)
+		__free_pages(se_mem->se_page, 0);
+	kmem_cache_free(se_mem_cache, se_mem);
 	return -1;
 }
 
Signature · 1 line
1.7.4
#2 lore raw

PATCH 2/12 target: Fix top-level configfs_subsystem default_group shutdown breakage

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch fixes two bugs uncovered during testing with slub_debug=FPUZ during module_exit() -> target_core_exit_configfs() with release of configfs subsystem consumer default groups, namely how this should be working with fs/configfs/dir.c:configfs_unregister_subsystem() release logic for struct config_group->default_group.

The first issue involves configfs_unregister_subsystem() expecting to walk+drain the top-level subsys->su_group.default_groups directly in unlink_group(), and not directly from the configfs subsystem consumer for the top level struct config_group->default_groups. This patch drops the walk+drain of subsys->su_group.default_groups from TCM configfs subsystem consumer code, and moves the top-level ->default_groups kfree() after configfs_unregister_subsystem() has been called.

The second issue involves calling core_alua_free_lu_gp(se_global->default_lu_gp) to release the default_lu_gp->lu_gp_group before configfs_unregister_subsystem() has been called. This patches also moves the core_alua_free_lu_gp() call to release default_lu_group->lu_gp_group after the subsys has been unregistered.

Finally, this patch explictly clears the [lu_gp,alua,hba]_cg->default_groups pointers after kfree() to ensure that no stale memory is picked up from child struct config_group->default_group[] while configfs_unregister_subsystem() is called.

---
 drivers/target/target_core_configfs.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
drivers/target/target_core_configfs.c +11 -9
index 30ae3af..431cd2e 100644
@@ -3206,8 +3206,7 @@ static void target_core_exit_configfs(void)
 		config_item_put(item);
 	}
 	kfree(lu_gp_cg->default_groups);
-	core_alua_free_lu_gp(se_global->default_lu_gp);
-	se_global->default_lu_gp = NULL;
+	lu_gp_cg->default_groups = NULL;
 
 	alua_cg = &se_global->alua_group;
 	for (i = 0; alua_cg->default_groups[i]; i++) {
@@ -3216,6 +3215,7 @@ static void target_core_exit_configfs(void)
 		config_item_put(item);
 	}
 	kfree(alua_cg->default_groups);
+	alua_cg->default_groups = NULL;
 
 	hba_cg = &se_global->target_core_hbagroup;
 	for (i = 0; hba_cg->default_groups[i]; i++) {
@@ -3224,15 +3224,17 @@ static void target_core_exit_configfs(void)
 		config_item_put(item);
 	}
 	kfree(hba_cg->default_groups);
-
-	for (i = 0; subsys->su_group.default_groups[i]; i++) {
-		item = &subsys->su_group.default_groups[i]->cg_item;
-		subsys->su_group.default_groups[i] = NULL;
-		config_item_put(item);
-	}
+	hba_cg->default_groups = NULL;
+	/*
+	 * We expect subsys->su_group.default_groups to be released
+	 * by configfs subsystem provider logic..
+	 */
+	configfs_unregister_subsystem(subsys);
 	kfree(subsys->su_group.default_groups);
 
-	configfs_unregister_subsystem(subsys);
+	core_alua_free_lu_gp(se_global->default_lu_gp);
+	se_global->default_lu_gp = NULL;
+
 	printk(KERN_INFO "TARGET_CORE[0]: Released ConfigFS Fabric"
 			" Infrastructure\n");
 
Signature · 1 line
1.7.4
#3 lore raw

PATCH 3/12 target: Move core_delete_hba() into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the core_delete_hba() call in target_core_call_delhbafromtarget() and subsequent release struct se_hba memory to inside of the configfs callback target_core_hba_item_ops->release() called from within fs/configfs/item.c:
config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning while calling core_delete_hba() -> kfree(hba) directly after config_item_put():

[ 1734.081444] =============================================================================
[ 1734.081635] BUG kmalloc-256: Poison overwritten
[ 1734.081635] -----------------------------------------------------------------------------
[ 1734.081635]
[ 1734.081635] INFO: 0xffff88000d290824-0xffff88000d290824. First byte 0x6a instead of 0x6b
[ 1734.081635] INFO: Allocated in core_alloc_hba+0x3a/0x231 [target_core_mod] age=3714 cpu=0 pid=11015
[ 1734.081635] INFO: Freed in core_delete_hba+0x8a/0x90 [target_core_mod] age=4 cpu=0 pid=11040
[ 1734.081635] INFO: Slab 0xffffea00002e0f80 objects=24 used=6 fp=0xffff88000d2907b0 flags=0x1000000000040c1
[ 1734.081635] INFO: Object 0xffff88000d2907b0 @offset=1968 fp=0xffff88000d290b88
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_configfs.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/target/target_core_configfs.c +12 -3
index 431cd2e..9e74aa1 100644
@@ -2942,6 +2942,13 @@ SE_HBA_ATTR(hba_mode, S_IRUGO | S_IWUSR);
 
 CONFIGFS_EATTR_OPS(target_core_hba, se_hba, hba_group);
 
+static void target_core_hba_release(struct config_item *item)
+{
+	struct se_hba *hba = container_of(to_config_group(item),
+				struct se_hba, hba_group);
+	core_delete_hba(hba);
+}
+
 static struct configfs_attribute *target_core_hba_attrs[] = {
 	&target_core_hba_hba_info.attr,
 	&target_core_hba_hba_mode.attr,
@@ -2949,6 +2956,7 @@ static struct configfs_attribute *target_core_hba_attrs[] = {
 };
 
 static struct configfs_item_operations target_core_hba_item_ops = {
+	.release		= target_core_hba_release,
 	.show_attribute		= target_core_hba_attr_show,
 	.store_attribute	= target_core_hba_attr_store,
 };
@@ -3025,10 +3033,11 @@ static void target_core_call_delhbafromtarget(
 	struct config_group *group,
 	struct config_item *item)
 {
-	struct se_hba *hba = item_to_hba(item);
-
+	/*
+	 * core_delete_hba() is called from target_core_hba_item_ops->release()
+	 * -> target_core_hba_release()
+	 */
 	config_item_put(item);
-	core_delete_hba(hba);
 }
 
 static struct configfs_group_operations target_core_group_ops = {
Signature · 1 line
1.7.4
#4 lore raw

PATCH 4/12 target: Move subdev release logic into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the se_free_virtual_device() / se_subsystem_api->free_device() and subsequent release of struct se_subsystem_dev memory to inside of the configfs callback target_core_dev_item_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling target_core_drop_subdev() -> kfree(se_dev) directly after config_item_put():

[ 5147.638639] =============================================================================
[ 5147.638959] BUG kmalloc-4096: Poison overwritten
[ 5147.639124] -----------------------------------------------------------------------------
[ 5147.639124]
[ 5147.639294] INFO: 0xffff88000d2f887c-0xffff88000d2f887c. First byte 0x6a instead of 0x6b
[ 5147.639294] INFO: Allocated in kzalloc+0xf/0x11 [target_core_mod] age=2602 cpu=0 pid=14639
[ 5147.639294] INFO: Freed in target_core_drop_subdev+0x18d/0x199 [target_core_mod] age=25 cpu=0 pid=14654
[ 5147.639294] INFO: Slab 0xffffea00002e2640 objects=7 used=1 fp=0xffff88000d2f8000 flags=0x1000000000040c1
[ 5147.639294] INFO: Object 0xffff88000d2f8000 @offset=0 fp=0xffff88000d2fb0d8
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_configfs.c |   64 ++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 33 deletions(-)
drivers/target/target_core_configfs.c +31 -33
index 9e74aa1..a9e0c66 100644
@@ -2003,9 +2003,35 @@ static void target_core_dev_release(struct config_item *item)
 {
 	struct se_subsystem_dev *se_dev = container_of(to_config_group(item),
 				struct se_subsystem_dev, se_dev_group);
+	struct se_hba *hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item);
+	struct se_subsystem_api *t = hba->transport;
 	struct config_group *dev_cg = &se_dev->se_dev_group;
 
 	kfree(dev_cg->default_groups);
+	/*
+	 * This pointer will set when the storage is enabled with:
+	 *`echo 1 > $CONFIGFS/core/$HBA/$DEV/dev_enable`
+	 */
+	if (se_dev->se_dev_ptr) {
+		printk(KERN_INFO "Target_Core_ConfigFS: Calling se_free_"
+			"virtual_device() for se_dev_ptr: %p\n",
+			se_dev->se_dev_ptr);
+
+		se_free_virtual_device(se_dev->se_dev_ptr, hba);
+	} else {
+		/*
+		 * Release struct se_subsystem_dev->se_dev_su_ptr..
+		 */
+		printk(KERN_INFO "Target_Core_ConfigFS: Calling t->free_"
+			"device() for se_dev_su_ptr: %p\n",
+			se_dev->se_dev_su_ptr);
+
+		t->free_device(se_dev->se_dev_su_ptr);
+	}
+
+	printk(KERN_INFO "Target_Core_ConfigFS: Deallocating se_subsystem"
+			"_dev_t: %p\n", se_dev);
+	kfree(se_dev);
 }
 
 static ssize_t target_core_dev_show(struct config_item *item,
@@ -2799,13 +2825,11 @@ static void target_core_drop_subdev(
 	struct se_subsystem_api *t;
 	struct config_item *df_item;
 	struct config_group *dev_cg, *tg_pt_gp_cg;
-	int i, ret;
+	int i;
 
 	hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item);
 
-	if (mutex_lock_interruptible(&hba->hba_access_mutex))
-		goto out;
-
+	mutex_lock(&hba->hba_access_mutex);
 	t = hba->transport;
 
 	spin_lock(&se_global->g_device_lock);
@@ -2828,38 +2852,12 @@ static void target_core_drop_subdev(
 		dev_cg->default_groups[i] = NULL;
 		config_item_put(df_item);
 	}
-
-	config_item_put(item);
 	/*
-	 * This pointer will set when the storage is enabled with:
-	 * `echo 1 > $CONFIGFS/core/$HBA/$DEV/dev_enable`
+	 * The releasing of se_dev and associated se_dev->se_dev_ptr is done
+	 * from target_core_dev_item_ops->release() ->target_core_dev_release().
 	 */
-	if (se_dev->se_dev_ptr) {
-		printk(KERN_INFO "Target_Core_ConfigFS: Calling se_free_"
-			"virtual_device() for se_dev_ptr: %p\n",
-				se_dev->se_dev_ptr);
-
-		ret = se_free_virtual_device(se_dev->se_dev_ptr, hba);
-		if (ret < 0)
-			goto hba_out;
-	} else {
-		/*
-		 * Release struct se_subsystem_dev->se_dev_su_ptr..
-		 */
-		printk(KERN_INFO "Target_Core_ConfigFS: Calling t->free_"
-			"device() for se_dev_su_ptr: %p\n",
-			se_dev->se_dev_su_ptr);
-
-		t->free_device(se_dev->se_dev_su_ptr);
-	}
-
-	printk(KERN_INFO "Target_Core_ConfigFS: Deallocating se_subsystem"
-		"_dev_t: %p\n", se_dev);
-
-hba_out:
+	config_item_put(item);
 	mutex_unlock(&hba->hba_access_mutex);
-out:
-	kfree(se_dev);
 }
 
 static struct configfs_group_operations target_core_hba_group_ops = {
Signature · 1 line
1.7.4
#5 lore raw

PATCH 5/12 target: Move core_alua_free_lu_gp() into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the core_alua_free_lu_gp() and subsequent release of struct t10_alua_lu_gp memory to inside of the configfs callback target_core_alua_lu_gp_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling core_alua_free_lu_gp() -> kfree(lu_gp) directly after config_item_put():

[  293.452366] =============================================================================
[  293.452653] BUG t10_alua_lu_gp_cache: Poison overwritten
[  293.452653] -----------------------------------------------------------------------------
[  293.452653]
[  293.452653] INFO: 0xffff88001f7c2174-0xffff88001f7c2174. First byte 0x6a instead of 0x6b
[  293.452653] INFO: Allocated in core_alua_allocate_lu_gp+0x1c/0xa0 [target_core_mod] age=1799 cpu=0 pid=5229
[  293.452653] INFO: Freed in core_alua_free_lu_gp+0x105/0x111 [target_core_mod] age=52 cpu=0 pid=5235
[  293.452653] INFO: Slab 0xffffea00006e3270 objects=25 used=0 fp=0xffff88001f7c2000 flags=0x100000000004080
[  293.452653] INFO: Object 0xffff88001f7c2140 @offset=320 fp=0xffff88001f7c2280
[  293.452653]
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_configfs.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
drivers/target/target_core_configfs.c +13 -2
index a9e0c66..a745101 100644
@@ -2194,7 +2194,16 @@ static struct configfs_attribute *target_core_alua_lu_gp_attrs[] = {
 	NULL,
 };
 
+static void target_core_alua_lu_gp_release(struct config_item *item)
+{
+	struct t10_alua_lu_gp *lu_gp = container_of(to_config_group(item),
+			struct t10_alua_lu_gp, lu_gp_group);
+
+	core_alua_free_lu_gp(lu_gp);
+}
+
 static struct configfs_item_operations target_core_alua_lu_gp_ops = {
+	.release		= target_core_alua_lu_gp_release,
 	.show_attribute		= target_core_alua_lu_gp_attr_show,
 	.store_attribute	= target_core_alua_lu_gp_attr_store,
 };
@@ -2245,9 +2254,11 @@ static void target_core_alua_drop_lu_gp(
 	printk(KERN_INFO "Target_Core_ConfigFS: Releasing ALUA Logical Unit"
 		" Group: core/alua/lu_gps/%s, ID: %hu\n",
 		config_item_name(item), lu_gp->lu_gp_id);
-
+	/*
+	 * core_alua_free_lu_gp() is called from target_core_alua_lu_gp_ops->release()
+	 * -> target_core_alua_lu_gp_release()
+	 */
 	config_item_put(item);
-	core_alua_free_lu_gp(lu_gp);
 }
 
 static struct configfs_group_operations target_core_alua_lu_gps_group_ops = {
Signature · 1 line
1.7.4
#6 lore raw

PATCH 6/12 target: Move core_alua_free_tg_pt_gp() into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the core_alua_free_tg_pt_gp() and subsequent release of struct t10_alua_tg_pt_gp memory to inside of the configfs callback target_core_alua_tg_pt_gp_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling core_alua_free_tg_pt_gp() -> kfree(tg_pt_gp) directly after config_item_put():

[10703.173250] =============================================================================
[10703.173250] BUG t10_alua_tg_pt_gp_cache: Poison overwritten
[10703.173250] -----------------------------------------------------------------------------
[10703.173250]
[10703.173250] INFO: 0xffff88001eb1637c-0xffff88001eb1637c. First byte 0x6a instead of 0x6b
[10703.173250] INFO: Allocated in core_alua_allocate_tg_pt_gp+0x21/0x126 [target_core_mod] age=2297 cpu=0 pid=21770
[10703.173250] INFO: Freed in core_alua_free_tg_pt_gp+0xf2/0xfe [target_core_mod] age=67 cpu=0 pid=21775
[10703.173250] INFO: Slab 0xffffea00006b6cd0 objects=21 used=0 fp=0xffff88001eb16000 flags=0x100000000004080
[10703.173250] INFO: Object 0xffff88001eb16300 @offset=768 fp=0xffff88001eb16480
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_configfs.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
drivers/target/target_core_configfs.c +17 -3
index a745101..53742bc 100644
@@ -2614,7 +2614,16 @@ static struct configfs_attribute *target_core_alua_tg_pt_gp_attrs[] = {
 	NULL,
 };
 
+static void target_core_alua_tg_pt_gp_release(struct config_item *item)
+{
+	struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(to_config_group(item),
+			struct t10_alua_tg_pt_gp, tg_pt_gp_group);
+
+	core_alua_free_tg_pt_gp(tg_pt_gp);
+}
+
 static struct configfs_item_operations target_core_alua_tg_pt_gp_ops = {
+	.release		= target_core_alua_tg_pt_gp_release,
 	.show_attribute		= target_core_alua_tg_pt_gp_attr_show,
 	.store_attribute	= target_core_alua_tg_pt_gp_attr_store,
 };
@@ -2667,9 +2676,11 @@ static void target_core_alua_drop_tg_pt_gp(
 	printk(KERN_INFO "Target_Core_ConfigFS: Releasing ALUA Target Port"
 		" Group: alua/tg_pt_gps/%s, ID: %hu\n",
 		config_item_name(item), tg_pt_gp->tg_pt_gp_id);
-
+	/*
+	 * core_alua_free_tg_pt_gp() is called from target_core_alua_tg_pt_gp_ops->release()
+	 * -> target_core_alua_tg_pt_gp_release().
+	 */
 	config_item_put(item);
-	core_alua_free_tg_pt_gp(tg_pt_gp);
 }
 
 static struct configfs_group_operations target_core_alua_tg_pt_gps_group_ops = {
@@ -2854,7 +2865,10 @@ static void target_core_drop_subdev(
 		config_item_put(df_item);
 	}
 	kfree(tg_pt_gp_cg->default_groups);
-	core_alua_free_tg_pt_gp(T10_ALUA(se_dev)->default_tg_pt_gp);
+	/*
+	 * core_alua_free_tg_pt_gp() is called from ->default_tg_pt_gp
+	 * directly from target_core_alua_tg_pt_gp_release().
+	 */
 	T10_ALUA(se_dev)->default_tg_pt_gp = NULL;
 
 	dev_cg = &se_dev->se_dev_group;
Signature · 1 line
1.7.4
#7 lore raw

PATCH 7/12 target: Move fabric dependent struct se_wwn free into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the struct target_core_fabric_ops->fabric_drop_wwn() callback and subsequent fabric dependent release of struct se_wwn memory to inside of the configfs callback target_fabric_tpg_item_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling tfc->fabric_drop_wwn() directly after config_item_put() for the fabric dependent data structure containing struct se_wwn->wwn_group:

[ 1327.103030] =============================================================================
[ 1327.103063] BUG kmalloc-2048: Poison overwritten
[ 1327.103063] -----------------------------------------------------------------------------
[ 1327.103063]
[ 1327.103063] INFO: 0xffff8800030c89ac-0xffff8800030c89ac. First byte 0x6a instead of 0x6b
[ 1327.103063] INFO: Allocated in kzalloc+0xf/0x11 [iscsi_target_mod] age=15782 cpu=0 pid=5838
[ 1327.103063] INFO: Freed in __core_del_tiqn+0x5e/0x65 [iscsi_target_mod] age=113 cpu=0 pid=5870
[ 1327.103063] INFO: Slab 0xffffea00000aabc0 objects=15 used=3 fp=0xffff8800030c8848 flags=0x1000000000040c1
[ 1327.103063] INFO: Object 0xffff8800030c8848 @offset=2120 fp=0xffff8800030c8000
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_fabric_configfs.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
drivers/target/target_core_fabric_configfs.c +15 -7
index 32b148d..1ef3783 100644
@@ -893,12 +893,26 @@ static void target_fabric_drop_tpg(
 	tf->tf_ops.fabric_drop_tpg(se_tpg);
 }
 
+static void target_fabric_release_wwn(struct config_item *item)
+{
+	struct se_wwn *wwn = container_of(to_config_group(item),
+				struct se_wwn, wwn_group);
+	struct target_fabric_configfs *tf = wwn->wwn_tf;
+
+	tf->tf_ops.fabric_drop_wwn(wwn);
+}
+
+static struct configfs_item_operations target_fabric_tpg_item_ops = {
+	.release	= target_fabric_release_wwn,
+};
+
 static struct configfs_group_operations target_fabric_tpg_group_ops = {
 	.make_group	= target_fabric_make_tpg,
 	.drop_item	= target_fabric_drop_tpg,
 };
 
-TF_CIT_SETUP(tpg, NULL, &target_fabric_tpg_group_ops, NULL);
+TF_CIT_SETUP(tpg, &target_fabric_tpg_item_ops, &target_fabric_tpg_group_ops,
+		NULL);
 
 /* End of tfc_tpg_cit */
 
@@ -932,13 +946,7 @@ static void target_fabric_drop_wwn(
 	struct config_group *group,
 	struct config_item *item)
 {
-	struct target_fabric_configfs *tf = container_of(group,
-				struct target_fabric_configfs, tf_group);
-	struct se_wwn *wwn = container_of(to_config_group(item),
-				struct se_wwn, wwn_group);
-
 	config_item_put(item);
-	tf->tf_ops.fabric_drop_wwn(wwn);
 }
 
 static struct configfs_group_operations target_fabric_wwn_group_ops = {
Signature · 1 line
1.7.4
#8 lore raw

PATCH 8/12 target: Move fabric dependent se_portal_group free into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the struct target_core_fabric_ops->fabric_drop_tpg() callback and subsequent fabric dependent release of struct se_portal_group memory to inside of the configfs callback target_fabric_tpg_base_item_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling tfc->fabric_drop_tpg() directly after config_item_put() for the fabric dependent data structure containing struct se_portal_group->tpg_group:

[ 2283.331123] =============================================================================
[ 2283.331282] BUG lio_tpg_cache: Poison overwritten
[ 2283.331282] -----------------------------------------------------------------------------
[ 2283.331282]
[ 2283.331282] INFO: 0xffff880001e48b7c-0xffff880001e48b7c. First byte 0x6a instead of 0x6b
[ 2283.331282] INFO: Allocated in core_alloc_portal_group+0x24/0x102 [iscsi_target_mod] age=48820 cpu=0 pid=8220
[ 2283.331282] INFO: Freed in iscsi_tpg_del_portal_group+0x290/0x2a1 [iscsi_target_mod] age=34618 cpu=0 pid=8266
[ 2283.331282] INFO: Slab 0xffffea0000069fc0 objects=16 used=0 fp=0xffff880001e48000 flags=0x100000000004080
[ 2283.331282] INFO: Object 0xffff880001e487c0 @offset=1984 fp=0xffff880001e48f80
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_fabric_configfs.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
drivers/target/target_core_fabric_configfs.c +11 -3
index 1ef3783..225284d 100644
@@ -814,7 +814,18 @@ TF_CIT_SETUP(tpg_param, &target_fabric_tpg_param_item_ops, NULL, NULL);
  */
 CONFIGFS_EATTR_OPS(target_fabric_tpg, se_portal_group, tpg_group);
 
+static void target_fabric_tpg_release(struct config_item *item)
+{
+	struct se_portal_group *se_tpg = container_of(to_config_group(item),
+			struct se_portal_group, tpg_group);
+	struct se_wwn *wwn = se_tpg->se_tpg_wwn;
+	struct target_fabric_configfs *tf = wwn->wwn_tf;
+
+	tf->tf_ops.fabric_drop_tpg(se_tpg);
+}
+
 static struct configfs_item_operations target_fabric_tpg_base_item_ops = {
+	.release		= target_fabric_tpg_release,
 	.show_attribute		= target_fabric_tpg_attr_show,
 	.store_attribute	= target_fabric_tpg_attr_store,
 };
@@ -872,8 +883,6 @@ static void target_fabric_drop_tpg(
 	struct config_group *group,
 	struct config_item *item)
 {
-	struct se_wwn *wwn = container_of(group, struct se_wwn, wwn_group);
-	struct target_fabric_configfs *tf = wwn->wwn_tf;
 	struct se_portal_group *se_tpg = container_of(to_config_group(item),
 				struct se_portal_group, tpg_group);
 	struct config_group *tpg_cg = &se_tpg->tpg_group;
@@ -890,7 +899,6 @@ static void target_fabric_drop_tpg(
 	}
 
 	config_item_put(item);
-	tf->tf_ops.fabric_drop_tpg(se_tpg);
 }
 
 static void target_fabric_release_wwn(struct config_item *item)
Signature · 1 line
1.7.4
#9 lore raw

PATCH 9/12 target: Move fabric dependent se_node_acl free into ->release callback()

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the struct target_core_fabric_ops->fabric_drop_nodeacl() callback and subsequent fabric dependent release of struct se_node_acl memory to the configfs callback target_fabric_nacl_base_item_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling tfc->fabric_drop_node_acl() directly after config_item_put() for the fabric dependent data structure containing struct se_node_acl->acl_group:

[ 2500.148656] =============================================================================
[ 2500.148656] BUG kmalloc-2048: Poison overwritten
[ 2500.148656] -----------------------------------------------------------------------------
[ 2500.148656]
[ 2500.148656] INFO: 0xffff880001e6a6f4-0xffff880001e6a6f4. First byte 0x6a instead of 0x6b
[ 2500.148656] INFO: Allocated in 0xffffffffa02b9e55 age=265456 cpu=0 pid=8233
[ 2500.148656] INFO: Freed in 0xffffffffa02c8f9b age=251652 cpu=0 pid=8244
[ 2500.148656] INFO: Slab 0xffffea000006a6c0 objects=15 used=5 fp=0xffff880001e6a120 flags=0x1000000000040c1
[ 2500.148656] INFO: Object 0xffff880001e6a120 @offset=8480 fp=0xffff880001e698d8
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_fabric_configfs.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/target/target_core_fabric_configfs.c +14 -5
index 225284d..dfa3267 100644
@@ -345,7 +345,18 @@ static void target_fabric_drop_mappedlun(
 	core_dev_free_initiator_node_lun_acl(se_tpg, lacl);
 }
 
+static void target_fabric_nacl_base_release(struct config_item *item)
+{
+	struct se_node_acl *se_nacl = container_of(to_config_group(item),
+			struct se_node_acl, acl_group);
+	struct se_portal_group *se_tpg = se_nacl->se_tpg;
+	struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
+
+	tf->tf_ops.fabric_drop_nodeacl(se_nacl);
+}
+
 static struct configfs_item_operations target_fabric_nacl_base_item_ops = {
+	.release		= target_fabric_nacl_base_release,
 	.show_attribute		= target_fabric_nacl_base_attr_show,
 	.store_attribute	= target_fabric_nacl_base_attr_store,
 };
@@ -404,9 +415,6 @@ static void target_fabric_drop_nodeacl(
 	struct config_group *group,
 	struct config_item *item)
 {
-	struct se_portal_group *se_tpg = container_of(group,
-			struct se_portal_group, tpg_acl_group);
-	struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
 	struct se_node_acl *se_nacl = container_of(to_config_group(item),
 			struct se_node_acl, acl_group);
 	struct config_item *df_item;
@@ -419,9 +427,10 @@ static void target_fabric_drop_nodeacl(
 		nacl_cg->default_groups[i] = NULL;
 		config_item_put(df_item);
 	}
-
+	/*
+	 * struct se_node_acl free is done in target_fabric_nacl_base_release()
+	 */
 	config_item_put(item);
-	tf->tf_ops.fabric_drop_nodeacl(se_nacl);
 }
 
 static struct configfs_group_operations target_fabric_nacl_group_ops = {
Signature · 1 line
1.7.4
#10 lore raw

PATCH 10/12 target: Move fabric dependent struct se_tpg_np free into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the struct target_core_fabric_ops->fabric_drop_np() callback and subsequent fabric dependent release of struct se_tpg_np memory to the configfs callback target_fabric_np_base_item_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling tfc->fabric_drop_np() directly after config_item_put() for the fabric dependent data structure containing struct se_tpg_np->tpg_np_group:

[ 3967.988931] =============================================================================
[ 3967.989501] BUG kmalloc-512: Poison overwritten
[ 3967.989692] -----------------------------------------------------------------------------
[ 3967.989692]
[ 3967.989692] INFO: 0xffff880012255524-0xffff880012255524. First byte 0x6a instead of 0x6b
[ 3967.989692] INFO: Allocated in kzalloc+0xf/0x11 [iscsi_target_mod] age=6769 cpu=0 pid=9702
[ 3967.989692] INFO: Freed in iscsi_tpg_del_network_portal+0x18e/0x205 [iscsi_target_mod] age=7 cpu=0 pid=9723
[ 3967.989692] INFO: Slab 0xffffea00003f8260 objects=28 used=12 fp=0xffff880012255488 flags=0x1000000000040c1
[ 3967.989692] INFO: Object 0xffff880012255488 @offset=5256 fp=0xffff880012255b60
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_fabric_configfs.c |   22 +++++++++++++++-------
 include/target/target_core_base.h            |    1 +
 2 files changed, 16 insertions(+), 7 deletions(-)
drivers/target/target_core_fabric_configfs.c +15 -7
index dfa3267..9b6dd20 100644
@@ -446,7 +446,18 @@ TF_CIT_SETUP(tpg_nacl, NULL, &target_fabric_nacl_group_ops, NULL);
 
 CONFIGFS_EATTR_OPS(target_fabric_np_base, se_tpg_np, tpg_np_group);
 
+static void target_fabric_np_base_release(struct config_item *item)
+{
+	struct se_tpg_np *se_tpg_np = container_of(to_config_group(item),
+				struct se_tpg_np, tpg_np_group);
+	struct se_portal_group *se_tpg = se_tpg_np->tpg_np_parent;
+	struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
+
+	tf->tf_ops.fabric_drop_np(se_tpg_np);
+}
+
 static struct configfs_item_operations target_fabric_np_base_item_ops = {
+	.release		= target_fabric_np_base_release,
 	.show_attribute		= target_fabric_np_base_attr_show,
 	.store_attribute	= target_fabric_np_base_attr_store,
 };
@@ -475,6 +486,7 @@ static struct config_group *target_fabric_make_np(
 	if (!(se_tpg_np) || IS_ERR(se_tpg_np))
 		return ERR_PTR(-EINVAL);
 
+	se_tpg_np->tpg_np_parent = se_tpg;
 	config_group_init_type_name(&se_tpg_np->tpg_np_group, name,
 			&TF_CIT_TMPL(tf)->tfc_tpg_np_base_cit);
 
@@ -485,14 +497,10 @@ static void target_fabric_drop_np(
 	struct config_group *group,
 	struct config_item *item)
 {
-	struct se_portal_group *se_tpg = container_of(group,
-				struct se_portal_group, tpg_np_group);
-	struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
-	struct se_tpg_np *se_tpg_np = container_of(to_config_group(item),
-				struct se_tpg_np, tpg_np_group);
-
+	/*
+	 * struct se_tpg_np is released via target_fabric_np_base_release()
+	 */
 	config_item_put(item);
-	tf->tf_ops.fabric_drop_np(se_tpg_np);
 }
 
 static struct configfs_group_operations target_fabric_np_group_ops = {
include/target/target_core_base.h +1 -0
index 574bafd..b638eae 100644
@@ -873,6 +873,7 @@ struct se_port {
 } ____cacheline_aligned;
 
 struct se_tpg_np {
+	struct se_portal_group *tpg_np_parent;
 	struct config_group	tpg_np_group;
 } ____cacheline_aligned;
 
Signature · 1 line
1.7.4
#11 lore raw

PATCH 11/12 target: Move fabric independent se_lun_acl free into ->release() callback

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch moves the call for core_dev_free_initiator_node_lun_acl() and subsequent release of fabric independent struct se_lun_acl memory to inside of the configfs callback target_fabric_mappedlun_item_ops->release() called from within fs/configfs/item.c:config_item_cleanup() context. This patch resolves the following SLUB 'Poison overwritten' warning when calling core_dev_free_initiator_node_lun_acl() directly after config_item_put() for the fabric independent struct se_lun_acl->se_lun_group:

[ 3968.067934] =============================================================================
[ 3968.068257] BUG kmalloc-1024: Poison overwritten
[ 3968.068423] -----------------------------------------------------------------------------
[ 3968.068424]
[ 3968.068844] INFO: 0xffff88001ac5b8cc-0xffff88001ac5b8cc. First byte 0x6a instead of 0x6b
[ 3968.068844] INFO: Allocated in kzalloc+0xf/0x11 [target_core_mod] age=6749 cpu=0 pid=9707
[ 3968.068844] INFO: Freed in core_dev_free_initiator_node_lun_acl+0x6b/0x77 [target_core_mod] age=2 cpu=0 pid=9725
[ 3968.068844] INFO: Slab 0xffffea00005db340 objects=29 used=10 fp=0xffff88001ac5b7a8 flags=0x1000000000040c1
[ 3968.068844] INFO: Object 0xffff88001ac5b7a8 @offset=14248 fp=0xffff88001ac5c8c8
Cc Joel Becker <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 drivers/target/target_core_fabric_configfs.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
drivers/target/target_core_fabric_configfs.c +10 -5
index 9b6dd20..b65d1c8 100644
@@ -214,12 +214,22 @@ TCM_MAPPEDLUN_ATTR(write_protect, S_IRUGO | S_IWUSR);
 
 CONFIGFS_EATTR_OPS(target_fabric_mappedlun, se_lun_acl, se_lun_group);
 
+static void target_fabric_mappedlun_release(struct config_item *item)
+{
+	struct se_lun_acl *lacl = container_of(to_config_group(item),
+				struct se_lun_acl, se_lun_group);
+	struct se_portal_group *se_tpg = lacl->se_lun_nacl->se_tpg;
+
+	core_dev_free_initiator_node_lun_acl(se_tpg, lacl);
+}
+
 static struct configfs_attribute *target_fabric_mappedlun_attrs[] = {
 	&target_fabric_mappedlun_write_protect.attr,
 	NULL,
 };
 
 static struct configfs_item_operations target_fabric_mappedlun_item_ops = {
+	.release		= target_fabric_mappedlun_release,
 	.show_attribute		= target_fabric_mappedlun_attr_show,
 	.store_attribute	= target_fabric_mappedlun_attr_store,
 	.allow_link		= target_fabric_mappedlun_link,
@@ -337,12 +347,7 @@ static void target_fabric_drop_mappedlun(
 	struct config_group *group,
 	struct config_item *item)
 {
-	struct se_lun_acl *lacl = container_of(to_config_group(item),
-			struct se_lun_acl, se_lun_group);
-	struct se_portal_group *se_tpg = lacl->se_lun_nacl->se_tpg;
-
 	config_item_put(item);
-	core_dev_free_initiator_node_lun_acl(se_tpg, lacl);
 }
 
 static void target_fabric_nacl_base_release(struct config_item *item)
Signature · 1 line
1.7.4
#12 lore raw

PATCH 12/12 target: Remove procfs based target_core_mib.c code

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch removes the legacy procfs based target_core_mib.c code, and moves the necessary scsi_index_tables functions and defines into target_core_transport.c and target_core_base.h code to allow existing fabric independent statistics to function.

This includes the removal of a handful of 'atomic_t mib_ref_count' counters used in struct se_node_acl, se_session and se_hba to prevent removal while using seq_list procfs walking logic.

(cherry picked from commit f22fab6bcd803aa26c2dc3e19561cbfab8328173)
---
 drivers/target/Makefile                |    1 -
 drivers/target/target_core_configfs.c  |   15 -
 drivers/target/target_core_device.c    |    3 -
 drivers/target/target_core_hba.c       |    1 -
 drivers/target/target_core_mib.c       | 1098 --------------------------------
 drivers/target/target_core_mib.h       |   21 -
 drivers/target/target_core_tpg.c       |   10 -
 drivers/target/target_core_transport.c |   43 +-
 include/target/target_core_base.h      |   20 +-
 include/target/target_core_transport.h |    2 +
 10 files changed, 51 insertions(+), 1163 deletions(-)
 delete mode 100644 drivers/target/target_core_mib.c
 delete mode 100644 drivers/target/target_core_mib.h
drivers/target/Makefile +0 -1
index ab3b40f..7a46d0e 100644
@@ -13,7 +13,6 @@ target_core_mod-y		:= target_core_configfs.o \
 				   target_core_cdb.o \
 				   target_core_ua.o \
 				   target_core_rd.o \
-				   target_core_mib.o
 
 obj-$(CONFIG_TARGET_CORE)	+= target_core_mod.o
 
drivers/target/target_core_configfs.c +0 -15
index 53742bc..955c051 100644
@@ -51,7 +51,6 @@
 #include "target_core_hba.h"
 #include "target_core_pr.h"
 #include "target_core_rd.h"
-#include "target_core_mib.h"
 
 static struct list_head g_tf_list;
 static struct mutex g_tf_lock;
@@ -3082,7 +3081,6 @@ static int target_core_init_configfs(void)
 	struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL;
 	struct config_group *lu_gp_cg = NULL;
 	struct configfs_subsystem *subsys;
-	struct proc_dir_entry *scsi_target_proc = NULL;
 	struct t10_alua_lu_gp *lu_gp;
 	int ret;
 
@@ -3188,21 +3186,10 @@ static int target_core_init_configfs(void)
 	if (core_dev_setup_virtual_lun0() < 0)
 		goto out;
 
-	scsi_target_proc = proc_mkdir("scsi_target", NULL);
-	if (!(scsi_target_proc)) {
-		printk(KERN_ERR "proc_mkdir(scsi_target, 0) failed\n");
-		goto out;
-	}
-	ret = init_scsi_target_mib();
-	if (ret < 0)
-		goto out;
-
 	return 0;
 
 out:
 	configfs_unregister_subsystem(subsys);
-	if (scsi_target_proc)
-		remove_proc_entry("scsi_target", NULL);
 	core_dev_release_virtual_lun0();
 	rd_module_exit();
 out_global:
@@ -3270,8 +3257,6 @@ static void target_core_exit_configfs(void)
 	printk(KERN_INFO "TARGET_CORE[0]: Released ConfigFS Fabric"
 			" Infrastructure\n");
 
-	remove_scsi_target_mib();
-	remove_proc_entry("scsi_target", NULL);
 	core_dev_release_virtual_lun0();
 	rd_module_exit();
 	release_se_global();
drivers/target/target_core_device.c +0 -3
index 9cd87fd..5d7bfc6 100644
@@ -829,9 +829,6 @@ static void se_dev_stop(struct se_device *dev)
 		}
 	}
 	spin_unlock(&hba->device_lock);
-
-	while (atomic_read(&hba->dev_mib_access_count))
-		cpu_relax();
 }
 
 int se_dev_check_online(struct se_device *dev)
drivers/target/target_core_hba.c +0 -1
index cc8fa05..d0d2ecc 100644
@@ -43,7 +43,6 @@
 #include <target/target_core_transport.h>
 
 #include "target_core_hba.h"
-#include "target_core_mib.h"
 
 static LIST_HEAD(subsystem_list);
 static DEFINE_MUTEX(subsystem_mutex);
drivers/target/target_core_mib.c deleted +0 -1098

1,098 lines not on this page · raw message

drivers/target/target_core_mib.h deleted +0 -21
deleted file mode 100644
index 5172674..0000000
@@ -1,21 +0,0 @@
-#ifndef TARGET_CORE_MIB_H
-#define TARGET_CORE_MIB_H
-
-typedef enum {
-	SCSI_INST_INDEX,
-	SCSI_DEVICE_INDEX,
-	SCSI_AUTH_INTR_INDEX,
-	SCSI_INDEX_TYPE_MAX
-} scsi_index_t;
-
-struct scsi_index_table {
-	spinlock_t	lock;
-	u32 		scsi_mib_index[SCSI_INDEX_TYPE_MAX];
-} ____cacheline_aligned;
-
-extern int init_scsi_target_mib(void);
-extern void remove_scsi_target_mib(void);
-extern void init_scsi_index_table(void);
-extern u32 scsi_get_new_index(scsi_index_t);
-
-#endif   /*** TARGET_CORE_MIB_H ***/
drivers/target/target_core_tpg.c +0 -10
index 1f69be1..c26f674 100644
@@ -45,7 +45,6 @@
 #include <target/target_core_fabric_ops.h>
 
 #include "target_core_hba.h"
-#include "target_core_mib.h"
 
 /*	core_clear_initiator_node_from_tpg():
  *
@@ -276,7 +275,6 @@ struct se_node_acl *core_tpg_check_initiator_node_acl(
 	spin_lock_init(&acl->device_list_lock);
 	spin_lock_init(&acl->nacl_sess_lock);
 	atomic_set(&acl->acl_pr_ref_count, 0);
-	atomic_set(&acl->mib_ref_count, 0);
 	acl->queue_depth = TPG_TFO(tpg)->tpg_get_default_depth(tpg);
 	snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname);
 	acl->se_tpg = tpg;
@@ -319,12 +317,6 @@ void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *nacl)
 		cpu_relax();
 }
 
-void core_tpg_wait_for_mib_ref(struct se_node_acl *nacl)
-{
-	while (atomic_read(&nacl->mib_ref_count) != 0)
-		cpu_relax();
-}
-
 void core_tpg_clear_object_luns(struct se_portal_group *tpg)
 {
 	int i, ret;
@@ -481,7 +473,6 @@ int core_tpg_del_initiator_node_acl(
 	spin_unlock_bh(&tpg->session_lock);
 
 	core_tpg_wait_for_nacl_pr_ref(acl);
-	core_tpg_wait_for_mib_ref(acl);
 	core_clear_initiator_node_from_tpg(acl, tpg);
 	core_free_device_list_for_node(acl, tpg);
 
@@ -730,7 +721,6 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
 		spin_unlock_bh(&se_tpg->acl_node_lock);
 
 		core_tpg_wait_for_nacl_pr_ref(nacl);
-		core_tpg_wait_for_mib_ref(nacl);
 		core_free_device_list_for_node(nacl, se_tpg);
 		TPG_TFO(se_tpg)->tpg_release_fabric_acl(se_tpg, nacl);
 
drivers/target/target_core_transport.c +34 -9

73 lines not on this page · raw message

include/target/target_core_base.h +15 -5
index b638eae..56f2168 100644
@@ -201,6 +201,21 @@ typedef enum {
 	SAM_TASK_ATTR_EMULATED
 } t10_task_attr_index_t;
 
+/*
+ * Used for target SCSI statistics
+ */
+typedef enum {
+	SCSI_INST_INDEX,
+	SCSI_DEVICE_INDEX,
+	SCSI_AUTH_INTR_INDEX,
+	SCSI_INDEX_TYPE_MAX
+} scsi_index_t;
+
+struct scsi_index_table {
+	spinlock_t	lock;
+	u32		scsi_mib_index[SCSI_INDEX_TYPE_MAX];
+} ____cacheline_aligned;
+
 struct se_cmd;
 
 struct t10_alua {
@@ -584,8 +599,6 @@ struct se_node_acl {
 	spinlock_t		stats_lock;
 	/* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
 	atomic_t		acl_pr_ref_count;
-	/* Used for MIB access */
-	atomic_t		mib_ref_count;
 	struct se_dev_entry	*device_list;
 	struct se_session	*nacl_sess;
 	struct se_portal_group *se_tpg;
@@ -601,8 +614,6 @@ struct se_node_acl {
 } ____cacheline_aligned;
 
 struct se_session {
-	/* Used for MIB access */
-	atomic_t		mib_ref_count;
 	u64			sess_bin_isid;
 	struct se_node_acl	*se_node_acl;
 	struct se_portal_group *se_tpg;
@@ -812,7 +823,6 @@ struct se_hba {
 	/* Virtual iSCSI devices attached. */
 	u32			dev_count;
 	u32			hba_index;
-	atomic_t		dev_mib_access_count;
 	atomic_t		load_balance_queue;
 	atomic_t		left_queue_depth;
 	/* Maximum queue depth the HBA can handle. */
include/target/target_core_transport.h +2 -0
index feaf5d4..96e13e7 100644
@@ -113,6 +113,8 @@ extern struct kmem_cache *se_mem_cache;
 
 extern int init_se_global(void);
 extern void release_se_global(void);
+extern void init_scsi_index_table(void);
+extern u32 scsi_get_new_index(scsi_index_t);
 extern void transport_init_queue_obj(struct se_queue_obj *);
 extern int transport_subsystem_check_init(void);
 extern int transport_subsystem_register(struct se_subsystem_api *);
Signature · 1 line
1.7.4