Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1147291pxv; Fri, 9 Jul 2021 19:31:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfUujv4AyYht42krNW5vWgDLwRL3ddSTUVGJW1xhV5gkHuCStm7AL3sz08iZAX/FhuM1Sv X-Received: by 2002:aa7:db94:: with SMTP id u20mr50600826edt.381.1625884269730; Fri, 09 Jul 2021 19:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884269; cv=none; d=google.com; s=arc-20160816; b=dmTUAZCJ4grufJCaxq6qFEeKdCiLzaSH+06iTHLxLtbco2OTb9YLlM+9qfOB1oLPvd 6M8fqfjyOWkBDoqpWK8wYhzmogLeL0SIUY1BVodh/pKdFjkTJBChK6GTHCcNfSAxWvug U2yv5QrF1pXxV05IA1+voLB0qwbHh4DIUS+ppUaLNE/3X7iP5cctxKLQoBN9NSQrEQVY Dd2zISyLL4e8CRGLwI0PC3mh2lyYxm/snab/pNR7k6WPBKCOR6xdVNYmzbELAGVz21ww VOHi18EHcvCmzGOJTihiHkHbFAHWA8CIyr13aGbrP5gm5cRhL4Re6YRaEiO7iDWdhPGu HWKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GWkGAJWMZk21zfl+FOhjoJyqghD6dFe8V19MMhgpmSs=; b=u3BpkgRtblLOTXLfUMiPb1maS6Dk6nAko9xEGHakpV2bufYdYkCoNFLE1ln5OokjJP 7i/QxEEYmExDI0MSSjwwthEZd89xR1aulkYS4jwq4/E1SACXM382VXwfxG7dxbaeIlqf peQevbvSTuMGxjhHC6dJqVFUvjeqZo45KKs4zwkEACnCJ9qt4M+T+fB6DDfFqOr0XOzz ffsXxknjebUsLxXZzP7JPvC65HTJM3yf4vT/u2B2wTYm+w+Xg/7XUzV6VmgKRPh94muu 37ctueCeF9VUjXHcGuPs4H/xCU2B/bpuPzzlH/7FjKvQaODEJu3pPnubG+bCEAwXlIK5 54GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F5M1LHgG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si9418321ejm.546.2021.07.09.19.30.46; Fri, 09 Jul 2021 19:31:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F5M1LHgG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233734AbhGJCcm (ORCPT + 99 others); Fri, 9 Jul 2021 22:32:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:42072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233919AbhGJC2s (ORCPT ); Fri, 9 Jul 2021 22:28:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 18BBA613E6; Sat, 10 Jul 2021 02:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883918; bh=vvNFKjo3S7GYrtBrbT3IM7WLg8q6w99zy/ti0f4UP0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F5M1LHgGEuh1bAlWyG4C5rhonM76Lp4pmnCKam/LTg5jZTJ3XSLxQDOZO6S8vcd6w ZSGZwiXGt3b8nnAthyuggnM6syAVqbQws8+Nr8FQ3LQtgqnVfIDRxVsb3L3Tq452Mt 4lIeSz6WezVS1yqSuFj77j8ZkJOiYWQc/CrEgepflc3J/ImYkXY5AtfdBtVG423y4f dzXfucmEZvPy6eGXV0BQ9ejdrKcrrm/T0v0TW9VRSuqHLjSKkoDR0gXUDlNdNTjdpn Y3z2cOz4aPoePK/0WBceuBkiRIrRMfypTa2j0nqE+l1JM/15R+zfloLhXENwC/Cnl6 iBBSHDcPLUS8A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mike Christie , Lee Duncan , "Martin K . Petersen" , Sasha Levin , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 37/93] scsi: iscsi: Add iscsi_cls_conn refcount helpers Date: Fri, 9 Jul 2021 22:23:31 -0400 Message-Id: <20210710022428.3169839-37-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022428.3169839-1-sashal@kernel.org> References: <20210710022428.3169839-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Christie [ Upstream commit b1d19e8c92cfb0ded180ef3376c20e130414e067 ] There are a couple places where we could free the iscsi_cls_conn while it's still in use. This adds some helpers to get/put a refcount on the struct and converts an exiting user. Subsequent commits will then use the helpers to fix 2 bugs in the eh code. Link: https://lore.kernel.org/r/20210525181821.7617-11-michael.christie@oracle.com Reviewed-by: Lee Duncan Signed-off-by: Mike Christie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libiscsi.c | 7 ++----- drivers/scsi/scsi_transport_iscsi.c | 12 ++++++++++++ include/scsi/scsi_transport_iscsi.h | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 41b8192d207d..67ac0a46889c 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1348,7 +1348,6 @@ void iscsi_session_failure(struct iscsi_session *session, enum iscsi_err err) { struct iscsi_conn *conn; - struct device *dev; spin_lock_bh(&session->frwd_lock); conn = session->leadconn; @@ -1357,10 +1356,8 @@ void iscsi_session_failure(struct iscsi_session *session, return; } - dev = get_device(&conn->cls_conn->dev); + iscsi_get_conn(conn->cls_conn); spin_unlock_bh(&session->frwd_lock); - if (!dev) - return; /* * if the host is being removed bypass the connection * recovery initialization because we are going to kill @@ -1370,7 +1367,7 @@ void iscsi_session_failure(struct iscsi_session *session, iscsi_conn_error_event(conn->cls_conn, err); else iscsi_conn_failure(conn, err); - put_device(dev); + iscsi_put_conn(conn->cls_conn); } EXPORT_SYMBOL_GPL(iscsi_session_failure); diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index c53c3f9fa526..a7db7c06f21c 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2351,6 +2351,18 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn) } EXPORT_SYMBOL_GPL(iscsi_destroy_conn); +void iscsi_put_conn(struct iscsi_cls_conn *conn) +{ + put_device(&conn->dev); +} +EXPORT_SYMBOL_GPL(iscsi_put_conn); + +void iscsi_get_conn(struct iscsi_cls_conn *conn) +{ + get_device(&conn->dev); +} +EXPORT_SYMBOL_GPL(iscsi_get_conn); + /* * iscsi interface functions */ diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 8a26a2ffa952..600f12105791 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -433,6 +433,8 @@ extern void iscsi_remove_session(struct iscsi_cls_session *session); extern void iscsi_free_session(struct iscsi_cls_session *session); extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, int dd_size, uint32_t cid); +extern void iscsi_put_conn(struct iscsi_cls_conn *conn); +extern void iscsi_get_conn(struct iscsi_cls_conn *conn); extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); extern void iscsi_unblock_session(struct iscsi_cls_session *session); extern void iscsi_block_session(struct iscsi_cls_session *session); -- 2.30.2