diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-03-09 02:45:02 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-03-10 17:42:09 -0500 |
commit | afb999ffc48f5e7ec18e6f8f9e68aa3d0085862d (patch) | |
tree | 781a1055eaed8bef8148c95fa6f9e779484511c6 | |
parent | 01468346546a9bcc09035a7e8b71f78af5b7133a (diff) |
target: Add se_node_acl->acl_kref for ->acl_free_comp usage
This patch adds se_node_acl->acl_kref for use with ->acl_free_comp
during explict se_node_acl release. It adds kref_init() during
se_node_acl setup, kref_get() during __transport_register_session()
-> target_put_nacl() with existing transport_deregister_session()
fabric callback usage.
It also moves transport_free_session() to release *se_sess memory
after target_put_nacl() execution in transport_deregister_session()
Cc: Roland Dreier <roland@purestorage.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Joern Engel <joern@logfs.org>
Cc: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_tpg.c | 2 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 25 | ||||
-rw-r--r-- | include/target/target_core_base.h | 1 | ||||
-rw-r--r-- | include/target/target_core_fabric.h | 1 |
4 files changed, 24 insertions, 5 deletions
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 9cdfd061eacf..bbed260ec71f 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -274,6 +274,7 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( | |||
274 | 274 | ||
275 | INIT_LIST_HEAD(&acl->acl_list); | 275 | INIT_LIST_HEAD(&acl->acl_list); |
276 | INIT_LIST_HEAD(&acl->acl_sess_list); | 276 | INIT_LIST_HEAD(&acl->acl_sess_list); |
277 | kref_init(&acl->acl_kref); | ||
277 | init_completion(&acl->acl_free_comp); | 278 | init_completion(&acl->acl_free_comp); |
278 | spin_lock_init(&acl->device_list_lock); | 279 | spin_lock_init(&acl->device_list_lock); |
279 | spin_lock_init(&acl->nacl_sess_lock); | 280 | spin_lock_init(&acl->nacl_sess_lock); |
@@ -403,6 +404,7 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( | |||
403 | 404 | ||
404 | INIT_LIST_HEAD(&acl->acl_list); | 405 | INIT_LIST_HEAD(&acl->acl_list); |
405 | INIT_LIST_HEAD(&acl->acl_sess_list); | 406 | INIT_LIST_HEAD(&acl->acl_sess_list); |
407 | kref_init(&acl->acl_kref); | ||
406 | init_completion(&acl->acl_free_comp); | 408 | init_completion(&acl->acl_free_comp); |
407 | spin_lock_init(&acl->device_list_lock); | 409 | spin_lock_init(&acl->device_list_lock); |
408 | spin_lock_init(&acl->nacl_sess_lock); | 410 | spin_lock_init(&acl->nacl_sess_lock); |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 9e61abc5d9d3..efefbec286fc 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -282,6 +282,8 @@ void __transport_register_session( | |||
282 | &buf[0], PR_REG_ISID_LEN); | 282 | &buf[0], PR_REG_ISID_LEN); |
283 | se_sess->sess_bin_isid = get_unaligned_be64(&buf[0]); | 283 | se_sess->sess_bin_isid = get_unaligned_be64(&buf[0]); |
284 | } | 284 | } |
285 | kref_get(&se_nacl->acl_kref); | ||
286 | |||
285 | spin_lock_irq(&se_nacl->nacl_sess_lock); | 287 | spin_lock_irq(&se_nacl->nacl_sess_lock); |
286 | /* | 288 | /* |
287 | * The se_nacl->nacl_sess pointer will be set to the | 289 | * The se_nacl->nacl_sess pointer will be set to the |
@@ -335,6 +337,19 @@ int target_put_session(struct se_session *se_sess) | |||
335 | } | 337 | } |
336 | EXPORT_SYMBOL(target_put_session); | 338 | EXPORT_SYMBOL(target_put_session); |
337 | 339 | ||
340 | static void target_complete_nacl(struct kref *kref) | ||
341 | { | ||
342 | struct se_node_acl *nacl = container_of(kref, | ||
343 | struct se_node_acl, acl_kref); | ||
344 | |||
345 | complete(&nacl->acl_free_comp); | ||
346 | } | ||
347 | |||
348 | void target_put_nacl(struct se_node_acl *nacl) | ||
349 | { | ||
350 | kref_put(&nacl->acl_kref, target_complete_nacl); | ||
351 | } | ||
352 | |||
338 | void transport_deregister_session_configfs(struct se_session *se_sess) | 353 | void transport_deregister_session_configfs(struct se_session *se_sess) |
339 | { | 354 | { |
340 | struct se_node_acl *se_nacl; | 355 | struct se_node_acl *se_nacl; |
@@ -411,17 +426,17 @@ void transport_deregister_session(struct se_session *se_sess) | |||
411 | } | 426 | } |
412 | spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); | 427 | spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); |
413 | 428 | ||
414 | transport_free_session(se_sess); | ||
415 | |||
416 | pr_debug("TARGET_CORE[%s]: Deregistered fabric_sess\n", | 429 | pr_debug("TARGET_CORE[%s]: Deregistered fabric_sess\n", |
417 | se_tpg->se_tpg_tfo->get_fabric_name()); | 430 | se_tpg->se_tpg_tfo->get_fabric_name()); |
418 | /* | 431 | /* |
419 | * Awake sleeping ->acl_free_comp caller from configfs se_node_acl | 432 | * If last kref is dropping now for an explict NodeACL, awake sleeping |
420 | * removal context | 433 | * ->acl_free_comp caller to wakeup configfs se_node_acl->acl_group |
434 | * removal context. | ||
421 | */ | 435 | */ |
422 | if (se_nacl && comp_nacl == true) | 436 | if (se_nacl && comp_nacl == true) |
423 | complete(&se_nacl->acl_free_comp); | 437 | target_put_nacl(se_nacl); |
424 | 438 | ||
439 | transport_free_session(se_sess); | ||
425 | } | 440 | } |
426 | EXPORT_SYMBOL(transport_deregister_session); | 441 | EXPORT_SYMBOL(transport_deregister_session); |
427 | 442 | ||
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index f8aa300b0d25..2cda5638a4cc 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -642,6 +642,7 @@ struct se_node_acl { | |||
642 | struct list_head acl_list; | 642 | struct list_head acl_list; |
643 | struct list_head acl_sess_list; | 643 | struct list_head acl_sess_list; |
644 | struct completion acl_free_comp; | 644 | struct completion acl_free_comp; |
645 | struct kref acl_kref; | ||
645 | }; | 646 | }; |
646 | 647 | ||
647 | struct se_session { | 648 | struct se_session { |
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 7e76aa167009..032c48753cfa 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h | |||
@@ -108,6 +108,7 @@ void transport_register_session(struct se_portal_group *, | |||
108 | void target_get_session(struct se_session *); | 108 | void target_get_session(struct se_session *); |
109 | int target_put_session(struct se_session *); | 109 | int target_put_session(struct se_session *); |
110 | void transport_free_session(struct se_session *); | 110 | void transport_free_session(struct se_session *); |
111 | void target_put_nacl(struct se_node_acl *); | ||
111 | void transport_deregister_session_configfs(struct se_session *); | 112 | void transport_deregister_session_configfs(struct se_session *); |
112 | void transport_deregister_session(struct se_session *); | 113 | void transport_deregister_session(struct se_session *); |
113 | 114 | ||