From patchwork Wed Apr 17 21:44:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10906267 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 7DABD17E0 for ; Wed, 17 Apr 2019 21:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 685ED28A93 for ; Wed, 17 Apr 2019 21:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D0DF28BA9; Wed, 17 Apr 2019 21:45:44 +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 F301628A93 for ; Wed, 17 Apr 2019 21:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387556AbfDQVpl (ORCPT ); Wed, 17 Apr 2019 17:45:41 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36859 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387600AbfDQVpb (ORCPT ); Wed, 17 Apr 2019 17:45:31 -0400 Received: by mail-pl1-f195.google.com with SMTP id ck15so120401plb.3 for ; Wed, 17 Apr 2019 14:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0sISpMETIoFW4aa7wZzd//XMlizWjNwapA9loNGUa+w=; b=h/NvuAniTjy8Nci/r5VYg6W9oH0A6lBFliRZGipopLbYZCM1m/u9bEdAO8BE64IRPs p2T6fLYRA6R7QGcppXdmlJ30DZobsBRErlrer5fplSr9bM2wnxqDFfk2sJU6hpHGKDEL h2Q6b6BiPgQHYHND+HEgh+7nk/B7kym6zOIdM8FCBVo5sCuKACi6xz09jJyCDSpKC34r loH4AoaobFtn51tvkx7fXwR3l3EEfNTKp4jrgUG7r1T8ROGEjI27p3wQuZbYLtvZU4Pe 64SOQoZ+4tJsT0VzUwOGMxmDFE5d2uk+1+xEwoPEBV8MltsXT1XBw6xZleraUZJudjtl VQzQ== X-Gm-Message-State: APjAAAWKyevLQvi/0GZzvoaCpTnO/fQYlYa692UgcfnmtzVrrCrazIxe L9ed3WMUiyYatVKR3F6bvGw= X-Google-Smtp-Source: APXvYqwUn5nKu1zJeBUjBSNkr1kM+37vmxaejL6tRnY1y9MK9Zs7r6HgNjEhbNVaWFPoJzbKNRRxFQ== X-Received: by 2002:a17:902:1602:: with SMTP id g2mr2195737plg.325.1555537531095; Wed, 17 Apr 2019 14:45:31 -0700 (PDT) Received: from desktop-bart.svl.corp.google.com ([2620:15c:2cd:203:5cdc:422c:7b28:ebb5]) by smtp.gmail.com with ESMTPSA id d68sm219314pfg.16.2019.04.17.14.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 14:45:30 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: linux-scsi@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Himanshu Madhani , Giridhar Malavali Subject: [PATCH 31/34] qla2xxx: Complain loudly about reference count underflow Date: Wed, 17 Apr 2019 14:44:40 -0700 Message-Id: <20190417214443.243152-32-bvanassche@acm.org> X-Mailer: git-send-email 2.20.GIT In-Reply-To: <20190417214443.243152-1-bvanassche@acm.org> References: <20190417214443.243152-1-bvanassche@acm.org> MIME-Version: 1.0 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 A reference count underflow is a severe bug. Hence complain loudly if a reference count underflow happens. Cc: Himanshu Madhani Cc: Giridhar Malavali Signed-off-by: Bart Van Assche --- drivers/scsi/qla2xxx/qla_nvme.c | 15 +++++---------- drivers/scsi/qla2xxx/qla_os.c | 16 ++-------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 4c1112107e88..22e3fba28e51 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -131,11 +131,8 @@ static void qla_nvme_sp_ls_done(void *ptr, int res) struct nvmefc_ls_req *fd; struct nvme_private *priv; - if (atomic_read(&sp->ref_count) == 0) { - ql_log(ql_log_warn, sp->fcport->vha, 0x2123, - "SP reference-count to ZERO on LS_done -- sp=%p.\n", sp); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } atomic_dec(&sp->ref_count); @@ -160,6 +157,9 @@ static void qla_nvme_sp_done(void *ptr, int res) nvme = &sp->u.iocb_cmd; fd = nvme->u.nvme.desc; + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) + return; + atomic_dec(&sp->ref_count); if (res == QLA_SUCCESS) { @@ -199,13 +199,8 @@ static void qla_nvme_abort_work(struct work_struct *work) return; } - if (atomic_read(&sp->ref_count) == 0) { - WARN_ON(1); - ql_log(ql_log_info, fcport->vha, 0xffff, - "%s: command already aborted on sp: %p\n", - __func__, sp); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } rval = ha->isp_ops->abort_command(sp); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 73ddd02d1a39..e1c82a0a9745 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -716,14 +716,8 @@ qla2x00_sp_compl(void *ptr, int res) struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct completion *comp = sp->comp; - if (atomic_read(&sp->ref_count) == 0) { - ql_dbg(ql_dbg_io, sp->vha, 0x3015, - "SP reference-count to ZERO -- sp=%p cmd=%p.\n", - sp, GET_CMD_SP(sp)); - if (ql2xextended_error_logging & ql_dbg_io) - WARN_ON(atomic_read(&sp->ref_count) == 0); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } atomic_dec(&sp->ref_count); @@ -827,14 +821,8 @@ qla2xxx_qpair_sp_compl(void *ptr, int res) struct scsi_cmnd *cmd = GET_CMD_SP(sp); struct completion *comp = sp->comp; - if (atomic_read(&sp->ref_count) == 0) { - ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, - "SP reference-count to ZERO -- sp=%p cmd=%p.\n", - sp, GET_CMD_SP(sp)); - if (ql2xextended_error_logging & ql_dbg_io) - WARN_ON(atomic_read(&sp->ref_count) == 0); + if (WARN_ON_ONCE(atomic_read(&sp->ref_count) == 0)) return; - } atomic_dec(&sp->ref_count);