Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1151225pxv; Fri, 9 Jul 2021 19:39:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2zn85hr9dys0Ifsah5/Ko0Uq3tVXJUx3xc/z1BRz8ZQeLFmZqPMWPijMEWq1zRrB720oy X-Received: by 2002:a17:907:9809:: with SMTP id ji9mr27135618ejc.63.1625884771229; Fri, 09 Jul 2021 19:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884771; cv=none; d=google.com; s=arc-20160816; b=yDexZKNHSdVDw2d50FDZLenmU2ZKjB7pQHCkq2Aeuo4s5nG7PbVjaW70e8MU4XVPGs YEPzG/SEMYZ0a8oOaTDkGjQYiG2Wvm7NcYW2jpnUi8FMuA0A7pq8LF0yal1aMKNJK1W3 bzF7Sl/wkukEvsRhZP3+ntuRIGK3Li6AlOhtXLxc7K9pcImIVmKrSDC4VlE0ZQCjeTA4 czLpqCrWb3rBf1/FxZx1jzmvrRZm3A7sa/80a4JF9GjZExhZTCCKj5bPUcjVtSVRFONr 3kRKzHxS6A6H63RhvRC9YutSYC7hz2z3mEGlAHAhxDLcs+Dp2wROtCBB18cY3f5ilFWW oigw== 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=wrkI2NRF63AIAR/lN8oC8TbocX9umlVrvf0LHm9CgDE=; b=zcaVC4Oe+vktMtmONe+KTEdDy7KkDw1hFJbz4Jm2foKt7nm7Aa3T9poP3+9tudSox1 B8/Wlo1Pb0O8wKecgh4PBLuPeriDrnA1rxa/LW/NXBaxVRB9KF8hPKfRWR2W4OUW3sNw drUdAE4hKinqO907OtLnmL5aPZEnWa6WhkDFlo+EqVFxBy1cRZzVO70rG+MwGyJqTXtL 24MBr/JXtuRuVCPG5UIDCplfY4sPLxiZ1hVlZW6jpJRpdBNWgbF4sVIcfxcHMr6T35IV Wb1bqVvt6mREY236nu2KYYCDlrS4OUQIdtxJ95JrEt/0SJzQK2723uthVrE8G6ZA0pZx aaVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fMp18Kx1; 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 w3si9184003ejf.235.2021.07.09.19.39.08; Fri, 09 Jul 2021 19:39:31 -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=fMp18Kx1; 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 S234534AbhGJCix (ORCPT + 99 others); Fri, 9 Jul 2021 22:38:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:53316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233721AbhGJCfY (ORCPT ); Fri, 9 Jul 2021 22:35:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D766A613EB; Sat, 10 Jul 2021 02:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625884340; bh=ueO+DyAUuyzO2QJUmIGDwazdbbXNYoUKKL9SK3kwnhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fMp18Kx1inItIGZSh4Yclg1fQS7hx/Nu25eeXR+9xMx6BUCHIIH4rLpZSNmsDWxQF cFNQSSohMVw3xiKSVvVthlAOgq0Eai+hNQ2qHlDeBvgBETFkeyqUyklS3MAleAg3ft Xy4+rZ/yNxyFE9J3fJpG6VeNIluQ5m1tVPt6L0jV/WIIVaqP5rbW3/3I7ujmwcLgut StnuSmlj3rBUeWQ9O354MQAGz1ADgDmx0G5kfeapw5ij/fOcF9aWbMmepc9oIQrTxm NjlMTQwv6xIFnJ4OmFGhcrQ0z32OBrk3tUkKLUWHDD6c7rfUfq68I1CeCQLFYBd82x 26kYHZNkHO8IA== 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 4.19 13/39] scsi: iscsi: Add iscsi_cls_conn refcount helpers Date: Fri, 9 Jul 2021 22:31:38 -0400 Message-Id: <20210710023204.3171428-13-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710023204.3171428-1-sashal@kernel.org> References: <20210710023204.3171428-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 81471c304991..52521b68f0a7 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1385,7 +1385,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; @@ -1394,10 +1393,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 @@ -1407,7 +1404,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 e340b05278b6..2aaa5a2bd613 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2306,6 +2306,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 b266d2a3bcb1..484e9787d817 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -436,6 +436,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