From patchwork Tue Nov 27 23:04:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10701583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80E3714BD for ; Tue, 27 Nov 2018 23:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 727C92BDDD for ; Tue, 27 Nov 2018 23:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 665FA2C8ED; Tue, 27 Nov 2018 23:05:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 958D02BDDD for ; Tue, 27 Nov 2018 23:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726370AbeK1KEt (ORCPT ); Wed, 28 Nov 2018 05:04:49 -0500 Received: from out002.mailprotect.be ([83.217.72.86]:39045 "EHLO out002.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbeK1KEt (ORCPT ); Wed, 28 Nov 2018 05:04:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=9Rwg1nGqQT6l1M3vNu5Y4qVzN71lgTp2ndhMzxGxeQI=; b=hCJsju/J5/cX 5cH6npjMJLKTvBTH8a7CfU/BdGo1Nh/c3pb9L9XbXQwpKwavD1xSTI7ZnsrUB+R05nlNmrtzT76Q7 dAHgConEUp4q834nkdUwYnTJuSCYk9m18cuDP3aQUJVxCp5/ZQpI9cKaMfzgD9+D7B69RFZvTVHDu kTmRXuxw3PO6Zxckdu7zjDkE2qIAzXL0TPIcqgrXN/6XZzMVMudPJABIgpIIQZnkiIuMntY/ZDCuD ZkkmazwxDwLMDNig7jO80IL0M9zJ5WIz2Aa1/KXa1iVi+WRNW4CKvvnng3ARGLgOdp/07fkMVRGrC /aR0h5wIOeF+QBTSxYE74A==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out002.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1gRmPq-000ALH-Ic; Wed, 28 Nov 2018 00:05:15 +0100 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id EB4DEC03F9; Wed, 28 Nov 2018 00:05:09 +0100 (CET) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Bart Van Assche , Himanshu Madhani Subject: [PATCH 2/2] qla2xxx: Split the __qla2x00_abort_all_cmds() function Date: Tue, 27 Nov 2018 15:04:55 -0800 Message-Id: <20181127230455.259829-3-bvanassche@acm.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: <20181127230455.259829-1-bvanassche@acm.org> References: <20181127230455.259829-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.159 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.05) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5kC5M4sLmCzHTrVLheRIlFJ602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTarjontMPw7f3NqDIrNV7pphXnBH4p08Ft9j1x3N/nLO18D Od3nQsC62ajtEOV/fohsGOPFT2pee2Xw2nnaC+uuZzUV2SSE877X6ek5VphlU4lE4xwlSMNZQReC h1BkhSvwYJg8Zt8D44lX+/mPOqzZYqVFg3z5lbRdfQAf/u3PyUGlz8CJSOMrvzx9TVg3RkWfxtCc dRl7A1rc4fLqM7Ws+yiBn1++U1P6gFCnKfjMMqxWoq/FM2XXTzjR7Qr2fwNFyFWesvfWEQ3buhdR df3sTqn1gyiGMs00+yjdEjhJY611qc5TTtnihBuF8qtjLQ/YOACnRq3hbWW5upKABHmcPEg+PVRT iaxPY52n0Pp/8yWZ4SOzQFmgsMTstbIfeOKPPhkxeOWI8nHYm5pmBDqF+55c8zrSmk/soiXY2/fQ 5x9a3CrsA/tn9dp59VE0LfDdgRj6yrQAuxbFOPSpYqPfmLF0wqTcEF+RrgN98ekFapM+X2fvWkTN Ck2gofSHg/s1d/TEuR+B72bMzWq28zMasfxDp5icgsxZIhdVp7l79qa5zn3o6MtK8pf0hPbAkeCZ ME8HeiOTBXPmeRcbGamAcxw3qqhc+N6cuEg4XWh5Fos1uU38r1dSTIHlWhlpRNodsCC6nAa578KW 6nXEp/zTEK1zROq44YHhY+hlHCcZX60Azxg3YaKd1VkEETUR8cEzN9VLYXnPHpe/XBgPmmCASkpK mWMXMp0oGc7StEekwtM+m4WpRRDP6YzwkAPgQJbSWCBit6HLj4sk0KgEJq1mb5boiIOii8qS/cv3 /I88AZu1b5AlmeNmGTYh1q/TezHERLuoic1wP2v/OLoMINbDXPWlFdaGOH191uXjgjQN/QUwKDrf q3v5/q7pQUfnocaiuYnh9c+mZpu2meXeARjc7poMdKebspwo4rT4U0yHnsFEFmAKKS84AwX/iljz 3ffA09zWNv+KijMnEXNmm8NfjLcQpkmn967DSqJU//PeK5A5Fxib54hor19Rav1EA3VvRSeyeah7 LB+FgVuMLpaBl5pWcs7QDDX5FrGcNuOikev71tJhco6bnXR0nWNBphk= X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Nesting in __qla2x00_abort_all_cmds() is way too deep. Reduce the nesting level by introducing a helper function. This patch does not change any functionality. Cc: Himanshu Madhani Signed-off-by: Bart Van Assche Acked-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 89 +++++++++++++++++------------------ 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index b658b9a5eb1e..247f16969f0f 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1746,10 +1746,52 @@ qla2x00_loop_reset(scsi_qla_host_t *vha) return QLA_SUCCESS; } +static void qla2x00_abort_srb(struct qla_qpair *qp, srb_t *sp, const int res, + unsigned long *flags) + __releases(qp->qp_lock_ptr) + __acquires(qp->qp_lock_ptr) +{ + scsi_qla_host_t *vha = qp->vha; + struct qla_hw_data *ha = vha->hw; + int status; + + if (sp->type == SRB_NVME_CMD || sp->type == SRB_NVME_LS) { + if (!sp_get(sp)) { + /* got sp */ + spin_unlock_irqrestore(qp->qp_lock_ptr, *flags); + qla_nvme_abort(ha, sp, res); + spin_lock_irqsave(qp->qp_lock_ptr, *flags); + } + } else if (GET_CMD_SP(sp) && !ha->flags.eeh_busy && + !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && + !qla2x00_isp_reg_stat(ha) && sp->type == SRB_SCSI_CMD) { + /* + * Don't abort commands in adapter during EEH recovery as it's + * not accessible/responding. + * + * Get a reference to the sp and drop the lock. The reference + * ensures this sp->done() call and not the call in + * qla2xxx_eh_abort() ends the SCSI cmd (with result 'res'). + */ + if (!sp_get(sp)) { + spin_unlock_irqrestore(qp->qp_lock_ptr, *flags); + status = qla2xxx_eh_abort(GET_CMD_SP(sp)); + spin_lock_irqsave(qp->qp_lock_ptr, *flags); + /* + * Get rid of extra reference caused by early exit + * from qla2xxx_eh_abort(). + */ + if (status == FAST_IO_FAIL) + atomic_dec(&sp->ref_count); + } + } + sp->done(sp, res); +} + static void __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) { - int cnt, status; + int cnt; unsigned long flags; srb_t *sp; scsi_qla_host_t *vha = qp->vha; @@ -1768,50 +1810,7 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) req->outstanding_cmds[cnt] = NULL; switch (sp->cmd_type) { case TYPE_SRB: - if (sp->type == SRB_NVME_CMD || - sp->type == SRB_NVME_LS) { - if (!sp_get(sp)) { - /* got sp */ - spin_unlock_irqrestore - (qp->qp_lock_ptr, - flags); - qla_nvme_abort(ha, sp, res); - spin_lock_irqsave - (qp->qp_lock_ptr, flags); - } - } else if (GET_CMD_SP(sp) && - !ha->flags.eeh_busy && - (!test_bit(ABORT_ISP_ACTIVE, - &vha->dpc_flags)) && - !qla2x00_isp_reg_stat(ha) && - (sp->type == SRB_SCSI_CMD)) { - /* - * Don't abort commands in adapter - * during EEH recovery as it's not - * accessible/responding. - * - * Get a reference to the sp and drop - * the lock. The reference ensures this - * sp->done() call and not the call in - * qla2xxx_eh_abort() ends the SCSI cmd - * (with result 'res'). - */ - if (!sp_get(sp)) { - spin_unlock_irqrestore - (qp->qp_lock_ptr, flags); - status = qla2xxx_eh_abort( - GET_CMD_SP(sp)); - spin_lock_irqsave - (qp->qp_lock_ptr, flags); - /* - * Get rid of extra reference caused - * by early exit from qla2xxx_eh_abort - */ - if (status == FAST_IO_FAIL) - atomic_dec(&sp->ref_count); - } - } - sp->done(sp, res); + qla2x00_abort_srb(qp, sp, res, &flags); break; case TYPE_TGT_CMD: if (!vha->hw->tgt.tgt_ops || !tgt ||