All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] target: Move backend memory release to configfs_item_operations->release()
@ 2011-02-02  8:26 Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 1/4] target: Move core_delete_hba() into ->release() callback Nicholas A. Bellinger
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-02  8:26 UTC (permalink / raw)
  To: linux-scsi; +Cc: Christoph Hellwig, Joel Becker, Fubo Chen, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

Greetings all,

This series addresses four scenarios in backend HBA/DEV target_core_configfs.c
code where config_item_put() being called upon the following TCM config_groups:

	struct se_hba->hba_group

	struct se_subsystem_dev->se_dev_group

	struct t10_alua_lu_gp->lu_gp_group

	struct t10_alua_tg_pt_gp->tg_pt_gp_group

and subsequently releasing memory of these four parent TCM data structures
is causing a number of SLUB 'Poison overwritten' warnings during slub_debug=FPUZ
testing with .38-rc2 code.

This series addresses the issue by using moving existing release logic
of the parent structure containing a struct_config_group into it's own
seperate struct configfs_item_operations->release() callback.

Please review and comment,

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>

Nicholas Bellinger (4):
  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

 drivers/target/target_core_configfs.c |  114 +++++++++++++++++++++------------
 1 files changed, 73 insertions(+), 41 deletions(-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] target: Move core_delete_hba() into ->release() callback
  2011-02-02  8:26 [PATCH 0/4] target: Move backend memory release to configfs_item_operations->release() Nicholas A. Bellinger
@ 2011-02-02  8:26 ` Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 2/4] target: Move subdev release logic " Nicholas A. Bellinger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-02  8:26 UTC (permalink / raw)
  To: linux-scsi; +Cc: Christoph Hellwig, Joel Becker, Fubo Chen, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

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 <jlbec@evilplan.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_configfs.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 7d7dfbc..ccb5554 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2998,6 +2998,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,
@@ -3005,6 +3012,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,
 };
@@ -3081,10 +3089,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 = {
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] target: Move subdev release logic into ->release() callback
  2011-02-02  8:26 [PATCH 0/4] target: Move backend memory release to configfs_item_operations->release() Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 1/4] target: Move core_delete_hba() into ->release() callback Nicholas A. Bellinger
@ 2011-02-02  8:26 ` Nicholas A. Bellinger
  2011-02-03 19:48   ` Fubo Chen
  2011-02-02  8:26 ` [PATCH 3/4] target: Move core_alua_free_lu_gp() " Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 4/4] target: Move core_alua_free_tg_pt_gp() " Nicholas A. Bellinger
  3 siblings, 1 reply; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-02  8:26 UTC (permalink / raw)
  To: linux-scsi; +Cc: Christoph Hellwig, Joel Becker, Fubo Chen, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

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 <jlbec@evilplan.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_configfs.c |   64 ++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index ccb5554..3715c91 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2004,9 +2004,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,
@@ -2847,13 +2873,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, *dev_stat_grp;
-	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);
@@ -2884,38 +2908,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 = {
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] target: Move core_alua_free_lu_gp() into ->release() callback
  2011-02-02  8:26 [PATCH 0/4] target: Move backend memory release to configfs_item_operations->release() Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 1/4] target: Move core_delete_hba() into ->release() callback Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 2/4] target: Move subdev release logic " Nicholas A. Bellinger
@ 2011-02-02  8:26 ` Nicholas A. Bellinger
  2011-02-02  8:26 ` [PATCH 4/4] target: Move core_alua_free_tg_pt_gp() " Nicholas A. Bellinger
  3 siblings, 0 replies; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-02  8:26 UTC (permalink / raw)
  To: linux-scsi; +Cc: Christoph Hellwig, Joel Becker, Fubo Chen, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

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 <jlbec@evilplan.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_configfs.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 3715c91..3933409 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2195,7 +2195,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,
 };
@@ -2246,9 +2255,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 = {
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] target: Move core_alua_free_tg_pt_gp() into ->release() callback
  2011-02-02  8:26 [PATCH 0/4] target: Move backend memory release to configfs_item_operations->release() Nicholas A. Bellinger
                   ` (2 preceding siblings ...)
  2011-02-02  8:26 ` [PATCH 3/4] target: Move core_alua_free_lu_gp() " Nicholas A. Bellinger
@ 2011-02-02  8:26 ` Nicholas A. Bellinger
  3 siblings, 0 replies; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-02  8:26 UTC (permalink / raw)
  To: linux-scsi; +Cc: Christoph Hellwig, Joel Becker, Fubo Chen, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

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 <jlbec@evilplan.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_configfs.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 3933409..5be35b8 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2615,7 +2615,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,
 };
@@ -2668,9 +2677,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 = {
@@ -2910,7 +2921,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;
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] target: Move subdev release logic into ->release() callback
  2011-02-02  8:26 ` [PATCH 2/4] target: Move subdev release logic " Nicholas A. Bellinger
@ 2011-02-03 19:48   ` Fubo Chen
  2011-02-03 21:19     ` Nicholas A. Bellinger
  0 siblings, 1 reply; 9+ messages in thread
From: Fubo Chen @ 2011-02-03 19:48 UTC (permalink / raw)
  To: Nicholas A. Bellinger; +Cc: linux-scsi, Christoph Hellwig, Joel Becker

On Wed, Feb 2, 2011 at 9:26 AM, Nicholas A. Bellinger
<nab@linux-iscsi.org> wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> 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 <jlbec@evilplan.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
> ---
>  drivers/target/target_core_configfs.c |   64 ++++++++++++++++-----------------
>  1 files changed, 31 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index ccb5554..3715c91 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -2004,9 +2004,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,
> @@ -2847,13 +2873,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, *dev_stat_grp;
> -       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);
> @@ -2884,38 +2908,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 = {

Hello Nicholas,

How to apply this patch ? This is what I get:

# git diff v2.6.38-rc2 | wc
      0       0       0
# patch -p1 < ../p2.patch
patching file drivers/target/target_core_configfs.c
Hunk #1 FAILED at 2004.
Hunk #2 FAILED at 2847.
Hunk #3 succeeded at 2800 (offset -84 lines).
2 out of 3 hunks FAILED -- saving rejects to file
drivers/target/target_core_configfs.c.rej

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] target: Move subdev release logic into ->release() callback
  2011-02-03 19:48   ` Fubo Chen
@ 2011-02-03 21:19     ` Nicholas A. Bellinger
  2011-02-05  9:16       ` Fubo Chen
  0 siblings, 1 reply; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-03 21:19 UTC (permalink / raw)
  To: Fubo Chen; +Cc: linux-scsi, Christoph Hellwig, Joel Becker, James Bottomley

On Thu, 2011-02-03 at 20:48 +0100, Fubo Chen wrote:
> On Wed, Feb 2, 2011 at 9:26 AM, Nicholas A. Bellinger
> <nab@linux-iscsi.org> wrote:
> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> >
> > 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 <jlbec@evilplan.org>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
> > ---
> >  drivers/target/target_core_configfs.c |   64 ++++++++++++++++-----------------
> >  1 files changed, 31 insertions(+), 33 deletions(-)
> >
> > diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> > index ccb5554..3715c91 100644
> > --- a/drivers/target/target_core_configfs.c
> > +++ b/drivers/target/target_core_configfs.c
> > @@ -2004,9 +2004,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,
> > @@ -2847,13 +2873,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, *dev_stat_grp;
> > -       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);
> > @@ -2884,38 +2908,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 = {
> 
> Hello Nicholas,
> 
> How to apply this patch ? This is what I get:
> 
> # git diff v2.6.38-rc2 | wc
>       0       0       0
> # patch -p1 < ../p2.patch
> patching file drivers/target/target_core_configfs.c
> Hunk #1 FAILED at 2004.
> Hunk #2 FAILED at 2847.
> Hunk #3 succeeded at 2800 (offset -84 lines).
> 2 out of 3 hunks FAILED -- saving rejects to file
> drivers/target/target_core_configfs.c.rej
> 

Hi Fubo,

Note that these are all incremental patches against the LIO upstream
lio-core-2.6.git/linus-38-rc3 tree, and not against the mainline target
code.

If you really want to apply these by hand (you should really be using
git btw ;), then you will need to first apply the series of 24 patches
against .38-rc2 mainline target code from my
scsi-post-merge-2.6.git/for-38-rc3-v2 here:

http://marc.info/?l=linux-scsi&m=129632617326015&w=2

--nab


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] target: Move subdev release logic into ->release() callback
  2011-02-03 21:19     ` Nicholas A. Bellinger
@ 2011-02-05  9:16       ` Fubo Chen
  2011-02-05 23:18         ` Nicholas A. Bellinger
  0 siblings, 1 reply; 9+ messages in thread
From: Fubo Chen @ 2011-02-05  9:16 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: linux-scsi, Christoph Hellwig, Joel Becker, James Bottomley

On Thu, Feb 3, 2011 at 10:19 PM, Nicholas A. Bellinger
<nab@linux-iscsi.org> wrote:
> On Thu, 2011-02-03 at 20:48 +0100, Fubo Chen wrote:
>> On Wed, Feb 2, 2011 at 9:26 AM, Nicholas A. Bellinger
>> [ ... ]
>>
>> How to apply this patch ? This is what I get:
>>
>> # git diff v2.6.38-rc2 | wc
>>       0       0       0
>> # patch -p1 < ../p2.patch
>> patching file drivers/target/target_core_configfs.c
>> Hunk #1 FAILED at 2004.
>> Hunk #2 FAILED at 2847.
>> Hunk #3 succeeded at 2800 (offset -84 lines).
>> 2 out of 3 hunks FAILED -- saving rejects to file
>> drivers/target/target_core_configfs.c.rej
>>
>
> Hi Fubo,
>
> Note that these are all incremental patches against the LIO upstream
> lio-core-2.6.git/linus-38-rc3 tree, and not against the mainline target
> code.
>
> If you really want to apply these by hand (you should really be using
> git btw ;), then you will need to first apply the series of 24 patches
> against .38-rc2 mainline target code from my
> scsi-post-merge-2.6.git/for-38-rc3-v2 here:
>
> http://marc.info/?l=linux-scsi&m=129632617326015&w=2

Hi Nicholas,

How to use git ? With scsi-post-merge-2.6.git/for-38-rc3-v2, I get this:

$ git cherry-pick 31747a72e8d02ac2f9fa1198f2fceb9e565025a3
target: Fix top-level configfs_subsystem default_group shutdown breakage
 Author: Nicholas Bellinger <nab@linux-iscsi.org>
 1 files changed, 11 insertions(+), 9 deletions(-)

$ git cherry-pick ba20ac32737242678f1fa80efc92750334fe1720
target: Move core_delete_hba() into ->release() callback
 Author: Nicholas Bellinger <nab@linux-iscsi.org>
 1 files changed, 12 insertions(+), 3 deletions(-)

$ git cherry-pick dae431fdc82508ae37ea9bbaf071713d23224e4a
Automatic cherry-pick failed.  After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
and commit the result with:

        git commit -c dae431fdc82508ae37ea9bbaf071713d23224e4a

$ git diff
diff --cc drivers/target/target_core_configfs.c
index 9e74aa1,3715c91..0000000
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@@ -2798,8 -2872,8 +2824,13 @@@ static void target_core_drop_subdev
        struct se_hba *hba;
        struct se_subsystem_api *t;
        struct config_item *df_item;
++<<<<<<< HEAD
 +      struct config_group *dev_cg, *tg_pt_gp_cg;
 +      int i, ret;
++=======
+       struct config_group *dev_cg, *tg_pt_gp_cg, *dev_stat_grp;
+       int i;
++>>>>>>> dae431f... target: Move subdev release logic into ->release() callback

        hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item);

What does this mean ?

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] target: Move subdev release logic into ->release() callback
  2011-02-05  9:16       ` Fubo Chen
@ 2011-02-05 23:18         ` Nicholas A. Bellinger
  0 siblings, 0 replies; 9+ messages in thread
From: Nicholas A. Bellinger @ 2011-02-05 23:18 UTC (permalink / raw)
  To: Fubo Chen; +Cc: linux-scsi, Christoph Hellwig, Joel Becker, James Bottomley

On Sat, 2011-02-05 at 10:16 +0100, Fubo Chen wrote:
> On Thu, Feb 3, 2011 at 10:19 PM, Nicholas A. Bellinger
> <nab@linux-iscsi.org> wrote:
> > On Thu, 2011-02-03 at 20:48 +0100, Fubo Chen wrote:
> >> On Wed, Feb 2, 2011 at 9:26 AM, Nicholas A. Bellinger
> >> [ ... ]
> >>
> >> How to apply this patch ? This is what I get:
> >>
> >> # git diff v2.6.38-rc2 | wc
> >>       0       0       0
> >> # patch -p1 < ../p2.patch
> >> patching file drivers/target/target_core_configfs.c
> >> Hunk #1 FAILED at 2004.
> >> Hunk #2 FAILED at 2847.
> >> Hunk #3 succeeded at 2800 (offset -84 lines).
> >> 2 out of 3 hunks FAILED -- saving rejects to file
> >> drivers/target/target_core_configfs.c.rej
> >>
> >
> > Hi Fubo,
> >
> > Note that these are all incremental patches against the LIO upstream
> > lio-core-2.6.git/linus-38-rc3 tree, and not against the mainline target
> > code.
> >
> > If you really want to apply these by hand (you should really be using
> > git btw ;), then you will need to first apply the series of 24 patches
> > against .38-rc2 mainline target code from my
> > scsi-post-merge-2.6.git/for-38-rc3-v2 here:
> >
> > http://marc.info/?l=linux-scsi&m=129632617326015&w=2
> 
> Hi Nicholas,
> 
> How to use git ? With scsi-post-merge-2.6.git/for-38-rc3-v2, I get this:
> 

If you are using a linux kernel git tree, you want to be 'git pulling'
directly from the lio-core-2.6.git/linus-38-rc3 upstream code, and not
cherry-picking individual commits.

> $ git cherry-pick 31747a72e8d02ac2f9fa1198f2fceb9e565025a3
> target: Fix top-level configfs_subsystem default_group shutdown breakage
>  Author: Nicholas Bellinger <nab@linux-iscsi.org>
>  1 files changed, 11 insertions(+), 9 deletions(-)
> 
> $ git cherry-pick ba20ac32737242678f1fa80efc92750334fe1720
> target: Move core_delete_hba() into ->release() callback
>  Author: Nicholas Bellinger <nab@linux-iscsi.org>
>  1 files changed, 12 insertions(+), 3 deletions(-)
> 
> $ git cherry-pick dae431fdc82508ae37ea9bbaf071713d23224e4a
> Automatic cherry-pick failed.  After resolving the conflicts,
> mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
> and commit the result with:
> 
>         git commit -c dae431fdc82508ae37ea9bbaf071713d23224e4a
> 
> $ git diff
> diff --cc drivers/target/target_core_configfs.c
> index 9e74aa1,3715c91..0000000
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@@ -2798,8 -2872,8 +2824,13 @@@ static void target_core_drop_subdev
>         struct se_hba *hba;
>         struct se_subsystem_api *t;
>         struct config_item *df_item;
> ++<<<<<<< HEAD
>  +      struct config_group *dev_cg, *tg_pt_gp_cg;
>  +      int i, ret;
> ++=======
> +       struct config_group *dev_cg, *tg_pt_gp_cg, *dev_stat_grp;
> +       int i;
> ++>>>>>>> dae431f... target: Move subdev release logic into ->release() callback
> 
>         hba = item_to_hba(&se_dev->se_dev_hba->hba_group.cg_item);
> 
> What does this mean ?
> 

This means you tried to pick one of the 'for-mainline' target patches
from scsi-post-merge-2.6.git (these are intended for the SCSI maintainer
btw, please don't use them directly) into a local lio-core-2.6.git
cloned tree, yes..?

Please select the latter/bottom code from the two chunks above and
remove the git conflict placeholders.  Then make sure it builds as
expected w/o warnings, and resolve the conflicted cherry-picked commit
with:
	 
	git commit -c dae431fdc8

Once done, go ahead and pull directly from lio-core-2.6.git/linus-38-rc3
-> rcX branches directly to obtain LIO upstream code.

--nab



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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-02-05 23:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-02  8:26 [PATCH 0/4] target: Move backend memory release to configfs_item_operations->release() Nicholas A. Bellinger
2011-02-02  8:26 ` [PATCH 1/4] target: Move core_delete_hba() into ->release() callback Nicholas A. Bellinger
2011-02-02  8:26 ` [PATCH 2/4] target: Move subdev release logic " Nicholas A. Bellinger
2011-02-03 19:48   ` Fubo Chen
2011-02-03 21:19     ` Nicholas A. Bellinger
2011-02-05  9:16       ` Fubo Chen
2011-02-05 23:18         ` Nicholas A. Bellinger
2011-02-02  8:26 ` [PATCH 3/4] target: Move core_alua_free_lu_gp() " Nicholas A. Bellinger
2011-02-02  8:26 ` [PATCH 4/4] target: Move core_alua_free_tg_pt_gp() " Nicholas A. Bellinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.