@@ -505,23 +505,6 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
505505 if (write_pending )
506506 cmd -> t_state = TRANSPORT_WRITE_PENDING ;
507507
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-
525508 if (remove_from_lists ) {
526509 target_remove_from_state_list (cmd );
527510
@@ -1078,13 +1061,10 @@ void transport_init_se_cmd(
10781061 int task_attr ,
10791062 unsigned char * sense_buffer )
10801063{
1081- INIT_LIST_HEAD (& cmd -> se_lun_node );
10821064 INIT_LIST_HEAD (& cmd -> se_delayed_node );
10831065 INIT_LIST_HEAD (& cmd -> se_qf_node );
10841066 INIT_LIST_HEAD (& cmd -> se_cmd_list );
10851067 INIT_LIST_HEAD (& cmd -> state_list );
1086- init_completion (& cmd -> transport_lun_fe_stop_comp );
1087- init_completion (& cmd -> transport_lun_stop_comp );
10881068 init_completion (& cmd -> t_transport_stop_comp );
10891069 init_completion (& cmd -> cmd_wait_comp );
10901070 init_completion (& cmd -> task_stop_comp );
@@ -1705,29 +1685,14 @@ void target_execute_cmd(struct se_cmd *cmd)
17051685 /*
17061686 * If the received CDB has aleady been aborted stop processing it here.
17071687 */
1708- if (transport_check_aborted_status (cmd , 1 )) {
1709- complete (& cmd -> transport_lun_stop_comp );
1688+ if (transport_check_aborted_status (cmd , 1 ))
17101689 return ;
1711- }
17121690
1713- /*
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- }
17271691 /*
17281692 * Determine if frontend context caller is requesting the stopping of
17291693 * this command for frontend exceptions.
17301694 */
1695+ spin_lock_irq (& cmd -> t_state_lock );
17311696 if (cmd -> transport_state & CMD_T_STOP ) {
17321697 pr_debug ("%s:%d CMD_T_STOP for ITT: 0x%08x\n" ,
17331698 __func__ , __LINE__ ,
@@ -2390,149 +2355,6 @@ void target_wait_for_sess_cmds(struct se_session *se_sess)
23902355}
23912356EXPORT_SYMBOL (target_wait_for_sess_cmds );
23922357
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- */
2398- static 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-
2442- static 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- */
2505- check_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-
25362358static int transport_clear_lun_ref_thread (void * p )
25372359{
25382360 struct se_lun * lun = p ;
@@ -2583,43 +2405,6 @@ bool transport_wait_for_tasks(struct se_cmd *cmd)
25832405 spin_unlock_irqrestore (& cmd -> t_state_lock , flags );
25842406 return false;
25852407 }
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- }
26232408
26242409 if (!(cmd -> transport_state & CMD_T_ACTIVE )) {
26252410 spin_unlock_irqrestore (& cmd -> t_state_lock , flags );
0 commit comments