From patchwork Tue Mar 5 10:58:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 10839311 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 1A9D717E4 for ; Tue, 5 Mar 2019 11:01:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 069A62BCAB for ; Tue, 5 Mar 2019 11:01:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 051762BDF0; Tue, 5 Mar 2019 11:01:14 +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.9 required=2.0 tests=BAYES_00,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 8B01D2BCAB for ; Tue, 5 Mar 2019 11:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727269AbfCELBN (ORCPT ); Tue, 5 Mar 2019 06:01:13 -0500 Received: from mail-eopbgr810089.outbound.protection.outlook.com ([40.107.81.89]:12428 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727477AbfCELBN (ORCPT ); Tue, 5 Mar 2019 06:01:13 -0500 Received: from DM6PR07CA0020.namprd07.prod.outlook.com (2603:10b6:5:94::33) by BN7PR07MB4371.namprd07.prod.outlook.com (2603:10b6:406:b5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.15; Tue, 5 Mar 2019 11:00:31 +0000 Received: from BY2NAM05FT011.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::205) by DM6PR07CA0020.outlook.office365.com (2603:10b6:5:94::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1665.15 via Frontend Transport; Tue, 5 Mar 2019 11:00:31 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by BY2NAM05FT011.mail.protection.outlook.com (10.152.100.148) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1686.5 via Frontend Transport; Tue, 5 Mar 2019 11:00:30 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 5 Mar 2019 03:00:14 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id x25B0ETo013428; Tue, 5 Mar 2019 03:00:14 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x25B0EHX013427; Tue, 5 Mar 2019 03:00:14 -0800 From: Saurav Kashyap To: CC: , Subject: [PATCH 24/26] qedf: Correctly handle refcounting of rdata. Date: Tue, 5 Mar 2019 02:58:59 -0800 Message-ID: <20190305105901.13185-25-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190305105901.13185-1-skashyap@marvell.com> References: <20190305105901.13185-1-skashyap@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131962572311006634;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(346002)(376002)(39860400002)(396003)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(42186006)(305945005)(97736004)(86362001)(6862004)(76176011)(36756003)(2906002)(26005)(87636003)(8936002)(498600001)(6666004)(51416003)(356004)(4326008)(26826003)(446003)(486006)(8676002)(2616005)(81156014)(126002)(2351001)(50226002)(336012)(68736007)(105606002)(54906003)(80596001)(5660300002)(85426001)(81166006)(106466001)(11346002)(1076003)(476003)(69596002)(36906005)(47776003)(316002)(48376002)(50466002)(16586007)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR07MB4371;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01a3d18f-fe83-4f53-c51e-08d6a159c8a2 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600127)(711020)(4605104)(2017052603328);SRVR:BN7PR07MB4371; X-MS-TrafficTypeDiagnostic: BN7PR07MB4371: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0967749BC1 X-Microsoft-Exchange-Diagnostics: 1;BN7PR07MB4371;23:KtEVHk4DquRlkwa6XZusJfTSDenX11FRVOLNmJ0OJfj0eXCJcHLiUI5b0yrdnPTDlIP6uvbSZm0k0YzrMs8HsLtAo9E7lZmVokiOLo6bBBfZTRMYf0UBbg+VX5cHAh4WPNPdFF6bR41CG2zNnYfNaDOSRbasjziyYLmaQKsVyqD0d+z7ZBvggLQ/AIvc1meWJUwQGBarBcTJApqVfZc79WEEZara1PSqkh0vrAqPiQ7I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GbMeJ5ZeUTsXB+7FTHVkmACZNWTZ0+jkCQpz8iNcicroXECXBPmSpHPOL6Qn2MpXql8VN5zthpWsY5fjmYENY480NlymdGXkz9Y7LKnc5qq7Ad+U2b31mK2RAKxBilWtsJFS02so0m5XTLBdsHzJ+tlmcZnM3VYuU4CpmvsOf9m3PJnjtxUf/qWfUkeptl6a6WPQWBCnGjXU3V54tRIS/bAD2vzoIM3kbRzsjp10j6x3W7OKTkzF5YkP0d5NR50p9QbLAzVDZbQE3csY/BVEAoIG1/UqsaFNi4enoIodTvaJXPNqBtxsNp1hna2jYbHuTq+GyTy87F3I3qW6bIU6iJY4PDQy63rLL7P/LYBgkXBzc0kndNdb2+tTPVys4thKO/4iRXkc8D9ubCUYNs9jE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Mar 2019 11:00:30.7193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01a3d18f-fe83-4f53-c51e-08d6a159c8a2 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR07MB4371 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 - handle refcount of rdata during error conditions. Signed-off-by: Saurav Kashyap --- drivers/scsi/qedf/qedf_io.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index d98f5f4..b9877f1 100644 --- a/drivers/scsi/qedf/qedf_io.c +++ b/drivers/scsi/qedf/qedf_io.c @@ -2241,7 +2241,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, unsigned long flags; struct fcoe_wqe *sqe; u16 sqe_idx; - struct fc_rport_priv *rdata = fcport->rdata; if (!sc_cmd) { QEDF_ERR(&(qedf->dbg_ctx), "invalid arg\n"); @@ -2252,22 +2251,14 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n"); rc = FAILED; - return FAILED; - } - - if (!rdata || !kref_get_unless_zero(&rdata->kref)) { - QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM, "stale rport\n"); - return FAILED; + goto no_flush; } - QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM, - "portid = 0x%x tm_flags = %d\n", - rdata->ids.port_id, tm_flags); io_req = qedf_alloc_cmd(fcport, QEDF_TASK_MGMT_CMD); if (!io_req) { QEDF_ERR(&(qedf->dbg_ctx), "Failed TMF"); rc = -EAGAIN; - goto reset_tmf_err; + goto no_flush; } if (tm_flags == FCP_TMF_LUN_RESET) @@ -2356,8 +2347,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, QEDF_ERR(&(qedf->dbg_ctx), "task mgmt command success...\n"); rc = SUCCESS; } -reset_tmf_err: - kref_put(&rdata->kref, fc_rport_destroy); return rc; } @@ -2405,7 +2394,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) rc = fc_block_scsi_eh(sc_cmd); if (rc) - return rc; + goto tmf_err; if (!fcport) { QEDF_ERR(NULL, "device_reset: rport is NULL\n"); @@ -2442,7 +2431,13 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) } if (test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) { - QEDF_ERR(&qedf->dbg_ctx, "fcport is uploading.\n"); + if (!fcport->rdata) + QEDF_ERR(&qedf->dbg_ctx, "fcport %p is uploading.\n", + fcport); + else + QEDF_ERR(&qedf->dbg_ctx, + "fcport %p port_id=%06x is uploading.\n", + fcport, fcport->rdata->ids.port_id); rc = FAILED; goto tmf_err; } @@ -2450,6 +2445,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags); tmf_err: + kref_put(&rdata->kref, fc_rport_destroy); return rc; }