Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1145152pxv; Fri, 9 Jul 2021 19:26:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJQQ+eVq+0mutRcUG5l+jYYPDvLGiSd1b+aeyARNSopBLB0y5ciI/jFyumbr987mPXre6X X-Received: by 2002:a17:906:3ed4:: with SMTP id d20mr41679277ejj.515.1625884012562; Fri, 09 Jul 2021 19:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625884012; cv=none; d=google.com; s=arc-20160816; b=GBiCZGau+oCkMAyzin6K07ZqR5ZnVShvz/4LeEnFbQV1q9TY2EPxSS8POWPQILoTu0 LdFiqIiloNw0P+Mwg89oERl1bVHDPygJBRwOMz/pWUgI4Z+N5smXOlQmarhPFXKLumta yWYf2TTenWya30ous0MbfSeSquQnoIyAmrQ1Ok+ewDUu/T0PcEtdYeOnQB7QTcJj80gw HGw/4uT174a0/jy3x4EoNvHFD6LEVLqIMCqW6FLjhbR2sO83HikVDBnoH4j6AUjy93DK KrG8Nfq2y7xG7amoXrM9++FG0JCFYfD3fuLaI7gDFEKWhdm8hQYATYrx8CZ/rxf+d4j+ R/yQ== 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=Ws8KYbcMTBSfivkdzQG2IkMWH/fogo+SJiu8UQSGb3I=; b=zmlfst3Z/C8KLR9v9ZYCt4WQ82MWbVXpmqemay4xW9mm63EhLixZyTrUKy8veUYwcu gwNryKu4YbNjkdSR6DRzWwouv5ocFolLYtQ0b2UBt6NrWWa3lwtj+8I+ETNmcfnrwQuB F653xLZSuwg9GrNtlWCJYIDKkfVEqiBw6g2V6KygOa9Obmj8P0Ajk1jjFDG2zitOjwfq nNXnR6q87rl7VRijLVUtjJ/kMNK76hKMOrNLYV5Q5UnxeXRz6Gw+ekXX6R1CyXARQGAk NYcQVaNm2GGysnHss9Wx1xsJxhInXuazSvjsMF6d3cZatHqD1R9OKIuFk/izpdyb+4hp jXDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sfe+3D+3; 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 jy12si8799816ejc.729.2021.07.09.19.26.29; Fri, 09 Jul 2021 19:26:52 -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=sfe+3D+3; 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 S231803AbhGJC01 (ORCPT + 99 others); Fri, 9 Jul 2021 22:26:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:42738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233224AbhGJCZe (ORCPT ); Fri, 9 Jul 2021 22:25:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A79560BD3; Sat, 10 Jul 2021 02:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883769; bh=7qYOdwUMptCr5BbkWuan4Mf4wHExUrwkhqKgzUYttF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfe+3D+3zV6nnsafuqQ/GmDadgDUD1webS2yBW6VUv5bvXD9nmyAGW7yECYathVyO Bo2VtaWQ3SxiOELqIZd54qepr8RBHVQaxcKpjF04kGgYuJXKPPD6F78ZrEAKHQ+x6L TONDxR8u45wtfseniPCzcZFAaZ+sS+Q71/B8utw+kAluYaJfERa1W4zsnVWbWg9hjK nzKWDuPnLNiiNKzNFpzXfQVt/Xd5kvpTJFOAlQwib+lrs9b2Y4tOf2lsjS8ajA6Vf9 SywqmvboZKnXdwYuuORcX/xBDcug/0TBNsctjeyhp8/vdOIGy/whCBuyaboBxyYwJZ QBUsQQGbC5/7A== 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.12 040/104] scsi: iscsi: Add iscsi_cls_conn refcount helpers Date: Fri, 9 Jul 2021 22:20:52 -0400 Message-Id: <20210710022156.3168825-40-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-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 2aaf83678654..ab39d7f65bbb 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1361,7 +1361,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; @@ -1370,10 +1369,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 @@ -1383,7 +1380,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 82491343e94a..869cfc329da9 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2348,6 +2348,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 8874016b3c9a..eb6ed499324d 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -435,6 +435,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