From patchwork Sun Apr 11 07:55:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 419412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C8D1C433B4 for ; Sun, 11 Apr 2021 07:56:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 523AE611CE for ; Sun, 11 Apr 2021 07:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbhDKH4i (ORCPT ); Sun, 11 Apr 2021 03:56:38 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47706 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235071AbhDKH4e (ORCPT ); Sun, 11 Apr 2021 03:56:34 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7oLPm128258; Sun, 11 Apr 2021 07:55:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=rTVY5gwUSmjiV+mMIv3DACwgKheeUkYWLyJhX6pOGaM=; b=UNwePx68Jv0eP9GYnznhbZ0Gnv1lCXnppaANcq8RAoHlAKwxbu5vwXOChkaSTMU6MFIE aEnn9L+goWjI202Z06mfdZRakoxdzfAIBCYmlDHyp9XCdcVRQx2Hr9PED2ajRGAWJhco 61nUMXu9iCBPHJB5m8GoSMhlLl59zouGcWzLx18z1hC29g/09pipnC/jJV2K/oke97c9 sdHOikoCTkMO0goATYLSltWHROQADt0ud+YXfF4SjB8QVTGBI7ocJC/EFYVyZ4SINLKw pLUNuDLXfk7kgzM1pFnRQIFOWlAo4bgykQg71nyWsMMZruH/LAO3wbsx3u8yqW3PCLVe UQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 37u4nn998r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:55:57 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7tXbM017877; Sun, 11 Apr 2021 07:55:57 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2049.outbound.protection.outlook.com [104.47.73.49]) by aserp3020.oracle.com with ESMTP id 37unww7qm8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:55:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nz/1Bfx0jJZxSueBdr8m0cM5ScVo1AeIIcZc4/w3YiWiLdYu6WfuVFN0oE67GSdftzl3ZuTU7IZa7nDeIl7O+LkHH6jMtqs69LlF/vACwpGrH6OI705SOsovcycC7e/Yd6oIVl+VSIroJrjS3PEBsUnYX4M1EAX+X/h/KU1OazuiWIc/z/62D0E1QsUdSoIX7/EfQwFYj/XnXaroeRepBZuQTz2kyqCKm2X3Cd0hORoPJMBdxPN6MtJ+EWalAks845WyEj0+AChD7+zO0VL+Q3TMQF1bNOjFh+a7SHp5rOG299px0CmbOlqAkS/RAevdSq83ugg7Y6QmxsrVWHFoMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rTVY5gwUSmjiV+mMIv3DACwgKheeUkYWLyJhX6pOGaM=; b=MstGVmpGG9+q+MQZx+7VkiLTRK6B5ir8ABI9EYpRLP2mwlg6hN2EgWcZya94Uauv0fWBP7Cgey1KKpJAwjJwVABD97iCGwrZxBZglavv1X/BbW1rLmtpqB6cin3bo343bDzSqcfK6jTJNLIE43zMuQwByHbjj/zl+snq4QeyNYvxpgdZeAx45i3Km8d3yvOYiQv9DWwptSRY3KYaY33KVahxHa6udgyniMtr+1sDr44zIDta6nyPjYX0R0q8QcO6N0Ww3DaJwHfcOtIEwB9sYN86sG9ryrJpa7jQj6JzEb6cztvPE592LF3TuvD2aQF37JSWYhIlM8HWeBA+Mkiw0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rTVY5gwUSmjiV+mMIv3DACwgKheeUkYWLyJhX6pOGaM=; b=efjkrEkaKIstOBBCcFIK88Pafmr2IS8zazjU9TO8rp3OpaUUJPG//h++OTupk/0Igk+Or6OVO0HW2te1rOJm8sjuVLgb3elVtX/QGPggn70IKD7GOuMGByI3gGnkdb8tMUxVHkZ2mzKxy9O95kyh3Dab3iXwanMn0UB2vdxIXxI= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB3842.namprd10.prod.outlook.com (2603:10b6:a03:1f9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Sun, 11 Apr 2021 07:55:55 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.4020.018; Sun, 11 Apr 2021 07:55:54 +0000 From: Mike Christie To: lduncan@suse.com, martin.petersen@oracle.com, rbharath@google.com, krisman@collabora.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie , Gulam Mohamed Subject: [RFC 1/7] scsi: iscsi: fix iscsi cls conn state Date: Sun, 11 Apr 2021 02:55:39 -0500 Message-Id: <20210411075545.27866-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210411075545.27866-1-michael.christie@oracle.com> References: <20210411075545.27866-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Sun, 11 Apr 2021 07:55:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7af89a59-9544-4bb5-ab6b-08d8fcbf3bce X-MS-TrafficTypeDiagnostic: BY5PR10MB3842: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:67; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LuyuhrYW5mmr1KUv2jA4fHZ+TxyymvN1l7mh6r8nJItJLh+UybGl4mFoIT4dTM2x8bJz+UEAlHX7zqz6nDb5YWggSwXrCxqnOm5bvbZ62F1H3TizOco+1qtACcy04pLp1G4sL/b19tP3EypE5bjIMzOFyNmaygBsJgE0L0q4DXnqi/fnngjUpCKBrUxfV6qHSJNJLyVjroOLMtw1uo02FOq/pnDFbsbsXtn40DXzbraCcJW3Ks56tOM8FwQt81qHOiUf75/Qz8/yXwW6n/IbhTfGV4A3fHo8lIggFa9YyJlaS28EX1y3ttK3iahAMFBtsXf+YsDRJnsrvkQsm1iLZh2EsKrvdmdkXAxKAhqwVv5+818pEhgCvAu1k/GwiNXPiOscI91yh6DpdLU62SJ+nCqoZQhos5A1LfRGIicsjCH9hXimg66z/l1kFuI+41Azb4Qja9fEq2gwH6p4pKpDdnPavBY8W4WsQjQPTlNmiFiYvlUMRM+DQzNkNltlEgrclFpqgpA+yoHfKqOjotdpDsdTChM6gBRYDYNa9+bfKUptNrTzZWWexXJDEgJbyo4AWxkbLJzpBexu3Tg690ti5R2XWEL360wHVKQ6/YmFDzIB8YvZT6Rf5MJH3Gi1MVB0pYiAOsiqOTrj/xm71HYIHvT3AkP7tAwsS9+OFayx/gcvYpdGIMMmqotIHNVKRtjR X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(376002)(346002)(396003)(366004)(136003)(8936002)(16526019)(6486002)(316002)(66476007)(6506007)(956004)(54906003)(2906002)(8676002)(2616005)(26005)(5660300002)(6666004)(86362001)(38350700002)(52116002)(38100700002)(69590400012)(186003)(66946007)(1076003)(83380400001)(36756003)(6512007)(107886003)(478600001)(4326008)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: dvPJtK0dftFo5ylP+Yh3WOK6u1bCKMlkgBf5qI0pUwx6blSSYboY8foeCO6BFH/u/6/mxOV9uDJWfJvtT3rCORue6ZseXQmL+0TM5stnQSK5/2uH3Lnz9UuvEbkWZbbHte4t7nPO6PZDOtCK0AUCKP/0cMrXqK8vQERy74PX1XJVAo9z91z0In2xcoBvTTy8ePEVqBrlm2tddG9hV7E3oeitzhnnEi+1Xgd/asamMabiNkR7pITPRG9av08h7g4XDCLZIlTc4OIsyOAT2h/4d3y2+zGNkHznr1Swa7x9jv2VMaYzVqBp7iCncMyXpeM1vmkscZJbQKcdFJfW5wOKC0WVFY8ZfF7+DpjIbi7gkJs4BWlHzbeP4palmpj+vwU0R45SNCj3KnAXi/OZYpNECOq0zfH4PWdpXPBojP+2gEC6FqvMJLca4pbmF2KPEJoReyuyPHsebD9thhxinTLL0eIsGLxkrBSvCAE9Gf0jnuIAh9i668m06IRZ5ecJyCmqIZ9F5JpUsYvZ6YeORa6rtJtaYk2GtGy9vFokSlYz14jlQgZV13xS+PUepEjCgN6AVUg87QOLnHXLpmqVTxO927VUST/ACV9SFvcRpTsx2yjRJutG8zx5Oh6/FgB6+CYD6CWzKMygsqwgCRm4tSMP8YInAHgNPS4FoV6haz7slpvelpfXB5HdY25SQMz/9w8A3rGIaPBW13h8VkxIcAIarqPaZh3LZ5pYMh4riJDOOEwyB8sCtD1LuGDeRyuT4bPyxTfU7zxGwxdMWHeiOJX+oEh/sJUX2rh4seFTqnDI3En0B/jhVELSiMoDshwX9/fhG2gtHs8QXZIJ1g72nOx1/xH7vDKLI6A82SVGlIGtMBccOtvaKDdYd4ovNg99GuYwjxmmA1bUh4k1uAH7U3sCNVS9zs6Krk0j98EQFtJGKExBJeAeXrexzXwIpKj0BuUeADtdTK7g389CEhVSfy3/ZTY2nTUCRaPk5YcjhF42aK6z6FRnB4VNQTKDD6jBZkTSFqC7M1wvLI1Lf8etns/I6JDt6rvaNJGtiEJCChjNwfkeHwmYt2G77vajTofcpTNfIrYHzmtwzW4Rpyo3A5gaIwBMvMpM+HbL+UvXeRyUBWl06Zq/f5Bed4k3LZuDMznXdj+si8/YHAE3teyUrcW6xu56yoVMgM2Hp2YiVSamr7lbdkSSz7Xih5U9EbNR+h7OIS443KwVQj783gZ5KzSYrzySlLm1XIq4bqkKHiKVSVhFUOdRZH72y6hWwVrMpszRr7Q/096DU4WBf4L9rjIwXGyRDrwe5DMoC5dl/GXN5bl+spg1CUqtxv/zk4HgG1v5 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7af89a59-9544-4bb5-ab6b-08d8fcbf3bce X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2021 07:55:54.7507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7J14/gWtO+67gLgX0wHbAGTr3xLLFOLFelNcXU3Z4HZn/eV0cwXdhjO2RVeyhGW7aXMh86O25ceoFw4BFG4hkMKpboKKsqWzxHFdOmo0fus= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3842 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110060 X-Proofpoint-ORIG-GUID: hnD24suPN5caqpMG5QRSWB3d2tNprKYS X-Proofpoint-GUID: hnD24suPN5caqpMG5QRSWB3d2tNprKYS X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110059 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In commit 9e67600ed6b8 ("scsi: iscsi: Fix race condition between login and sync thread") I missed that libiscsi was now setting the iscsi class state, and that patch ended up resetting the state during conn stoppage and using the wrong state value during ep_disconnect. This patch moves the setting of the class state to the class module and then fixes the two issues above. Fixes: 9e67600ed6b8 ("scsi: iscsi: Fix race condition between login and sync thread") Cc: Gulam Mohamed Reviewed-by: Mike Christie Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 26 +++----------------------- drivers/scsi/scsi_transport_iscsi.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 04633e5157e9..4834219497ee 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -3179,9 +3179,10 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) } } -static void iscsi_start_session_recovery(struct iscsi_session *session, - struct iscsi_conn *conn, int flag) +void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) { + struct iscsi_conn *conn = cls_conn->dd_data; + struct iscsi_session *session = conn->session; int old_stop_stage; mutex_lock(&session->eh_mutex); @@ -3239,27 +3240,6 @@ static void iscsi_start_session_recovery(struct iscsi_session *session, spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); } - -void iscsi_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) -{ - struct iscsi_conn *conn = cls_conn->dd_data; - struct iscsi_session *session = conn->session; - - switch (flag) { - case STOP_CONN_RECOVER: - cls_conn->state = ISCSI_CONN_FAILED; - break; - case STOP_CONN_TERM: - cls_conn->state = ISCSI_CONN_DOWN; - break; - default: - iscsi_conn_printk(KERN_ERR, conn, - "invalid stop flag %d\n", flag); - return; - } - - iscsi_start_session_recovery(session, conn, flag); -} EXPORT_SYMBOL_GPL(iscsi_conn_stop); int iscsi_conn_bind(struct iscsi_cls_session *cls_session, diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index f4bf62b007a0..441f0152193f 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2474,10 +2474,22 @@ static void iscsi_if_stop_conn(struct iscsi_cls_conn *conn, int flag) * it works. */ mutex_lock(&conn_mutex); + switch (flag) { + case STOP_CONN_RECOVER: + conn->state = ISCSI_CONN_FAILED; + break; + case STOP_CONN_TERM: + conn->state = ISCSI_CONN_DOWN; + break; + default: + iscsi_cls_conn_printk(KERN_ERR, conn, + "invalid stop flag %d\n", flag); + goto unlock; + } + conn->transport->stop_conn(conn, flag); - conn->state = ISCSI_CONN_DOWN; +unlock: mutex_unlock(&conn_mutex); - } static void stop_conn_work_fn(struct work_struct *work) @@ -2968,7 +2980,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport, mutex_lock(&conn->ep_mutex); conn->ep = NULL; mutex_unlock(&conn->ep_mutex); - conn->state = ISCSI_CONN_DOWN; + conn->state = ISCSI_CONN_FAILED; } transport->ep_disconnect(ep); From patchwork Sun Apr 11 07:55:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 419415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62E3DC433ED for ; Sun, 11 Apr 2021 07:56:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33FE7611CE for ; Sun, 11 Apr 2021 07:56:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233612AbhDKH41 (ORCPT ); Sun, 11 Apr 2021 03:56:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33464 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbhDKH40 (ORCPT ); Sun, 11 Apr 2021 03:56:26 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7oLfe044432; Sun, 11 Apr 2021 07:55:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=AdrLeK6jS8cVeWXrn6bZE5v/0JnyCRbGcv1sxBaB2lY=; b=kIrVu24HXq9KWjufsNz1svKOikpMHwkaqNq2ebLeJkpnQjt9VbX4ZviQfqrD3D1N9nDX tcE3ZmF9+lsocAFAa0BZEM0BYtoKzq9rwxa7a+cl27Ca4xx9PDvDf4H8qOjB3U17oiAv rIJkcwljmUu0+aDYBw7dNi1X48qvUSIHUDzDi/a+KYhDCCpvT+bXo1uI9lN9/Bd1/0MW D2SbkjlvBbGbObEB2oIwYbYPLnZeKSeK7brjBIB+yLvQHRTDVkfFXvbJXWNRx1xU1c4w ZCvZWhxyabHlzTZ8nGLuRIiR6RFgb4lMzAg2CKQBr5IYWryKoIZSWf9P4dtz4wJcqv2G kw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 37u3ym99ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:55:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7tXbO017877; Sun, 11 Apr 2021 07:55:58 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2049.outbound.protection.outlook.com [104.47.73.49]) by aserp3020.oracle.com with ESMTP id 37unww7qm8-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:55:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sx3FT2VngPCxSmYH0/gymUs0O+5s/Rt3YsydIrQ9uKRWKDsNBH8AdJYNyplp7Wz2CViNVt9I4YLyE3fnxfVKb0LyazUTFofQF4Imkj2jTejEn9x/Ou1VycR119UGWLtpo75fI/aygSAowA4Y0GEdVLvDUX9EsVoj+vMKAHZE4UMUrX2CryBJH0uZ4TLwBn0L6iE3VBNWUSvFEEvPwJdmGlQVitwb7VjraYags56tjMBtSnnd9QsSitrY+7mMVfKd4B15Ka7FkljIMMg44xmNeAgisefMTEaHe+eA2Co04eJPVJWM6lMkROFJaftHzAZkMBMq2vQ+TFKfuAJJWXo89A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AdrLeK6jS8cVeWXrn6bZE5v/0JnyCRbGcv1sxBaB2lY=; b=ftrOOMvFpHL7+A8j7oHG6GckXINUdwL3ZuEPZoyun03HkpLDjVwwgZV82x13vu7kMHUFHc+0vfOToKOJXKXOMfxcFjdOBg/US4xlb/WAy6yRXyy3I7M3ywFD5XwCRY2RdyrAO39mmzcOIKrvw9VOXqJgsenw9L9aD2JTwSp2OnUSmo1ggXGUL6bmccewcJ6v/zMXMMJThXvISQFz6VNsrEk34mPXBAILCdA+aWQKfI/O00ehkhjwzFdtxxAxGITu+9dftE7r84gxZ7y2QzoXaP+NRHSBI6f1vgSxiwNFJXV/dQMmWw1UBGkVA92qSsuGTk1iS6Ui/46WRLAsxWyX2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AdrLeK6jS8cVeWXrn6bZE5v/0JnyCRbGcv1sxBaB2lY=; b=C50kvoh9suzun/xUst7dIPyjuJ8NWJOV6CCrZpxqXWO2V7EmOjxNyms54F6QeC7o7cYtbzbZlniwQyPrwNpGOU2MNOofyNIz1/HQx4VQRkniIWv1JjWc3RifIKw+qpe/gAbADfdXdbcqAU6JfX5sn2LUVM34447A/rnewdZTYfE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB3842.namprd10.prod.outlook.com (2603:10b6:a03:1f9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Sun, 11 Apr 2021 07:55:56 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.4020.018; Sun, 11 Apr 2021 07:55:56 +0000 From: Mike Christie To: lduncan@suse.com, martin.petersen@oracle.com, rbharath@google.com, krisman@collabora.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [RFC 3/7] scsi: iscsi: make iscsi_eh_timer wq generic Date: Sun, 11 Apr 2021 02:55:41 -0500 Message-Id: <20210411075545.27866-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210411075545.27866-1-michael.christie@oracle.com> References: <20210411075545.27866-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Sun, 11 Apr 2021 07:55:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 947bf6fa-f96c-4194-8549-08d8fcbf3cff X-MS-TrafficTypeDiagnostic: BY5PR10MB3842: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eiQnzXLQkA1g+X5P4y64D4DGNk0wJSCwotUHfGDbBw5lc3wrheb6UbjZSxghTp6h+3ezPQEJloc3JjORaV68KKPI0YhW5SMNbsQAtA1/JNvdxad0FSatNkWGzOl8MMuLai3BN9dabLUrqRYXQ/z7PdOW0wKQySWA+nJKwJUC0/eCt9L6llgRsbXUk+zSGkufXLXcVOchfjy1HbUWXuTgk5Tm/iWAbYTRCOYXHFLPau82naVUamO73al25xkaR7P1iTjzQl3pdXj4qpc5uLqpA0v+sViq0/OTfrUOqV66Q2PuzgfcTaCiFNXEn7UAWg8d0XB9D/GHAFoOL4uJylgtqw9gBI/vCKzvCqjjChs87Tu1Pr5CCdhThxhLZXtOsIjqAd9TWb8I3ToMCgXpNbValUVPbuC5XLVmMHX4r4jr88uOnwO3PVGKqQ0VZEStLoYuYb7aXdlNmMIDc455nCMTU0Ov4xeTbDkNkxHaw/ZJUIyvMxDtrDe+ipOEz7JSJRZyNVJGul7oBtu6f6vhU/ZK6tBCmGOy/nSI6edk8dGvRi3bz9uzL+53VnouVTnpEURviL0H1eyoaF9NR2sfbHX1hIeaQYvgHE82DoF7k8RSOuf/l+do1LTY4+Snn8ZpWaZB8K2ItM03CNfULJJOkZs3W3jFi17LijnZXSXWuYeFOJsxUsVltDuzc6dC129VYwOQw4ZOQpZQ0xc+yinPhfzoOA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(376002)(346002)(396003)(366004)(136003)(8936002)(16526019)(6486002)(316002)(66476007)(6506007)(956004)(2906002)(8676002)(2616005)(26005)(5660300002)(6666004)(86362001)(38350700002)(52116002)(38100700002)(69590400012)(186003)(66946007)(1076003)(83380400001)(36756003)(6512007)(107886003)(478600001)(4326008)(66556008)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eNcZQrwCJSHysyYfMs46amAj/TDP269GUxY5H2S65ePF4CemS0INwVOqhUX3jgk4RFKoeHCM+qM1bILBta87zjtRinMEG3EZ2xN9xBURLLe/GGrScXF7qZbw6SRpw4D90xjgU1o6gjg/+27kzE4da61Hgqg6X8tZoJHSsqdTiiVhm4mHjC6SEklPYIRylcPcE/QcMc+LoCmQDsARAtSlFQfnB3G9oCS4q/3fz0IT7btJgd2SeDXRmcEnPkKPPDH9cMDfTmVdR7Zl3XHu4m4vQmjl/6pgJF7b0RNm1FhU2fKdmvJpCXm5zJB3ly4giMUH2O/bT4E5Im8hZY5qZThohyUXh2L70Rbw2/+qJHQDBOHx93zgO0wjlzPJTKRy35+YZ+YnYHUfvChSx2keYFYokD1tl/YBpezm69Rj/ctzBz6SvwdnUdVIYJUpWKsTWneGeQLOidMoXl6Hi8SfGWkC5uiIl514k3OJuRvl/rZoabuqP2yXN4JQkhhBHyan2APBxhpQEsAVWVNH3bZuBl112RvbHLMYr6j00cCdwajiZmF8ch1XyuYRcEVilDJGPZb6/oAHeSDb/gfIgARaXLeddQYDrx2DCpKL+3yFZLTXYhvpgkm4Ha5w8sD2QrXt+Z2+1bsKb9T3HtlSCNIijFaIv2PUyiMhtwumIjWqey5LyoW2TsMqrrxjLRDg29pAwemLgxNRFwDEc/M/s4/W6/doaY0nSOCE4pl+/47bdB0yuG2QOXhGt0rQv63vecM4jTzk7VOFWVR11vWzjZ2e6VD6y7TW076gEyc/d+6lfUP0ye7uqXGAwQuTxXwJA66uPwiG7xkvCGG1bno9mneC7owleRuAleTwxpAXva5FWcAIIrpP8GVpQAIDNlFCpIijwEUY7/5vjlf/gst2pHl6bnBDruR01//3w3kgLcXDVb8LMYxDYsN2IVN8n98kt5p8czaLwVOlGOepHmGKvVdqucfnrKx8UvWuigH3QuDvrnDdT3UgY3dwtmP4QTnrxtXNlUt86+R5bQtW/4C5awC4W80s6ceuXummHNoigcMfdqvv2Q9gap4W7pTtLCDTPXhEGXKQ5uSaYOegholFw7PDbfR4HojCvqBeTY+45zNYFrlgrkDHevkgqlLP1JG8xrekyzbsDgHNgiIVWhLjN31VbanOZnph8ZceNRYPHJOan8Sv5CQT7nF7dL9YCKJ81WNKwMEwf0RzvjDtHrgGXqORuDxdPJSldBYiDWlBJ2Ckz5A6wPXk782K+aCmNzMCOc+In4ulrScEnZkT4hQEH266obIS+OtuBH1TBeBUQEzYBij33OumCegbf8jer3SOwIzhy/O0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 947bf6fa-f96c-4194-8549-08d8fcbf3cff X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2021 07:55:56.7165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j6i9qatyh5+FbPfcClOosmuOEZTRg+71PM5GrCu2PttWt75NZFOM3hDFF+M29xgeLH2OVp7Tn6B8GwXIU+QrZ32ukuYe48NZNgb3hGEoR+E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3842 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110060 X-Proofpoint-GUID: NyU5V0EAA1zn8RYt-FkCb605UdtW7Z34 X-Proofpoint-ORIG-GUID: NyU5V0EAA1zn8RYt-FkCb605UdtW7Z34 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110059 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patches add more management related works for operations like conn stop and ep disconnect so this patch makes the iscsi_eh_timer workqueue more generic so we don't have to add another one. This patch does: - Allows more than 1 work to be running. There is no need to limit this because each operation will flush/cancel operations it has conflicts with. For example the unblock flushes the block which sync cancels the recovery. - Renames the wq to reflect it can be used for any management operation. Signed-off-by: Mike Christie --- drivers/scsi/scsi_transport_iscsi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 168953cc0ff9..0ea8ed288f54 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -93,7 +93,7 @@ static void stop_conn_work_fn(struct work_struct *work); static DECLARE_WORK(stop_conn_work, stop_conn_work_fn); static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ -static struct workqueue_struct *iscsi_eh_timer_workq; +static struct workqueue_struct *iscsi_mgmt_workq; static struct workqueue_struct *iscsi_destroy_workq; @@ -1976,7 +1976,7 @@ static void __iscsi_unblock_session(struct work_struct *work) */ void iscsi_unblock_session(struct iscsi_cls_session *session) { - queue_work(iscsi_eh_timer_workq, &session->unblock_work); + queue_work(iscsi_mgmt_workq, &session->unblock_work); /* * Blocking the session can be done from any context so we only * queue the block work. Make sure the unblock work has completed @@ -2000,14 +2000,14 @@ static void __iscsi_block_session(struct work_struct *work) scsi_target_block(&session->dev); ISCSI_DBG_TRANS_SESSION(session, "Completed SCSI target blocking\n"); if (session->recovery_tmo >= 0) - queue_delayed_work(iscsi_eh_timer_workq, + queue_delayed_work(iscsi_mgmt_workq, &session->recovery_work, session->recovery_tmo * HZ); } void iscsi_block_session(struct iscsi_cls_session *session) { - queue_work(iscsi_eh_timer_workq, &session->block_work); + queue_work(iscsi_mgmt_workq, &session->block_work); } EXPORT_SYMBOL_GPL(iscsi_block_session); @@ -4802,10 +4802,10 @@ static __init int iscsi_transport_init(void) goto unregister_flashnode_bus; } - iscsi_eh_timer_workq = alloc_workqueue("%s", + iscsi_mgmt_workq = alloc_workqueue("%s", WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND, - 1, "iscsi_eh"); - if (!iscsi_eh_timer_workq) { + 0, "iscsi_mgmt"); + if (!iscsi_mgmt_workq) { err = -ENOMEM; goto release_nls; } @@ -4821,7 +4821,7 @@ static __init int iscsi_transport_init(void) return 0; destroy_wq: - destroy_workqueue(iscsi_eh_timer_workq); + destroy_workqueue(iscsi_mgmt_workq); release_nls: netlink_kernel_release(nls); unregister_flashnode_bus: @@ -4844,7 +4844,7 @@ static __init int iscsi_transport_init(void) static void __exit iscsi_transport_exit(void) { destroy_workqueue(iscsi_destroy_workq); - destroy_workqueue(iscsi_eh_timer_workq); + destroy_workqueue(iscsi_mgmt_workq); netlink_kernel_release(nls); bus_unregister(&iscsi_flashnode_bus); transport_class_unregister(&iscsi_connection_class); From patchwork Sun Apr 11 07:55:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 419413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 479AEC433B4 for ; Sun, 11 Apr 2021 07:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1465A611CE for ; Sun, 11 Apr 2021 07:56:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235112AbhDKH4e (ORCPT ); Sun, 11 Apr 2021 03:56:34 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60014 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233696AbhDKH4a (ORCPT ); Sun, 11 Apr 2021 03:56:30 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7pVSa180160; Sun, 11 Apr 2021 07:56:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=05pUn6y81TJ+Z5O1EOahcdiXgWzFShidFYYhkG6fB1U=; b=fKNFZh2Fs5xZjPpP8PDKHOWQw96zL14sLLMQosf6IsGMVAZZCkVowjvCU+pKYcEZo/zf pvT+p0HJIovzc4BDXpbtJUh/tCdA3Wd1On0ZF23Ccf0WBwUeGMflbvNTQqX1gb2imdPL dwm89CnzcC6/ZHKir29s1h0O5vQSQ75zCiXwwqiW0/r47mWPhvwAULdlyGDCcWzxUkXq 59YIIpQbBFkDyDlq/nXXqMDXA/fn/Kt/SpxNkLYAEWz/BiRZ9Z+hARiM4oAEwvhWGkoz o0luu3crtooaRAIZ9UsSoYjB5UsJV/75baT1coQwiOvi3TPkvqxmndBWL8IX3We5x4a/ oA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 37u3er9aky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:56:00 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7tXbQ017877; Sun, 11 Apr 2021 07:55:59 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2049.outbound.protection.outlook.com [104.47.73.49]) by aserp3020.oracle.com with ESMTP id 37unww7qm8-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:55:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z3YbjqwB4WhCTVkwiGOWUrDm2X3Ihh3KAWkV5ee8g6Esc1NAVU9RaIG/oWu6c/MnidizGGUIiGW9BagzZ5/Hjn8jzC2GfLJOGuL/PCXm7ZgC62jEwNt9H3RcmF2lON9j8hweAMwPBJH9qPGuj2E3hz5AgwWdYzKk2X2dMs5uGgkwHYDOLRFtIrED5v+BYh87nyEURb7n5SiCmXhdLwmOZ+lflHqiBRxqrZ1ORtef0RZFTi19mFuyiSGh8ubf9vTjn1wfzx2nlPtDL6N1CtWoJSw51zRyhSBKUsX4/GqKQegB1stZpQWxcC2XY1TFjATIeHEuGWu8L82X13PrCBIAHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=05pUn6y81TJ+Z5O1EOahcdiXgWzFShidFYYhkG6fB1U=; b=ZMrCQPDU8opOIzdJai7U5+VDWycN1bZD01W9j/Kg18qGyDjFobe6seRX9a+004v9ylqyMI1SfePZ73uIYWLZq/Z7ty2gwZJn+IhHoYgFcTslSrexMsDUAfZGN0oR7/JER0PvHVkLdnjpVEAwoJvZpp5ECN72tlB4rj32Az5swD6O9kQSAxCHoPd97HeTQg8UwoyqP8OuvMClovHV5c1Dp9GUTdGs3bYARiSEr7UgKD3nZq/ZMn8IEwQoAksMPMYiI8qN5RdsWQmRK/d3d2mKdsl2JJT6EY5mw6hzospz92unzHXvHByNUkd28boEtI7MVx2geGwPVlpSl6cobJD7YA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=05pUn6y81TJ+Z5O1EOahcdiXgWzFShidFYYhkG6fB1U=; b=axL7UXjNxMQs0GJb+3mgveWWqR/GiUtx3GQ6PVGoe37YDQ54K8mfJdWoRPQiFlhCjzgZdJDDbJBQxVGDu84Mm42GWBSROdKxCtkiKbufUd/c2j9MspNSkcOWMuOd8kbXvLMJa0vTKsGGuG4+CDll50YqBFdRQX13XOlC8oJfeP8= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB3842.namprd10.prod.outlook.com (2603:10b6:a03:1f9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Sun, 11 Apr 2021 07:55:57 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.4020.018; Sun, 11 Apr 2021 07:55:57 +0000 From: Mike Christie To: lduncan@suse.com, martin.petersen@oracle.com, rbharath@google.com, krisman@collabora.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [RFC 4/7] scsi: iscsi: have callers do the put on iscsi_lookup_endpoint Date: Sun, 11 Apr 2021 02:55:42 -0500 Message-Id: <20210411075545.27866-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210411075545.27866-1-michael.christie@oracle.com> References: <20210411075545.27866-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Sun, 11 Apr 2021 07:55:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae58b3ad-207b-4718-5cc7-08d8fcbf3d94 X-MS-TrafficTypeDiagnostic: BY5PR10MB3842: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N2gNDGw0lVmvzZ2tvljF1Ug6J9PFVxSpyWzUn1qc1JSjx0z+2uLMHnc/Li44LnFIgDsY63Cw6B1NxhPAnWM9BbTTBitnj3n7nPgyLC1p62V0bymX2Xm/77Xx89JdYrwdYwWWYpVj7dei4ysELPXSX++M3Na/tCJbtozJEqdZYWwEaINJKpM5UeOCOHfn6XVGjhiP9L47pnVfBoxWLj65Pu5oKMrl1zqH1UFBqgu0pcE77LwJ3EuYKuxhOGtcMK4wXYzRklxxKXlTv6miWA3K6RWr8aaKhmdiDi3p9MzuzfR2d8NMU0cGI7SWWQ1PNnDBHB56MPGiMWGnQAIImvR+o7Hi/INrCMHjkziGqH0/bTWGM0ragnViaot4JN67WN2dkTTvygTvjnxlKmb+U9EtWtEQc8V2vFpXPl92ysf4E5KKCz6DYF0IZV1Tc2INxNg1sbwO/IPuHf4a5n2PkXWgC9+uTctHVV5SE5Ht2LTMiXuC4zfZ/fM1D2ol0N1GP0EZML4cbYKtuK+mTJDfR23X8FkZqiHNgqovyhddsW2p0NI4rDlzCZX5Lz2eGV/RRmmT8WX23OoizYMBo2POSgEAtbuc16nLOYtrTGgMrXEYTI8We3PeHyMZbB/Sq63u4No8AOUtpcq9H30JYots6V0Y83qKFBH9jizrvQvn8otMCICdnVpwu20uXWe7kWtYYAFB X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(376002)(346002)(396003)(366004)(136003)(8936002)(16526019)(6486002)(316002)(66476007)(6506007)(956004)(2906002)(8676002)(2616005)(26005)(5660300002)(6666004)(86362001)(38350700002)(52116002)(38100700002)(69590400012)(186003)(66946007)(1076003)(83380400001)(36756003)(6512007)(107886003)(478600001)(4326008)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: wxADpJHdqhRUJdXzGAOSZldJrufcUIlu7yemRGAzd4nEsaZDUfg3Z1ysvjKFJOpQwuwli/99FyoYofA32aTr992Na7sP3JYAfFV0W38+4BGhrXXxJ3l2cmhxhIXDPHczav696CKJz0kqybzI1Wr3vid9bSpCFmkyhJS7+bTyf6LNj2y+p4neCnMruzNkVEjxBjSdckrvNEehk/lwQgLhqLDjNVoHuHmNup4g6m2D2px1aLS1HN+hCHqiEVNBzptfoUa+YQHblJ0Zdtkikqm7mgFO4ww28Ta9i7+H4oN8ch79JfW2dACJlG4ZjumwWpqZlCwEZTweLmIaJWEBt9R+y0/6czRpUiavIE4TJSpVYvHDBDJTwvv11TyoSLf0ooq8LC8YEZ3ntztQZ8PNqzk6vDHH0gdK6vKUOPQWnCvkmld4uYCMhK2v76l/YYo3RTubaykJStJMl8or3n1H33V3lW+RjOGd5/nCWRqyZo11gT6HqYAuGSnMq94XE+jpOpOCCahCkIOqbc6NAi5QF1IoecPQ1gCzeVFTEverJ1DiWaAwDgaR97tgjtmz6s4efMkb0ymuMZAT/6cUENAfndj0tAlv+/wvrN0wSnykxETUGo10v4nOGJxexAAyoPpXl9jYXcKXpCXfTZ0FgPHA0Bqt7I7cvrS1+H9Y0sOgGMEjUmbw8ds6CTT/MR0oLSR8v9xSq5LMw3dW7zo3B2164DQ7pY30eKAE5ogG6OGQhfPvSZbHhWuDy8REXlDS27Un2DHAh/M96O9WcVckSA8tvXB1rr70LD+O5px379En2D5LXiolD9xaMOTIJ2z9ufRUJsa2FlR/HJTNKmRJNAyeZOfvI0w56siVrDIGoh6xeELu4A77eaHoVvmw4unsqSHkzaT5XCqXXJYz04CwS/S6hmYoyKWLDjvWt2Vjj9UUP+baJJQga2qS070KknjkA6hrrqNyC0S19ADXdx6QNDBfkNlCDyR5nYuoNnAWCNWVxo7bLHfSH5HXKGJVsk6EKQO+iLQmDfFYT+gkD8isY0TtPxlUlW4xMCGTUxpZ5jjTc1TbmRyrti4Q/xVwS5CzsvjVisAbnC+U2MGSuTxN9GHlkWDLy4R/ZQYbcrDBlaER1ZL5uIvALjl000Pi52AKHG/OJzg4Z+Npu9BDFq5Yqtdh2OPG4szsnDv14nS6uFRLTlvyFB5UFgS57+tV+JyljLdBF4jeUKU2IXpn4XB+iEhSEwBwXG7uVIC9HdjYxNheg17Z0WPWSNbZzhnE4WpnW8Rv54G1WpnTYznZadK3+cCqKjE6bf9R2F1yvY02W7ZWE90nOJOUXeaZhZRI50EJHwmw6e8e X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae58b3ad-207b-4718-5cc7-08d8fcbf3d94 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2021 07:55:57.6650 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cuWoC2OyXSAbf+gUEJ1lGbOMKB0rC0Ew1448psJlsJh+F7uA+mnfnEuRBLPEzV9VGlkuTqMRFEu+kODoCR8N2+f4AididJ1ZIhcsgTNcaKM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3842 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110060 X-Proofpoint-ORIG-GUID: KLqAuTADJxvGgpzIMlt-f66v6BTp3Nln X-Proofpoint-GUID: KLqAuTADJxvGgpzIMlt-f66v6BTp3Nln X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110059 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patches allow the kernel to do ep_disconnect. In that case we will have to get a proper refcount on the ep so one thread does not delete it from under another. Signed-off-by: Mike Christie --- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 + drivers/scsi/be2iscsi/be_iscsi.c | 19 ++++++++++++------ drivers/scsi/bnx2i/bnx2i_iscsi.c | 23 +++++++++++++++------- drivers/scsi/cxgbi/libcxgbi.c | 12 ++++++++---- drivers/scsi/qedi/qedi_iscsi.c | 25 +++++++++++++++++------- drivers/scsi/qla4xxx/ql4_os.c | 1 + drivers/scsi/scsi_transport_iscsi.c | 25 ++++++++++++++++-------- include/scsi/scsi_transport_iscsi.h | 1 + 8 files changed, 75 insertions(+), 32 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 8fcaa1136f2c..54d756e5c033 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -506,6 +506,7 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session, iser_conn->iscsi_conn = conn; out: + iscsi_put_endpoint(ep); mutex_unlock(&iser_conn->state_mutex); return error; } diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index a13c203ef7a9..c4881657a807 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -182,6 +182,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, struct beiscsi_endpoint *beiscsi_ep; struct iscsi_endpoint *ep; uint16_t cri_index; + int rc = 0; ep = iscsi_lookup_endpoint(transport_fd); if (!ep) @@ -189,15 +190,17 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, beiscsi_ep = ep->dd_data; - if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) - return -EINVAL; + if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) { + rc = -EINVAL; + goto put_ep; + } if (beiscsi_ep->phba != phba) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n", beiscsi_ep->phba, phba); - - return -EEXIST; + rc = -EEXIST; + goto put_ep; } cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid); if (phba->conn_table[cri_index]) { @@ -209,7 +212,8 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, beiscsi_ep->ep_cid, beiscsi_conn, phba->conn_table[cri_index]); - return -EINVAL; + rc = -EINVAL; + goto put_ep; } } @@ -226,7 +230,10 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, "BS_%d : cid %d phba->conn_table[%u]=%p\n", beiscsi_ep->ep_cid, cri_index, beiscsi_conn); phba->conn_table[cri_index] = beiscsi_conn; - return 0; + +put_ep: + iscsi_put_endpoint(ep); + return rc; } static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 1e6d8f62ea3c..b119285cfa8d 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1420,17 +1420,23 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session, * Forcefully terminate all in progress connection recovery at the * earliest, either in bind(), send_pdu(LOGIN), or conn_start() */ - if (bnx2i_adapter_ready(hba)) - return -EIO; + if (bnx2i_adapter_ready(hba)) { + ret_code = -EIO; + goto put_ep; + } bnx2i_ep = ep->dd_data; if ((bnx2i_ep->state == EP_STATE_TCP_FIN_RCVD) || - (bnx2i_ep->state == EP_STATE_TCP_RST_RCVD)) + (bnx2i_ep->state == EP_STATE_TCP_RST_RCVD)) { /* Peer disconnect via' FIN or RST */ - return -EINVAL; + ret_code = -EINVAL; + goto put_ep; + } - if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) - return -EINVAL; + if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) { + ret_code = -EINVAL; + goto put_ep; + } if (bnx2i_ep->hba != hba) { /* Error - TCP connection does not belong to this device @@ -1441,7 +1447,8 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session, iscsi_conn_printk(KERN_ALERT, cls_conn->dd_data, "belong to hba (%s)\n", hba->netdev->name); - return -EEXIST; + ret_code = -EEXIST; + goto put_ep; } bnx2i_ep->conn = bnx2i_conn; bnx2i_conn->ep = bnx2i_ep; @@ -1458,6 +1465,8 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session, bnx2i_put_rq_buf(bnx2i_conn, 0); bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE); +put_ep: + iscsi_put_endpoint(ep); return ret_code; } diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index f078b3c4e083..f6bcae829c29 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -2690,11 +2690,13 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session, err = csk->cdev->csk_ddp_setup_pgidx(csk, csk->tid, ppm->tformat.pgsz_idx_dflt); if (err < 0) - return err; + goto put_ep; err = iscsi_conn_bind(cls_session, cls_conn, is_leading); - if (err) - return -EINVAL; + if (err) { + err = -EINVAL; + goto put_ep; + } /* calculate the tag idx bits needed for this conn based on cmds_max */ cconn->task_idx_bits = (__ilog2_u32(conn->session->cmds_max - 1)) + 1; @@ -2715,7 +2717,9 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session, /* init recv engine */ iscsi_tcp_hdr_recv_prep(tcp_conn); - return 0; +put_ep: + iscsi_put_endpoint(ep); + return err; } EXPORT_SYMBOL_GPL(cxgbi_bind_conn); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 08c05403cd72..76d40c79e6ef 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -377,6 +377,7 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session, struct qedi_ctx *qedi = iscsi_host_priv(shost); struct qedi_endpoint *qedi_ep; struct iscsi_endpoint *ep; + int rc = 0; ep = iscsi_lookup_endpoint(transport_fd); if (!ep) @@ -384,11 +385,16 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session, qedi_ep = ep->dd_data; if ((qedi_ep->state == EP_STATE_TCP_FIN_RCVD) || - (qedi_ep->state == EP_STATE_TCP_RST_RCVD)) - return -EINVAL; + (qedi_ep->state == EP_STATE_TCP_RST_RCVD)) { + rc = -EINVAL; + goto put_ep; + } + + if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) { + rc = -EINVAL; + goto put_ep; + } - if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) - return -EINVAL; qedi_ep->conn = qedi_conn; qedi_conn->ep = qedi_ep; @@ -398,13 +404,18 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session, qedi_conn->cmd_cleanup_req = 0; qedi_conn->cmd_cleanup_cmpl = 0; - if (qedi_bind_conn_to_iscsi_cid(qedi, qedi_conn)) - return -EINVAL; + if (qedi_bind_conn_to_iscsi_cid(qedi, qedi_conn)) { + rc = -EINVAL; + goto put_ep; + } + spin_lock_init(&qedi_conn->tmf_work_lock); INIT_LIST_HEAD(&qedi_conn->tmf_work_list); init_waitqueue_head(&qedi_conn->wait_queue); - return 0; +put_ep: + iscsi_put_endpoint(ep); + return rc; } static int qedi_iscsi_update_conn(struct qedi_ctx *qedi, diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 7bd9a4a04ad5..18d63a0af14c 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -3234,6 +3234,7 @@ static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session, conn = cls_conn->dd_data; qla_conn = conn->dd_data; qla_conn->qla_ep = ep->dd_data; + iscsi_put_endpoint(ep); return 0; } diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 0ea8ed288f54..036486310260 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -268,9 +268,20 @@ void iscsi_destroy_endpoint(struct iscsi_endpoint *ep) } EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint); +void iscsi_put_endpoint(struct iscsi_endpoint *ep) +{ + put_device(&ep->dev); +} +EXPORT_SYMBOL_GPL(iscsi_put_endpoint); + +/** + * iscsi_lookup_endpoint - get ep from handle + * @handle: endpoint handle + * + * Caller must do a iscsi_put_endpoint. + */ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) { - struct iscsi_endpoint *ep; struct device *dev; dev = class_find_device(&iscsi_endpoint_class, NULL, &handle, @@ -278,13 +289,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) if (!dev) return NULL; - ep = iscsi_dev_to_endpoint(dev); - /* - * we can drop this now because the interface will prevent - * removals and lookups from racing. - */ - put_device(dev); - return ep; + return iscsi_dev_to_endpoint(dev); } EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); @@ -2984,6 +2989,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport, } transport->ep_disconnect(ep); + iscsi_put_endpoint(ep); return 0; } @@ -3009,6 +3015,7 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, ev->r.retcode = transport->ep_poll(ep, ev->u.ep_poll.timeout_ms); + iscsi_put_endpoint(ep); break; case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT: rc = iscsi_if_ep_disconnect(transport, @@ -3691,6 +3698,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) ev->u.c_bound_session.initial_cmdsn, ev->u.c_bound_session.cmds_max, ev->u.c_bound_session.queue_depth); + iscsi_put_endpoint(ep); break; case ISCSI_UEVENT_DESTROY_SESSION: session = iscsi_session_lookup(ev->u.d_session.sid); @@ -3762,6 +3770,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) mutex_lock(&conn->ep_mutex); conn->ep = ep; mutex_unlock(&conn->ep_mutex); + iscsi_put_endpoint(ep); } else iscsi_cls_conn_printk(KERN_ERR, conn, "Could not set ep conn " diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index fc5a39839b4b..165e629fba02 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -441,6 +441,7 @@ extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time); extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size); extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep); extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle); +extern void iscsi_put_endpoint(struct iscsi_endpoint *ep); extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd); extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *t, From patchwork Sun Apr 11 07:55:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 419414 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C850C433ED for ; Sun, 11 Apr 2021 07:56:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6409B611CE for ; Sun, 11 Apr 2021 07:56:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235085AbhDKH4c (ORCPT ); Sun, 11 Apr 2021 03:56:32 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33508 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235071AbhDKH4a (ORCPT ); Sun, 11 Apr 2021 03:56:30 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7o2Ha044069; Sun, 11 Apr 2021 07:56:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=W2lYpb7y6ya5D8LbWo7OmUde00ED7kFeyWaNlmOK44k=; b=YiQUE6USe8tRNscFDLdYH+r6joKn+hA0xMpQQ4ra5MfzpNwu8WRYWnb6ZTJfau6DYkDU D6/7yxIRsEguYX8K8O21mYbYsSSSUA+KttHMUOpLT+HsxRfXLxDD3ks3Wl3E/+zYgIHz fMDRFToVxo5qCQ+zKE94GcNjJVIa2e70i/lEJC7EBAfg7npiU5XzehiUe/vsLvweJYpk rldQ4OjtrERy34ouWkw9KGQWLXOK5ATsbzEFZUz1dqL0mpTvLuQUj7fYIlv22ySGXm1S eimiDRt2Q7Q4KBM9hshOFy3B9zMuPLibMipsBz1cMA6xttHNwPxGPp/R3oCY17dGQjP9 7A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37u3ym99sw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:56:02 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13B7tK7T052414; Sun, 11 Apr 2021 07:56:01 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2042.outbound.protection.outlook.com [104.47.73.42]) by userp3020.oracle.com with ESMTP id 37unsprjdy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Apr 2021 07:56:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NmgKsxMmE52swOsq0qssM2SMxihmaE+IVHhUQixe6cNI8QQyksEXji2IizRgCYRtJ/wmtvND1vDylLoyEzMvL5aboF6zWD2+TVfzpYIurR1hTTqwe2BW/KmwdraBs1K7BG8uOB3+x2CUBLdeZN4gLBquFeuSatDE1pnegui+hYvSLSxrc0tereTv7d8ZohCxquUJSbURRMq8cuYsLMYILwk46/Rp1p/d8aCAjfCiMor9NnE2UazQK3gW4Grzr17cbVwoTUIFLXvrlT3J440M+uc/PbH3IDurCiKTzIVp8tdk/bsP+YQNud2GfwRxyt0D5yrAaZWT8i7PqdaU7PuDcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W2lYpb7y6ya5D8LbWo7OmUde00ED7kFeyWaNlmOK44k=; b=NwnguIP+JA91xpoWDqppZH1BKZpf5csPUqwFY1zcPQgWbtg8PB75juHPdMtL2BBqNbe2EhpKei7xstBTHF4w+vsrct+EF/lynsI5aCOocQ0uN1FWSjW57JnrUIEd90tcCsYU8LQ8Vt1xXKJZ/P9bveygULcRfw53mxl+EFdZ+uwbE++lPf76g8CiP6AFrQ66gGRMJodFPYTdUahzb/FjiIioPH/JiUNYBAVnrvv1Djqwvm8p1p8+xk8WjFqEy+3ZxQPYR091tJoPQI+tAfY3L06jMpjCcEvg48F2VaR7i1zRD04hfLXF9Ohof/6iXk25myiITw+OOv03nF+RcrwVlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W2lYpb7y6ya5D8LbWo7OmUde00ED7kFeyWaNlmOK44k=; b=TwyWIvsU8/oa2ZI/QI6yczzavJhwGV6AIYS3nzxGHzNO2O0A78PBj4PcI3b/UCKyh2CUU+pckqrQbBAwhA0WcI6ID54kQPqQL8hVLRSgK0C3ps+IziHb1TGq5DHd9lqfQrX882kx4HdK8JfUgNOmXafJR4PCYNQJIIg4gmjik+0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB3842.namprd10.prod.outlook.com (2603:10b6:a03:1f9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Sun, 11 Apr 2021 07:55:59 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::50bb:7b66:35ee:4a4%7]) with mapi id 15.20.4020.018; Sun, 11 Apr 2021 07:55:59 +0000 From: Mike Christie To: lduncan@suse.com, martin.petersen@oracle.com, rbharath@google.com, krisman@collabora.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [RFC 6/7] scsi: iscsi: remove conn_mutex Date: Sun, 11 Apr 2021 02:55:44 -0500 Message-Id: <20210411075545.27866-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210411075545.27866-1-michael.christie@oracle.com> References: <20210411075545.27866-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR18CA0010.namprd18.prod.outlook.com (2603:10b6:5:15b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Sun, 11 Apr 2021 07:55:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96e56dbc-617e-4e88-3b29-08d8fcbf3ec3 X-MS-TrafficTypeDiagnostic: BY5PR10MB3842: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:83; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ucnBXdkEypZPmwecjPgujsowM/ziJ0znBg2nhJHz2wQptkVGvYoWJC5Npwr8rXnK0o6Or59/T7iFe0vVd/5V6qL2+8BMhMYP/l9+TSZyV9eVqYKUZ3aoNkFfnXN96SImY8MnNVX9IUESaMpWsWx/6QIoyJR4A9gEsk2FK9KAJdTC/4JvlN/efou4fgPWHwMhC6p7yX4F7X/dNiX9cywNP91h+zmOfW3IdbCl4EX1Rj3uR5hTL4xvBvwxeZxP965x1cd08clTJbs1OLTGehznKq3y0HHm0WN5Z66N3up3kB4OkK9DwM+speoZwOd7XQ6R2myJymQlgVK1Zmt0lVyE2HMKfkwk6TS9xMQUeaCywkHfk9Tdbr6j15zK9Kagqx57t7a5AecOe32aNxWn4vYbHPh/yrfXIxlkZ7eMfbit9ZL2Ph1jQo23qatT6kPp9XyZ/0KOcvZTQutcHyvLww++jtRWJZpnmdbd5/na4Chevahk+2pIBWTTtSqIYEGFag5rFQ6MYtn1YFAceDkO6VIffkr9z4FAayb//JCOgidgUYlzLw2nlbwfPYVcbyUQ/W9lB7WVwj89AJ7OHPrysWn+VtdQC4U3QP0HBkPN57H7FZNGXAnUEe+Absp6nnFeK61F/8kL6RwLrY9uTvc0SgDhMzlmNC3w/GDF7rmNBBLCVbTx20f9eDcPoAXzpK6Qx6EF X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(376002)(346002)(396003)(366004)(136003)(8936002)(16526019)(6486002)(316002)(66476007)(6506007)(956004)(2906002)(8676002)(2616005)(26005)(5660300002)(6666004)(86362001)(38350700002)(52116002)(38100700002)(69590400012)(186003)(66946007)(1076003)(83380400001)(36756003)(6512007)(107886003)(478600001)(4326008)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: l8Yxff90uH4m23ssbR5FiLQpvv4W79WpVksbVeQZN5TFPqIrBax6vAPGW7Hh7AXig0IEiG3SjzaZMKL4RHhXMJWIXLmd3lxmgtmd6fb0RUdx4J815XefA4V4AHeHscTtNxBcrCeuPjjIt2kMk4OtFIJMxU2T4xKearrxfHFCapQ415ZQsFE1/3IM5WlblgBflq3NooWUttlXivHhXpCFxAnAklzdE3+8aWJLu3t0jRs4xiSIRoj2P4r6W6mchfeU8uOHZYXTHGMkieVxVXx1yKV5uyclzNXWHr+FlQkIoi/ongefrwD1kcvXIR6HI2uxrx3lb4QRW08v5cNcyxw/Jnt73r/hXt+glDjh9rhnv5tGo3qeLfXNcIDTCdCf0zKSUc8H7rk4bw2S3cA/BJcpxJ5AQPcOKjiT3oxSVVWwS4zxr6bwwBFst0ZahlHa/aukkSvH0BBuZbXT/ynMUuwUpMQ/0lxR2n12PXZT/x1nvOqhxLdhvVwVH7u4yxv5+WuB7StmYVZkePeejnYenZs4YHHWsyN6W1tjYQc4yOKfYQ09J0fOnoFi6+pzz1el8H+ADi0P5PsFDTK6t8CUDZw8FlPYVmVvee4JyH8ORQK+MjL8iCa1+FKaVDNOGwXJJPzIU8wLA57xUNMZNzRRyxFJcMcFo2sCv5fxpKce7rgl2z1qX/x1KGSDvKUzmk4/WlwvmPOTeOaude/LT4uJDYHeCPHIqhXz1XmVC7u9rxdYrqVcgG6lV/oV+ONABsgZbeIVXUvqOr1ghfX/VbXcOpgYduc0xSastFzAq5gnxDutiJM9Ffazr1TjiyDK5aS7qBl77jcHKp5kkbxwJ4n/CGfWOkn18m/dPPv+rYwWFncQBEqUq7DXizb5W7cLzGMTJPvW144fHs4KvjLbifHWB35X98xYvnz4/zSjxNYMLwFZ5hp4fWleZQNlfrkB3az+w6LSSI1PApWZ7gxdUvo4UfF5MVlw2SPY2J8ktyuzl2pLzjUvJgFXX64pzhHFXmM2+t3UBKod+6h3lnkQ/sJ9uztqgS5Oh+GUBuXbfAGQPFuSgAp7a36I4gQv9RVjlL8dslqZnZKO0vyIhEkJFMK02QpeGZiyU/5JU2AysJ/8s8yPfcEsoL9hpAh5qz1sNZLbQgKgmEMg4eMSwzofNmoty0emJlMnm7NnrQTBmlaujEQP4qbLipLooQ/pJHQXyJkPMQm+NdBblLaf0zzPrIYQUL5BiGiyWTIk7eAT7T17NMIujKRS4O5OAaApDQyQRP0/XC/eY2PqnfZW7E6MlSiyUgjPjIUrwt/tlWsDhf4BwJCDYipeqJvVbzXUebMe4gEOXulN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96e56dbc-617e-4e88-3b29-08d8fcbf3ec3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2021 07:55:59.6859 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y0wLkxcZE9CtnmVr4gwQ7bCCi/Mx1Y/5EMd14U7W78/6r5ZiG4R6Y6zvpfd6muwpNdkZpuZ0CcdylTVbSjCQ4Fyke25HYv4AgC8r/hd4M8c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3842 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110060 X-Proofpoint-GUID: H3OP8MWBHy9mxsuTo7lofIv_7mDqKfKy X-Proofpoint-ORIG-GUID: H3OP8MWBHy9mxsuTo7lofIv_7mDqKfKy X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9950 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104110059 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We don't need the conn mutex now because conn stop and ep_disconnect wait for kernel conn_stop/ep_disconnects. Signed-off-by: Mike Christie --- drivers/scsi/scsi_transport_iscsi.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index da9fce1dceeb..ed69449166ae 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1619,12 +1619,6 @@ static DECLARE_TRANSPORT_CLASS(iscsi_connection_class, static struct sock *nls; static DEFINE_MUTEX(rx_queue_mutex); -/* - * conn_mutex protects the {start,bind,stop,destroy}_conn from racing - * against the kernel stop_connection recovery mechanism - */ -static DEFINE_MUTEX(conn_mutex); - static LIST_HEAD(sesslist); static DEFINE_SPINLOCK(sesslock); static LIST_HEAD(connlist); @@ -2886,11 +2880,8 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev ISCSI_DBG_TRANS_CONN(conn, "Destroying transport conn\n"); - mutex_lock(&conn_mutex); if (transport->destroy_conn) transport->destroy_conn(conn); - mutex_unlock(&conn_mutex); - return 0; } @@ -3773,13 +3764,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) break; } - mutex_lock(&conn_mutex); ev->r.retcode = transport->bind_conn(session, conn, ev->u.b_conn.transport_eph, ev->u.b_conn.is_leading); if (!ev->r.retcode) conn->state = ISCSI_CONN_BOUND; - mutex_unlock(&conn_mutex); if (ev->r.retcode || !transport->ep_connect) break; @@ -3802,11 +3791,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) case ISCSI_UEVENT_START_CONN: conn = iscsi_conn_lookup(ev->u.start_conn.sid, ev->u.start_conn.cid); if (conn) { - mutex_lock(&conn_mutex); ev->r.retcode = transport->start_conn(conn); if (!ev->r.retcode) conn->state = ISCSI_CONN_UP; - mutex_unlock(&conn_mutex); } else err = -EINVAL; @@ -3829,14 +3816,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid); if (conn) { - mutex_lock(&conn_mutex); ev->r.retcode = transport->send_pdu(conn, (struct iscsi_hdr*)((char*)ev + sizeof(*ev)), (char*)ev + sizeof(*ev) + ev->u.send_pdu.hdr_size, ev->u.send_pdu.data_size); - mutex_unlock(&conn_mutex); - } - else + } else err = -EINVAL; break; case ISCSI_UEVENT_GET_STATS: