diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-03-10 17:32:52 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-03-10 17:41:59 -0500 |
commit | 01468346546a9bcc09035a7e8b71f78af5b7133a (patch) | |
tree | 5d7b69d10a2fb7e7f34717531fd099cae24f8044 /drivers/target | |
parent | 41ac82b668177876d5965d5f60956fb0fbcdb514 (diff) |
target: Add se_node_acl->acl_free_comp for NodeACL release path
Add se_node_acl->acl_free_comp for NodeACL release path to wait for outstanding
fabric session shutdown to complete in transport_deregister_session() before
finishing NodeACL release from configfs process context.
Also make transport_deregister_session() clear the comp_nacl bit
to skip se_node_acl->acl_free_comp completion for dynamically generated
NodeACL during fabric session shutdown.
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>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_tpg.c | 2 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 40 |
2 files changed, 26 insertions, 16 deletions
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 32153404da1..9cdfd061eac 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 | init_completion(&acl->acl_free_comp); | ||
277 | spin_lock_init(&acl->device_list_lock); | 278 | spin_lock_init(&acl->device_list_lock); |
278 | spin_lock_init(&acl->nacl_sess_lock); | 279 | spin_lock_init(&acl->nacl_sess_lock); |
279 | atomic_set(&acl->acl_pr_ref_count, 0); | 280 | atomic_set(&acl->acl_pr_ref_count, 0); |
@@ -402,6 +403,7 @@ struct se_node_acl *core_tpg_add_initiator_node_acl( | |||
402 | 403 | ||
403 | INIT_LIST_HEAD(&acl->acl_list); | 404 | INIT_LIST_HEAD(&acl->acl_list); |
404 | INIT_LIST_HEAD(&acl->acl_sess_list); | 405 | INIT_LIST_HEAD(&acl->acl_sess_list); |
406 | init_completion(&acl->acl_free_comp); | ||
405 | spin_lock_init(&acl->device_list_lock); | 407 | spin_lock_init(&acl->device_list_lock); |
406 | spin_lock_init(&acl->nacl_sess_lock); | 408 | spin_lock_init(&acl->nacl_sess_lock); |
407 | atomic_set(&acl->acl_pr_ref_count, 0); | 409 | atomic_set(&acl->acl_pr_ref_count, 0); |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 7badc87e4bb..9e61abc5d9d 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -372,13 +372,16 @@ EXPORT_SYMBOL(transport_free_session); | |||
372 | void transport_deregister_session(struct se_session *se_sess) | 372 | void transport_deregister_session(struct se_session *se_sess) |
373 | { | 373 | { |
374 | struct se_portal_group *se_tpg = se_sess->se_tpg; | 374 | struct se_portal_group *se_tpg = se_sess->se_tpg; |
375 | struct target_core_fabric_ops *se_tfo; | ||
375 | struct se_node_acl *se_nacl; | 376 | struct se_node_acl *se_nacl; |
376 | unsigned long flags; | 377 | unsigned long flags; |
378 | bool comp_nacl = true; | ||
377 | 379 | ||
378 | if (!se_tpg) { | 380 | if (!se_tpg) { |
379 | transport_free_session(se_sess); | 381 | transport_free_session(se_sess); |
380 | return; | 382 | return; |
381 | } | 383 | } |
384 | se_tfo = se_tpg->se_tpg_tfo; | ||
382 | 385 | ||
383 | spin_lock_irqsave(&se_tpg->session_lock, flags); | 386 | spin_lock_irqsave(&se_tpg->session_lock, flags); |
384 | list_del(&se_sess->sess_list); | 387 | list_del(&se_sess->sess_list); |
@@ -391,29 +394,34 @@ void transport_deregister_session(struct se_session *se_sess) | |||
391 | * struct se_node_acl if it had been previously dynamically generated. | 394 | * struct se_node_acl if it had been previously dynamically generated. |
392 | */ | 395 | */ |
393 | se_nacl = se_sess->se_node_acl; | 396 | se_nacl = se_sess->se_node_acl; |
394 | if (se_nacl) { | 397 | |
395 | spin_lock_irqsave(&se_tpg->acl_node_lock, flags); | 398 | spin_lock_irqsave(&se_tpg->acl_node_lock, flags); |
396 | if (se_nacl->dynamic_node_acl) { | 399 | if (se_nacl && se_nacl->dynamic_node_acl) { |
397 | if (!se_tpg->se_tpg_tfo->tpg_check_demo_mode_cache( | 400 | if (!se_tfo->tpg_check_demo_mode_cache(se_tpg)) { |
398 | se_tpg)) { | 401 | list_del(&se_nacl->acl_list); |
399 | list_del(&se_nacl->acl_list); | 402 | se_tpg->num_node_acls--; |
400 | se_tpg->num_node_acls--; | 403 | spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); |
401 | spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); | 404 | core_tpg_wait_for_nacl_pr_ref(se_nacl); |
402 | 405 | core_free_device_list_for_node(se_nacl, se_tpg); | |
403 | core_tpg_wait_for_nacl_pr_ref(se_nacl); | 406 | se_tfo->tpg_release_fabric_acl(se_tpg, se_nacl); |
404 | core_free_device_list_for_node(se_nacl, se_tpg); | 407 | |
405 | se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, | 408 | comp_nacl = false; |
406 | se_nacl); | 409 | spin_lock_irqsave(&se_tpg->acl_node_lock, flags); |
407 | spin_lock_irqsave(&se_tpg->acl_node_lock, flags); | ||
408 | } | ||
409 | } | 410 | } |
410 | spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); | ||
411 | } | 411 | } |
412 | spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); | ||
412 | 413 | ||
413 | transport_free_session(se_sess); | 414 | transport_free_session(se_sess); |
414 | 415 | ||
415 | pr_debug("TARGET_CORE[%s]: Deregistered fabric_sess\n", | 416 | pr_debug("TARGET_CORE[%s]: Deregistered fabric_sess\n", |
416 | se_tpg->se_tpg_tfo->get_fabric_name()); | 417 | se_tpg->se_tpg_tfo->get_fabric_name()); |
418 | /* | ||
419 | * Awake sleeping ->acl_free_comp caller from configfs se_node_acl | ||
420 | * removal context | ||
421 | */ | ||
422 | if (se_nacl && comp_nacl == true) | ||
423 | complete(&se_nacl->acl_free_comp); | ||
424 | |||
417 | } | 425 | } |
418 | EXPORT_SYMBOL(transport_deregister_session); | 426 | EXPORT_SYMBOL(transport_deregister_session); |
419 | 427 | ||