[PATCH v6 33/33] target: Move target_remove_from_state_list() into target_release_cmd_kref()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The only code that iterates over the state list is the LUN reset
code. Deferring removal from the state list is fine since that
code grabs a reference to the command before it does any other
processing. Leaving out the se_cmd.state_active test is fine
because this test is already performed by
target_remove_from_state_list().

Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
Reviewed-by: Hannes Reinecke <hare@xxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Andy Grover <agrover@xxxxxxxxxx>
Cc: David Disseldorp <ddiss@xxxxxxx>
---
 drivers/target/target_core_transport.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index e4c12f7e0437..f51251261208 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -604,8 +604,6 @@ static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd)
 {
 	unsigned long flags;
 
-	target_remove_from_state_list(cmd);
-
 	spin_lock_irqsave(&cmd->t_state_lock, flags);
 	/*
 	 * Determine if frontend context caller is requesting the stopping of
@@ -2479,15 +2477,6 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
 	if (wait_for_tasks)
 		target_wait_free_cmd(cmd);
 
-	if (cmd->se_cmd_flags & SCF_SE_LUN_CMD) {
-		/*
-		 * Handle WRITE failure case where transport_generic_new_cmd()
-		 * has already added se_cmd to state_list, but fabric has
-		 * failed command before I/O submission.
-		 */
-		if (cmd->state_active)
-			target_remove_from_state_list(cmd);
-	}
 	BUG_ON(!cmd->se_tfo);
 	return target_put_sess_cmd(cmd);
 }
@@ -2550,6 +2539,8 @@ static void target_release_cmd_kref(struct kref *kref)
 
 	WARN_ON_ONCE(atomic_read(&se_cmd->tgt_ref.refcount) != 0);
 
+	target_remove_from_state_list(se_cmd);
+
 	if (se_cmd->lun_ref_active)
 		percpu_ref_put(&se_cmd->se_lun->lun_ref);
 
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux