From patchwork Sun Feb 7 04:46:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378286 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.7 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 B02FDC433DB for ; Sun, 7 Feb 2021 04:47:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7055764E92 for ; Sun, 7 Feb 2021 04:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbhBGErZ (ORCPT ); Sat, 6 Feb 2021 23:47:25 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:51706 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhBGErY (ORCPT ); Sat, 6 Feb 2021 23:47:24 -0500 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 1174j8EH174809; Sun, 7 Feb 2021 04:46:27 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=Ug42sge7obdQ9l3QP/YnwoHy2xUqve80OzhxVRG6CFc=; b=ttAqb8RonumMmWCIH2gZ5sEgM8a/jC54wmWEwWpHzZyw8/s9hjxJz4GuQh6LJWDMrqnW YNaBh1fC6WaCzMfOkY3cnUJfoa+67MH0anV6Mnryx3wf63F9ccNwCxBEsBjFijLsnArs +tCy2N1f8uPzIL2ElbJIBMcvny4udKQk7huyz4irSPsc8+K0xPeJLg8AfL8xhAWeLfhL h3ZGcjOA93BeoT+MlxNLhZensurdjGx7wSuigWsLc/noXijJdDQ09ZI9Vu/Y8/5ozIG1 K3rKpPfLRNy3BuIdvf53DABVPk47L5pOgPulvTO6XsDy2v02L46H32+mEz0rQceWhIwx aw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36hk2k9b75-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:26 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174ixmg004585; Sun, 7 Feb 2021 04:46:26 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2057.outbound.protection.outlook.com [104.47.38.57]) by userp3030.oracle.com with ESMTP id 36j51tcnyt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MPOPJnkScFGTdH471ddWhRIT0dPo80obQi3/4tCTJP6ltnS5yu2EEekkpFEfwhMbdN8i8h5VpECqR2+ao89NMoAneGpsepVSRBz8jTTRwWv19YOn0pEIhGH4guuWWhGr0jLQFME+YCKv10A+axtouDaVKIexLh8Mkyb0LFEhOES1W6OWBOiWSQ/MJ6OzElGsAGPBD+GBEEsqAI3iR/qMcxZFXA3Rf/T21VqDikj7qDx+pprED443XfA5wPkNtkgVCE3plqhrnL44miTqf4b8QzFDGPyfoTbI5zJhmECEFL2up8NHouRzZ9RjrLAg2qLs7Z1oRtNv4NnVcFoy72GHXA== 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=Ug42sge7obdQ9l3QP/YnwoHy2xUqve80OzhxVRG6CFc=; b=QfvaybnhItlPEYlHPfeodk9/Crpn62srfD9sQm/atvdZ+tjiXnJyTt8NnjH4aorEjnK7+L/AlgBT0RA0cFYnbTGXD4ZeXW4tWGFLFtMa0932fGvpHEm1n5OgmanN463A6h4p/G8Mez76Uss3GttUOKafXKuf6fr9WPzPan/9BtfKtQL3fJbcUXpMDRzuKxWPdDiIqCRDqinBsSlsuQim8QdlGgEMiBI2LPwnGx22mjMrqYTIwz//jw9zgcZNt7XuOvR+2SBtwNtetcMwztfeBziEE0jxA2qN/VDuPBZNuDK7m/DSc+3rN1fgEcEbc5cecoIlrthdYhKuO8CwUMLijg== 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=Ug42sge7obdQ9l3QP/YnwoHy2xUqve80OzhxVRG6CFc=; b=KXVwk0AaZibWpKWoK8kIa2Vljt9a1PCjNFk36kXkzaYqZJBrMGMqp3HnCrICRGd68bzf2E20cSxwFnAcwYkalNIPyXsL+yZhXe/lT1InEzeklXR3a+6T44IeDYK0+K84M5ytWL7qki/vd7DloZ4LZFdOnC8xTwgvGSkuSUuVXiY= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:22 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:22 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 1/9] libiscsi: fix iscsi_prep_scsi_cmd_pdu error handling Date: Sat, 6 Feb 2021 22:46:00 -0600 Message-Id: <20210207044608.27585-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9577cc19-617c-4cdc-b94f-08d8cb23514b X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G1/B0bCczo1MAmZc77eAdl33mHf6UauY/FoXtookxCzsJxY4c/zHIUjgm3j6jOSFf3sUdCHlshQXJud0g0d+k2abtjSJ99Lq/1IW2IzmKSDvy2aBX2K7riNFOTWF3KPn82TPJi5eGaB5v8S8YspFz76iTsk62Hk8AwzEUC5Fzarx02i0/nq/ZlyhJ7LAbTcoJt9QK9np6JSurWK03tVQOVioIoL9042QqZPoJTMcrGTscQvSUZT9LQp5NZKka34/gAwobe9DF/97OevgZs8ryrHER45iSamgJG6OMIsNFVcz1Dbfwxfq6L5vUEqw0a8pgiTUMYfo1yPTMJZAl7cYDD9xTYUMOPKH8XiqSMiFSL7Aa+MVeU4MYHO71Rr2ZzCrd8MqPyU24nQ0k/aR5Zs4ngLcpW2Il/GWq4ayo4FiZsL9Acm1XB6D9hfO2pIvMIYIKuWHGzjAWh+9OuAGoNp7cqyjX2WuUdzxTNjskc9X2KFNaAagrp/UjW9zfeSilAnyPwPzvgz39Pt2fOKy9FBGaWIOh8HSZWt0N+5remWmM0ZJ/N5A/9J//8A7Ft/97bYWiOhFo0mNo0dwVziUsBmgGQ== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vBscKfRQqTqaaVSGLMKXHb/UaFmKIFS8eIijEw7PHDNNh1D/s63EbHYtUyTCN3tbOw4tQ80SxofMGBKwKuY5p464RcfxP0ULGs0lPTQ7MWEinth0GPmFRKCoTl5PiyztfFbOtTEElIgebZuIX+xxUc2X4PXGK9ka3NHpTABEIEOu0dxLSHnie5+4Gv78DR6KAB+HKzGHNJBlXk8PTOSpGPvx02KY4lmpna2V/E1CL12mR0F/i9cqnj59sWVfaKClLxOghmrLZWGHsSpSiXvLMwmqMly+gUsoWKZig5m/VvY3YHUEHrXi1n6KyX0m1HImW1XOI7RiRSaRhZ0EGWrjmtFUKy9uuTSqT3gYlAj90DtoOFZf7bwU/E/GNGxOaZL0YCL+ePC4yBXDzGBln9/y5hIk0Vw4sGvBDqK+Zr8OtQUN2QBCyNZ0DuxBWmGcVD/VFmgqx78PESS9nDs+ZXYBhkoOMvvN75T+eBSFjXArJzyWL77VJpJqbGFvvsOfF1eRLA3v3vDwErW7JQJ6S32lkD1szSPa8WUGwmBAJvMjgBndnWU+6n5pd5EiLSX4VryfnP+4/ekCw2OT1kq0zup4UCQWD3jPRlChXwK920bYVdtvFCpMC6wUSjzzLcdl0UHWKOACHHevkcte38TvjJR9Kmx4cz1B9opzoC3pueb+ZVv6nqgwqdLiCQKYpntsZyC4sdEx7oqnGxK4RYtuLm/US0ik9ye8QuMo+4atUa99krFD0Hr21gHpfXbXDgyvaKYjf6aMie59Fl47qifT5AcE6r5acD8DyAWYYN8KSgCPFwAkloNUXC996TfB1vj8RA5silJnPdtaIh3iTn8Hy4kdX3RhATxY0MaJR1ZqA/WqmFpNyq4LVgU7SMk1YN+H+Tx7TQWxjV4xpBkbC1oNb3q+UuGxeU5pnL5+f5uEvV2B/httZ25o509+2g1PmA0cyVPC0Z/4UPYPHb2orrrgdxZ1cFGRGyFTwCn3MsSsaQHhYA+7yse7A9Lw6FQVtmZ8TJ3NixoSrD9ec4QqMEtJZFWyu55vpBdHtBm6A725fJ8PsNqpymDBcx9uov8yrp7vebhd6+f864hR0vW+JCTvY5WUv/QkvYf8HtFJw0OBiFfcIM2u+E53QZhdtRt9XlM95wTZVBjOLJT+X+Rx2d26S/cQL62uvYTTMaK0XG70FboIWPbelwOppTbPILLMFmiuoGPxoaBBP1eGTbBYPb5Y+C7hDYH/o80lokS2w4nfT67/v2/UuG0ppFIC3PlStO3X1lObnlhxiEn4tVTemjFUvehGqXEVsOQWwrqsdWySHkDxt1y9Bw0kACruIP2JkX8nEhn9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9577cc19-617c-4cdc-b94f-08d8cb23514b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:22.4434 (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: 4CtzaD+NOcr7iwIJDG7zjIC6fGshFBGk0yuCWE0ersQ1EUsSVyC22VlTPByNVgaJQixXVB7JpItpHHhUQbKU76myj02+bK8at0T9xY2gUqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If iscsi_prep_scsi_cmd_pdu fails we try to add it back to the cmdqueue, but we leave it partially setup. We don't have functions that can undo the pdu and init task setup. We only have cleanup_task which can cleanup both parts. So this has us just fail the cmd and go through the standard cleanup routine and then have scsi-ml retry it like is done when it fails in the queuecommand path. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 4e668aafbcca..cee1dbaa1b93 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1532,14 +1532,9 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) } rc = iscsi_prep_scsi_cmd_pdu(conn->task); if (rc) { - if (rc == -ENOMEM || rc == -EACCES) { - spin_lock_bh(&conn->taskqueuelock); - list_add_tail(&conn->task->running, - &conn->cmdqueue); - conn->task = NULL; - spin_unlock_bh(&conn->taskqueuelock); - goto done; - } else + if (rc == -ENOMEM || rc == -EACCES) + fail_scsi_task(conn->task, DID_IMM_RETRY); + else fail_scsi_task(conn->task, DID_ABORT); spin_lock_bh(&conn->taskqueuelock); continue; From patchwork Sun Feb 7 04:46:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378896 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.7 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 B40D6C433DB for ; Sun, 7 Feb 2021 04:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6550464E92 for ; Sun, 7 Feb 2021 04:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbhBGEsT (ORCPT ); Sat, 6 Feb 2021 23:48:19 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38674 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbhBGEr3 (ORCPT ); Sat, 6 Feb 2021 23:47:29 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174k8Z9168246; Sun, 7 Feb 2021 04:46:27 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=1tWtUab7ch6wmPkyaW7fD2E6/Jg4CuZZ12/6+GejAtc=; b=tpaaKsVI2Kr+0N7GG8TpAv5hWz/QgWNad7PmzWYje8Rwc7qZqs4TZ9P0nCCTnzyFKlT/ QFVH9cU830rdnIjHafhpBIj2e+j95vB66XnW4flYmTwJLeH5Mgfa78e8NAyZSHd5zKlK sJa8fRi0blZRKrxarnA0u2dzY3t1L/mxkbt9uDz3jv/DOGFfseYN7W0xvhUXnQ73Vh7G yusdSvoP/IlY5BXeBlpIhTya0I9ihDPbRCNpTmgl5smYo8ht6ZUTqWzFDFsURFSdkKH0 0NHXHmy0jLwHFdb33FCktd+UhjZoPPaYnms+YyRWNcAD+Z3yTQpWk8ke7IcAYS39gfw9 xA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36hgma9fnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174ixmh004585; Sun, 7 Feb 2021 04:46:26 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2057.outbound.protection.outlook.com [104.47.38.57]) by userp3030.oracle.com with ESMTP id 36j51tcnyt-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oAXwFsj0gcnXFTsd0DTq+iiQLHB/MZH18s3ochS0WXX/CTWbfXY5xsKA5ouBPHBhLv4xUGZ3dVR55K1/APCUvVZREYUpkUELdzIMD8ixR6Db2Ra43Kn4sOIcqxZReky/LlR9b4/6Ec3xQxehV6sYtnUz2zpfb13nCF5ABq5B/eqeCsxdmc6dc4JWGbxLwc1AeAR+lx33gapjNHweQv5AjdCh85IdZWU028yPhxMEA0iLuvNTTPQf+9KokDi8SQZFIv+RZhVwIUPXj2e9LQJSwGBeW2wszQ8cJe67pj4aKWIg2EbgfeSUCrMZdVBcOkPowKmWYWYdYmqyv1IFnjhEqQ== 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=1tWtUab7ch6wmPkyaW7fD2E6/Jg4CuZZ12/6+GejAtc=; b=b39BsIDd40pGaxZ5M92xFVCvOf4eIbu0sULS5NLjyglqDbZ5C8Bge/42qujbADg5bWUR/WIBJwcny12VXNeA3K5y/2F9rzX0s/c1jkc4Hbe6iFPDNxQbR2OPnd0knbtjuOogD4R2kUN6fDILkJeVszQRikYbugyudtLa4XvkW6r0iFxTURl62pBY3iQ8zW10vi638gdhUjrLplyEp0nmCxO1fhyLPr+v1Hd998UDrVGJKbGVsbe+g3xPlwxuKQ3OD7Gfkwr8PHWyGU0zSNOzZ2nLkZHVW4fmPCkpDP6nfZAwJ+H7oUj4utpUjCN2tYPIfBx0bYkiipvHTv9QDV6PZg== 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=1tWtUab7ch6wmPkyaW7fD2E6/Jg4CuZZ12/6+GejAtc=; b=OYO8FhlbMkGR/DNxHHohwC4QFc9MU6Mt6q5sn4MIfSsfnA8+CkVsbSAfjt2/adO9KNFn/k54I/qYQrQXR83vEJTw2gbkh6jOssFjt6Ule2iB04rcgA/0iogAvluq9YMrbIzMmolGX1bxTwUwaWrlRKm9drGrgSYRpdJozOvVRos= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:23 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:23 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 2/9] libiscsi: drop taskqueuelock Date: Sat, 6 Feb 2021 22:46:01 -0600 Message-Id: <20210207044608.27585-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cf7c4ef-03c2-4e3e-c3ff-08d8cb235229 X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8XRY4QIv+XOagdDp/SnSmQMOgdpiBlhqsyBtKwcvGrtWMWyrGN29zipP9H9nc8XHqd4DwcIM9g0e1X+GKqF1YIps/EJSqwyM4wJfEEO5n/303mlDq9wF7zDc2OPW2mammy7/Wf4W8v6MTlpMFOtHBNsGp3GIBhueI0am03lczSqbsckjs0S3Qt5lkJI5pS1qx6qnx+kvOL22aCrgTL/JCUdet8N+54nw7WSr2Gz24rZYrGfqlaCOwmiHLAsH69ET8o+cfQIDogyP8uxDqvAw9vTN+B19B7XRnk0rd7WlsAh70kkGV0YeL/x55Pn7pm78C684b4sFWcRyqmT4HcB5ZH5WgR1iZHMa784M/wJW1dlWRdJCc8z8orJjGfZE6/swEwuv49wa2Oh4YDf0YtGCzfoQdDwGpdLLf5qWCLpTAOQ51HCucDQowYn+41nlGGs5k2Ws45BmH+y9RwTcFsmMBRxkeym5lXP6IUOvhTH99fD/Uw7lp/66twtS+D9ABsOSrlzjkeEbHuY5C58TvEGrcddri+hyNPs+uVKkMXHmsxfGe7GvYOeB6q9dQBvh+L1Y/i2rn5s7inuTNlURZePlyQ== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(30864003)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3MqmdOXTYjORvm12IHNWRGP+hFIgHSw5c0Zurn+l3n2wEtXTWoACW/qbJaLaxtF6VnbK2z/8KCBYwn6gQZPmf5RWOdNwavVP+TohjAqS1bZ8+6y83OWryjssIZcS3By73wbzLISs+kP6heImJaSydb95SKqVGaXxmScgRc8AqQUWyDJjQrRlg6GUnb1kNJPLtysJqucQpWQS2TuIfzb71GhqOGArHnOwhmzl13Q0SdraQXsJB6ZDHnY5yqhm4s3JwVq6Gm1TAj1Y1+TXDdQVj32bUK6uwItWEKZroOxZsuwXGvacjhl4XV1DRV0W2rVGygUtB2JGGN5o0OfIn8/vgT7Jp7ixCxhVOL4JLSY9RFSXtorEC+zvRsClDFXKew7UMfU5GuxC/vk8B7QIoB0M/ROUvTbfB36kVcaCAYE8Czwv8zqjeTStoT3jV9v6tRLkzVyeSqteXu6kwHXVmHTrgRMhkhNXYklMvpmar6gH+1QD087Fwms8KtPH0rkrCWCKeCQvY9ArKmi5+uta674kGfHKn2SZ3nkIgPJD3J3s0U5KgzPV6KnTHzoJFQstxOGwRI9uGdN8EwjGrDbeBg3v52eV6H+A2ABfud7h3nukVtzZkKUCH4P/zSPeDqKBKZ95tDYuLUgD3U/ehLvlpvFOvRl7xTvK8kxzV+Ch1PJlcVqm7EGisFgFlTk2pguVAHwO5YkdPSshKqMUs0gLDhxrX2EIm8WAltyFZHwm0D+TSUJBweGmmuXKlcncRyVio6QXSVrWtK9Z2VL5YkMB9vGiVcpxZyDHzbpWmsVlVnJ5SGWchuw6BM6uV4xQ8aJFHtrSjQgSTqXND0PYP2HRBBOFSCx/CXk5uED9egwrTi73wnxKLWXpGCPN57j3zSOfiZgEx6CyGql+xyHs8u36DS9nvX8BpNTwycxxczsIl+4BPuPWWyD6GpBWpNMduoALW/H00CKzxgWLwk41iZfZBMNPkK8Ec9IEKyHfnV2O5CLBC+elcGfiqtfEjTGnbgb6D1eB9U0CWAFd2P9msj7JwmFk0QmZ9qRUBkMK9ksQy3l3tY7hGtqf9anVx32jRSbA5MWAtufV+kw4PXB4/OJhnJDzS+Cl8gnMq+JHqwrgTku+Dtap8XmYgxX+sHflv3jwtO/MUzWJhOShX21K9K7iJLo4AvEWbR3HC4Yu6DJhq7YkmPirc/Y1sgmEDCyhmwr/bR5tSvjfDUhVYOSHXtPcXdRcGTo1rIykJxwLs5p8ANFWZFo+ma0ITN9gavQwUu7uAfUKBf/jbTxt9W4QBoUk0E3eIwgKZJxtkLspm0G0OY0J3ls8ciVbdvgI8Ep+TfL3ScCs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cf7c4ef-03c2-4e3e-c3ff-08d8cb235229 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:23.7836 (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: l9+1iusqwffcr1QGuHSmNulXNuMyYLzdFpMBohU5o3StuJSSjvNUvaHhIWF/fbzbdnVu1BTT6eGfVkEyLWja+JHK5xJSsk95TNMEfalx8Hk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The purpose of the taskqueuelock was to handle the issue where a bad target decides to send a R2T and before it's data has been sent decides to send a cmd response to complete the cmd. The following patches fix up the frwd/back locks so they are taken from the queue/xmit (frwd) and completion (back) paths again. To get there this patch removes the taskqueuelock which for iscsi xmit wq based drivers was taken in the queue, xmit and completion paths. Instead of the lock, we just make sure we have a ref to the task when we queue a R2T, and then we always remove the task from the requeue list in the xmit path or the forced cleanup paths. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 178 +++++++++++++++++++++++------------- drivers/scsi/libiscsi_tcp.c | 86 +++++++++++------ include/scsi/libiscsi.h | 4 +- 3 files changed, 172 insertions(+), 96 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index cee1dbaa1b93..3d74fdd9f31a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -523,16 +523,6 @@ static void iscsi_complete_task(struct iscsi_task *task, int state) WARN_ON_ONCE(task->state == ISCSI_TASK_FREE); task->state = state; - spin_lock_bh(&conn->taskqueuelock); - if (!list_empty(&task->running)) { - pr_debug_once("%s while task on list", __func__); - list_del_init(&task->running); - } - spin_unlock_bh(&conn->taskqueuelock); - - if (conn->task == task) - conn->task = NULL; - if (READ_ONCE(conn->ping_task) == task) WRITE_ONCE(conn->ping_task, NULL); @@ -564,9 +554,40 @@ void iscsi_complete_scsi_task(struct iscsi_task *task, } EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task); +/* + * Must be called with back and frwd lock + */ +static bool cleanup_queued_task(struct iscsi_task *task) +{ + struct iscsi_conn *conn = task->conn; + bool early_complete = false; + + /* Bad target might have completed task while it was still running */ + if (task->state == ISCSI_TASK_COMPLETED) + early_complete = true; + + if (!list_empty(&task->running)) { + list_del_init(&task->running); + /* + * If it's on a list but still running, this could be from + * a bad target sending a rsp early, cleanup from a TMF, or + * session recovery. + */ + if (task->state == ISCSI_TASK_RUNNING || + task->state == ISCSI_TASK_COMPLETED) + __iscsi_put_task(task); + } + + if (conn->task == task) { + conn->task = NULL; + __iscsi_put_task(task); + } + + return early_complete; +} /* - * session back_lock must be held and if not called for a task that is + * session frwd_lock must be held and if not called for a task that is * still pending or from the xmit thread, then xmit thread must * be suspended. */ @@ -585,6 +606,13 @@ static void fail_scsi_task(struct iscsi_task *task, int err) if (!sc) return; + /* regular RX path uses back_lock */ + spin_lock_bh(&conn->session->back_lock); + if (cleanup_queued_task(task)) { + spin_unlock_bh(&conn->session->back_lock); + return; + } + if (task->state == ISCSI_TASK_PENDING) { /* * cmd never made it to the xmit thread, so we should not count @@ -600,9 +628,6 @@ static void fail_scsi_task(struct iscsi_task *task, int err) sc->result = err << 16; scsi_set_resid(sc, scsi_bufflen(sc)); - - /* regular RX path uses back_lock */ - spin_lock_bh(&conn->session->back_lock); iscsi_complete_task(task, state); spin_unlock_bh(&conn->session->back_lock); } @@ -748,9 +773,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, if (session->tt->xmit_task(task)) goto free_task; } else { - spin_lock_bh(&conn->taskqueuelock); list_add_tail(&task->running, &conn->mgmtqueue); - spin_unlock_bh(&conn->taskqueuelock); iscsi_conn_queue_work(conn); } @@ -1411,31 +1434,61 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) return 0; } -static int iscsi_xmit_task(struct iscsi_conn *conn) +static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task, + bool was_requeue) { - struct iscsi_task *task = conn->task; int rc; - if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) - return -ENODATA; - spin_lock_bh(&conn->session->back_lock); - if (conn->task == NULL) { + + if (!conn->task) { + /* Take a ref so we can access it after xmit_task() */ + __iscsi_get_task(task); + } else { + /* Already have a ref from when we failed to send it last call */ + conn->task = NULL; + } + + /* + * If this was a requeue for a R2T we have an extra ref on the task in + * case a bad target sends a cmd rsp before we have handled the task. + */ + if (was_requeue) + __iscsi_put_task(task); + + /* + * Do this after dropping the extra ref because if this was a requeue + * it's removed from that list and cleanup_queued_task would miss it. + */ + if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { + /* + * Save the task and ref in case we weren't cleaning up this + * task and get woken up again. + */ + conn->task = task; spin_unlock_bh(&conn->session->back_lock); return -ENODATA; } - __iscsi_get_task(task); spin_unlock_bh(&conn->session->back_lock); + spin_unlock_bh(&conn->session->frwd_lock); rc = conn->session->tt->xmit_task(task); spin_lock_bh(&conn->session->frwd_lock); if (!rc) { /* done with this task */ task->last_xfer = jiffies; - conn->task = NULL; } /* regular RX path uses back_lock */ spin_lock(&conn->session->back_lock); + if (rc && task->state == ISCSI_TASK_RUNNING) { + /* + * get an extra ref that is released next time we access it + * as conn->task above. + */ + __iscsi_get_task(task); + conn->task = task; + } + __iscsi_put_task(task); spin_unlock(&conn->session->back_lock); return rc; @@ -1445,9 +1498,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn) * iscsi_requeue_task - requeue task to run from session workqueue * @task: task to requeue * - * LLDs that need to run a task from the session workqueue should call - * this. The session frwd_lock must be held. This should only be called - * by software drivers. + * Callers must have taken a ref to the task that is going to be requeued. */ void iscsi_requeue_task(struct iscsi_task *task) { @@ -1457,11 +1508,18 @@ void iscsi_requeue_task(struct iscsi_task *task) * this may be on the requeue list already if the xmit_task callout * is handling the r2ts while we are adding new ones */ - spin_lock_bh(&conn->taskqueuelock); - if (list_empty(&task->running)) + spin_lock_bh(&conn->session->frwd_lock); + if (list_empty(&task->running)) { list_add_tail(&task->running, &conn->requeue); - spin_unlock_bh(&conn->taskqueuelock); + } else { + /* + * Don't need the extra ref since it's already requeued and + * has a ref. + */ + iscsi_put_task(task); + } iscsi_conn_queue_work(conn); + spin_unlock_bh(&conn->session->frwd_lock); } EXPORT_SYMBOL_GPL(iscsi_requeue_task); @@ -1487,7 +1545,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) } if (conn->task) { - rc = iscsi_xmit_task(conn); + rc = iscsi_xmit_task(conn, conn->task, false); if (rc) goto done; } @@ -1497,49 +1555,41 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) * only have one nop-out as a ping from us and targets should not * overflow us with nop-ins */ - spin_lock_bh(&conn->taskqueuelock); check_mgmt: while (!list_empty(&conn->mgmtqueue)) { - conn->task = list_entry(conn->mgmtqueue.next, - struct iscsi_task, running); - list_del_init(&conn->task->running); - spin_unlock_bh(&conn->taskqueuelock); - if (iscsi_prep_mgmt_task(conn, conn->task)) { + task = list_entry(conn->mgmtqueue.next, struct iscsi_task, + running); + list_del_init(&task->running); + if (iscsi_prep_mgmt_task(conn, task)) { /* regular RX path uses back_lock */ spin_lock_bh(&conn->session->back_lock); - __iscsi_put_task(conn->task); + __iscsi_put_task(task); spin_unlock_bh(&conn->session->back_lock); - conn->task = NULL; - spin_lock_bh(&conn->taskqueuelock); continue; } - rc = iscsi_xmit_task(conn); + rc = iscsi_xmit_task(conn, task, false); if (rc) goto done; - spin_lock_bh(&conn->taskqueuelock); } /* process pending command queue */ while (!list_empty(&conn->cmdqueue)) { - conn->task = list_entry(conn->cmdqueue.next, struct iscsi_task, - running); - list_del_init(&conn->task->running); - spin_unlock_bh(&conn->taskqueuelock); + task = list_entry(conn->cmdqueue.next, struct iscsi_task, + running); + list_del_init(&task->running); if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { - fail_scsi_task(conn->task, DID_IMM_RETRY); - spin_lock_bh(&conn->taskqueuelock); + fail_scsi_task(task, DID_IMM_RETRY); continue; } - rc = iscsi_prep_scsi_cmd_pdu(conn->task); + rc = iscsi_prep_scsi_cmd_pdu(task); if (rc) { if (rc == -ENOMEM || rc == -EACCES) - fail_scsi_task(conn->task, DID_IMM_RETRY); + fail_scsi_task(task, DID_IMM_RETRY); else - fail_scsi_task(conn->task, DID_ABORT); - spin_lock_bh(&conn->taskqueuelock); + fail_scsi_task(task, DID_ABORT); continue; } - rc = iscsi_xmit_task(conn); + rc = iscsi_xmit_task(conn, task, false); if (rc) goto done; /* @@ -1547,7 +1597,6 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) * we need to check the mgmt queue for nops that need to * be sent to aviod starvation */ - spin_lock_bh(&conn->taskqueuelock); if (!list_empty(&conn->mgmtqueue)) goto check_mgmt; } @@ -1561,21 +1610,17 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) task = list_entry(conn->requeue.next, struct iscsi_task, running); + if (iscsi_check_tmf_restrictions(task, ISCSI_OP_SCSI_DATA_OUT)) break; - conn->task = task; - list_del_init(&conn->task->running); - conn->task->state = ISCSI_TASK_RUNNING; - spin_unlock_bh(&conn->taskqueuelock); - rc = iscsi_xmit_task(conn); + list_del_init(&task->running); + rc = iscsi_xmit_task(conn, task, true); if (rc) goto done; - spin_lock_bh(&conn->taskqueuelock); if (!list_empty(&conn->mgmtqueue)) goto check_mgmt; } - spin_unlock_bh(&conn->taskqueuelock); spin_unlock_bh(&conn->session->frwd_lock); return -ENODATA; @@ -1741,9 +1786,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc) goto prepd_reject; } } else { - spin_lock_bh(&conn->taskqueuelock); list_add_tail(&task->running, &conn->cmdqueue); - spin_unlock_bh(&conn->taskqueuelock); iscsi_conn_queue_work(conn); } @@ -2914,7 +2957,6 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, INIT_LIST_HEAD(&conn->mgmtqueue); INIT_LIST_HEAD(&conn->cmdqueue); INIT_LIST_HEAD(&conn->requeue); - spin_lock_init(&conn->taskqueuelock); INIT_WORK(&conn->xmitwork, iscsi_xmitworker); /* allocate login_task used for the login/text sequences */ @@ -3080,10 +3122,16 @@ fail_mgmt_tasks(struct iscsi_session *session, struct iscsi_conn *conn) ISCSI_DBG_SESSION(conn->session, "failing mgmt itt 0x%x state %d\n", task->itt, task->state); + + spin_lock_bh(&session->back_lock); + if (cleanup_queued_task(task)) { + spin_unlock_bh(&session->back_lock); + continue; + } + state = ISCSI_TASK_ABRT_SESS_RECOV; if (task->state == ISCSI_TASK_PENDING) state = ISCSI_TASK_COMPLETED; - spin_lock_bh(&session->back_lock); iscsi_complete_task(task, state); spin_unlock_bh(&session->back_lock); } diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 83f14b2c8804..2e9ffe3d1a55 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -524,48 +524,79 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task) /** * iscsi_tcp_r2t_rsp - iSCSI R2T Response processing * @conn: iscsi connection - * @task: scsi command task + * @hdr: PDU header */ -static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) +static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) { struct iscsi_session *session = conn->session; - struct iscsi_tcp_task *tcp_task = task->dd_data; - struct iscsi_tcp_conn *tcp_conn = conn->dd_data; - struct iscsi_r2t_rsp *rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr; + struct iscsi_tcp_task *tcp_task; + struct iscsi_tcp_conn *tcp_conn; + struct iscsi_r2t_rsp *rhdr; struct iscsi_r2t_info *r2t; - int r2tsn = be32_to_cpu(rhdr->r2tsn); + struct iscsi_task *task; u32 data_length; u32 data_offset; + int r2tsn; int rc; + spin_lock(&session->back_lock); + task = iscsi_itt_to_ctask(conn, hdr->itt); + if (!task) { + spin_unlock(&session->back_lock); + return ISCSI_ERR_BAD_ITT; + } else if (task->sc->sc_data_direction != DMA_TO_DEVICE) { + spin_unlock(&session->back_lock); + return ISCSI_ERR_PROTO; + } + /* + * A bad target might complete the cmd before we have handled R2Ts + * so get a ref to the task that will be dropped in the xmit path. + */ + if (task->state != ISCSI_TASK_RUNNING) { + spin_unlock(&session->back_lock); + /* Let the path that got the early rsp complete it */ + return 0; + } + task->last_xfer = jiffies; + __iscsi_get_task(task); + + tcp_conn = conn->dd_data; + rhdr = (struct iscsi_r2t_rsp *)tcp_conn->in.hdr; + /* fill-in new R2T associated with the task */ + iscsi_update_cmdsn(session, (struct iscsi_nopin *)rhdr); + spin_unlock(&session->back_lock); + if (tcp_conn->in.datalen) { iscsi_conn_printk(KERN_ERR, conn, "invalid R2t with datalen %d\n", tcp_conn->in.datalen); - return ISCSI_ERR_DATALEN; + rc = ISCSI_ERR_DATALEN; + goto put_task; } + tcp_task = task->dd_data; + r2tsn = be32_to_cpu(rhdr->r2tsn); if (tcp_task->exp_datasn != r2tsn){ ISCSI_DBG_TCP(conn, "task->exp_datasn(%d) != rhdr->r2tsn(%d)\n", tcp_task->exp_datasn, r2tsn); - return ISCSI_ERR_R2TSN; + rc = ISCSI_ERR_R2TSN; + goto put_task; } - /* fill-in new R2T associated with the task */ - iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); - - if (!task->sc || session->state != ISCSI_STATE_LOGGED_IN) { + if (session->state != ISCSI_STATE_LOGGED_IN) { iscsi_conn_printk(KERN_INFO, conn, "dropping R2T itt %d in recovery.\n", task->itt); - return 0; + rc = 0; + goto put_task; } data_length = be32_to_cpu(rhdr->data_length); if (data_length == 0) { iscsi_conn_printk(KERN_ERR, conn, "invalid R2T with zero data len\n"); - return ISCSI_ERR_DATALEN; + rc = ISCSI_ERR_DATALEN; + goto put_task; } if (data_length > session->max_burst) @@ -579,7 +610,8 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) "invalid R2T with data len %u at offset %u " "and total length %d\n", data_length, data_offset, task->sc->sdb.length); - return ISCSI_ERR_DATALEN; + rc = ISCSI_ERR_DATALEN; + goto put_task; } spin_lock(&tcp_task->pool2queue); @@ -589,7 +621,8 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) "Target has sent more R2Ts than it " "negotiated for or driver has leaked.\n"); spin_unlock(&tcp_task->pool2queue); - return ISCSI_ERR_PROTO; + rc = ISCSI_ERR_PROTO; + goto put_task; } r2t->exp_statsn = rhdr->statsn; @@ -607,6 +640,10 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task) iscsi_requeue_task(task); return 0; + +put_task: + iscsi_put_task(task); + return rc; } /* @@ -730,20 +767,11 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) rc = iscsi_complete_pdu(conn, hdr, NULL, 0); break; case ISCSI_OP_R2T: - spin_lock(&conn->session->back_lock); - task = iscsi_itt_to_ctask(conn, hdr->itt); - spin_unlock(&conn->session->back_lock); - if (!task) - rc = ISCSI_ERR_BAD_ITT; - else if (ahslen) + if (ahslen) { rc = ISCSI_ERR_AHSLEN; - else if (task->sc->sc_data_direction == DMA_TO_DEVICE) { - task->last_xfer = jiffies; - spin_lock(&conn->session->frwd_lock); - rc = iscsi_tcp_r2t_rsp(conn, task); - spin_unlock(&conn->session->frwd_lock); - } else - rc = ISCSI_ERR_PROTO; + break; + } + rc = iscsi_tcp_r2t_rsp(conn, hdr); break; case ISCSI_OP_LOGIN_RSP: case ISCSI_OP_TEXT_RSP: diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index b3bbd10eb3f0..44a9554aea62 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -187,7 +187,7 @@ struct iscsi_conn { struct iscsi_task *task; /* xmit task in progress */ /* xmit */ - spinlock_t taskqueuelock; /* protects the next three lists */ + /* items must be added/deleted under frwd lock */ struct list_head mgmtqueue; /* mgmt (control) xmit queue */ struct list_head cmdqueue; /* data-path cmd queue */ struct list_head requeue; /* tasks needing another run */ @@ -332,7 +332,7 @@ struct iscsi_session { * cmdsn, queued_cmdsn * * session resources: * * - cmdpool kfifo_out , * - * - mgmtpool, */ + * - mgmtpool, queues */ spinlock_t back_lock; /* protects cmdsn_exp * * cmdsn_max, * * cmdpool kfifo_in */ From patchwork Sun Feb 7 04:46:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378894 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.7 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 5F37DC433DB for ; Sun, 7 Feb 2021 04:48:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 215CD64E0F for ; Sun, 7 Feb 2021 04:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbhBGEsy (ORCPT ); Sat, 6 Feb 2021 23:48:54 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:49840 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbhBGEre (ORCPT ); Sat, 6 Feb 2021 23:47:34 -0500 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 1174kSqo151605; Sun, 7 Feb 2021 04:46:28 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=qZ6X1PhkkpKFhCy/QAAPyGD6yYOlfifebmxonTWXKoE=; b=CsX2eOdaXCjuD5Ty9ZgGm3JuZvoOjAfkDefgHf+4uPcb8h79pbqQTctvksmzUAiqYlmt MgbJcAYo5uAlYoMxbHfeHx0X39xjT3HXzn0FCTJe03r5BxYvpUxBvFo9XMHN06cJRBJK I9Gxm4eOYyJJolOf93l/wPFDwi4qllgej1+jsMeRHHGKkgok+UVsAt8DcMssYpV56cuz BQUqaBCtsEyXL+D5YFsoFBu74Pz7jXA0OioW0pxVgia2l1NIDpZspuzO53lgAFDSKl5M z7LtIz5QE+PVIBTpSW2GMyufVdLM5540uJ7wR2nh/IoO4S3WGZJOvSgQvlMzp2TLLBK/ IQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 36hkrmsa2j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174ixmi004585; Sun, 7 Feb 2021 04:46:27 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2057.outbound.protection.outlook.com [104.47.38.57]) by userp3030.oracle.com with ESMTP id 36j51tcnyt-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=haUcF3jxXkjCNuKIx9rZB2H6p4c+7wE/1jcDe5X+QaJ2iJtdpUmhEBuhOyYHBxi6zJ0gxX8iOIQBd8BhYUxCk1y/3EvVrEvi9Hk4/2kEmOCyqmjCHMDFtN8bCsjU5LORZ5QJPDagB8HyzJoe9FdCwzwCE7InOgDVI8j8bE1HOU+F59WKwLNuy71eBhbbgUxo58lHmDAo1ucDDOOP0fRzYRNGw5evD3EOk0bO6INzFw3Y3mVT0d3DjlB+T2ON+Bs88NlCbeALKVPGL7mE1WVwYhKCNHgBGCSw+Q8hCu0jYFV+unm3ECexHeX93ivev+M3jrbBo2ewDwt3vY1szX/Lew== 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=qZ6X1PhkkpKFhCy/QAAPyGD6yYOlfifebmxonTWXKoE=; b=ixp94uo7UJwWo7cDR4iMnkkhovPAg+zsang+RtylVfFA86vklPK+q+/ek0sb4s47RT0AO5sgQ06UADfDltIgeWglN/YaLjHMUp9Q9gQJkA+fvIQl+Mr8G+MOACcR9+mvVkrSLSBRKymzfe5E3mEweJ3mIGhzduzkOJV4d78O/2pkBSFTOeVhK++FX0j0CtcZoQWENK65d4eoEYUy2oTA7CNah8b7uobzCtPuwS7LM7WudN845jNVr37tLy+if8aGjN88rfly39s/f/oBWqtkiEmgxtJhZSUJHU3HMy7Tlbb1L0kdQ299B/s6fmdwt0ZmJraFjth72u6azMssoUFqeA== 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=qZ6X1PhkkpKFhCy/QAAPyGD6yYOlfifebmxonTWXKoE=; b=Njk6cAvm34tek4hj9YBiMPgAeh8WfZLGVxYv+t8XThnkZUiXj+yET6FZILz/cMZa+G/IjgnJYIm6tixuJREBJWcnBK6fFTLvZ1B1j+LrKGJJjm1zrXIvmtk+xB+UsunUnJhnFzkNFCLgyzanf+5bm2z04N3XtxrwvYKumaLdF2U= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:25 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:25 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie , Wu Bo Subject: [PATCH 3/9] libiscsi: fix iscsi_task use after free Date: Sat, 6 Feb 2021 22:46:02 -0600 Message-Id: <20210207044608.27585-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 23f78c6a-6a0e-4317-3f54-08d8cb23530a X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:486; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6tKcHC95NFtrI2+q9R4O1dJgg4GcEDxTzvyQpS8FOcHk+/dfgoqmXrbg8RWILivzY5AWWzELl0PHfCGJXUxqKXofmwEE+3JQfPM4lCd0KuyyVLYvIAMzdL8nK4mA6ut6fLLGC9uGJU9aPt0IJyM/mzN8K2E61OgcMJKl/J4ZCvzS1NZHyEeJpLnXuWW2pa/fijPsmQaf++7mUK2H0p0r7TzfmWWVEhhZevHS8AWIGsC/VcAJ+betAyjnxIGG9nro5vsDOJDNY1t5FTtwu9sC+6mz+bQNbbpdRt+JgtczAgU1h5xcndgfNtp1hVVpC0mjCyMF2bdMdJvrWwnJj86xvYrCKXYuvkBsEo/6dLlFmcYguYnMgGReKOAMwPJ7RrBBVxUPmq1pezeLkE9Bn4gN2B/j+TOuoT09qxIb+o8LxSufb/YziHdi0XYnKLcWRxqq2osfV2ypyk5IwVgLAzdexkqRe4JaAfyIQyGyj5gxflOZzCP54Ayn4DLEgCzqCZJXkti+n8OZgVFTbFsd+YvjzBRxPsjJhWOwi5nZvqMfOlrXN52i8lXuKMCqe196DZxgdzSgAOzncQk/vukUsW4hgA== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(54906003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(30864003)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PjY+gjgsxZXN6tCnadaMmoYYUISWlJ2JmpjvkvMJN8sDp4fbVXctO2va+lY+/VpopvTBvWnExryTOyrXfbF/MZpdFL6oGEVzmWgpiVaQC5qSq8Y3vB8bu2CwRU8Rw5Dq/XC0s+yNvJIW6+yIh4rxeolclNPe6XXXSEQg6uEnrze1618ad4KwBi86Bq1nLH/XIR5Bl3gKOAYF832h8ND6daOSNkjOu+6Tx20DBX8O0Huxx0Xkjd8QeDp+6Y5WGdzISn7tPnXXtlKFnkKaX0bieady5YmXGiUTzQzL7nu5ndzPPZACTs2jlod6G6tb3zYOi+jreD3nJFvglXTL1UOoK7aLtufnkj5TeNcNsN2JCiINN4EZJbCa8anREgM1jalafKZvjXa3N5Ys547w0hl2jS6pgT9AONjR4macp2l1zh6SuJ6xU+sbajreh8nYvahe1An7TCWxC5BOn8HPBkuv/07c6XjSTTUWLY1Xy153w6rgOQO43M2x4+CoHd64dXLk62agvp2nORH5guNxGaeaIOkBYQWgeIB0TonO2GWCNPxqX2drrRE1tuN/i7ely60P1SQmSX5Mv5kmXCl/KrUJxzmOzyap6Ojfz4rNd14kSeeRgy7goG39rgvV0tYG+84l7mheLr8uS9lqgrItwzwEjd/YMES0GJwVzRdnX4mZYZVCW30vmZhZnlHUFFEDFtiPeDnfSeKu22eqZ9Uus7EqirDDK6Zr4Y4SNwwoUVr0cvmkFhw3saCunhHjMpwzgrvu3gM/ZDT2Ba4eso3f3UQAsUnq3gKSnEjJxdx/hCr1LBJz+axOD3X5bUdAjqtMEnzdkwMjXQGOQeq48yedFyjflT8i+Gwc9zv3xxKyVLvR2UOF12+Mz5gRVc8KrPcw+HBIBBrNeJSSBJ7bPL2DXofjur8VFnEIMi1T1cXuGFJQHs9MLmVRnRXGeIgdgI1cNN4ahioRUPLQEFUKPeahGRhCWN8RZnVX/r30vCAFexeySKgR08JW6O1cHvy/HB3yJ1Ca+oYO+VPynfjGYK0Mv5rTInT/QhdA3SuBzHJ1+auDpuqsMgOZ5hgPvwc1TMScjp4HqNwvqzs03zHuxoPCbz2bjtbAmsKBhk/Q9n6lrAcUGgfbJzGVw0d3LpnMdmVVJk3HPD1/xdJ008TGHHS23GHSoDSCUBHPr+NApE5eC51kKSasknuQg8QG1eL7Ir1YbTdMNsEVIf8hxKKYj50wD2Ppr/p3lcqBFUX9jwNi0UPmaEy0AWbBGsuuK/832VEo+WpHqJ4Oee3rHN964TOGzrZQ3iwFvPwb4RNg2WoWY0I5YIZ0AwsqDsaEq6J8niPWGBlO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23f78c6a-6a0e-4317-3f54-08d8cb23530a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:25.2378 (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: 3TP5SyAV3HD7RdvTVBuFRMIVsv+hvCiXhnEqy6X5jAfEzRKNsFzP3l7ItcXd5ATDz5qysKORfywnZzLb1Mjw7D5D7mrIvGcHhDYNdGkv8kU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The following bug was reported and debugged by wubo40@huawei.com: When testing kernel 4.18 version, NULL pointer dereference problem occurs in iscsi_eh_cmd_timed_out function. I think this bug in the upstream is still exists. The analysis reasons are as follows: 1) For some reason, I/O command did not complete within the timeout period. The block layer timer works, call scsi_times_out() to handle I/O timeout logic. At the same time the command just completes. 2) scsi_times_out() call iscsi_eh_cmd_timed_out() to processing timeout logic. although there is an NULL judgment for the task, the task has not been released yet now. 3) iscsi_complete_task() call __iscsi_put_task(), The task reference count reaches zero, the conditions for free task is met, then iscsi_free_task () free the task, and let sc->SCp.ptr = NULL. After iscsi_eh_cmd_timed_out passes the task judgment check, there may be NULL dereference scenarios later. CPU0 CPU3 |- scsi_times_out() |- iscsi_complete_task() | | |- iscsi_eh_cmd_timed_out() |- __iscsi_put_task() | | |- task=sc->SCp.ptr, task is not NUL, check passed |- iscsi_free_task(task) | | | |-> sc->SCp.ptr = NULL | | |- task is NULL now, NULL pointer dereference | | | \|/ \|/ Calltrace: [380751.840862] BUG: unable to handle kernel NULL pointer dereference at 0000000000000138 [380751.843709] PGD 0 P4D 0 [380751.844770] Oops: 0000 [#1] SMP PTI [380751.846283] CPU: 0 PID: 403 Comm: kworker/0:1H Kdump: loaded Tainted: G [380751.851467] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) [380751.856521] Workqueue: kblockd blk_mq_timeout_work [380751.858527] RIP: 0010:iscsi_eh_cmd_timed_out+0x15e/0x2e0 [libiscsi] [380751.861129] Code: 83 ea 01 48 8d 74 d0 08 48 8b 10 48 8b 4a 50 48 85 c9 74 2c 48 39 d5 74 [380751.868811] RSP: 0018:ffffc1e280a5fd58 EFLAGS: 00010246 [380751.870978] RAX: ffff9fd1e84e15e0 RBX: ffff9fd1e84e6dd0 RCX: 0000000116acc580 [380751.873791] RDX: ffff9fd1f97a9400 RSI: ffff9fd1e84e1800 RDI: ffff9fd1e4d6d420 [380751.876059] RBP: ffff9fd1e4d49000 R08: 0000000116acc580 R09: 0000000116acc580 [380751.878284] R10: 0000000000000000 R11: 0000000000000000 R12: ffff9fd1e6e931e8 [380751.880500] R13: ffff9fd1e84e6ee0 R14: 0000000000000010 R15: 0000000000000003 [380751.882687] FS: 0000000000000000(0000) GS:ffff9fd1fac00000(0000) knlGS:0000000000000000 [380751.885236] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [380751.887059] CR2: 0000000000000138 CR3: 000000011860a001 CR4: 00000000003606f0 [380751.889308] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [380751.891523] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [380751.893738] Call Trace: [380751.894639] scsi_times_out+0x60/0x1c0 [380751.895861] blk_mq_check_expired+0x144/0x200 [380751.897302] ? __switch_to_asm+0x35/0x70 [380751.898551] blk_mq_queue_tag_busy_iter+0x195/0x2e0 [380751.900091] ? __blk_mq_requeue_request+0x100/0x100 [380751.901611] ? __switch_to_asm+0x41/0x70 [380751.902853] ? __blk_mq_requeue_request+0x100/0x100 [380751.904398] blk_mq_timeout_work+0x54/0x130 [380751.905740] process_one_work+0x195/0x390 [380751.907228] worker_thread+0x30/0x390 [380751.908713] ? process_one_work+0x390/0x390 [380751.910350] kthread+0x10d/0x130 [380751.911470] ? kthread_flush_work_fn+0x10/0x10 [380751.913007] ret_from_fork+0x35/0x40 crash> dis -l iscsi_eh_cmd_timed_out+0x15e xxxxx/drivers/scsi/libiscsi.c: 2062 1970 enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) { ... 1984 spin_lock_bh(&session->frwd_lock); 1985 task = (struct iscsi_task *)sc->SCp.ptr; 1986 if (!task) { 1987 /* 1988 * Raced with completion. Blk layer has taken ownership 1989 * so let timeout code complete it now. 1990 */ 1991 rc = BLK_EH_DONE; 1992 goto done; 1993 } ... 2052 for (i = 0; i < conn->session->cmds_max; i++) { 2053 running_task = conn->session->cmds[i]; 2054 if (!running_task->sc || running_task == task || 2055 running_task->state != ISCSI_TASK_RUNNING) 2056 continue; 2057 2058 /* 2059 * Only check if cmds started before this one have made 2060 * progress, or this could never fail 2061 */ 2062 if (time_after(running_task->sc->jiffies_at_alloc, 2063 task->sc->jiffies_at_alloc)) <--- 2064 continue; 2065 ... } carsh> struct scsi_cmnd ffff9fd1e6e931e8 struct scsi_cmnd { ... SCp = { ptr = 0x0, <--- iscsi_task this_residual = 0, ... }, } To prevent this, we take a ref to the cmd under the back (completion) lock so if the completion side were to call iscsi_complete_task on the task while the timer/eh paths are not holding the back_lock it will not be freed from under us. Note that this requires the previous patch, "libiscsi: drop taskqueuelock" because bnx2i sleeps in its cleanup_task callout if the cmd is aborted. If the EH/timer and completion path are racing we don't know which path will do the last put. The previous patch moved the operations we needed to do under the forward lock to cleanup_queued_task. Once that has run we can drop the forward lock for the cmd and bnx2i no longer has to worry about if the EH, timer or completion path did the ast put and if the forward lock is held or not since it won't be. Reported-by: Wu Bo Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 - drivers/scsi/libiscsi.c | 71 ++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index fdd446765311..1e6d8f62ea3c 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1171,10 +1171,8 @@ static void bnx2i_cleanup_task(struct iscsi_task *task) bnx2i_send_cmd_cleanup_req(hba, task->dd_data); spin_unlock_bh(&conn->session->back_lock); - spin_unlock_bh(&conn->session->frwd_lock); wait_for_completion_timeout(&bnx2i_conn->cmd_cleanup_cmpl, msecs_to_jiffies(ISCSI_CMD_CLEANUP_TIMEOUT)); - spin_lock_bh(&conn->session->frwd_lock); spin_lock_bh(&conn->session->back_lock); } bnx2i_iscsi_unmap_sg_list(task->dd_data); diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 3d74fdd9f31a..ec159bcb7460 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -587,9 +587,8 @@ static bool cleanup_queued_task(struct iscsi_task *task) } /* - * session frwd_lock must be held and if not called for a task that is - * still pending or from the xmit thread, then xmit thread must - * be suspended. + * session frwd lock must be held and if not called for a task that is still + * pending or from the xmit thread, then xmit thread must be suspended */ static void fail_scsi_task(struct iscsi_task *task, int err) { @@ -597,16 +596,6 @@ static void fail_scsi_task(struct iscsi_task *task, int err) struct scsi_cmnd *sc; int state; - /* - * if a command completes and we get a successful tmf response - * we will hit this because the scsi eh abort code does not take - * a ref to the task. - */ - sc = task->sc; - if (!sc) - return; - - /* regular RX path uses back_lock */ spin_lock_bh(&conn->session->back_lock); if (cleanup_queued_task(task)) { spin_unlock_bh(&conn->session->back_lock); @@ -626,6 +615,7 @@ static void fail_scsi_task(struct iscsi_task *task, int err) else state = ISCSI_TASK_ABRT_TMF; + sc = task->sc; sc->result = err << 16; scsi_set_resid(sc, scsi_bufflen(sc)); iscsi_complete_task(task, state); @@ -1893,27 +1883,39 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, } /* - * Fail commands. session lock held and recv side suspended and xmit - * thread flushed + * Fail commands. session frwd lock held and xmit thread flushed. */ static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error) { + struct iscsi_session *session = conn->session; struct iscsi_task *task; int i; - for (i = 0; i < conn->session->cmds_max; i++) { - task = conn->session->cmds[i]; + spin_lock_bh(&session->back_lock); + for (i = 0; i < session->cmds_max; i++) { + task = session->cmds[i]; if (!task->sc || task->state == ISCSI_TASK_FREE) continue; if (lun != -1 && lun != task->sc->device->lun) continue; - ISCSI_DBG_SESSION(conn->session, + __iscsi_get_task(task); + spin_unlock_bh(&session->back_lock); + + ISCSI_DBG_SESSION(session, "failing sc %p itt 0x%x state %d\n", task->sc, task->itt, task->state); fail_scsi_task(task, error); + + spin_unlock_bh(&session->frwd_lock); + iscsi_put_task(task); + spin_lock_bh(&session->frwd_lock); + + spin_lock_bh(&session->back_lock); } + + spin_unlock_bh(&session->back_lock); } /** @@ -1991,6 +1993,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc); spin_lock_bh(&session->frwd_lock); + spin_lock(&session->back_lock); task = (struct iscsi_task *)sc->SCp.ptr; if (!task) { /* @@ -1998,8 +2001,11 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) * so let timeout code complete it now. */ rc = BLK_EH_DONE; + spin_unlock(&session->back_lock); goto done; } + __iscsi_get_task(task); + spin_unlock(&session->back_lock); if (session->state != ISCSI_STATE_LOGGED_IN) { /* @@ -2058,6 +2064,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) goto done; } + spin_lock(&session->back_lock); for (i = 0; i < conn->session->cmds_max; i++) { running_task = conn->session->cmds[i]; if (!running_task->sc || running_task == task || @@ -2090,10 +2097,12 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) "last xfer %lu/%lu. Last check %lu.\n", task->last_xfer, running_task->last_xfer, task->last_timeout); + spin_unlock(&session->back_lock); rc = BLK_EH_RESET_TIMER; goto done; } } + spin_unlock(&session->back_lock); /* Assumes nop timeout is shorter than scsi cmd timeout */ if (task->have_checked_conn) @@ -2115,9 +2124,12 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) rc = BLK_EH_RESET_TIMER; done: - if (task) - task->last_timeout = jiffies; spin_unlock_bh(&session->frwd_lock); + + if (task) { + task->last_timeout = jiffies; + iscsi_put_task(task); + } ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? "timer reset" : "shutdown or nh"); return rc; @@ -2225,15 +2237,20 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) conn->eh_abort_cnt++; age = session->age; + spin_lock(&session->back_lock); task = (struct iscsi_task *)sc->SCp.ptr; - ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", - sc, task->itt); - - /* task completed before time out */ - if (!task->sc) { + if (!task || !task->sc) { + /* task completed before time out */ ISCSI_DBG_EH(session, "sc completed while abort in progress\n"); - goto success; + + spin_unlock(&session->back_lock); + spin_unlock_bh(&session->frwd_lock); + mutex_unlock(&session->eh_mutex); + return SUCCESS; } + ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt); + __iscsi_get_task(task); + spin_unlock(&session->back_lock); if (task->state == ISCSI_TASK_PENDING) { fail_scsi_task(task, DID_ABORT); @@ -2295,6 +2312,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) success_unlocked: ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n", sc, task->itt); + iscsi_put_task(task); mutex_unlock(&session->eh_mutex); return SUCCESS; @@ -2303,6 +2321,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) failed_unlocked: ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc, task ? task->itt : 0); + iscsi_put_task(task); mutex_unlock(&session->eh_mutex); return FAILED; } From patchwork Sun Feb 7 04:46:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378898 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.7 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 6AFC0C433E6 for ; Sun, 7 Feb 2021 04:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 311AD64EA0 for ; Sun, 7 Feb 2021 04:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbhBGErp (ORCPT ); Sat, 6 Feb 2021 23:47:45 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:41640 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbhBGEr1 (ORCPT ); Sat, 6 Feb 2021 23:47:27 -0500 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 1174iOOA107572; Sun, 7 Feb 2021 04:46:28 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=eLvjdxoSH/zTAbl4x6JLodnVmaUEkNxPVYI0EocdgXY=; b=Fh4mBejevCUHQK0meR5dWK+TRPDfbUxjJsALLqC27XQVclbmdBAixPiC0Klu6zf9/pQT HLyynIOmNWtHJUj2Gzo6TJKm2p0ztRpccUOPkH18nRDP9zGGAKP4v9JzjsEYcccZZ82X gWO+27wtflNyovvFdalIlW9OQtSSeKxE9QHfJkh38V/XfyFmQYnRCLeoD4O0QXr2SmOf xkRvg6ESipSIEVyccejtNfVchMZLkXbvcUUSPzE6+BVZE8cALbHMFV9u//fi3zKCgkOa UcRo6sD70jRPX1KqPloedlY9vNuNMFCZtqSAoS9BWlKIqUi2ChCoVWD8v5jAXWW/qf4j Gw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 36hjhqhbt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:28 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174ixmj004585; Sun, 7 Feb 2021 04:46:28 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2057.outbound.protection.outlook.com [104.47.38.57]) by userp3030.oracle.com with ESMTP id 36j51tcnyt-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O0NaQ6l2N2vMXjilxiHPnzAmDe/hZwuSATrI/KwZqeGyqIjN4u0R1YjubPpNOa4Xq+EfDPkM8hQsZcgjgNvNCLqa+xwI3svKemmnfH6XRFm+A97cspKWe/5BC3UDZAKLZnbn86JH7U+/edpwm+sBMQp1NLJ0JYHxZZfqUHUj9J447l8CABopsW2/IYXuGXouIFvI7TQxVMSEWKrt8Fbc/7CWUYrg7xmC+18WqH+YhnyA6u06x8mjjVFetPwSYJzQLPaXtgDJ7xQRfBVCuKS2AMNx4Sfl1jBUknPp1k/SWFilgzcoHkqFTi4uPjGg0uZlCxr39RVPFdpJmCTYSTkzLw== 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=eLvjdxoSH/zTAbl4x6JLodnVmaUEkNxPVYI0EocdgXY=; b=WK0naZXCnpKPCS2z/72nv+j0Q48pWgfZpE1fztlt65pBFW8oAdS0vzY67mu6kEUZxgUClw0cowZ/VmVl2cz40l6U9QzzK0dCj9jEMoBFSYaao0FlJgar07H3NyW3HHKvx6ZNTuQDx2ftatFFk6iaDGdLIhRuC7Do7QFNCPqnut8SJxuTHexaE+NCIqXU4O7a7VKKaGQnFgeaQKn/h8Sc9iaDMR32HZChO2iDvsEFGMDzoq3Cf9U/NUtHUdOhQgqqWzM5RdrQLWgzW8VVK9sDT76SFn9EOzNeZmwHay8Ss4/Ic4XAud9mDV9xBZUkiEurzCtcZcC6WcFDnoTtN2N8yg== 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=eLvjdxoSH/zTAbl4x6JLodnVmaUEkNxPVYI0EocdgXY=; b=TNtV1QiNs6Z8ujL5BF8pBHJmC1yisMmmN2CJKKkMbMoIW+sv9ABkoXWxXq+rIJMBVugEzuPRLUPP1K2Z1uyJh/8ZNn7oO5U7A7LdEw+0lj9/YMqsh0v6wEdHLyP2ymh2YTTqD3nBy6y55TeAQlY4I2yv2Xfv6q3/+6wuKBJ/V+k= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:26 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:26 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 4/9] libiscsi: fix iscsi host workq destruction Date: Sat, 6 Feb 2021 22:46:03 -0600 Message-Id: <20210207044608.27585-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 019d56c4-aae8-4307-610e-08d8cb2353d5 X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fQG7B6AQU4oJX4y41+nX/G9KthV360pZexwKGJwudKjQdMVKZKjStheFoiJ2VQ0FpwRTiZ57uVF5yMZYJfHjazwxXb9eUUNXJuJFlHzsvSmXeU0uUntAZafV3cUcqBnzPZTet8+YdV4nPABVAKZKzYM4GDD1SmhOk6p8lvmw8c9e9dgrm14fS6TsLeN9vP+88HSTTRLK39Q9INNvvSZ4gqCbWvSbJidyfSIOfoTuKgiWSie/q4JONrhsSZHNIx6oVhF2OtBoBX2oKfDO953TEwuFEKd/x0Kv2IFdEhSEVRzL3HE3F0ucOr8C6T1OF8uVsOD+uzD0bDqkLJnZUwIbB1AzBNLCpcmSv9h+eV/hMg3aQnKNmFiKbifLgulwy18NIPNfysmSnWkzsFhLbuWBi5PjTYyKQTEGTGmwWPMndnh+0o6eflC8qaLgCwboggjH0hgAt2F4gSmq6ZkUnktG7Mov+uxkUXjMcjIu2ogd2DtvxQG2Y8/EOHp5hDqcKsdOd3XksiP6ZT4+QYZDSKOr+8s36iT1wazJedX3NbraVz7w1LUiadiaa6XewBT6xzOqp3wDQlu8LsGhdNs17VyBMA== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: oavgv74KrWLmX2WuSjQKNCMBi4c4zNxNIZVsaZqywqEaxk7X8EEYaWIJvPsXG0EOnEo9cs2LHBr/crqr51v7c0muU4T92oWV/flZGJ60O+IQ9JAhfuoXTnoxHi0d++sfKC2MEdtAjD+EdI1PU5oLHaGLK1G49TedOlZs4awDIq4FUBUqUpm5/OT92lmcnLO6cPKwuLVyMqJ2B1QAAn/qXd66uaz/gtP1CZrIYCEGDdKY+FolCmDvQz8IxZMI4uxmnBKXcy8cQEdDaPO9zStm4rwdpe9U9i+p88339aBNSNBU0GTeSH4AP/F4M/ASBz2ny/MVo+hPR0k4at5nrvt7X9nxuTnLVgQWYeFb3rhWakWjvbmD+9M5BrSH4EzARSqQ7A0mo6zjrQGbyZ6IItUKYFzobGt+px/ZOopzVKw0ujWvdCv0hAYnSc/Ik/61AVWdPiFCHYQ0qH9l+Iyd6sRIZcJvOGfRab9DffhMFo3Nmgj6T5dTmi2zzniKl2f62b78okpJ18r3vwFWipbmOG903OBecLNkRbs2KsnZx8Mrbm7CHsNGon9PkQC6Lr5oGo/7557XGrh1xDYK5Kv1StLUxlkvnSHRE9bJiwsGlHKPU1On016JEajruo1BN0LBJ1kPJqwPcHeOtnYOK8JQesfs//8yf4bGCfbdgVNswuuqp8QztEsa4tQ4dk/Dp8/s0mwn1I9Uy3UtEk99ZZu0OdBtb6BXisIrtkINKXYsYtaBwYHesati6MxupPPw6gX4KtjGhaYfH1MY7PibQSI+qu2TCYHsSmE6vy4GXPRKrXs5gGdZ0rtZCpmUd/+pFsxup/DnXti7LWbwnIPUE7HgXUNAEADGKOPkKim5YtAJWzjK9kvNKHmux0lRyZARZKmlnNQwPcdfLfxsFL8fK4cH8mTpqBfA3ZeOL6l59vzo3bDE2Q3MEZSmX83lswMDvjfh1qLpXw+CytG5TxbWl3wFg/Ob6SnwJ1kANPlYsQzlRARYSFZgi8v7xKpJCsp7ZXANC5LVJWp1AF8V1Rhpq224yVCUzjoTCEDv3Qme/NsGeqXuxHkNsQnFHd51KolO3ykaVqc0JSdNUSrPFj/qxJ2ix8OeF9R27+Ue/9WkxevUYWLS7/T3ANfXmQjhoanCz8z6dKIkKiHRfFo2Ue2zfXkuHJtox3GsVeCFZJEvr63FepMOc79NEh98sk42NLBYlpPZGHbEJF0hagXvoinU1doz4ZLngvAtJihyDUVDJAkQxdtAA+Ojv2RchViA/ggJI3V7wwLsJtKUJTiXEAaV78W3IKruFxsbraNsa6ud9JmxlH19P8HFUw0SUYS/gxNblp1HYIvQ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 019d56c4-aae8-4307-610e-08d8cb2353d5 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:26.6280 (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: kCZK/8krkKLOTfaKWunWabd2RGlWxgUhUdfP+6v8v+jHtDMnz7oAmaJqejz8UP0SgV4/kyOPZqgHVsAxnz3wSRfgPTV7ikjpFabsDcUT02E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We allocate the iscsi host workq in iscsi_host_alloc so iscsi_host_free should do the destruction. Drivers can then do their error/goto handling and call iscsi_host_free to clean up what has been allocated in iscsi_host_alloc. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index ec159bcb7460..b271d3accd2a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2738,8 +2738,6 @@ void iscsi_host_remove(struct Scsi_Host *shost) flush_signals(current); scsi_remove_host(shost); - if (ihost->workq) - destroy_workqueue(ihost->workq); } EXPORT_SYMBOL_GPL(iscsi_host_remove); @@ -2747,6 +2745,9 @@ void iscsi_host_free(struct Scsi_Host *shost) { struct iscsi_host *ihost = shost_priv(shost); + if (ihost->workq) + destroy_workqueue(ihost->workq); + kfree(ihost->netdev); kfree(ihost->hwaddress); kfree(ihost->initiatorname); From patchwork Sun Feb 7 04:46:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378282 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.7 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 2B0D4C433E0 for ; Sun, 7 Feb 2021 04:48:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFC6964E8F for ; Sun, 7 Feb 2021 04:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbhBGEs0 (ORCPT ); Sat, 6 Feb 2021 23:48:26 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38696 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbhBGEra (ORCPT ); Sat, 6 Feb 2021 23:47:30 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174kVo1168284; Sun, 7 Feb 2021 04:46:31 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=fXLWGDb0Awq2YgQWc8+hl/MWbXDYQdV3tzHjFEVwbyY=; b=y2cUMmo57L+YpW6CtEV13VVcS5bWj+iShow0y5lttB2CXN90KmUoTWVLhyjVQCXc2ti9 bVC8AmJdbSo6LXCbixH3FADNX4rAgmiQYUht6WZWh98qDqrwlr8EmY04xGblJhuYtr4j t3wszLFNmQ/zpoHVx8P9lm0WJVcY8mAFg0PGXetv5yrUTTmUOfLJh/Sm0GA7zqXtoWPv ejxXICFzEu3TyqJUnZ3IMKWSnTwHirM4TVM4R8qn112ibTAjRKYy4GNzECN0YZvokzxo zIjpSuWwuML7a6Y5cf84DNl5KC3W3Gkul28kAhYGW0ZBwk3HV9EwyBODUnvTL9aJEfeL zw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36hgma9fnx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:31 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174inaL004118; Sun, 7 Feb 2021 04:46:30 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2058.outbound.protection.outlook.com [104.47.38.58]) by userp3030.oracle.com with ESMTP id 36j51tcp26-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PFAvsOFgloJw+A9vHfFU+TO3inG1aegP2NP+PByyhk/4GctmMYPyrd+AjFnqdK2gd/js/2zrQz0Mt/LshgQ8e6FiXhsAS45saBgK4gjjbL+lx0Tdw5oQbtkWyoWvqMLzhUrEA5faBuqCF4UXkrgdHfiYu7f92Xnd5fFgOaXTNDrVnDYWwfILdpRo4s8uz6BcapM9OalCMugG6a/XoBOhnHgNJ9GU3JNKnUhgcgSDWnyQtLroeylNROiQ7Ik8RXmwy0CY2evhTNdFbK91soxE8oKDLYUxytf/b9QcgrX2C82gB+I3loyRLn8oLj5zigg7dTLPDtOQRPSYG6F39BDY5A== 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=fXLWGDb0Awq2YgQWc8+hl/MWbXDYQdV3tzHjFEVwbyY=; b=MRELMQ8joGRVXUS816TNGndUJxetcem8dFU9jbzTUS6C67N45zBz2P4X0jKzXQw1SxUGzPVkfptDsNwpNMfBeWYcG1gDoEpY2NNnVrrfWSRkrK+243nWmYb7Tdp3w5T5i5yxdffD93b94XRbrZN55IwbZ9c17H1wuOp1+7ODsjYFTZNZ6nn6A9s5QoiZ/mgNuAH+UGd9wIcmD/BQWS/Z03SFBsXooWMNuGxjLqf1Ih3tQ9WfH5ah9SWwjUunfNlO2da8SYYUkItnUwOPkgKFu4L4TGui8g7Gesow63w1XWL0gCnQvclzeEEHwzbNdZ8UbO+hn/heobjHiq3Cdw50PQ== 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=fXLWGDb0Awq2YgQWc8+hl/MWbXDYQdV3tzHjFEVwbyY=; b=QDtYB7EHX2Dt+YYY7fqYZWaIODOv07y+q3LcL3ra5vVK6LIqqwV5KFjei6A2sitEfW4U64JGuDLJGYz0Omn00W+5tfASBlNgT2/div+FWh/ulhOcbW80HtHFQIwIUklAqkjd0E2AqLf3asUIumQVTsTlJxdh9/e5rsuqjURHY98= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:28 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:28 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 5/9] libiscsi: add helper to calc max scsi cmds per session Date: Sat, 6 Feb 2021 22:46:04 -0600 Message-Id: <20210207044608.27585-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e54b3a00-fe1f-43ac-8ee4-08d8cb2354ac X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r8TfBEVpztcuMw2DB9BmH/Nnj+Zfq1iduUc01zK2qp3/pwSBgz9E52k7Z4TqGA+mDrPSIHtaos/7UCZ+BHtLsjdkrd1Pa+/KJXklI9fZujE43PA5qOQHEWSYZvIdOWZvkAo4TzONVUTuRWVuG0Zrd+VBpNgHbAW9Sp0GzUXz5tbbaympPiy4Q09OoGKKpvREEVlyJ9z5x9ksHYxTmXHivyu7qxoQsC4dk7L4zIgqVJ9Zv/lqflG+944V1MfHb+ddUHitK0mJe+loks3sW1Pmwi2sH0eyCrby6B21kn1I38xB4JkRtnDuRh7SizVZzaY3LMNxzh36gswlQrYWMDdF6gNb6s9Ng/m0SusZPDhu2rUxXNMlZNwB6ByQpJYzvBuRgeQ0BIBwCCgpc9r9/WzJNlzm4b5JA5LbdBYVQdQCD/RRsgvtkdXbJcAPW+bq2VinHbvYeLK7G9yBuezDNpV+huajswMgy1hd+YgBMh5/poGB/anCZtBvKIEGj3+nBJymidaLwBk91NsLW6rombChpIB8ySK8zB0Zq8zyyNASsSDeo5qgPgpdHS9BzWxd2/Q5YuDpxFipAZPl09ce365Odw== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vmspqmi0/4NZLKrggXd1qy3UwcHxFs5WjroOKAMbR5y6SmvUFnvRgzUKudJUWJTRhWESWrlFebGiMjwMGXEmvMre1Lou5zscZzBqp+g0LIN/Xh2zKi5SkFI/aiKVV8jy7FN1/RZAG98uZHqXjbjygCNa6iDJtyt4CP0WTisff3cTE7Cqfz8srIFg+IWMPUlIFqkbDKM8wKklhXs/H1KRHuO/5GfNXNCq7X8tSNWoZfJMzjbUz61FIkbgD+XuCplfkWa8OAFaB4Sc9B9vaZIGFIbspYuxJQbF0Y80yXYC647MZPvPNGr66PqI/irxDC/gjYp72N+M+GcRek1IjbP9JPN4RO6GPXsfyRjXbTXBH8iyL/lMAqvS+e6C8LcPSF5D3EqBmBYjFNb105ad+bux2AfghLdGD4GEYxTAXAcgpjOYSlY+ZdMT7gJre1vnpTCRXK2ftWJmtKg8dbzGWfRIp+efsOsfstQJ0OAbERLH845vn3yA7Opk38JyCmK3b5ZFc8hazhkdcEYaTuQJVrzX79D1wxRV73yVzKYecLwDRX9Rch3YrJiJu3sjdHSPahhHQB+2EFzhC+xhDYU388adW7YEQsgjaUx0NPD8dv/Gu652F68sbFpSHF390l1zmz9omjzbqi9GeKPpeu7LoPJHyxAQ5O2Datnr8Igq60IiHe05nbhDos+SQe4opjUfbJnsWm2HnxSLYjw9ms81HYYEq82Ypn+2BWagrX6WuXhrmNMei59gMWqLDkJaNZN2k5E+KtiF50t1XVSXZo2zvmM+z+TGbd3NpBHT9FFw4hsxVEQFA87WAnC/5MtcYyZPzzGM+Hw+Eg8tOBjQRT8A+hzMbwwVbDsOVWyu4yCgvSrk6HrfsMUShlzqWdxErqDafcKSXiPmlYxbDhxBEZse3IP75qvUIzFXKxQ8Q9UerXQg5GqB/4JVzGDCJl1zg1sziHHY0gUhM1cOmv3UhkbK+HVSosKl4iaNynnJSHLwYfQpy6f6XdJ3sP7guwq4CMDhpo9cILk7pDPx3GEfshI6jgVxRcW0sMFnrjf/IH8PBO7I/XDOV+KdoR36dk05Gdfxzyk3FPcVR0jE5q/U/886yUgiFCY3AmfkwbdfZDeYk+hwEygI6v1r1kNhCbkakcGaLp8kuFxWf7ao0H6qnF5SUkFrZaC7T2OLMq7zsx+LkO0+0EZX26wMBOkD02aji7wVW5lVwZi9ww9+OptyLrYBRQUoGtIHilvzniHrMKMCokLHTSuKOi2BoYx9RET1PKdqIwUMtzY3GyGxaA0Obgdem414GAFf3StXkP7+/RO8gk86fVxyHUwHuTSrtXE3ix2TCKt3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e54b3a00-fe1f-43ac-8ee4-08d8cb2354ac X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:28.0022 (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: eVQwQGAjZb0gATZqXDMR4whwfvP2du1xWrepG5r4j0aAtngIJVNrSC/GGxsL+NIwUXIaScBSJQO4fg2xZKPyOL1h19CBLHOIvY9cYOqgdr8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This patch just breaks out the code that calculates the number of scsi cmds that will be used for a scsi session. It also adds a check that we don't go over the host's can_queue value. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 86 ++++++++++++++++++++++++++--------------- include/scsi/libiscsi.h | 2 + 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index b271d3accd2a..f64e2077754c 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2648,6 +2648,56 @@ void iscsi_pool_free(struct iscsi_pool *q) } EXPORT_SYMBOL_GPL(iscsi_pool_free); +int iscsi_host_get_max_scsi_cmds(struct Scsi_Host *shost, + uint16_t requested_cmds_max) +{ + int scsi_cmds, total_cmds = requested_cmds_max; + +check: + if (!total_cmds) + total_cmds = ISCSI_DEF_XMIT_CMDS_MAX; + /* + * The iscsi layer needs some tasks for nop handling and tmfs, + * so the cmds_max must at least be greater than ISCSI_MGMT_CMDS_MAX + * + 1 command for scsi IO. + */ + if (total_cmds < ISCSI_TOTAL_CMDS_MIN) { + printk(KERN_ERR "iscsi: invalid max cmds of %d. Must be a power of two that is at least %d.\n", + total_cmds, ISCSI_TOTAL_CMDS_MIN); + return -EINVAL; + } + + if (total_cmds > ISCSI_TOTAL_CMDS_MAX) { + printk(KERN_INFO "iscsi: invalid max cmds of %d. Must be a power of 2 less than or equal to %d. Using %d.\n", + requested_cmds_max, ISCSI_TOTAL_CMDS_MAX, + ISCSI_TOTAL_CMDS_MAX); + total_cmds = ISCSI_TOTAL_CMDS_MAX; + } + + if (!is_power_of_2(total_cmds)) { + total_cmds = rounddown_pow_of_two(total_cmds); + if (total_cmds < ISCSI_TOTAL_CMDS_MIN) { + printk(KERN_ERR "iscsi: invalid max cmds of %d. Must be a power of 2 greater than %d.\n", requested_cmds_max, ISCSI_TOTAL_CMDS_MIN); + return -EINVAL; + } + + printk(KERN_INFO "iscsi: invalid max cmds %d. Must be a power of 2. Rounding max cmds down to %d.\n", + requested_cmds_max, total_cmds); + } + + scsi_cmds = total_cmds - ISCSI_MGMT_CMDS_MAX; + if (shost->can_queue && scsi_cmds > shost->can_queue) { + total_cmds = shost->can_queue; + + printk(KERN_INFO "iscsi: requested max cmds %u is higher than driver limit. Using driver limit %u\n", + requested_cmds_max, shost->can_queue); + goto check; + } + + return scsi_cmds; +} +EXPORT_SYMBOL_GPL(iscsi_host_get_max_scsi_cmds); + /** * iscsi_host_add - add host to system * @shost: scsi host @@ -2801,7 +2851,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, struct iscsi_host *ihost = shost_priv(shost); struct iscsi_session *session; struct iscsi_cls_session *cls_session; - int cmd_i, scsi_cmds, total_cmds = cmds_max; + int cmd_i, scsi_cmds; unsigned long flags; spin_lock_irqsave(&ihost->lock, flags); @@ -2812,37 +2862,9 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, ihost->num_sessions++; spin_unlock_irqrestore(&ihost->lock, flags); - if (!total_cmds) - total_cmds = ISCSI_DEF_XMIT_CMDS_MAX; - /* - * The iscsi layer needs some tasks for nop handling and tmfs, - * so the cmds_max must at least be greater than ISCSI_MGMT_CMDS_MAX - * + 1 command for scsi IO. - */ - if (total_cmds < ISCSI_TOTAL_CMDS_MIN) { - printk(KERN_ERR "iscsi: invalid can_queue of %d. can_queue " - "must be a power of two that is at least %d.\n", - total_cmds, ISCSI_TOTAL_CMDS_MIN); + scsi_cmds = iscsi_host_get_max_scsi_cmds(shost, cmds_max); + if (scsi_cmds < 0) goto dec_session_count; - } - - if (total_cmds > ISCSI_TOTAL_CMDS_MAX) { - printk(KERN_ERR "iscsi: invalid can_queue of %d. can_queue " - "must be a power of 2 less than or equal to %d.\n", - cmds_max, ISCSI_TOTAL_CMDS_MAX); - total_cmds = ISCSI_TOTAL_CMDS_MAX; - } - - if (!is_power_of_2(total_cmds)) { - printk(KERN_ERR "iscsi: invalid can_queue of %d. can_queue " - "must be a power of 2.\n", total_cmds); - total_cmds = rounddown_pow_of_two(total_cmds); - if (total_cmds < ISCSI_TOTAL_CMDS_MIN) - goto dec_session_count; - printk(KERN_INFO "iscsi: Rounding can_queue to %d.\n", - total_cmds); - } - scsi_cmds = total_cmds - ISCSI_MGMT_CMDS_MAX; cls_session = iscsi_alloc_session(shost, iscsit, sizeof(struct iscsi_session) + @@ -2858,7 +2880,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, session->lu_reset_timeout = 15; session->abort_timeout = 10; session->scsi_cmds_max = scsi_cmds; - session->cmds_max = total_cmds; + session->cmds_max = scsi_cmds + ISCSI_MGMT_CMDS_MAX; session->queued_cmdsn = session->cmdsn = initial_cmdsn; session->exp_cmdsn = initial_cmdsn + 1; session->max_cmdsn = initial_cmdsn + 1; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 44a9554aea62..02f966e9358f 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -395,6 +395,8 @@ extern struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht, extern void iscsi_host_remove(struct Scsi_Host *shost); extern void iscsi_host_free(struct Scsi_Host *shost); extern int iscsi_target_alloc(struct scsi_target *starget); +extern int iscsi_host_get_max_scsi_cmds(struct Scsi_Host *shost, + uint16_t requested_cmds_max); /* * session management From patchwork Sun Feb 7 04:46:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378283 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.7 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 AD0F3C433E6 for ; Sun, 7 Feb 2021 04:48:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8960F64E92 for ; Sun, 7 Feb 2021 04:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbhBGEsV (ORCPT ); Sat, 6 Feb 2021 23:48:21 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38684 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhBGEr3 (ORCPT ); Sat, 6 Feb 2021 23:47:29 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174js3J168228; Sun, 7 Feb 2021 04:46:32 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=S/2UGkixiZtBVS3dPLVmX3uuS/lusXXb171MjXJHbCQ=; b=so5a0OHeePNmE28WSoEmgN08vAMBqiXLBAszcWptCrVIgpGa611iv0R1Ijl94rJm5bQZ n/rdI8pufBO09QNV20ERjMG+EJg09DeFzgPghJMcxK85B26H0qYmurUUdW8x6lxI1k7e 5eMULXL4fZi6ZKydFKwWZ8XWL0uf9mMJEWOLjj9Tf1fUxPHVtIT2xyzmz8tFM96DjQml ZWBCB6yiJqHdP/j460kgDtG7J3vwXEoVg5IGrP0KE3/9i8dyhzLsWDsOeI2GD0E/JX+3 DYIwaZTTgUzF2CUdXu++8LrjLohqDil4s2Pnxe7FjeeEki7qz30VSMHTDUdYQ5SEmipQ Eg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36hgma9fny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:32 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174inaM004118; Sun, 7 Feb 2021 04:46:31 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2058.outbound.protection.outlook.com [104.47.38.58]) by userp3030.oracle.com with ESMTP id 36j51tcp26-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R09qbYwXVsf+OVFEpVKZYElp5cv4BrdmAhlYl7uipc9OMviECg6bZv7OB3T2RLNc46B6Bh17YE1UgjU4wavZSG1kYreHbL/yNXZ2IJ8AUZOv3aaqrTOPyqh49UDjyBpaYYUQGVNzHIogSOQoqFNdu6BJCHFNHYnsa7dx6GrADXiidvkB/ZTQft+bxkc84vHXIN71X9Y0hEio1niqsag4dQ56i2m2+6HYn5ibMZ8d5iaw/zV/vTfHBVOHGhYdKpRdDdiZpm4K9E6oCWlIlyKvQVM4W5Sgpc2CWg2XBtSB0K9a6dji73QmIPH2tkAr4dlPL4nRQt4q9KmmWZf+Y5/jhQ== 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=S/2UGkixiZtBVS3dPLVmX3uuS/lusXXb171MjXJHbCQ=; b=RbeAC/ZpJYSj6KAUWlGy7p/Wx2nOgXPET5ce+eW5yGnVzz8FEHZ4lhikqVUfADakd/B0/hdy7tLy5SYKA5bD+TLAJjG6i3WXTofa99HQc1Tp+e6tAElF0dCO2+IbIn5dmzatpXO7PTQQdDeHy9yFrIOcPJ23qQhq/DEvVd1zgkpq1K2efh+b870hM/5Vi15aywFGRUs9MskeRY5Xp+aiaGP93faWRz8v5L3iYwrUMynLz8uAM7ezkKYY8qeI5vqjyc29Mv1ji6Xrma4cnal7RfRYBVzqYfwi90XSLh2K2oW1Tb3/7RKVgJ/8XoNhBQiuZEDbQvhIZ3hiycDRz7SLZQ== 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=S/2UGkixiZtBVS3dPLVmX3uuS/lusXXb171MjXJHbCQ=; b=acbklflbvdfB1oRmnLBqvmfwEd25/TCnfT6r4lrSOp8nlOMr18Qq5RYWROzmWS5XaYlVrGZc6mMKMfROEblEBX5qt57YuYhbwaOc+IeZkEheW1lkdAT4cjlabCsP91NtmlkG0D4LAbBS/HaKMPROwBAZ17KtXD4zsMnfXMWIEwE= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:29 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:29 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 6/9] iscsi_tcp: fix shost can_queue initialization Date: Sat, 6 Feb 2021 22:46:05 -0600 Message-Id: <20210207044608.27585-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f249bf2b-4ba6-489a-9a38-08d8cb235581 X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: 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: bv4IBcedtXyfPARUAHYnybtA/BkPXFl6eFBPzLIHbqyprfV1OVldRS65S1YXtGhRDBUnjAPh0ypMb7x50dcO851DsxsXAkAhJsLbT+orVZlP6Dc1eOBEFisVNJDftk1b08Ukv7csPQQIDE2I9bNOol3rPJNjRNapARXXdZiXXc/x7W86lneq8SzCuYvwcL51FSOcV6Tvhu99yvAbEMIJCNSo+VDi+BUsY6eTqt/pRW4mgE5aPq6q/EraclwYx1SV5QKOGHwLAFZZrs8BkuUilCR4L7sogKEW4rrNEB42cvP4CrK+fY0dVy/UtJuJ5sbhy4ERmqeFBBo1fZik8O/eT+vVR8oWStSMPAwG5cEcVrYsX/TQE4ESk62cYbcVvnY3cciTu/linMJc2diG39FDuSfORM5Kw0e8q1c+AaS6geyLOedtZV6KpXXKDuK1VgTT0eYi8ai9ZQmmdgFj6fjf7vOkKFhkeABMHI7UDoXOSQtN8/EBwveDnXdZDWxXynVjh2k+ziISV1NnqTw4o/gG/DckV3SX24lFFrnR2qyljoIwewpei2UZ2s4LyWKfyHE02mVkV7yMjHRxbBtapC4s9A== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9AITIo62H2jbKCzTzLvhbkJP38FIkA3hXPEIaR43eiTPQSJLyuVdAqvcAJW8P299pbwAvoMtah/MDcfQ5ocMSTQgiadY1m9wRGz0VZob32od2uoSVBLCk3jYERV4aZdM+T9LQ0iQjNc7FNIQrJDmUqLDcDF/phMFoeR0z1Pp2bFR9rRrn0TOFJchb0CGkF+zbjFcQmot2YZEMvdbal1eLP7JlTSf6BbvxD74gJubTOE0/ygent2Y5FkyFmix8AP7EXa5R2+JrVkLT6R21ljElKpfRGdsxCng4owVlC01GNekIP/pVltI8E2fq1F54sneshhMqoh7HA/pgYW56llxNwtAecrZd1yr5gW2FoPYjzWS6HW/fPHUVYEVy+TVd/F+3diITszYTwz9NMeW0I1pclnwAeY1Zql93Kpzh566IBYVhLgKPGFD6s7YAJldtLI1joCPQA21gBDXOVtyOKgcErF0wjv7/TV5A5Q/zHBA/1FZqYwAlKM6KVUKYTjOee4JfhazS/t/l7pP/Zn2YDOO57LL/8f5lTnd8MXF/Gwxfe7g0rQI8kwfYFzP3elVbWab2E8DQSdNnbMETP1fTZqpf0J7p2t1f89SZ44M3AqVux+xALjXBdhC83690VCGqTqbr4DL1SVD0c6zAZWzIrByk5mG9DVN49IDk6yorurx+einJ+63gtq71WU5G9HqWaXsC5EfsjRE/p3w57aRPKZRzoo/nivkm5aGcpt43+HgFSS2sO8fs8ygJGLjOENqoG/gQbwldo9/vpqogpuhKwZxKBzvCBWHLdEtOnCUzJJ/sHanJXaNgyD9Z0dwAnkEDOYotg0O8Ky33ZRkyG6OZl0WCyUQqgbgw13NI7v/17bAvJmW8ZDy0NcvBQY30sI4gPLI5qUl9B2KrZwvlq4g10A4+zcCobJqBVhQ8muOvfn9e33hNC/JeMDb8mAkSMK37mzI9xOjQMXd7ZY0oHgh1sIAJIYhl2NfDg1D4TdK5dRUgy79hCXFP+fu64Cx3KF5NeNgWXH6Yw3D55JUVuY6Lt8Z1LAKtimGKI5aWNp5GNcIdmMgegtv0GfGOARSG1HW64dVIvDpW682ERL+VqsGSxrFxgXC7AVTOBGxNTFE96Y88uENnfeN+LHAdePz4OgDnfg3U3BGGtZPx76rLrQYvTMpXQWzH0LlHyENyva5n5SRxbqhRvZ/HtXjbo3JOUXFAc39TdyRpr4mEe+ToIcqROG8TUpdxjx6xFlBjY9E637gKGozJ6RlTD27kK7GGIWNXp5nWCDx/MwcZe4IeO7qdQakfZci27inrwDrtI7lH61MO/qfelrnpZiUhIMFHKYc2uF3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f249bf2b-4ba6-489a-9a38-08d8cb235581 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:29.3794 (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: 2VhgOhZkNviGZCnDU4/FaMPoCEMtrya1t0AggnPWopAKvz+Sk+obt7k4rNOF5AINIQOZCPo5ovweNPFMFylhsf5Yw9VH/ZZD+ZhcavWYMBY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We are setting the shost's can_queue after we add the host which is too late, because scsi-ml will have allocated the tag set based on the can_queue value at that time. This patch has us use the iscsi_host_get_max_scsi_cmds helper to figure out the number of scsi cmds. It also fixes up the template can_queue so it reflects the max scsi cmds we can support like how other drivers work. Signed-off-by: Mike Christie --- drivers/scsi/iscsi_tcp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index a9ce6298b935..dd33ce0e3737 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -847,6 +847,7 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, struct iscsi_session *session; struct iscsi_sw_tcp_host *tcp_sw_host; struct Scsi_Host *shost; + int rc; if (ep) { printk(KERN_ERR "iscsi_tcp: invalid ep %p.\n", ep); @@ -864,6 +865,11 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, shost->max_channel = 0; shost->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE; + rc = iscsi_host_get_max_scsi_cmds(shost, cmds_max); + if (rc < 0) + goto free_host; + shost->can_queue = rc; + if (iscsi_host_add(shost, NULL)) goto free_host; @@ -878,7 +884,6 @@ iscsi_sw_tcp_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, tcp_sw_host = iscsi_host_priv(shost); tcp_sw_host->session = session; - shost->can_queue = session->scsi_cmds_max; if (iscsi_tcp_r2tpool_alloc(session)) goto remove_session; return cls_session; @@ -981,7 +986,7 @@ static struct scsi_host_template iscsi_sw_tcp_sht = { .name = "iSCSI Initiator over TCP/IP", .queuecommand = iscsi_queuecommand, .change_queue_depth = scsi_change_queue_depth, - .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1, + .can_queue = ISCSI_TOTAL_CMDS_MAX, .sg_tablesize = 4096, .max_sectors = 0xFFFF, .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, From patchwork Sun Feb 7 04:46:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378285 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.7 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 55EFDC433E0 for ; Sun, 7 Feb 2021 04:47:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 136BB64E92 for ; Sun, 7 Feb 2021 04:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbhBGEra (ORCPT ); Sat, 6 Feb 2021 23:47:30 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38672 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbhBGEr1 (ORCPT ); Sat, 6 Feb 2021 23:47:27 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174kX4N168289; Sun, 7 Feb 2021 04:46:33 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=pX36xKTyjoZmT8eSx91b73yb4X8qpqrQqg/v2v51m1w=; b=YnGQyEDKcq6KX78hwh078+NvFA+9B3O4bqspX0QIZAJ/Q4HR0ncVDsTF75u4RfyGqA4u +OLcrEPwj6exbTGC01BAnkYWbrdC2ZLmGUm0cq03M72qEEl05S7e+1BrTBdxDsUtoBXs HBFXltbqTyEXYK6AzEXRX4VJnhbQJl1HZzj/cCgXsA/n0lfSvrN5AqVc17qznMirKUNF dp59uJEs++n31fC99wz0tNHiRHFgtYEgC84f0j77JpExMAK8NbIMJoBjQI/99aEJ/WRt E7aiahnH4/asOFfYI/sJb+wKhi9+7R1CUfcMHPMPbpUDQK1uWyrZaK3DG3NuWNazbfWa jg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36hgma9fp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:32 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174inaN004118; Sun, 7 Feb 2021 04:46:32 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2058.outbound.protection.outlook.com [104.47.38.58]) by userp3030.oracle.com with ESMTP id 36j51tcp26-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gKZy+/HQIRisQyLTnxcBj0S7n4IdFK1Of5xdx95e++6PZpDhbhgc6e8bnfLEUjuJY9zqs+ES1Pe6o9i1TX+GYCJAwJNbs+062jnypkUCDILlniVQbaM74dDKRYujxbj9gp+0j+e+U1plqmVX5YsylpErEnCqyQC3DFUPiAtOemXeu+MvuKVsvU3XtgJP6O5MX06DDIWsv9TPztegUCeB8iR/qJkmVhRvdIi3stEY293vK3RE2gL0lmhkRBwd0wCtFAvoaVu0YAkd1b/PWEXXZxScfi26bJ4NgdiLsV2hFMiY3xsujjKDyWMBwiSgzDwZU3urY0HgGO0+qpnymHw9zA== 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=pX36xKTyjoZmT8eSx91b73yb4X8qpqrQqg/v2v51m1w=; b=DiZiLzjUV5GCjxO1DVfVeyRM3ZkiOi5vMAMcEgQIynUNLQKpWSWAk9fiKMC3SfJEjFEPTomZsBtpZ9zkKOIqmR8R0FyaL4nDTez4+8sqe1TvtNPmlwg6AiPEV3peGJuxznE9Iq8D9jEOjBn74HJzfW1DkvVI0KlxcGQFsP7wYzTgWhP5wH5qVIofnGilwLzE5j2ILP4R3qnUQ56st1M/vkNVyZ7TAerRM3USigbH6wQ84eZ6pLRRINHDJ5HrWQH6J2aMvb8TuFeWBo2jse9G73QA1DMBOuFXZYYRjbyVQuzS6LcRaTyUjBhJaQsYtWSnIhSz+NtLY0+7EqBKqCNQjw== 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=pX36xKTyjoZmT8eSx91b73yb4X8qpqrQqg/v2v51m1w=; b=N+MitAocDnJApvDFM19LrOXVoMe9cGCwrnmX840QAr9wxsG0FzD4btESGcT6JwX+R2+6kZyAEfalknZMOzWMejnORlRAEuu3z1l9LBAimtOqj3q6c+nwuGBP3J4Kph+XJIBIxDDQ0DzgFszvFBwIRuTvmCeJDzJt+IAqUOAjuQY= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:30 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:30 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 7/9] libiscsi: reset max/exp cmdsn during recovery Date: Sat, 6 Feb 2021 22:46:06 -0600 Message-Id: <20210207044608.27585-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60d523e2-26fb-42da-1b45-08d8cb23564e X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 01LnFysvt7TxUOVOZ5rtP4Qf18oIs9uCd6AuNxBGacVMy2qNFxaBWF+55A7ynRD7jE8tRqQBo3uOxIh0J/hJuOigNokv6dN/pAJn+RZKXJSt1VtmglPVeO23D5kVE0Zju6ax9maqQM6K23Kbq7vyX8W4TYyTWlbwoEPH84mN7QX/ggWGj1J8XOPFHNEnik0sHXswlcsuc2KW+OFLJVLhrTsJXfmJvLpzPe0y+4XiUN1zjEE9zeIUc0mWFTotpLXEvosiFWcj5HbuMTkJxxgt2ksoBqt9TtFIMUsGt8Ren9fAhGP4HYfBXmsYFVSriEZxmNkHiwYUs1PgHx8xitoD7aCDMQBb4kNeGbjT4dn5MtiTn6Jwog8/Oep2sWbgNpf2TNloHCG08HUE0IU7I8j691LhxW9wGKfw0bCP/Boj0cW73ml2mB1Hyo6/Zsuzrn7s6VL/jUQ2t4fQxIDkswEmkNP+Jlu00RKtb+1CnGgEsrGQbjoIcM4bPjtCN4Z0wZnt7HvTAJWR91+rin6l3smOer34P3RUEVi3DUtgoZkt2Ef/giQB4f4FaFuil6yOGkTeAw9BbbTov5MFFX2EIqScbw== 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GFvN9DXH612LZq3SOv+JuJ81eeNjl1ANlOE5ey528+SbKUO96aSH8XXFI9+RmC5uDGBWZ9v24tE55qumX33ydeXlj2cJbBrTubpdQVOqWD9M8sEnzHItWOsMCZ86DVGOzDXAShgsd08ZxfOTCFuaER2kHTrSzGxsaIkymcZUzn9oo7OuqqDjnYvTxNiQN6WxNqy5kR04WSJHR7mNhY98EGZ6ZHElRog+TnVvSeRXwfp9LXUGOa6EVbMm1f1MkkE5K53AfcTpQcEvf05fSBJQEmTTWPY3YHdKPOxCXfxmrR5WP5A0B31nFkA1z++EihCmMkI5QSHtZI8nRQTax9uB7eYBOvDvqlM8z2as731yK/aUdqOMgqfk7VvULkMeQcRlxOYE8ZgQ1Bv43HaWnkkGiU1250VyTrKaBBWnFN5JdR8sBS6T73DQ9Y0boQvkRXkiKDZ3bYadkP8i0Cfb5rT3ogejzYSwJiTwffx0+EXUFJfm+YgBWIAT4rXHewjfIXzxbdRSC3AJPfzq8SRSfZ6Qd/f8U1QWSuufOCXP7zmAxF6JZ9gk8AA5w4/HNAYkze8vJNhOMsRui0Ce829iyL27PwuXwL1SUO5duOeP4dTNqK7uoFx0zVPjRlPa0xS5MZ+Ba23sX4OdwVhNIi9jL4GA8tYD/nF27re+oZq2I/BRN1r60jdW0I9aOct9IPBognW6OtNs+YakLbQottvzNjGYcYlo0b0eWEhrguhRqVFmEp95fMB2WCk7q91zWQGD4bJfv6z46H1KpBD8VYPFXe8pCxSHJWbDHrlgrCrCPjABuZXjcTNdGCN6mzrHqawqftQSe9mzNE73pzX176cawFDUaiZXYNMZCfaju1jWnV4chB3QfDL9Y//z3J6sajkx/BwJkg04kcR/aKj6SdIQ7ACow9kp+8fB0oAA6bivvZPaaINb3KIU5GD/0+/9MOpFMuyKIC0nfRPW5IZ0N3ih8lCzvrpCSxIdLQMEBGEfybZcYKk8sTo9dUv/7cdBpb/MNlD/9xbBXhBP3brgFiPE65rcALJx5TlVBhrUovzB6GHwbETnia+eOo4yeekO8ZDIqQZY48Clh+xEQO1lx9SVmgAUkoDbxp7Mi+8ieIwfjhjSG/50J4YVAUdW+/hNM4UhVTFHfqXvHSekntVGD7BBp5o+m37vayGDYQcrSNsi/c5qaxI6WEjVOC1bk+ENMPRDicWDerjU3j5rGHMqKHj0SqqsLtgHgRUwC4zDEDArv2ElTCgMluIN0z+W6cpF3DhOIBsnsC0EwOIH+A90kMct9Yhcs4GK1bWUbg0gfb39eKw5WXin//1DZzTNwx3alPUYsaR/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60d523e2-26fb-42da-1b45-08d8cb23564e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:30.7217 (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: 1FVl69o1CuH5RATO2rpSi/ZXcokQTqKjgzVKyAeOLmC5/1jkz52mWWb2T13/3bpVGacVqM+CQC2n/5pFASK7mLOy6u3Pw6hmkxNg+nN1Yuc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If we lose the session then relogin, but the new cmdsn window has shrunk (due to something like an admin changing a setting) we will have the old exp/max_cmdsn values and will never be able to update them. For example, max_cmdsn would be 64, but if on the target the user set the window to be smaller then the target could try to return the max_cmdsn as 32. We will see that new max_cmdsn in the rsp but because it's lower than the old max_cmdsn when the window was larger we will not update it. So this patch has us reset the windown values during session cleanup so they can be updated after a new login. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index f64e2077754c..7ad11e42306d 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -3273,6 +3273,13 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session, session->leadconn = conn; spin_unlock_bh(&session->frwd_lock); + /* + * The target could have reduced it's window size between logins, so + * we have to reset max/exp cmdsn so we can see the new values. + */ + spin_lock_bh(&session->back_lock); + session->max_cmdsn = session->exp_cmdsn = session->cmdsn + 1; + spin_unlock_bh(&session->back_lock); /* * Unblock xmitworker(), Login Phase will pass through. */ From patchwork Sun Feb 7 04:46:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378895 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.7 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 EEEBFC433E0 for ; Sun, 7 Feb 2021 04:48:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0F1B64E92 for ; Sun, 7 Feb 2021 04:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbhBGEsW (ORCPT ); Sat, 6 Feb 2021 23:48:22 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:41664 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbhBGEra (ORCPT ); Sat, 6 Feb 2021 23:47:30 -0500 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 1174kZTT108603; Sun, 7 Feb 2021 04:46:35 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=23wu1yMWld9niuqGxoI6BMKHkdgBSWL5rhPPfv/xM+c=; b=GkKJyJ7HWGOoTFuCgH78TQAZrBQZnraA2oZPskjdVPVAyVo9+SIGPrv/7Jm0LM4w8XK4 0FW/J7vR9opII1FJxmUYC8NqGl3yMv2bfQ9Chgu5xQ+MHIAXhGH/rgpPQm/4DwjZbE5h jl/jSeBUDcrbzaBmWE+N3V9dRQNero6q/ByqbbooWWxWLw9fdHNqwC/LQUvWJ/yJiVcB 000k924Ioet3WXREKcXnhydjqr6RT6qC3QqUZNPrrWG+2jx/QD8JqIyuWS4pdE82NV9w UZoEfebntBGBBQa8o2nOepAsVbU3c7GIyqJxr/Lv2E4KI1nAsYhpjLpJGr3o6OdES4dp Fw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 36hjhqhbta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:35 +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 1174kRSR154156; Sun, 7 Feb 2021 04:46:34 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2055.outbound.protection.outlook.com [104.47.38.55]) by userp3020.oracle.com with ESMTP id 36j4vnmr7u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GUvv24QnV5xvO88ywpQHfJCBCmyQMMlLpbdVjuIeQ4FjjeZnNovX27zcgp3Uvhy6kHlGAEPVcuYzc5pS7S0cCyd4fPgazYKVdSfQokek2rNDX3utXXoKCHKy2VzTfWpJaDULZOWTSQ0M7ov2FYaJ0UERtonxot67HNtIau1OsTlC28sAiAXXhr3orbBoVE7YsEaxi1Zj883GzyGPbLs3VuW4e97xIvvWRjqBZjkHxTqn2JaAFl4A5BFmYeDqfiYb9WWyM0gqvoveOn9Xj+B/ra3rdCPnqXedEPj1f5hzei/FXX7V2BlznB7+AuefTz0rxGfg0Ati/DYmGMVPeauM9g== 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=23wu1yMWld9niuqGxoI6BMKHkdgBSWL5rhPPfv/xM+c=; b=dNCEASk0/vUYBeXZDIjRGX0vnlBIWZ4N5g0rwpRqm2aD+mjde80FxAXxYj0O9o8SLmTUbZ2feKJYZ1EbcL1ZZB1iVp88dDelup40IKSbCKyYv08izwQfS0X+bEWD70Y/pQGxDOvzxqaNTrb/3Ynq2Af7+HXnfxdM/5T//I/vCdUS06aZnJRjvlSlXtLuDp393MU6Pm/HHcVQYV/mfN1njV0BZ1YBplWoctLH+G+Bt7k98mkSfDwwf9l/KRBdm2S6XDqz+hHkcCA4ziwI8ElbojvEkZGxDv1mihJp5dgKy7Vr51l1CFzoIyN2QG84alomACM4nCT8dPeW8uVpcRS+YQ== 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=23wu1yMWld9niuqGxoI6BMKHkdgBSWL5rhPPfv/xM+c=; b=aodINSCdBl7askJqE8nL31+62FtXpRkBktMxg5S4HQFHibQ5TEbz6WH0r4Zi5ZE72n09OKGxTnZYkGuyEMT52EhrRB4kf6Y9VqgbE8sGL0P01FwmdqpzMlxoISvqaW2ZdlAZJwUp+Qj4jWI5MMKEzL9haJVxs+rBb4QbDynnTpM= 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 BYAPR10MB3429.namprd10.prod.outlook.com (2603:10b6:a03:81::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Sun, 7 Feb 2021 04:46:32 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:32 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 8/9] qla4xxx: use iscsi_is_session_online Date: Sat, 6 Feb 2021 22:46:07 -0600 Message-Id: <20210207044608.27585-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c21bba6-2de1-4cf4-b5f0-08d8cb235720 X-MS-TrafficTypeDiagnostic: BYAPR10MB3429: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A7inRXa5Z6W6GIDvPPuQmsQEQ4FO0XyxNCElkppNt6NamiRLqlwAM4wxJwSA0TpvOu22BPFNYC2iVTHddNzh8bzES3u+AEMt22oMZba7kdgdfFGKFpDEAwnAXyXq0sFXjW+CktqpSkcqcV1sq4VptvXnpdEJU388InqRLCaZJAALkNenNJ+bf88NhIIygduI4SW1L6hWC2WIeZMhCW+fOkFA0CNS3cQq4GU0jPCe4f8I2rrvBvN9BtZh/6f1eroJYuCFKZWokKEiiFtkLIsx+AFlNR13Lpduj/LAgn9l+2Uvs2dseJscEDGWsPZQWHeoVbb55zTzh1xi3/TOZDzhKUqqy8WHKxUvxgnDkY8QIAE1VCICQaLPHuU3D7RchROwRsi64v9wqB/MCBKCVBD/9ew1sxTQ3uDEPmD//6VZNp+wALpVwJtp8tCbHGG0L9Xz/wE7npfpIajHIu014RQjByTPtNZdDsGyXpkDwEVYKn8joKZgKepfy2YQ8UyOcUdrsbMIgJqYBcMXRD+UDzLjNwb7mQKod9VIlvqeXQ44YgEFUxyy6lLCRa2uLrGQ2nvUO4fH7P/dYjkHLqYecwCu83SRs+jjXnTYtFDAPRHHN/8= 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)(366004)(396003)(376002)(346002)(136003)(1076003)(6666004)(316002)(956004)(2616005)(5660300002)(66946007)(66476007)(66556008)(4744005)(6486002)(69590400011)(83380400001)(86362001)(36756003)(52116002)(107886003)(6512007)(26005)(478600001)(8676002)(2906002)(8936002)(16526019)(186003)(4326008)(6506007)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: F5PIHRO9/sFldMjKcR6CaMFDrMbthsAVGgetuPVaBmWicxgpBCaF34pOuYbAKkTkMbup2eRYWo+ifgLuzWoVfnxWmfGeAYF1pCU9c9O7AMzytfnRTzSHMz7hdhQE90uyhg+PeBd91b4OjaIsIKPDlh+ZZUikzrEdy/czNkVYJssMAO0wtOkUVB2dHmO5ycI3R066Dsq2NzsyNDFrX1WPlAKRv8+Usogclnj60yY+t12DHpMKXVBkmH+WpovCdHF+2t3YuPMJR4TsaoQSssZkON2Cj3wGSzc600vsJrnlEbZATlog6iySTohj+m1xWhkw1gzgNhguzKXwWo2DQVHVDOLT1px1ywp4mlCuD3aPEZGzptUuhDWgKbca/97CohH11+5GtLx7HXCnY0VFu6Bx+y/BlxmUlBxmM5GLAbkblnTHEA0dpdZjIiCkwlwuSm07f+/hgaseSWFFaGAvAgA6cQJRy5GAXB+RibzGWKTUrgP+MpI+kAhFNHfU2hldos74w5DGQQo3Ux/yy7knPF934cEk8c7huP1RCNU77ffYsDlhZOeJaKyvuqVJ99G5v0zae5CYRzR9fOkQzRQvz4J1TDqfMEp3LFWfVGhn7GeWjz01+WTDq5/XFrWF1U7CWohdrJtvrfudKk6qamf7SSZPqvG3C/NZPNvj3bXJ5XtSX898cLDygIssnTHQXswB3od/QlufPRpHTCO6EIObX6owQf56ASyl8LkkNsb/o2cYgs1sUlNe25zsUANMwS6h9qvX0a/pujcvipjc8uiTyg3sV5Hb6Y8ct3Z8Fs9LCDCz2HzrD43ZP+SbXlDuz4dCzl6mZ3jYyaGqIDD29B03/gSsjZ1kP8peHA7W1TYlEz9+n3lD5VRo8g2mfsUF4C9Ebu+dY7DS952BkE0yG9htxc6lRDgXhKMeUQ1/z2TcAyNNQOEF7vP8siwxde7UEAFXJ9/ikEPJDzrYtsKhuSPn36QrDBoM+ldujMVzLJ8mT6eDJaJ3tEgWQKF+mPkU0+aV14WPZ1nMRxCmGznQmKx9QzAg1xwoIi2uABbHV6j+lZPCBdRoaMpdr/wPQUCpx/b2lNsdkhCviPYl8jF+LoZ9k1EDg+YgAYbHd1XcWDt4iTUcVPfJ+5VUc9DrfQJRGbesulsO6fQUqZP6VZACSn/9xS1upQTPhf7O3fUPDxHWa04kHJxVMrsszHLMgcTjVSIQzyaD1Z6buWPu3ArqQx9/M1MpHfwXKLFzjpif9gLFRXNrsgGNYfgwAj6nYiMaP+K3qEO3TVZ3zyRhhuaZsPnmWNckpN0qfYgT6rDau9IH5KgaYCarIKBTdhGZVBnIgN4TOuzj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c21bba6-2de1-4cf4-b5f0-08d8cb235720 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:32.1559 (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: 0bO06KdDbPYJdqjLfMBGouFHnlh1rwZtUpCAEkOJLfY6r3fAKHndfaWMf4TD7OE5jlCjeV7x1OpByojilMdl8wHCU9S9af+vuaIQ7yTFScw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3429 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org __qla4xxx_is_chap_active just wants to know if a session is online and does not care about why it's not, so this has it use iscsi_is_session_online. This is not a bug now, but the next patch changes the behavior of iscsi_session_chkready so this patch just prepares the driver for that change. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/qla4xxx/ql4_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index a4b014e1cd8c..7bd9a4a04ad5 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -841,7 +841,7 @@ static int __qla4xxx_is_chap_active(struct device *dev, void *data) sess = cls_session->dd_data; ddb_entry = sess->dd_data; - if (iscsi_session_chkready(cls_session)) + if (iscsi_is_session_online(cls_session)) goto exit_is_chap_active; if (ddb_entry->chap_tbl_idx == *chap_tbl_idx) From patchwork Sun Feb 7 04:46:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 378284 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.7 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 EA197C433E0 for ; Sun, 7 Feb 2021 04:48:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B590764E92 for ; Sun, 7 Feb 2021 04:48:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbhBGEsH (ORCPT ); Sat, 6 Feb 2021 23:48:07 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:38668 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhBGEr2 (ORCPT ); Sat, 6 Feb 2021 23:47:28 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174kVo3168284; Sun, 7 Feb 2021 04:46:37 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=pMXpkNI9ZCemkBtXM+CZByGVCLY9xVWUkdF5WhWUe7o=; b=JeDAF4nGELxGUQm+8Fd5e/qGOb8xIaGT2awBXKZd4UTcsvqRuRhMCBwvl6B3zDaXpeks 0v6yT/dlyc+9HCDfCqPjEBLJAWMVnsnTeE7tl4gJgXmzbV28IbEVl9mY77E+FP7rcdhj aReXlzAoBXRUBnJy80VuYtCIdU8G7d4s4zGMbsEB0bmWawZvBjIR1xZGqabK+Zo3TbZ+ mQguq6YXmqnABQnSBMTVra0awyqo3u8qovVlSgt8KisjhTboX1Hv7WQvD4x75YbjmvK6 RNLjr1fkAtisUdwLKlQmmSB6cEYMZXL97fbSNGMiGhrrQFAWabyCLjsQin90iCmhj20O dQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 36hgma9fp3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:36 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1174iovc004149; Sun, 7 Feb 2021 04:46:36 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by userp3030.oracle.com with ESMTP id 36j51tcp44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Feb 2021 04:46:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dzbPyTfuzRhfE8S39pmzVsuqpNetcKzBJnzYFNvjWnzzC7bFXySeXPPQo11e2WTaMtxIKnnBgZwcVLC+7r93rSmXqQhPGZ6UUCVaF2FAf04gP44Pnmo98/5028Ig4QZinmocZCNTAnS4/9RXz5eL2bCuYTo+mk/NEjmortfLTpqE+nOXBtDHEcliLpSbafDKGqpdImxNgAyqVmDA+1r8xSdq1VdDeQAzbrqvysiUxSkfpiAWXXxN4x0wRLp/ZMCOItcHJ8OxaELlwDQHPLMU/gZ5RzrD+EqwhNYeQlZ9UHxDolJntnA8SZSQc70/eONvdeWdu7HRclN+mvok6A0Xug== 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=pMXpkNI9ZCemkBtXM+CZByGVCLY9xVWUkdF5WhWUe7o=; b=ADGHe4rBxqZm/sAmJyFONNGtOHdtEWBldyCw7b7MuBdyMffjeCeyPjI/Hn1YroyEdfWPpjlnVRt52CLdOLUInvvQPQMzMMZfo8bURnJHSJ3rVt5dbYHjlcNYdivA3uDAqzqXljNqbpSjPI2bC7DwNuUrlhvaMSAHKOYn+Rh9TPDDpMmCF9qf/ryvSvGK0Kr90/XEe0/g8xwfLYIDf0CVCMEO+Kk/4yavhQ7S28H97THoyDlxWcYIi/u/mjf4bd3jddPf1l+I8ukiUnM771WoyqQVOa754L1+0kDzW5rM1CCcTJTJ20iuZ64oV/PSEtJ9+iMaNXfOZ94AFlvEA1khRQ== 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=pMXpkNI9ZCemkBtXM+CZByGVCLY9xVWUkdF5WhWUe7o=; b=TDByf+aVZnU86q03NxxMjxtDbP4OVQhFY7uN/YpiHrDBOw+EsCJufSpjbDqJF4F+AIHQj6Re6QA0Sjdx3aPrv0EX/Zz5aZurnpOoy6Np13SWLQb9nlsDq7p5o4GS53c31wgeu9DZGQ2RboToZH8fPdAI6VarN7cOGCT/EmsVeyY= 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 (20.179.63.32) by BY5PR10MB4324.namprd10.prod.outlook.com (52.135.53.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Sun, 7 Feb 2021 04:46:33 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3825.030; Sun, 7 Feb 2021 04:46:33 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: lutianxiong@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com, haowenchao@huawei.com, Mike Christie Subject: [PATCH 9/9] iscsi class: drop session lock in iscsi_session_chkready Date: Sat, 6 Feb 2021 22:46:08 -0600 Message-Id: <20210207044608.27585-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207044608.27585-1-michael.christie@oracle.com> References: <20210207044608.27585-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) 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 CH2PR20CA0009.namprd20.prod.outlook.com (2603:10b6:610:58::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Sun, 7 Feb 2021 04:46:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75befb56-1cb6-456c-5097-08d8cb2357f3 X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iSS+n79tuRsopv7QX2qzNClVQjVq0BW/PvCtVw2vseD9lt6OMzI2xroSu8zv4fpyJjmKkQxRoI4gZgncKZ5hWaXAXdTdKGf56PKourThNq+KmIfBSSBAsdhBaMcS3x8c5ltS9oID87sFbtXEhb5HNljTdnuvpZvlH4JXN+aZ6pMEyurgNo8E8TcC+gNImUBfmodwo6YpHrU8LmtK94ToaRbZtJWAwlxRztmmjQcHflLuTvjbAEiHjEcHl1YeHmz6V9w9e18tFwwVlXDLv3cv6jFr48RD74xEVaa1xlN6GRRI5wdAzAJrULrdcSZiBGk/TgKyUGuwqMAoylGJrWMpNmVVf29OnAhGT7yik8euntbG9DM3KMTaMvUwCF5QCyTi9vjhPGrjHmXsPxCmPtL7jFjeDEUyMHH6tPKSTtUYaWaJjxB49FSTaOIHDQwg5oME28FiQEafCpiUNvJW2ot9ZYdWZtLaUTNrs6FGdKFhI54DFz0btKDya6UGfHwiLHNTQDQrIwCCMmAyRsa0+/bvxBWpvOBMrh+ulZoj/rviQ080qSfZ/633XfJB5Lawc/D/Ihpk40iMZGNPBANmuRlF2g== 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:(366004)(39860400002)(376002)(136003)(396003)(346002)(66946007)(107886003)(16526019)(4326008)(186003)(83380400001)(8676002)(26005)(8936002)(6512007)(69590400011)(2906002)(2616005)(956004)(86362001)(6666004)(478600001)(316002)(52116002)(5660300002)(66476007)(36756003)(66556008)(6486002)(6506007)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Qs1naYebJt2YOWOHwzZVW9lkbqWCrPS7GB7xfMWEcjdtWjyUbDb4VHX2re917aEqr971q4BsEsrLDgqXKKlFbzB9MpZyu23YptbuJrhugUr4WtavUbAw+ioUfmn1TqAUM9wNQIjMHtw6QgWDciSKNWiCt2+fgDK8F+vRPY5DYmlTnN3R0/EMAVE5UsEQzGWwrcZhZ8znKH6KcqmJ6cBWZhN4KiGzsDgjAQwR5YyDwOyq5VUES/SkLnac0jBIUPR9iWvK+Ry2nc0y8iVgQ4PuGswJpB3WqI9SM0CCiATcC1xE6WoxcRZzE+DIx0dq3obnVVqLvKtQH7lL3BqeEVA2MnVmKWi9fmXLsGtc2aiGGYGrn8Y5AxOOhCJvdMeyX+XtnActx3RPnxdlGEaeEKYHHyBGAX3f9RnGg/Svau+CdEhuK/Mxx0wyJh8a1m+1Q3hUcvPa6CSBy39KHWbkHnaDyGCE0nF8GGXXTTio9TusRZbqD1PUr373Dll6yggEsTfmbnKH4jK1g/ESBGBDYwIYP0r3Sfp8vgmScDVgeRxF0r6tnFyXidEIaeFZBMZeRIGR+s4Gn+Gvbugb80MXB1sqqO/n9RIe2mY3gGqhpYXDLStRS47Z9oQSNc6Yfu2gvG2BhHs82y+1f6HRUUxbUtVA51tl7rBgunQOTMpM6r+faP2QqUpZDSQUpvSdZzsK68iIVwHbuwaV7RU+MVaMyP/kFYdG/dzytApH3utsvVwvmCtziHGt4ElFV9TViO2gILy4sdwwtPIK8gXC7kRoDq/X1JlAsRUkN/XuQUBPTTdhBIwGui3QPc2WvQOWaevgDhoipWBlCJMQK7dAzkNabkEzWFZL306l9aAla19VyUrVfmZEyhejEv7BFjullBMae4Ny7WwvkWClXeWaxomTckd76fymYdyHQgQBrzMY5cjPdMXqmmttHnDVkQnv9yZu/XQkRbEftHoPEIpJ6QiYOQsamyUstaCdTDGS/k9Z4Id2E5ctanT+guZnm0A5pNCIaFaHHwtwsyrAN8A5+ev/MCfZG3XfVMrb77kGeFz+HEtbjrd1tDyu42+Jw9zmlkBUD72P0UQVnkuwuMbNOuLZF8igLtpna8+YE2n/DY3oFcUezoh6OW2onbuyA72/q1lLptWFe7GRMdI0SgVy8e8hkgPbZJjqOV+hcw2g21bg8jW/0k6nP/z4pgwSZwC5+B91b+pA6b6LB18uSEx8tXBNN/+L097LcST7atpKGPU+2WuYvuTJhz1CVKp2ZGyC2p0P+LKAOjMUWLVZwgiug2eXe5FUA8WCTZ4dt36/djK0+iuds6fZVX1R2RI0JvGVdfZWwmo0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75befb56-1cb6-456c-5097-08d8cb2357f3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2021 04:46:33.5001 (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: oSe9eO9CJgsPGhjIrp/Qg+UmoIpNlsB39PNCgLEQmZKFhwkijCkvAQzoFA81RJQsUuytnURsmoQ9qjaSpvNuMGHDHyUzNpemcAk9d+PL+R4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9887 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102070033 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The session lock in iscsi_session_chkready is not needed because when we transition from logged into to another state we will block and/or remove the devices under the session, so no new IO will be sent to the drivers after the block/remove. IO that races with the block/removal is cleaned up by the drivers when it handles all outstanding IO, so this just added an extra lock in the main IO path. This patch removes the lock like other transport classes. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/scsi_transport_iscsi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2e68c0a87698..969d24d580e2 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -1701,10 +1701,8 @@ static const char *iscsi_session_state_name(int state) int iscsi_session_chkready(struct iscsi_cls_session *session) { - unsigned long flags; int err; - spin_lock_irqsave(&session->lock, flags); switch (session->state) { case ISCSI_SESSION_LOGGED_IN: err = 0; @@ -1719,7 +1717,6 @@ int iscsi_session_chkready(struct iscsi_cls_session *session) err = DID_NO_CONNECT << 16; break; } - spin_unlock_irqrestore(&session->lock, flags); return err; } EXPORT_SYMBOL_GPL(iscsi_session_chkready);