Stable Archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: core: Fix handling of SCMD_FAIL_IF_RECOVERING
@ 2024-03-25 22:44 Bart Van Assche
  2024-04-05 19:49 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2024-03-25 22:44 UTC (permalink / raw
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, stable, James E.J. Bottomley,
	Mike Christie

There is code in the SCSI core that sets the SCMD_FAIL_IF_RECOVERING
flag but there is no code that clears this flag. Instead of only clearing
SCMD_INITIALIZED in scsi_end_request(), clear all flags. It is never
necessary to preserve any command flags inside scsi_end_request().

Cc: stable@vger.kernel.org
Fixes: 310bcaef6d7e ("scsi: core: Support failing requests while recovering")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_lib.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ca48ba9a229a..2fc2b97777ca 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -633,10 +633,9 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
 	if (blk_queue_add_random(q))
 		add_disk_randomness(req->q->disk);
 
-	if (!blk_rq_is_passthrough(req)) {
-		WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED));
-		cmd->flags &= ~SCMD_INITIALIZED;
-	}
+	WARN_ON_ONCE(!blk_rq_is_passthrough(req) &&
+		     !(cmd->flags & SCMD_INITIALIZED));
+	cmd->flags = 0;
 
 	/*
 	 * Calling rcu_barrier() is not necessary here because the

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: core: Fix handling of SCMD_FAIL_IF_RECOVERING
  2024-03-25 22:44 [PATCH] scsi: core: Fix handling of SCMD_FAIL_IF_RECOVERING Bart Van Assche
@ 2024-04-05 19:49 ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2024-04-05 19:49 UTC (permalink / raw
  To: Martin K . Petersen
  Cc: linux-scsi, stable, James E.J. Bottomley, Mike Christie

On 3/25/24 15:44, Bart Van Assche wrote:
> There is code in the SCSI core that sets the SCMD_FAIL_IF_RECOVERING
> flag but there is no code that clears this flag. Instead of only clearing
> SCMD_INITIALIZED in scsi_end_request(), clear all flags. It is never
> necessary to preserve any command flags inside scsi_end_request().
> 
> Cc: stable@vger.kernel.org
> Fixes: 310bcaef6d7e ("scsi: core: Support failing requests while recovering")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/scsi_lib.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index ca48ba9a229a..2fc2b97777ca 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -633,10 +633,9 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
>   	if (blk_queue_add_random(q))
>   		add_disk_randomness(req->q->disk);
>   
> -	if (!blk_rq_is_passthrough(req)) {
> -		WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED));
> -		cmd->flags &= ~SCMD_INITIALIZED;
> -	}
> +	WARN_ON_ONCE(!blk_rq_is_passthrough(req) &&
> +		     !(cmd->flags & SCMD_INITIALIZED));
> +	cmd->flags = 0;
>   
>   	/*
>   	 * Calling rcu_barrier() is not necessary here because the

Also for this patch, please help with reviewing this patch.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-05 19:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-25 22:44 [PATCH] scsi: core: Fix handling of SCMD_FAIL_IF_RECOVERING Bart Van Assche
2024-04-05 19:49 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).