All of lore.kernel.org
 help / color / mirror / Atom feed
From: Himanshu Madhani <hmadhani@marvell.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Quinn Tran <qutran@marvell.com>, Martin Wilck <mwilck@suse.com>,
	Daniel Wagner <dwagner@suse.de>,
	Roman Bolshakov <r.bolshakov@yadro.com>
Subject: Re: [PATCH 2/4] qla2xxx: Simplify the code for aborting SCSI commands
Date: Tue, 10 Dec 2019 19:41:25 +0000	[thread overview]
Message-ID: <D468C0DF-7ABC-45F3-B1C5-A751F4E21636@marvell.com> (raw)
In-Reply-To: <20191209180223.194959-3-bvanassche@acm.org>



On 12/9/19, 12:02 PM, "linux-scsi-owner@vger.kernel.org on behalf of Bart Van Assche" <linux-scsi-owner@vger.kernel.org on behalf of bvanassche@acm.org> wrote:

    Since the SCSI core does not reuse the tag of the SCSI command that is
    being aborted by .eh_abort() before .eh_abort() has finished it is not
    necessary to check from inside that callback whether or not the SCSI command
    has already completed. Instead, rely on the firmware to return an error code
    when attempting to abort a command that has already completed. Additionally,
    rely on the firmware to return an error code when attempting to abort an
    already aborted command.
    
    In qla2x00_abort_srb(), use blk_mq_request_started() instead of
    sp->completed and sp->aborted.
    
    This patch eliminates several race conditions triggered by the removed member
    variables.
    
    Cc: Quinn Tran <qutran@marvell.com>
    Cc: Martin Wilck <mwilck@suse.com>
    Cc: Daniel Wagner <dwagner@suse.de>
    Cc: Roman Bolshakov <r.bolshakov@yadro.com>
    Signed-off-by: Bart Van Assche <bvanassche@acm.org>
    ---
     drivers/scsi/qla2xxx/qla_def.h |  3 ---
     drivers/scsi/qla2xxx/qla_isr.c |  5 -----
     drivers/scsi/qla2xxx/qla_os.c  | 15 ++-------------
     3 files changed, 2 insertions(+), 21 deletions(-)
    
    diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
    index 460f443f6471..ab7424318ee8 100644
    --- a/drivers/scsi/qla2xxx/qla_def.h
    +++ b/drivers/scsi/qla2xxx/qla_def.h
    @@ -597,9 +597,6 @@ typedef struct srb {
     	struct fc_port *fcport;
     	struct scsi_qla_host *vha;
     	unsigned int start_timer:1;
    -	unsigned int abort:1;
    -	unsigned int aborted:1;
    -	unsigned int completed:1;
     
     	uint32_t handle;
     	uint16_t flags;
    diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
    index 2601d7673c37..721a8d83e350 100644
    --- a/drivers/scsi/qla2xxx/qla_isr.c
    +++ b/drivers/scsi/qla2xxx/qla_isr.c
    @@ -2487,11 +2487,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
     		return;
     	}
     
    -	if (sp->abort)
    -		sp->aborted = 1;
    -	else
    -		sp->completed = 1;
    -
     	if (sp->cmd_type != TYPE_SRB) {
     		req->outstanding_cmds[handle] = NULL;
     		ql_dbg(ql_dbg_io, vha, 0x3015,
    diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
    index 145ea93206f0..2231d99d311b 100644
    --- a/drivers/scsi/qla2xxx/qla_os.c
    +++ b/drivers/scsi/qla2xxx/qla_os.c
    @@ -1253,17 +1253,6 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
     		return SUCCESS;
     
     	spin_lock_irqsave(qpair->qp_lock_ptr, flags);
    -	if (sp->completed) {
    -		spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
    -		return SUCCESS;
    -	}
    -
    -	if (sp->abort || sp->aborted) {
    -		spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
    -		return FAILED;
    -	}
    -
    -	sp->abort = 1;
     	sp->comp = &comp;
     	spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
     
    @@ -1696,6 +1685,7 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
     	DECLARE_COMPLETION_ONSTACK(comp);
     	scsi_qla_host_t *vha = qp->vha;
     	struct qla_hw_data *ha = vha->hw;
    +	struct scsi_cmnd *cmd = GET_CMD_SP(sp);
     	int rval;
     	bool ret_cmd;
     	uint32_t ratov_j;
    @@ -1717,7 +1707,6 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
     		}
     
     		sp->comp = &comp;
    -		sp->abort =  1;
     		spin_unlock_irqrestore(qp->qp_lock_ptr, *flags);
     
     		rval = ha->isp_ops->abort_command(sp);
    @@ -1741,7 +1730,7 @@ static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res,
     		}
     
     		spin_lock_irqsave(qp->qp_lock_ptr, *flags);
    -		if (ret_cmd && (!sp->completed || !sp->aborted))
    +		if (ret_cmd && blk_mq_request_started(cmd->request))
     			sp->done(sp, res);
     	} else {
     		sp->done(sp, res);
    
Acked-By: Himanshu Madhani <hmadhani@marvell.com>


  parent reply	other threads:[~2019-12-10 19:41 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 18:02 [PATCH 0/4] qla2xxx patches for kernel v5.6 Bart Van Assche
2019-12-09 18:02 ` [PATCH 1/4] qla2xxx: Check locking assumptions at runtime in qla2x00_abort_srb() Bart Van Assche
2019-12-10 11:06   ` Martin Wilck
2019-12-10 19:39   ` Himanshu Madhani
2019-12-11 19:03   ` Roman Bolshakov
2019-12-09 18:02 ` [PATCH 2/4] qla2xxx: Simplify the code for aborting SCSI commands Bart Van Assche
2019-12-10 11:47   ` Martin Wilck
2019-12-10 17:57     ` Bart Van Assche
2019-12-10 20:29       ` Martin Wilck
2019-12-10 20:45         ` Bart Van Assche
2019-12-11 10:26           ` Martin Wilck
2019-12-12 16:01     ` Roman Bolshakov
2019-12-10 19:41   ` Himanshu Madhani [this message]
2019-12-12 16:04   ` Roman Bolshakov
2019-12-09 18:02 ` [PATCH 3/4] qla2xxx: Fix point-to-point mode for qla25xx and older Bart Van Assche
2019-12-10 10:52   ` Martin Wilck
2019-12-10 18:00     ` Bart Van Assche
2019-12-10 19:44       ` Martin Wilck
2019-12-12 20:07     ` Roman Bolshakov
2019-12-14  1:04       ` Roman Bolshakov
2019-12-15  0:09         ` Bart Van Assche
2019-12-16 11:45           ` Roman Bolshakov
2019-12-16 20:08             ` Roman Bolshakov
2019-12-16  8:37         ` Daniel Wagner
2019-12-10 19:40   ` Himanshu Madhani
2019-12-09 18:02 ` [PATCH 4/4] qla2xxx: Micro-optimize qla2x00_configure_local_loop() Bart Van Assche
2019-12-10 10:46   ` Martin Wilck
2019-12-14 12:30     ` Roman Bolshakov
2019-12-15  0:12     ` Bart Van Assche
2019-12-14 12:33   ` Roman Bolshakov
2019-12-15  0:14     ` Bart Van Assche
2020-02-06 13:23 ` [PATCH 0/4] qla2xxx patches for kernel v5.6 Martin Wilck
2020-02-06 20:49   ` Bart Van Assche
2020-02-06 20:52     ` Martin Wilck
2020-02-06 21:01       ` Bart Van Assche
2020-02-07  9:09         ` Martin Wilck
2020-02-08  3:17           ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D468C0DF-7ABC-45F3-B1C5-A751F4E21636@marvell.com \
    --to=hmadhani@marvell.com \
    --cc=bvanassche@acm.org \
    --cc=dwagner@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --cc=qutran@marvell.com \
    --cc=r.bolshakov@yadro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.