Move fabric configfs memory release to configfs_item_operations->release()
Subsystems (2)
cover Move fabric configfs memory release to configfs_item_operations->release()
From: Nicholas Bellinger <[email protected]>
Greetings all,
This followup series addresses five scenarios in generic target_core_fabric_configfs.c code where config_item_put() being called upon the following fabric groups with struct configfs_group_operations->drop_item() directly releasing struct config_group memory is causing a number of SLUB 'Poison overwritten' warnings during testing with .38-rc2.
struct se_wwn->wwn_group struct se_portal_group->tpg_group struct se_node_acl->acl_group struct se_tpg_np->tpg_np_group struct se_lun_acl->se_lun_group
As with the earlier series, these patches address the issue by using moving existing release logic of the parent structures containing a struct config_group into their own seperate struct configfs_item_operations->release() callbacks.
The first four patches are for struct target_core_fabric_ops cases where se_wwn, se_portal_group, se_node_acl and se_tpg_np memory is presented from target fabric module memory. The fifth patch is for struct se_lun_acl memory which is internal to target_core_fabric_configfs.c and not accessed directly by target fabric module code.
These patches resolve the existing slub_debug=FPUZ warnings/errors that I have encountered with generic /sys/kernel/config/target/$FABRIC_MOD ops, so please test, review and comment.
Thanks!
Nicholas Bellinger (5):
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
drivers/target/target_core_fabric_configfs.c | 93 +++++++++++++++++++------- include/target/target_core_base.h | 1 + 2 files changed, 69 insertions(+), 25 deletions(-)
PATCH 1/5 target: Move fabric dependent struct se_wwn free into ->release() callback
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
--- drivers/target/target_core_fabric_configfs.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
drivers/target/target_core_fabric_configfs.c +15 -7
@@ -1042,12 +1042,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 */
@@ -1081,13 +1095,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.5.6.5
PATCH 2/5 target: Move fabric dependent se_portal_group free into ->release() callback
In reply to Nicholas A. BellingerFrom: 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
--- drivers/target/target_core_fabric_configfs.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
drivers/target/target_core_fabric_configfs.c +11 -3
@@ -963,7 +963,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, };
@@ -1021,8 +1032,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;
@@ -1039,7 +1048,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.5.6.5
PATCH 3/5 target: Move fabric dependent se_node_acl free into ->release callback()
In reply to Nicholas A. BellingerFrom: 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
--- drivers/target/target_core_fabric_configfs.c | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/target/target_core_fabric_configfs.c +14 -5
@@ -419,7 +419,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, };
@@ -478,9 +489,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;
@@ -493,9 +501,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.5.6.5
PATCH 4/5 target: Move fabric dependent struct se_tpg_np free into ->release() callback
In reply to Nicholas A. BellingerFrom: 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
--- 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
@@ -520,7 +520,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, };
@@ -549,6 +560,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);
@@ -559,14 +571,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
@@ -901,6 +901,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.5.6.5
PATCH 5/5 target: Move fabric independent se_lun_acl free into ->release() callback
In reply to Nicholas A. BellingerFrom: 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
--- drivers/target/target_core_fabric_configfs.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/target/target_core_fabric_configfs.c +13 -3
@@ -215,12 +215,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,
@@ -394,7 +404,6 @@ static void target_fabric_drop_mappedlun( {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;struct config_item *df_item;struct config_group *lacl_cg =NULL , *ml_stat_grp =NULL ;int i;
@@ -414,9 +423,10 @@ static void target_fabric_drop_mappedlun(config_item_put (df_item); }kfree (lacl_cg->default_groups); - +/* +* struct se_lun_acl memory is released by target_fabric_mappedlun_release() +*/ 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.5.6.5