diff mbox

[v4,34/37] target: Move target_remove_from_state_list() into target_release_cmd_kref()

Message ID 20170208222507.25715-35-bart.vanassche@sandisk.com (mailing list archive)
State Superseded
Headers show

Commit Message

Bart Van Assche Feb. 8, 2017, 10:25 p.m. UTC
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@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andy Grover <agrover@redhat.com>
Cc: David Disseldorp <ddiss@suse.de>
---
 drivers/target/target_core_transport.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

Comments

Nicholas A. Bellinger Feb. 9, 2017, 11:30 a.m. UTC | #1
On Wed, 2017-02-08 at 14:25 -0800, Bart Van Assche wrote:
> 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@sandisk.com>
> Reviewed-by: Hannes Reinecke <hare@suse.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Andy Grover <agrover@redhat.com>
> Cc: David Disseldorp <ddiss@suse.de>
> ---
>  drivers/target/target_core_transport.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 99531dc85f9c..9fd8b3788800 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -596,8 +596,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
> @@ -2467,13 +2465,6 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
>  	} else {
>  		if (wait_for_tasks)
>  			target_wait_free_cmd(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);
>  	}
>  	/*
>  	 * Since the iSCSI and iSER targets driver assume that a SCSI command
> @@ -2546,6 +2537,8 @@ static void target_release_cmd_kref(struct kref *kref)
>  
>  	WARN_ON_ONCE(atomic_read(&se_cmd->tgt_ref) != 0);
>  
> +	target_remove_from_state_list(se_cmd);
> +
>  	if (se_cmd->lun_ref_active)
>  		percpu_ref_put(&se_cmd->se_lun->lun_ref);
>  

Same require as in patch #33.  Once the response has been queued the
association with the se_lun and underlying se_device needs to be
removed.

Waiting for fabric ACKs when a user has explicitly required configfs
shutdown of /sys/kernel/config/target/$FABRIC/$WWN/$TPG/lun/$LUN_ID/ is
not acceptable.

Dropping this patch.

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

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 99531dc85f9c..9fd8b3788800 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -596,8 +596,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
@@ -2467,13 +2465,6 @@  int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
 	} else {
 		if (wait_for_tasks)
 			target_wait_free_cmd(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);
 	}
 	/*
 	 * Since the iSCSI and iSER targets driver assume that a SCSI command
@@ -2546,6 +2537,8 @@  static void target_release_cmd_kref(struct kref *kref)
 
 	WARN_ON_ONCE(atomic_read(&se_cmd->tgt_ref) != 0);
 
+	target_remove_from_state_list(se_cmd);
+
 	if (se_cmd->lun_ref_active)
 		percpu_ref_put(&se_cmd->se_lun->lun_ref);