aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2013-11-07 00:05:19 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2013-11-07 17:25:02 -0500
commit4a9a6c8d538eff6d627fa14409c7c25aff652541 (patch)
treedded7528c07556c7b666e8c4351ca0eeb9097c3d /drivers
parent5277797dc4ed873d067477d84e910b39d113f649 (diff)
target: Drop left-over se_lun->lun_cmd_list shutdown code
Now with percpu refcounting for se_lun in place, go ahead and drop the legacy per se_cmd accounting for se_lun shutdown. This includes __transport_clear_lun_from_sessions(), the associated transport_lun_wait_for_tasks() logic, along with a handful of now unused se_cmd structure members and ->transport_state bits. Cc: Kent Overstreet <kmo@daterainc.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c10
-rw-r--r--drivers/target/target_core_tpg.c15
-rw-r--r--drivers/target/target_core_transport.c219
-rw-r--r--drivers/target/target_core_xcopy.c2
4 files changed, 4 insertions, 242 deletions
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 653ac6bfc57a..16087966cb7d 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1352,11 +1352,8 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
1352 1352
1353 /* XXX(hch): this is a horrible layering violation.. */ 1353 /* XXX(hch): this is a horrible layering violation.. */
1354 spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags); 1354 spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags);
1355 ioctx->cmd.transport_state |= CMD_T_LUN_STOP;
1356 ioctx->cmd.transport_state &= ~CMD_T_ACTIVE; 1355 ioctx->cmd.transport_state &= ~CMD_T_ACTIVE;
1357 spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags); 1356 spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags);
1358
1359 complete(&ioctx->cmd.transport_lun_stop_comp);
1360 break; 1357 break;
1361 case SRPT_STATE_CMD_RSP_SENT: 1358 case SRPT_STATE_CMD_RSP_SENT:
1362 /* 1359 /*
@@ -1364,9 +1361,6 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
1364 * not been received in time. 1361 * not been received in time.
1365 */ 1362 */
1366 srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx); 1363 srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx);
1367 spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags);
1368 ioctx->cmd.transport_state |= CMD_T_LUN_STOP;
1369 spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags);
1370 target_put_sess_cmd(ioctx->ch->sess, &ioctx->cmd); 1364 target_put_sess_cmd(ioctx->ch->sess, &ioctx->cmd);
1371 break; 1365 break;
1372 case SRPT_STATE_MGMT_RSP_SENT: 1366 case SRPT_STATE_MGMT_RSP_SENT:
@@ -1476,7 +1470,6 @@ static void srpt_handle_rdma_err_comp(struct srpt_rdma_ch *ch,
1476{ 1470{
1477 struct se_cmd *cmd; 1471 struct se_cmd *cmd;
1478 enum srpt_command_state state; 1472 enum srpt_command_state state;
1479 unsigned long flags;
1480 1473
1481 cmd = &ioctx->cmd; 1474 cmd = &ioctx->cmd;
1482 state = srpt_get_cmd_state(ioctx); 1475 state = srpt_get_cmd_state(ioctx);
@@ -1496,9 +1489,6 @@ static void srpt_handle_rdma_err_comp(struct srpt_rdma_ch *ch,
1496 __func__, __LINE__, state); 1489 __func__, __LINE__, state);
1497 break; 1490 break;
1498 case SRPT_RDMA_WRITE_LAST: 1491 case SRPT_RDMA_WRITE_LAST:
1499 spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags);
1500 ioctx->cmd.transport_state |= CMD_T_LUN_STOP;
1501 spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags);
1502 break; 1492 break;
1503 default: 1493 default:
1504 printk(KERN_ERR "%s[%d]: opcode = %u\n", __func__, 1494 printk(KERN_ERR "%s[%d]: opcode = %u\n", __func__,
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index f321af04ef03..f697f8baec54 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -654,9 +654,7 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
654 atomic_set(&lun->lun_acl_count, 0); 654 atomic_set(&lun->lun_acl_count, 0);
655 init_completion(&lun->lun_shutdown_comp); 655 init_completion(&lun->lun_shutdown_comp);
656 INIT_LIST_HEAD(&lun->lun_acl_list); 656 INIT_LIST_HEAD(&lun->lun_acl_list);
657 INIT_LIST_HEAD(&lun->lun_cmd_list);
658 spin_lock_init(&lun->lun_acl_lock); 657 spin_lock_init(&lun->lun_acl_lock);
659 spin_lock_init(&lun->lun_cmd_lock);
660 spin_lock_init(&lun->lun_sep_lock); 658 spin_lock_init(&lun->lun_sep_lock);
661 init_completion(&lun->lun_ref_comp); 659 init_completion(&lun->lun_ref_comp);
662 660
@@ -706,9 +704,7 @@ int core_tpg_register(
706 atomic_set(&lun->lun_acl_count, 0); 704 atomic_set(&lun->lun_acl_count, 0);
707 init_completion(&lun->lun_shutdown_comp); 705 init_completion(&lun->lun_shutdown_comp);
708 INIT_LIST_HEAD(&lun->lun_acl_list); 706 INIT_LIST_HEAD(&lun->lun_acl_list);
709 INIT_LIST_HEAD(&lun->lun_cmd_list);
710 spin_lock_init(&lun->lun_acl_lock); 707 spin_lock_init(&lun->lun_acl_lock);
711 spin_lock_init(&lun->lun_cmd_lock);
712 spin_lock_init(&lun->lun_sep_lock); 708 spin_lock_init(&lun->lun_sep_lock);
713 init_completion(&lun->lun_ref_comp); 709 init_completion(&lun->lun_ref_comp);
714 } 710 }
@@ -849,14 +845,6 @@ int core_tpg_post_addlun(
849 return 0; 845 return 0;
850} 846}
851 847
852static void core_tpg_shutdown_lun(
853 struct se_portal_group *tpg,
854 struct se_lun *lun)
855{
856 core_clear_lun_from_tpg(lun, tpg);
857 transport_clear_lun_ref(lun);
858}
859
860struct se_lun *core_tpg_pre_dellun( 848struct se_lun *core_tpg_pre_dellun(
861 struct se_portal_group *tpg, 849 struct se_portal_group *tpg,
862 u32 unpacked_lun) 850 u32 unpacked_lun)
@@ -891,7 +879,8 @@ int core_tpg_post_dellun(
891 struct se_portal_group *tpg, 879 struct se_portal_group *tpg,
892 struct se_lun *lun) 880 struct se_lun *lun)
893{ 881{
894 core_tpg_shutdown_lun(tpg, lun); 882 core_clear_lun_from_tpg(lun, tpg);
883 transport_clear_lun_ref(lun);
895 884
896 core_dev_unexport(lun->lun_se_dev, tpg, lun); 885 core_dev_unexport(lun->lun_se_dev, tpg, lun);
897 886
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index ad143d7293ec..e0669ac9278b 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -505,23 +505,6 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
505 if (write_pending) 505 if (write_pending)
506 cmd->t_state = TRANSPORT_WRITE_PENDING; 506 cmd->t_state = TRANSPORT_WRITE_PENDING;
507 507
508 /*
509 * Determine if IOCTL context caller in requesting the stopping of this
510 * command for LUN shutdown purposes.
511 */
512 if (cmd->transport_state & CMD_T_LUN_STOP) {
513 pr_debug("%s:%d CMD_T_LUN_STOP for ITT: 0x%08x\n",
514 __func__, __LINE__, cmd->se_tfo->get_task_tag(cmd));
515
516 cmd->transport_state &= ~CMD_T_ACTIVE;
517 if (remove_from_lists)
518 target_remove_from_state_list(cmd);
519 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
520
521 complete(&cmd->transport_lun_stop_comp);
522 return 1;
523 }
524
525 if (remove_from_lists) { 508 if (remove_from_lists) {
526 target_remove_from_state_list(cmd); 509 target_remove_from_state_list(cmd);
527 510
@@ -1078,13 +1061,10 @@ void transport_init_se_cmd(
1078 int task_attr, 1061 int task_attr,
1079 unsigned char *sense_buffer) 1062 unsigned char *sense_buffer)
1080{ 1063{
1081 INIT_LIST_HEAD(&cmd->se_lun_node);
1082 INIT_LIST_HEAD(&cmd->se_delayed_node); 1064 INIT_LIST_HEAD(&cmd->se_delayed_node);
1083 INIT_LIST_HEAD(&cmd->se_qf_node); 1065 INIT_LIST_HEAD(&cmd->se_qf_node);
1084 INIT_LIST_HEAD(&cmd->se_cmd_list); 1066 INIT_LIST_HEAD(&cmd->se_cmd_list);
1085 INIT_LIST_HEAD(&cmd->state_list); 1067 INIT_LIST_HEAD(&cmd->state_list);
1086 init_completion(&cmd->transport_lun_fe_stop_comp);
1087 init_completion(&cmd->transport_lun_stop_comp);
1088 init_completion(&cmd->t_transport_stop_comp); 1068 init_completion(&cmd->t_transport_stop_comp);
1089 init_completion(&cmd->cmd_wait_comp); 1069 init_completion(&cmd->cmd_wait_comp);
1090 init_completion(&cmd->task_stop_comp); 1070 init_completion(&cmd->task_stop_comp);
@@ -1705,29 +1685,14 @@ void target_execute_cmd(struct se_cmd *cmd)
1705 /* 1685 /*
1706 * If the received CDB has aleady been aborted stop processing it here. 1686 * If the received CDB has aleady been aborted stop processing it here.
1707 */ 1687 */
1708 if (transport_check_aborted_status(cmd, 1)) { 1688 if (transport_check_aborted_status(cmd, 1))
1709 complete(&cmd->transport_lun_stop_comp);
1710 return; 1689 return;
1711 }
1712 1690
1713 /* 1691 /*
1714 * Determine if IOCTL context caller in requesting the stopping of this
1715 * command for LUN shutdown purposes.
1716 */
1717 spin_lock_irq(&cmd->t_state_lock);
1718 if (cmd->transport_state & CMD_T_LUN_STOP) {
1719 pr_debug("%s:%d CMD_T_LUN_STOP for ITT: 0x%08x\n",
1720 __func__, __LINE__, cmd->se_tfo->get_task_tag(cmd));
1721
1722 cmd->transport_state &= ~CMD_T_ACTIVE;
1723 spin_unlock_irq(&cmd->t_state_lock);
1724 complete(&cmd->transport_lun_stop_comp);
1725 return;
1726 }
1727 /*
1728 * Determine if frontend context caller is requesting the stopping of 1692 * Determine if frontend context caller is requesting the stopping of
1729 * this command for frontend exceptions. 1693 * this command for frontend exceptions.
1730 */ 1694 */
1695 spin_lock_irq(&cmd->t_state_lock);
1731 if (cmd->transport_state & CMD_T_STOP) { 1696 if (cmd->transport_state & CMD_T_STOP) {
1732 pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08x\n", 1697 pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08x\n",
1733 __func__, __LINE__, 1698 __func__, __LINE__,
@@ -2390,149 +2355,6 @@ void target_wait_for_sess_cmds(struct se_session *se_sess)
2390} 2355}
2391EXPORT_SYMBOL(target_wait_for_sess_cmds); 2356EXPORT_SYMBOL(target_wait_for_sess_cmds);
2392 2357
2393/* transport_lun_wait_for_tasks():
2394 *
2395 * Called from ConfigFS context to stop the passed struct se_cmd to allow
2396 * an struct se_lun to be successfully shutdown.
2397 */
2398static int transport_lun_wait_for_tasks(struct se_cmd *cmd, struct se_lun *lun)
2399{
2400 unsigned long flags;
2401 int ret = 0;
2402
2403 /*
2404 * If the frontend has already requested this struct se_cmd to
2405 * be stopped, we can safely ignore this struct se_cmd.
2406 */
2407 spin_lock_irqsave(&cmd->t_state_lock, flags);
2408 if (cmd->transport_state & CMD_T_STOP) {
2409 cmd->transport_state &= ~CMD_T_LUN_STOP;
2410
2411 pr_debug("ConfigFS ITT[0x%08x] - CMD_T_STOP, skipping\n",
2412 cmd->se_tfo->get_task_tag(cmd));
2413 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2414 transport_cmd_check_stop(cmd, false, false);
2415 return -EPERM;
2416 }
2417 cmd->transport_state |= CMD_T_LUN_FE_STOP;
2418 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2419
2420 // XXX: audit task_flags checks.
2421 spin_lock_irqsave(&cmd->t_state_lock, flags);
2422 if ((cmd->transport_state & CMD_T_BUSY) &&
2423 (cmd->transport_state & CMD_T_SENT)) {
2424 if (!target_stop_cmd(cmd, &flags))
2425 ret++;
2426 }
2427 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2428
2429 pr_debug("ConfigFS: cmd: %p stop tasks ret:"
2430 " %d\n", cmd, ret);
2431 if (!ret) {
2432 pr_debug("ConfigFS: ITT[0x%08x] - stopping cmd....\n",
2433 cmd->se_tfo->get_task_tag(cmd));
2434 wait_for_completion(&cmd->transport_lun_stop_comp);
2435 pr_debug("ConfigFS: ITT[0x%08x] - stopped cmd....\n",
2436 cmd->se_tfo->get_task_tag(cmd));
2437 }
2438
2439 return 0;
2440}
2441
2442static void __transport_clear_lun_from_sessions(struct se_lun *lun)
2443{
2444 struct se_cmd *cmd = NULL;
2445 unsigned long lun_flags, cmd_flags;
2446 /*
2447 * Do exception processing and return CHECK_CONDITION status to the
2448 * Initiator Port.
2449 */
2450 spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
2451 while (!list_empty(&lun->lun_cmd_list)) {
2452 cmd = list_first_entry(&lun->lun_cmd_list,
2453 struct se_cmd, se_lun_node);
2454 list_del_init(&cmd->se_lun_node);
2455
2456 spin_lock(&cmd->t_state_lock);
2457 pr_debug("SE_LUN[%d] - Setting cmd->transport"
2458 "_lun_stop for ITT: 0x%08x\n",
2459 cmd->se_lun->unpacked_lun,
2460 cmd->se_tfo->get_task_tag(cmd));
2461 cmd->transport_state |= CMD_T_LUN_STOP;
2462 spin_unlock(&cmd->t_state_lock);
2463
2464 spin_unlock_irqrestore(&lun->lun_cmd_lock, lun_flags);
2465
2466 if (!cmd->se_lun) {
2467 pr_err("ITT: 0x%08x, [i,t]_state: %u/%u\n",
2468 cmd->se_tfo->get_task_tag(cmd),
2469 cmd->se_tfo->get_cmd_state(cmd), cmd->t_state);
2470 BUG();
2471 }
2472 /*
2473 * If the Storage engine still owns the iscsi_cmd_t, determine
2474 * and/or stop its context.
2475 */
2476 pr_debug("SE_LUN[%d] - ITT: 0x%08x before transport"
2477 "_lun_wait_for_tasks()\n", cmd->se_lun->unpacked_lun,
2478 cmd->se_tfo->get_task_tag(cmd));
2479
2480 if (transport_lun_wait_for_tasks(cmd, cmd->se_lun) < 0) {
2481 spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
2482 continue;
2483 }
2484
2485 pr_debug("SE_LUN[%d] - ITT: 0x%08x after transport_lun"
2486 "_wait_for_tasks(): SUCCESS\n",
2487 cmd->se_lun->unpacked_lun,
2488 cmd->se_tfo->get_task_tag(cmd));
2489
2490 spin_lock_irqsave(&cmd->t_state_lock, cmd_flags);
2491 if (!(cmd->transport_state & CMD_T_DEV_ACTIVE)) {
2492 spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags);
2493 goto check_cond;
2494 }
2495 cmd->transport_state &= ~CMD_T_DEV_ACTIVE;
2496 target_remove_from_state_list(cmd);
2497 spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags);
2498
2499 /*
2500 * The Storage engine stopped this struct se_cmd before it was
2501 * send to the fabric frontend for delivery back to the
2502 * Initiator Node. Return this SCSI CDB back with an
2503 * CHECK_CONDITION status.
2504 */
2505check_cond:
2506 transport_send_check_condition_and_sense(cmd,
2507 TCM_NON_EXISTENT_LUN, 0);
2508 /*
2509 * If the fabric frontend is waiting for this iscsi_cmd_t to
2510 * be released, notify the waiting thread now that LU has
2511 * finished accessing it.
2512 */
2513 spin_lock_irqsave(&cmd->t_state_lock, cmd_flags);
2514 if (cmd->transport_state & CMD_T_LUN_FE_STOP) {
2515 pr_debug("SE_LUN[%d] - Detected FE stop for"
2516 " struct se_cmd: %p ITT: 0x%08x\n",
2517 lun->unpacked_lun,
2518 cmd, cmd->se_tfo->get_task_tag(cmd));
2519
2520 spin_unlock_irqrestore(&cmd->t_state_lock,
2521 cmd_flags);
2522 transport_cmd_check_stop(cmd, false, false);
2523 complete(&cmd->transport_lun_fe_stop_comp);
2524 spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
2525 continue;
2526 }
2527 pr_debug("SE_LUN[%d] - ITT: 0x%08x finished processing\n",
2528 lun->unpacked_lun, cmd->se_tfo->get_task_tag(cmd));
2529
2530 spin_unlock_irqrestore(&cmd->t_state_lock, cmd_flags);
2531 spin_lock_irqsave(&lun->lun_cmd_lock, lun_flags);
2532 }
2533 spin_unlock_irqrestore(&lun->lun_cmd_lock, lun_flags);
2534}
2535
2536static int transport_clear_lun_ref_thread(void *p) 2358static int transport_clear_lun_ref_thread(void *p)
2537{ 2359{
2538 struct se_lun *lun = p; 2360 struct se_lun *lun = p;
@@ -2583,43 +2405,6 @@ bool transport_wait_for_tasks(struct se_cmd *cmd)
2583 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2405 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2584 return false; 2406 return false;
2585 } 2407 }
2586 /*
2587 * If we are already stopped due to an external event (ie: LUN shutdown)
2588 * sleep until the connection can have the passed struct se_cmd back.
2589 * The cmd->transport_lun_stopped_sem will be upped by
2590 * transport_clear_lun_from_sessions() once the ConfigFS context caller
2591 * has completed its operation on the struct se_cmd.
2592 */
2593 if (cmd->transport_state & CMD_T_LUN_STOP) {
2594 pr_debug("wait_for_tasks: Stopping"
2595 " wait_for_completion(&cmd->t_tasktransport_lun_fe"
2596 "_stop_comp); for ITT: 0x%08x\n",
2597 cmd->se_tfo->get_task_tag(cmd));
2598 /*
2599 * There is a special case for WRITES where a FE exception +
2600 * LUN shutdown means ConfigFS context is still sleeping on
2601 * transport_lun_stop_comp in transport_lun_wait_for_tasks().
2602 * We go ahead and up transport_lun_stop_comp just to be sure
2603 * here.
2604 */
2605 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2606 complete(&cmd->transport_lun_stop_comp);
2607 wait_for_completion(&cmd->transport_lun_fe_stop_comp);
2608 spin_lock_irqsave(&cmd->t_state_lock, flags);
2609
2610 target_remove_from_state_list(cmd);
2611 /*
2612 * At this point, the frontend who was the originator of this
2613 * struct se_cmd, now owns the structure and can be released through
2614 * normal means below.
2615 */
2616 pr_debug("wait_for_tasks: Stopped"
2617 " wait_for_completion(&cmd->t_tasktransport_lun_fe_"
2618 "stop_comp); for ITT: 0x%08x\n",
2619 cmd->se_tfo->get_task_tag(cmd));
2620
2621 cmd->transport_state &= ~CMD_T_LUN_STOP;
2622 }
2623 2408
2624 if (!(cmd->transport_state & CMD_T_ACTIVE)) { 2409 if (!(cmd->transport_state & CMD_T_ACTIVE)) {
2625 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 2410 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 7a870f6add7b..b12fc43b5463 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -574,10 +574,8 @@ static int target_xcopy_init_pt_lun(
574 return -ENOMEM; 574 return -ENOMEM;
575 } 575 }
576 init_completion(&pt_cmd->se_lun->lun_shutdown_comp); 576 init_completion(&pt_cmd->se_lun->lun_shutdown_comp);
577 INIT_LIST_HEAD(&pt_cmd->se_lun->lun_cmd_list);
578 INIT_LIST_HEAD(&pt_cmd->se_lun->lun_acl_list); 577 INIT_LIST_HEAD(&pt_cmd->se_lun->lun_acl_list);
579 spin_lock_init(&pt_cmd->se_lun->lun_acl_lock); 578 spin_lock_init(&pt_cmd->se_lun->lun_acl_lock);
580 spin_lock_init(&pt_cmd->se_lun->lun_cmd_lock);
581 spin_lock_init(&pt_cmd->se_lun->lun_sep_lock); 579 spin_lock_init(&pt_cmd->se_lun->lun_sep_lock);
582 init_completion(&pt_cmd->se_lun->lun_ref_comp); 580 init_completion(&pt_cmd->se_lun->lun_ref_comp);
583 581