Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7062841rwi; Mon, 24 Oct 2022 09:21:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6n70Oth2wGNzDC3e3iigWUWuGzZt+FWpo7Ws7VbewlZvnLq/4fWjS/tFAaBUPpm/ElZSLb X-Received: by 2002:a17:907:3d91:b0:78d:f675:5659 with SMTP id he17-20020a1709073d9100b0078df6755659mr27721345ejc.92.1666628476648; Mon, 24 Oct 2022 09:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666628476; cv=none; d=google.com; s=arc-20160816; b=DXFurmw5sWFsjjn3KHFLrEtv3WGLQlKNfAfzR8ZqubKkTnd3lTOMqKdX+0ysiNxnN4 mzbqa5Mgzth0D2QXaVK0we8Wb+A3SwnoD9dDRUJRptGrFKckr5RxlhqYcq3xWWIhE/Lj ekyf1xzqNEV4DrKYFzLDEHtdwgH6wKeLRl64QhdCJOYNu0cX6bnglWtyvAOACEeMHIkv gRtxUxCDhYLrl+TdxEtCPMAsmiiz8GBNg3W46oMHgiAl4UTbEkq2FLbXbG/6u+eWUYy/ HVbVLJL8Pzo0Lc9nSJ/xjWNgVy0YEjpkUOZnkz1Ir4emR6Zk/6eemSP+G7Fd2C3qOSJU gL2w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1dvHl3ddoSB+e232C/aREXv0lxaV3S8a9CIHDEbqiXw=; b=jx5tLf3LrmhWqqVYs5+3sH5Ana59v5o74vaLE/1gC+nb6+hug2dn65Vh6GEaC8Nv2o 836OrwdbRftmuOKLMMByi7HPBpogdkWjzNmQamWVVL33AviQiNBz7LTzZ6Aq/Em8tDDC myu1O9FNEz/inFKe2QKd9jVAgrt8+HzpCv5fGFguwmtB5h47Kx/lF3M9lu2yVElz9H5W SvbOvA1nOduUpi5Oc5ysqQoj81w9DLecnEv0UIW8oCYY2qoqHVSeWJNOavEsf7OnqoP4 iWKVfyIlp2ZIY5ps4cPQApqUdBKXE0KRVrcezdpYWbqu+Vwj/PPg9wnlT4OXor+QqTwF er+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ya7IHMhi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a11-20020a509b4b000000b00457f31c1a10si130005edj.584.2022.10.24.09.20.49; Mon, 24 Oct 2022 09:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ya7IHMhi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232821AbiJXQDm (ORCPT + 99 others); Mon, 24 Oct 2022 12:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232686AbiJXQCd (ORCPT ); Mon, 24 Oct 2022 12:02:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F1C491F4; Mon, 24 Oct 2022 07:55:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CD4EBB819EE; Mon, 24 Oct 2022 12:48:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D3F9C433D6; Mon, 24 Oct 2022 12:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615737; bh=dirqGtiqwRgMxq1A/NUdYxtS7zQOiVtCO+7bR8qfAAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ya7IHMhiOv/3b8OL1UShF7zg7ThR8F4MHHTmp32cXXdwuxJf/F+npugGTRlN5mrrC ZOyeYE87bbjRSFpfSi2ZhusgRZ/BjeH40NYoxlIl2TvPKa486o1TYoOcsAARaZOw7n pFepyxzPCh0fN/l567KP6bYTZ9EvZzN/3d4tAA18= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Duncan , Mike Christie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.15 334/530] scsi: iscsi: Add recv workqueue helpers Date: Mon, 24 Oct 2022 13:31:18 +0200 Message-Id: <20221024113100.129624348@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Christie [ Upstream commit 8af809966c0b34cfacd8da9a412689b8e9910354 ] Add helpers to allow the drivers to run their recv paths from libiscsi's workqueue. Link: https://lore.kernel.org/r/20220616224557.115234-3-michael.christie@oracle.com Reviewed-by: Lee Duncan Signed-off-by: Mike Christie Signed-off-by: Martin K. Petersen Stable-dep-of: 57569c37f0ad ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()") Signed-off-by: Sasha Levin --- drivers/scsi/libiscsi.c | 29 +++++++++++++++++++++++++++-- include/scsi/libiscsi.h | 4 ++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 1cb18b80d182..73d235540b98 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -93,6 +93,16 @@ inline void iscsi_conn_queue_xmit(struct iscsi_conn *conn) } EXPORT_SYMBOL_GPL(iscsi_conn_queue_xmit); +inline void iscsi_conn_queue_recv(struct iscsi_conn *conn) +{ + struct Scsi_Host *shost = conn->session->host; + struct iscsi_host *ihost = shost_priv(shost); + + if (ihost->workq && !test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags)) + queue_work(ihost->workq, &conn->recvwork); +} +EXPORT_SYMBOL_GPL(iscsi_conn_queue_recv); + static void __iscsi_update_cmdsn(struct iscsi_session *session, uint32_t exp_cmdsn, uint32_t max_cmdsn) { @@ -1943,7 +1953,7 @@ EXPORT_SYMBOL_GPL(iscsi_suspend_queue); /** * iscsi_suspend_tx - suspend iscsi_data_xmit - * @conn: iscsi conn tp stop processing IO on. + * @conn: iscsi conn to stop processing IO on. * * This function sets the suspend bit to prevent iscsi_data_xmit * from sending new IO, and if work is queued on the xmit thread @@ -1956,7 +1966,7 @@ void iscsi_suspend_tx(struct iscsi_conn *conn) set_bit(ISCSI_CONN_FLAG_SUSPEND_TX, &conn->flags); if (ihost->workq) - flush_workqueue(ihost->workq); + flush_work(&conn->xmitwork); } EXPORT_SYMBOL_GPL(iscsi_suspend_tx); @@ -1966,6 +1976,21 @@ static void iscsi_start_tx(struct iscsi_conn *conn) iscsi_conn_queue_xmit(conn); } +/** + * iscsi_suspend_rx - Prevent recvwork from running again. + * @conn: iscsi conn to stop. + */ +void iscsi_suspend_rx(struct iscsi_conn *conn) +{ + struct Scsi_Host *shost = conn->session->host; + struct iscsi_host *ihost = shost_priv(shost); + + set_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags); + if (ihost->workq) + flush_work(&conn->recvwork); +} +EXPORT_SYMBOL_GPL(iscsi_suspend_rx); + /* * We want to make sure a ping is in flight. It has timed out. * And we are not busy processing a pdu that is making diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index ffffce144fdb..5cf84228b51d 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -201,6 +201,8 @@ struct iscsi_conn { struct list_head cmdqueue; /* data-path cmd queue */ struct list_head requeue; /* tasks needing another run */ struct work_struct xmitwork; /* per-conn. xmit workqueue */ + /* recv */ + struct work_struct recvwork; unsigned long flags; /* ISCSI_CONN_FLAGs */ /* negotiated params */ @@ -441,8 +443,10 @@ extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, extern int iscsi_conn_get_addr_param(struct sockaddr_storage *addr, enum iscsi_param param, char *buf); extern void iscsi_suspend_tx(struct iscsi_conn *conn); +extern void iscsi_suspend_rx(struct iscsi_conn *conn); extern void iscsi_suspend_queue(struct iscsi_conn *conn); extern void iscsi_conn_queue_xmit(struct iscsi_conn *conn); +extern void iscsi_conn_queue_recv(struct iscsi_conn *conn); #define iscsi_conn_printk(prefix, _c, fmt, a...) \ iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \ -- 2.35.1