diff mbox

[v4,26/37] target: Simplify LUN RESET implementation

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

Commit Message

Bart Van Assche Feb. 8, 2017, 10:24 p.m. UTC
Due to the task management handling rework it is safe to wait for
a TMF that is not in the active state. Hence remove the CMD_T_ACTIVE
test from core_tmr_drain_tmr_list(). Additionally, call
__target_check_io_state() instead of open coding it.

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_tmr.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

Comments

Nicholas A. Bellinger Feb. 9, 2017, 11:07 a.m. UTC | #1
On Wed, 2017-02-08 at 14:24 -0800, Bart Van Assche wrote:
> Due to the task management handling rework it is safe to wait for
> a TMF that is not in the active state. Hence remove the CMD_T_ACTIVE
> test from core_tmr_drain_tmr_list(). Additionally, call
> __target_check_io_state() instead of open coding it.
> 
> 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_tmr.c | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
> index e4c8ebbcb20c..b31735c77621 100644
> --- a/drivers/target/target_core_tmr.c
> +++ b/drivers/target/target_core_tmr.c
> @@ -227,22 +227,13 @@ static void core_tmr_drain_tmr_list(
>  			continue;
>  
>  		spin_lock(&sess->sess_cmd_lock);
> -		spin_lock(&cmd->t_state_lock);
> -		if (!(cmd->transport_state & CMD_T_ACTIVE)) {
> -			spin_unlock(&cmd->t_state_lock);
> -			spin_unlock(&sess->sess_cmd_lock);
> -			continue;
> -		}
> -		cmd->transport_state |= CMD_T_ABORTED;
> -		spin_unlock(&cmd->t_state_lock);
> +		rc = __target_check_io_state(cmd, sess, 0);
> +		spin_unlock(&sess->sess_cmd_lock);
>  
> -		rc = kref_get_unless_zero(&cmd->cmd_kref);
>  		if (!rc) {
>  			printk("LUN_RESET TMR: non-zero kref_get_unless_zero\n");
> -			spin_unlock(&sess->sess_cmd_lock);
>  			continue;
>  		}
> -		spin_unlock(&sess->sess_cmd_lock);
>  
>  		list_move_tail(&tmr_p->tmr_list, &drain_tmr_list);
>  	}

This needs to honor TRANSPORT_ISTATE_PROCESSING state following the
early abort bug-fix in:

https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit/?id=c54eeffbe9338fa982dc853d816fda9202a13b5a

Dropping for now.


--
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
Bart Van Assche Feb. 9, 2017, 10:59 p.m. UTC | #2
On Thu, 2017-02-09 at 03:07 -0800, Nicholas A. Bellinger wrote:
> On Wed, 2017-02-08 at 14:24 -0800, Bart Van Assche wrote:
> > Due to the task management handling rework it is safe to wait for
> > a TMF that is not in the active state. Hence remove the CMD_T_ACTIVE
> > test from core_tmr_drain_tmr_list(). Additionally, call
> > __target_check_io_state() instead of open coding it.
> > 
> > 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_tmr.c | 13 ++-----------
> >  1 file changed, 2 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
> > index e4c8ebbcb20c..b31735c77621 100644
> > --- a/drivers/target/target_core_tmr.c
> > +++ b/drivers/target/target_core_tmr.c
> > @@ -227,22 +227,13 @@ static void core_tmr_drain_tmr_list(
> >  			continue;
> >  
> >  		spin_lock(&sess->sess_cmd_lock);
> > -		spin_lock(&cmd->t_state_lock);
> > -		if (!(cmd->transport_state & CMD_T_ACTIVE)) {
> > -			spin_unlock(&cmd->t_state_lock);
> > -			spin_unlock(&sess->sess_cmd_lock);
> > -			continue;
> > -		}
> > -		cmd->transport_state |= CMD_T_ABORTED;
> > -		spin_unlock(&cmd->t_state_lock);
> > +		rc = __target_check_io_state(cmd, sess, 0);
> > +		spin_unlock(&sess->sess_cmd_lock);
> >  
> > -		rc = kref_get_unless_zero(&cmd->cmd_kref);
> >  		if (!rc) {
> >  			printk("LUN_RESET TMR: non-zero kref_get_unless_zero\n");
> > -			spin_unlock(&sess->sess_cmd_lock);
> >  			continue;
> >  		}
> > -		spin_unlock(&sess->sess_cmd_lock);
> >  
> >  		list_move_tail(&tmr_p->tmr_list, &drain_tmr_list);
> >  	}
> 
> This needs to honor TRANSPORT_ISTATE_PROCESSING state following the
> early abort bug-fix in:
> 
> https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit/?id=c54eeffbe9338fa982dc853d816fda9202a13b5a

A previous patch removed all cancel_work() calls from the target core
so that but can no longer be triggered. That bug report shows again
that the current target core is too complex and needs to be simplified.

Bart.--
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_tmr.c b/drivers/target/target_core_tmr.c
index e4c8ebbcb20c..b31735c77621 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -227,22 +227,13 @@  static void core_tmr_drain_tmr_list(
 			continue;
 
 		spin_lock(&sess->sess_cmd_lock);
-		spin_lock(&cmd->t_state_lock);
-		if (!(cmd->transport_state & CMD_T_ACTIVE)) {
-			spin_unlock(&cmd->t_state_lock);
-			spin_unlock(&sess->sess_cmd_lock);
-			continue;
-		}
-		cmd->transport_state |= CMD_T_ABORTED;
-		spin_unlock(&cmd->t_state_lock);
+		rc = __target_check_io_state(cmd, sess, 0);
+		spin_unlock(&sess->sess_cmd_lock);
 
-		rc = kref_get_unless_zero(&cmd->cmd_kref);
 		if (!rc) {
 			printk("LUN_RESET TMR: non-zero kref_get_unless_zero\n");
-			spin_unlock(&sess->sess_cmd_lock);
 			continue;
 		}
-		spin_unlock(&sess->sess_cmd_lock);
 
 		list_move_tail(&tmr_p->tmr_list, &drain_tmr_list);
 	}