From patchwork Wed Feb 3 01:33:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 376669 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, URIBL_BLOCKED, 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 624F3C43381 for ; Wed, 3 Feb 2021 01:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3664A64DF8 for ; Wed, 3 Feb 2021 01:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbhBCBfR (ORCPT ); Tue, 2 Feb 2021 20:35:17 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:50444 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbhBCBfJ (ORCPT ); Tue, 2 Feb 2021 20:35:09 -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 1131XXTV192551; Wed, 3 Feb 2021 01:34:09 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=a2EqsGmWFdYYi3+1J8isb9Q7h4RxWjboCb1uh32HVFOhq1ytS7r101kfdju6D8TGiWCJ OC3LhNDmnCftIomFTJXMyG59ZfXKleEiWOZqMspcJQOOR+ynQh8HUwAtY8u8EKlP7D5u JhvKp7PXcBs0RNYanj+Ul2MtWYuZbBq2QpG3f1os8rLeXj6+A9pbE0oioUMgoBMmPi8l povqxR1eqvXrlK6goLYewrua4O6IeS3tvMnHliM+ahejQHEFEPH8XIuLPgau8W7OQqHU b7d3vyrpb2nGc2rMZ+4sOxMhlcLny0iC/hddqYHXjWioeEZGcb2ugctSJQHdnitTmTDi qQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36cvyawtyf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:09 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131OxjH139717; Wed, 3 Feb 2021 01:34:08 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2058.outbound.protection.outlook.com [104.47.44.58]) by aserp3020.oracle.com with ESMTP id 36dhc05qfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ns5Lm9h5G2kmBHrHkSyjtCs9Pj1lXchCEqUv4j0WCgZZa61dmhC+L2E2mO2Wmc8mG41ImIvgYK0EyCNFb0qbY9VWqK63/kVGkKwIpHUxkznODjHpdsUTPqgz5rWL+Ym2fqfvQ7+4MyUELKIvbOjoB8X3pn+qfDg43oZoesOKVcTe/8fOjMtGQWT7kJCOQSeP3V+wc2dmdAfdpvH8cImXXfnJC2Y7Est4YXLXAqs/qxtDtCIIrzyIsa+rjTURuWl3R9h4vIe0LCD6br32c73HYsoudQqPTe6x6PEMPLyTEqZw/Pmb0YiwgxFf7+QhlLp5k+Go8p1iiMBQdDIu654Sug== 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=Udg+ixl8+5YFBZLa9lnbeo633Ln+SbWehrUYV+DUSYlvj1nui9WSWzmByaUomb3Xqd7l1bNuQSYotiWx3f1E8xPZZDWVEInMoYD0sz0KwAqbwd7jDNW8GduxYK7YH64+Rry+foDAvO+DYZU7voYQ2vt53ggKyy1Ba8oxXeU1UxMsT82JLKtYDA/jKlP/P205Jy1kPo3HEf1R8aYFMZ+/rF6E15DEU0GeD97jmHzfQ0G903CN+Hhpot/4ROzvyApR4LeBP/3zXSSm9Z15kcHDx8aqKYmRuGypxnjUo4/MtpBJoZ2dwXUSItnOtRUUY4XGDruQX6GlkfzoI7N0ZP1gUw== 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=xc6xT047KTzpduq3ePuF1NruAU8zzY/zT5iQd2vukYjYvZOUyVITEQaTWT2s2gsiZ3YNKuWBGqPG79KbFqXIrC0NF6DQnmr0ViYu7k0YeUoPFGDGbGL0WGi8ywTRo7RccuRwYwggaiKacOtQ8Na9Bz0qMcIv+2PpsFD55Uv07LE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:06 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:06 +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: Tue, 2 Feb 2021 19:33:48 -0600 Message-Id: <20210203013356.11177-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d3e18d69-1bf8-483f-57f4-08d8c7e3cbaa X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: Mo0ClNKaWxvZsEueAPENIsiDzLX+AMc2BI9rvOAYScvPlEzUEYoyhvghuKIIGBF8WIUCHk+NQbmKgAdZq9soV3TJbmyRGvcjLLSv3uID1kmm0mLn+SjdhZrVUtjUS2jnb/jQw3JsfylxxHlPhYwAYFa/PymyjPiYFm2bqEGtFf1JVBkdb6zdomGpQqHxka/Fx76oA+a5ji0w3ofVLhTA5AgpWXBPBRH0+jDQBgi7S5UGIaKQLsolPXbMw2GSx+BWaS5FouwESgM+7DQkQChCyrDQoUFGxt6s7tZ5bkj3w9+mDpcwPlIgsiN6OENq+EyLOQbXfUQKG631nRYeq+cmORalQx/PDNurHePugo7SHbcSiMLZ2udlGFyeCjlK0E13fxJ8MeJqmoefSSodw+jhyISVwlWHtV2IlTBco31VgtiisLfMCCdrU+NyFhWNLGPNOnGszyRF2gmYsPC8+AG/Yu0VoGv6ySZpURQ9XLH835JdXXEGufN7t27Z8b6qCQupIAjXF0pE/wi12yrDL7q3URzIdlQ6IPfkrp9tS87OTHRt21JT94OTuvsGK8xApbat+5418PPhXg/xQRqRyLOGZw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 36pylN/ZKqeD3J0at4f8G4x0dK4biDMZtwNRghXBTuwlo946qX3r+SR9XsRfrmP4N10b+OY3jUidtvW9zcwxG6kq32ukBATMAg0rbsiAlqtyL6uDfwYDEI73FBhQygMHbyyCG1kmCnJafzFLdvQmTGNXegz5pvKJrGQdPl/kIgW27WGEneLTiT1nuQ2br5WTykH0bPwb6Mj1vPvGuC9/tBIpxgzy5/EgikeiU27R0jAfaDrsIdF2C8Q4vQlLJjLnUMx189oydBUXg8reYiy8W5vObhDXYQVlOLsEzbEcOk9GZq4ZOzJuDdTIhp1WH2KfDJZGKsNtdKoE1EsDidhx1H0c1/B7ZfUQoHTeaX+p4vJGGxZS4CcuH+xE9qjj8Hh9ShzcudMJKeVSRHzOm+5qqgPNNJMC6fXyzZCd+C5swPgh29qd7dOEigN5Vk2GjQFm32qOofmgxkf1BHCuMCJZqZDzjm+sZZq7yKh0QsiU1ahulgg3klNAW66Pr0ouU4L8Udji6F3RaaAygO0uTTk5l+dWkoKd35kMgaDrCquTjPR7+V51L7sOCQaYcCTcai/nyI9jRyIdOcBwuM681rrzzPbwy9oxYBUhIlIh/3p3W5wx+nMrMZ/8EbMII0xd90Dab8hlNQ6msS7O7w5zVRK+sBtqsaZqEqJ5AbcMDJmWqlzzayhRn/3sovb84BMTD657aPKa/dIWB9ZF9QxQGzishE9TIzUPOuBbUNz0b0SqznYc6If4hEMGn7d6EabuWWjMjw82Qa2MhLEih7B9PXcS6zCvt+7ig+McnMCuWoXIwJh2fzHgFLUtQlX6WbepJhJXhV/ybieyN12zymkm+lDbOFn7tcFoQiIw5OrM1Cp3UGMDKdWl1TUD5qXjaB5cHe2Q+c1tL80uPJFqkiNA5lRmrLj/L0oFt5zZxw+7l+1zys7hjRjy4yD7ERI3qwI1UJMBDCeNRbL/sdEoV1bbhC+cQW1fXbIuGp8OWQXRB0Gx+ITnzhzi2b1IDR7DIhA+tUh/jpi3EmvvIXLvPnLEUPmC0MaOw2OV4abJHW7p2RhFruaPut2J8aSxnNcL3mAO2q3g X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3e18d69-1bf8-483f-57f4-08d8c7e3cbaa X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:06.4595 (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: nQX569ghkFhStEGAQZgl39NTie7E5gs07H96fqPzNtVL8OsJedCvz6S6Ki+W6abgeR5fEwBpLveNyjjLK7oKKg1iyUqV4UgA3CMlAWJTy5I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 Wed Feb 3 01:33:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 375739 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, URIBL_BLOCKED, 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 7A0E4C433DB for ; Wed, 3 Feb 2021 03:36:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F4EA64F4A for ; Wed, 3 Feb 2021 03:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232375AbhBCDgr (ORCPT ); Tue, 2 Feb 2021 22:36:47 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:50680 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232255AbhBCDgj (ORCPT ); Tue, 2 Feb 2021 22:36:39 -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 1131XmLH176178; Wed, 3 Feb 2021 01:34:11 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=TKjQ+aARi6rBzeY9nnphB4Enz09RyKVx156qK85cSSw=; b=cRCQ3p6PPUpCUBH9PUAoWD4LW6Za6/bW/MOTDQAL0DsIHLGD46gFIjNMrE03jgOu0w/q WobAa6EbyKJomSkFutEM0/E+XRYQYbZ1osp7uVLWYan/GBSq8LzzT+5EFZZLVWEnmCHj 9+zJV/NMC9qM3LR1zoG1gLikep7qvuPf/Grz+XAHpvsXBizxttz5VvIuE4j/H521HgfK bMx/4qujs1/NxBmQdOd9tUKD0ptzNend5PRMXNWOzVrI8ZcT3l/rmXsxBtzsJbTztYPx DCDOKRLmLhjT2g+KCFY9qPKk90e2LnmcU5Ue9uR7IkK1YDcFgQoemPKGckCIyrj+TIx6 /g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36dn4wkgg4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:10 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131OxjJ139717; Wed, 3 Feb 2021 01:34:09 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2058.outbound.protection.outlook.com [104.47.44.58]) by aserp3020.oracle.com with ESMTP id 36dhc05qfv-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=duQ5m496wBz4wldsoQmlNVfgN7SqNxgXAm1sRYPPRjEV44qOF4Ltg558tu1tVctph8YnInO2jZReaLAQtqRAx800jdYdB1alkrR92Ee6RlXRKhuIGcoPoIefbrqIP8bU36A1kxbn66IL7kp1ISISDJJOV+GUWdebbOwgSMUnwxdm+fE0hreiHwwGyW6ya7DnGRr2GuiqQpxsGnen/a9tX3kjEspyy5iu2e38+7+OcW9dNBmGvS6Pg6JzYusK9KAsxxkIUEj69FATFC5OoWkz76F5JaUKflMbW8MmkNbdA4TWM6AQpTbPHU6jNE88PDnzlQdOmX6MMyg4XxoTnfnpog== 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=TKjQ+aARi6rBzeY9nnphB4Enz09RyKVx156qK85cSSw=; b=kPFYf8gh3hU+wscO9tUqp3LXmBcOhZceSxdnjfA/1ETVXYxv+6z+jsFTFK4AZV94rB2WPf8lj1rB6r1Az9Tp65DPMixgo4j6DxV26Lxke97MtQPcSEerpSU9fV2lmMplkaI0hmmkpki/F2QtttR8Z2avO5kxVP6BGdMPAbukCy827UpvDrZDDIUpvSuDaWeVNMVpyslvO5Hr7Y3sJ6vhQLkasybTF9meyAEPWEI5TDdLE2lG5T1FFbJFWfjUFdiHv2jE4q4pIlzIdb2PlfwitnFbXOTGHJ8BU9kTm30JStmc/W5cCL5K2qgRUYek8V7o1F5TAfJiVhiSS8mJIpQb+Q== 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=TKjQ+aARi6rBzeY9nnphB4Enz09RyKVx156qK85cSSw=; b=L+WdROeZuSnZlIRuZ1fH/Tog8HBBc7jM9gL2QhthMVBqcDKDkGkkwMAaTsxewre/89cwUM42tZEc3QZCOyuwSKdWEJfMoksXysxqY1IiRY7b0wg8wvg/Ax6LaecC3nAJKJbSCX6orKLvHYH1Tg1u+hCql0te5CpO7ern3Owb2U8= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:07 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:07 +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: Tue, 2 Feb 2021 19:33:49 -0600 Message-Id: <20210203013356.11177-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cdfa114-0230-4601-cb90-08d8c7e3cc53 X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: emZW+6lY7zhJyBjnCUu9n/4A9ZqDjBy2lSoN+RJL0JcgbFNCkL8pPPZNgD38lkdGxInEWDS2IyMIeS9hg1Tqm5PlCsK6qS2EpKGWfh+DRWMex1QgisF5Ig29tSmnOhjd+bBpHdU9aXfqS1VT7d+OfwMYvSBVvSxBR0EKN/Drwenab5sM1g/nnjjCO68DKe2oyzSclFyOcS63iMqRBcfZNO6lptRvmlvDjLPzgrwFTNnxBf9ztS2MvNlvOMYL/puQWfI+JKA5jaNOXSnSVemC9zYmoa68jBBXS9avacThjSZbnMBI5RlSAmiixPm7LFogi9FBaYc9CHKoxnmB+4+F2FBXWcyEoHEHiUZ7htSIY6i6lg4JguloFti4jN+Fo4wgG8hoo9wfsnTO9dV5yxx+zR4ViiLqY+c/xpG86is934cQhpudsBi9xWNG2ShVWuMk+1njE+K9PuwVDnNcu2iP5JEfQValglicI/CaKDmJNoFa8rXI2oJOzLxBpt3LT1Jy58b+rKpbf0NKSac5AyKLkDr/3s4+Vtm4/ED97SjpWW53igDpwOICQrTBBQPEzCOKD1tc1yUS5292E0SCu/CQpg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(30864003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ttA7rwTz5boKKYNhI10oJGdauJmEPa0y2DLjcLCkfZQb8jCIXL7zICR+ctPoq19vv+LligubZH6a7DETeVKEfgiFCkRCjIC+p4Q8CISzswBxZeSlLlz7K+wrnD+wGv0DJorxgc3mxaLlmTbjJR6lNyTwirLeW9lMe/042Hrm7nybmm6HjLp0UXoMIdy/AdPeVhgGDQ7f4n32/DoNXzDP1IdT7s7sq7QUutbwe+SNWeDebG176YKSjaL3Z7LmUGIXm0T2lrhTGndm9icCzdSkQQN6YhycWchR+iizcNjvePVnvNGb2/BBcAe+tYPUXjfuQUlOAQ17JJfEN8zA3o4a9as1+EFbiYrbpd0k9Khk8s7W8odVviBmw3WXNmvyGDcBpivCiuzigVJjfzGJ0JrVokAxveptgiqj/zk4j0Px7XwfezGg8aPMKPCtWkH82kgv0japNOMOev3uyB+wkg110LPJ46HYb9gmX5wJ+qzioWj3aYDnJb5GcJyAEFMkiA9xTbtvTUmTwBcPm2Y8z+/DprvmS1k1KwHbr8svR94UXR5EGCSCEUD3xM+UcQ2Ber+cEUuXdm2cRhG97y6FQPtuzW1ES3UlPcp5y12UKRdzdLgkBuqvYRJUaQMCudh+qnApIID8aaLbO/QDNocVs9XG28A4PEhgeJIxLKsj+tyLure8VXuKA/zzxsI2KFGYJlxV36y4pyudTu4peAsZ3+8PI3u65f4ECPgbet/5f+hz42cqU7uf9W/lC43X0J1BRWUI8B3d+PEDcf9bK6NCYnPU6giuhQlzv4ytQh0UQXFCaHQPkyOQAh+0/7UZgLwaHTNm7tURZbWyGXJMU72h1tLo47ekJDYCtzOzq33wnxaasmikKKt/qtLjwHsmQsi8/NwkqjP5X6Ew6Jz3s7FtfpVbSi8Xsp9tFgmsnzWqyJDelZV42jritVc2MXrvSXBDcdWTDBZB6dDLG84epXW9DSrb6ZErvGHkUCzToIN1eYmiLC9bWPIOyQOj7qNWQDBJONrkBsA1SsGSPJkXobWRmm/f/RB3vZxaEBJ/Taji6UfQ4qH37O0NRLewoZe+xfeSFXjP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cdfa114-0230-4601-cb90-08d8c7e3cc53 X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:07.4001 (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: gDUYn/BoyjGolJgPzhNfRirUwbbwsCiBrGIAK6R0eJWKvVI+GGZQrCI6ZbtObFohWhUq53q73ylgNI/KOsBTizqIA02/7JdcgWPE+cwmO3Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 | 84 +++++++++++------ include/scsi/libiscsi.h | 4 +- 3 files changed, 171 insertions(+), 95 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..14c9169f13ec 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) { 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 Wed Feb 3 01:33:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 376666 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, URIBL_BLOCKED, 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 11237C433DB for ; Wed, 3 Feb 2021 03:33:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0E0D64F5E for ; Wed, 3 Feb 2021 03:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232400AbhBCDdh (ORCPT ); Tue, 2 Feb 2021 22:33:37 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:46364 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232457AbhBCDdf (ORCPT ); Tue, 2 Feb 2021 22:33:35 -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 1131XeOJ175736; Wed, 3 Feb 2021 01:36:11 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=r0qKm9loON6+ks0TmUDoAAUIPzQSQxLCgMnxjUnJGHG78Pg4Mw9yS9I4huFzb2M9vlma K9mGceysq6+RvGrzKLhDdC8RXjaVhiWHF4gzDp3Dkf/N7xVmGzamQVtCLoGRQ3GLhxoT bAKQLQDBerS6DIANXbZSdiOBnPD8pvBnGOlmgJXYRKhV0XimQn1oYNH04qJ7knb0YTw8 n0B5GVGSh27aUmfmHI2VvS4MziOexNKzx7esoXy+fXmJac8satsECOc9Kl09UNyiBGNe zcZ8dmsuJOstS9ib+XDXZhrdqbN+6d2CUpGi/EJczUOc1jon2JyaGes5J7Mg5+A3jing dQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36dn4wkgme-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:36:11 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131OxjK139717; Wed, 3 Feb 2021 01:34:10 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2058.outbound.protection.outlook.com [104.47.44.58]) by aserp3020.oracle.com with ESMTP id 36dhc05qfv-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fd7YRWvMTssYK0egYtiZABLAp0jD1G0C9eciZ9lBSOZ4K40yNxJAeWCDlIjblm8UfL0Dsy7Vg5glciSklKVWL5zO2uM1B5QjvbaQjGn0T3pxpV9LKRlgZ/NbI1EjkWJnB0Lm/5VexK0TLWxmP0rJXDl7hW8XRblJKH9wfBIWVU4s4fZupxNuxwZ+nJWBNVYiG1Og/dUu3SIMu7y2FkyvfUFk6AKBGHho5MMEtQyqAKlARODu/yBsecbinFngBYUqdbF3BsB83n6DNP9z3cSqfEDzkwz8CcV14fA14beYZdTTmVbfifFiFxgdrm3rGSLuRZJ/WN5AGnUZynyw76LrRQ== 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=D1Bc89602ZkImXKVekBBYd/pHN+Zwabm9sM81HT18HpHAYmVVZO+iMijKhFlrfGkhJGN5OX0y+PfkGqkS4RpRlwRF4B3faW6bKaX1sEVQBs0LR2GPYctScwYdR9q4XWEsQ/32R5lpV4bYMcrXeqdk5usjbgXkyv1VGWtF6OihEDnBudIUJr+H5dohHKVgi/eFRg04N40vupVLbN8Avg5Rg94oPDv62bS7sRw5G9z5dnQ01gh6f0ixATP5Fu0+9oYejk4fVMZ9E4FEds/pwp0nCndKiptItBgr14osUcawynMZS97V5D8qt3Cn2ByuVR4rpBixGXzIUo7Z3MTUK0NeA== 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=tS+cIBAe+fvYGydfQ9Ep4GXRHLBwyadB/6YVj2TPut21QOqfvizI3QipcOGxz960XIxrdQEzuQjviAepcn7hTa/ogCc9onbALRLrr2F2Mja1FjjJPag0zLy8TEkaRBMO6up1mlZ/NmLcsg1yS3TrjYxCHPz7HpqRA4QD4gHivyY= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:08 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:08 +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: Tue, 2 Feb 2021 19:33:50 -0600 Message-Id: <20210203013356.11177-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ab703d7-0036-4b47-077b-08d8c7e3ccea X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: R0xHTfZ7bdAgVEQi8rOgLmKx0K/tTqsDUz0NpVN7SqddZDvnxaXlJe59+RMOXQsQk4pLpXt+34/crNEDa8LZF56wbtT83rcVQepvBVLem+g8K2zAtohV1pfiRAWyhdoGMetPNIhq4q7OqQOHKWPjcEKVEAAwbsM7sNZL0fDC+wmo+S4QPOh+uLdJC1XbScniXNYQzuitXlvYrnKyfdCeqCg6mzTMYiOQ+FsJjSUdRC9CHYkeF8pJGbVpr27yz5mMXB+HQFmamgSRXF65Z259AC+6NYmo2cLQnnqXJjD7KYQO795IPgUan+7aZhD2mZWhpD5wBsvGDHjTXDEB9SLfei8xzEzAxfF2S/gbAO5+FM6m5M1+GI1wPGogStFCzfAW3g9cuo4D/23X1n5FzVOoWW1epD8wVhakHBr9Vv+Y5dWA8WpPspDcI3ihDIwCMP4LcKwkMZ05S/nnEN3xHt+bgIeVMTqY25S5QsYOtuAF6VNOIq9mVcgiocaYcurWbtjOxUgtLAu3PGiaydakt3bdKpWUv5sTQ4GR6kru5PS1TEeT694AQqHtTvFZQbRtW/Ot0XLg+fosUMthVn911EhMrQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(54906003)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(30864003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 71RogRCmT/x1dIteiaGWjzA0CpvXEFqqgQnd/wTsg0GNgciha8HojKqnhARaCcioPgQdSqXNYujWMjcWksQUbxt4hkQauYZP36wxMoUDxD4aEHkeDdlHKfuAlU1d2n+fBTUs1J1kLLrpowqcrRnZzaflSMAKmKXLwt4GNmP2dRIHql4w1/LPLrT/EkhnAWqgEAJbgzwDxH1JAJ11dxSdbNWAqaRRkuj/7V7nw6y8hWRdNRbWDfJvQQO9x+WO8l7YpcRxZq8e04gbySUpCiVM2BqoOITzTiv7u1UrQ+CAevX5K10dCD8Q+bqfYMQENTuTsu2tHf2GqDaWdF2H9UQEAy5IvTyZjOuB5Bcb5cU/moiNFU/FXnvsScjGAYkKNpKvQMR28QnCBbHrgOlNY0b80HaVpW82k3K1g/kn1WeYP/K981MlKf4YfLieX+oE/EFkVNW61rNNSwDdkNthybQAPQHtYat7z294UQ/BdYwa0fkwgmlidEbPtQdHua08dkG/vzruFw24Ov6Dqbhtv2pngfOWj0mnVBg/1j5s1eOrKFCBCij/tROKDMcGUqnaHuIT1FX+wAytWmeSAwfY/rIjD7vXsxyFk4/tyyGt67y7Zyanqy4kW9Xy8FYTbLk3n8navJOokVVBHBdiJ8YTS1MdsxaLduENDYmOgI7Qz6VT601l/5wpgSl2S1feSlN4yTJFnv7rw2snbT2abVUrOXxZj861hRjJFI0u3Ds7GFwdXBjefCX6/YtXbGKNvSA7+puRoKch/IJD5Q7YN6oeDNLPneidrNfM3IMfxF534ZuJ2DkhYhcVgJJQe65BvTwGzqP2dB47JW9gsmATnISjV17/Ks+l0usvUoNfdLuhNwsYhkMncCpCv2zWaCilLcfdVQy9ESj397pF0cg0CV604r/kXZzxomOkSLfpq+b9GyR0W1QJDj8ZwsU6FW3LIup2dF7ONs1ICf/qQroY7IwwX70bMIGAepHrnb7Pu2vRFcvIhyehTBcBqaAvnCHg6vkE2BM4U6hOnmbk9k+ZXQDloPsNqLKnABfoCHff6j7LxYAD4a5MBkYZpxVROZ0q8ZfNACCs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ab703d7-0036-4b47-077b-08d8c7e3ccea X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:08.3827 (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: yd0jz9Gs5LTOn8B9q0ipZ34ctx0/HTS3cPiq2WSp52G4BxZFjPryGPVp4LLStHIZzjNQ7EvHd903QsuZZoTMlGW8xhNT1oxecGKhXIVhOx4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1011 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 Wed Feb 3 01:33:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 375740 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, URIBL_BLOCKED, 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 347DFC4332B for ; Wed, 3 Feb 2021 03:29:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EABFB64F84 for ; Wed, 3 Feb 2021 03:29:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbhBCD3K (ORCPT ); Tue, 2 Feb 2021 22:29:10 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:40612 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232503AbhBCD3H (ORCPT ); Tue, 2 Feb 2021 22:29:07 -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 1131XeOG175736; Wed, 3 Feb 2021 01:34:11 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=x501WBk9W5xKgWFFzzZk+DnrHXM4t5aCHN2G0bM9UZsqLlVvnRA97WTRMdpfPURt5wTD eiPWrGvU0HfscQ4eL3QjKpNUDPRjh6Ht/bp25MWcQMQKinBmZjsAhEPW40W0lmasM00B 1STpF4GGKa35ASXttyLuA7asw54RMHRtVHYBJsAoHpAGvQFu6hpFUZfxJHBR/9Vyz8Gl ffwJOSwWHKMzL8DiEVlFxSs3v+gwZP5u8ONLM+62I2aWCBLcPaboqhF0jURFD3hvy+s6 nYSiYAFxyESquy8nJz6AZk80AsU45I7jvYPZKU7khAZJNJMP+8s+91poDfTXdeQdDso0 eA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36dn4wkgg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:11 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131OxjL139717; Wed, 3 Feb 2021 01:34:10 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2058.outbound.protection.outlook.com [104.47.44.58]) by aserp3020.oracle.com with ESMTP id 36dhc05qfv-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ms361j9QYeURrkcPB6jiZEbJj06AgDGcv8gPpgeNewjSkVuJUhMEkxRILL8spXndru6AWU+voAGFSIGb8V020mo4BW5k2mR+kGDRniP8UYGZwf9eScLl1sjC7O45ZOpBa27mjvdA9KZBiGl828cWZmPq/MKBPBL9JjSR6DKGqC1sUOsjbPGOYDiXMa7SO6OjpwOpVuSFvWTWNswagqg9/W26ceM98IATt2x5Ir+iZChE/puru6bj6dkVHFiRCDUi3CwFu6ZsuSxHm4aZsZLSogx5vADmKkWcH8BLSvq6lE6bypbbqTwFxiEtEmXNXz27cjAD6quEdnnwE6jkpfaXrw== 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=c3v70tw3F5Wz4gf49P5V9/eKXpBFzQiNlGZigNlPEs2+EQp+sBxUXNRdOfo6EE+Q7/Kej9bD+LJFjs0kUhxn1kaNIOCxpwJEiZVq+L6QWPZS1v8T2x+h9F68eKkjIyRWgO4OANUiM00VlCVO9QKd/bKQWPA0IeHY+nCvZEQvKPh5Ap3UjcYJqwlPmM3M0lbCStOQV16g0K4ZuZ6nwaPxIL+CGLJKLk9lj4xNZt7QckjpQ9vk79bEzn6+Hqof6jJCGLT764zKpDSzNksOZlw2+cONmbMmruyoLWDLBNqilGo6oaxmIhjSnNsD5S9Ew8DZv09ofg4wSKRXHwk6XLsB2w== 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=lUikVHehDRzxIp3ptVNN2tpV6+KuxbwAm1QaN34jouziME3u93p7I3trnoONQIP24i65taj1vBFEUkmP+/GgOnuAfD290DcsM00QrMoJme8IQFyumiLm9tI6TudqS56A5IwmYlqYx9cZwI3akq+exgDI45KjtKuX3dQmA+CBxB0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:09 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:09 +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: Tue, 2 Feb 2021 19:33:51 -0600 Message-Id: <20210203013356.11177-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb30fda4-5077-41a7-f58d-08d8c7e3cd76 X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: lBDQqNibluZty6iAZ98Fp57G1KxKPJUFh8sqdngwZadkX0oJSYIkYe2hwtLDplvD9dgAsTI3bgzLlKkWkTtuHXtLwpcyJ+0Rttg6eBK6oPBJ5tQxKgYm40EBh8F/DHc7k1baV/AVPST8/K7MaL1vXMdd58NRpK0Zsp7kAgWvpjzEQCrVDGB37p0aT4LIr9Mib0ELFw3WlMwvOBxFEcT7NazAB3Pf7t8UbvjNLLpnfzXGsG+6FM35g6rSZhbg5xD5q5aaKVe4U2lfJGZCR84CuegU2vd63PMMq7vzzpOwZV0e98gQ8yviaeLqnPKvDqsnJEHnd6J7hbyk6qHEkFNAsC2ydkqn97C8wY/Y7/56DSEY5JqdfnAqv0glibYS61Wavsrj3V9NrNKkfMwZAGJNG05CeK+ditnuNLAPAVud0xAiKtPNDImEqm/oQHsxL6zuZV4CQouu0t/0tlAOKYuN5Aj//LlkSz1PeBs8ajgG5esJnoXF6HrssKIxEGUPt7NxEri7gVkEuSTlA1Id0MHLlAyYHcOSD5il2jYSFKVm9KP8l/LNdEjPIiX6vF6wqJce5eTNFDmrQQDoL76t6wCyIQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: JHEADjSIcMHoHJD0jByvRvd6xheZHOjmRo9oIqCJmsfk7uZpMKoUp7LSrDMgZiVCKmDzxZECY08urR7c62jfRaJIJeAwyBPjho3zjL7z1paatWIDPG9gJdK2XYxKQZklzibOXwhEAmo41zfPNuqBv5HLmnPWDGdIcV3+uOoVoBnSKSLSvJTyMLLBu1tGiCobo6uBS99yRDUl+qEdhPgeeWeXUTDjJ4lmdPmMJCtOOSW2LEeRu6khn9m/BVZbdFHZqKizy/QYYeO5lnzX8ILzcGiVvfb8NnT6WmGB+02Mr6+d0cHFQWmKBB0uiNhVGFjhKqyuXLGtrbvsW1FdWEgy2b9KzwEQSo9wMzy/QhY8FPUmvQto6gjiM/ypBvltFeCGwaNpDpszHCDAWmmxkHmEUte6VOH0df2TdgYsZC8oCLXVFqG4VIfsCzm4zIQxcNEhZlM2bX/P4noRy7PT0jS+m1VrVRzatjCyqyGmeZPqYXBE8HOOOzxlNYLGtMm1VbXloJUDZZd/o7HsrSFYjRzKMUJMxgDxx7/xUBugpX3o4atXBJhSRZdmp50R3IgGEh1ArU17hY4ZRwhBKLDHBWibL8jQ9t9AeDopeOUSI2SwqT7cuIF4nPxdP0qfRsK8XdRcDnfDkkK9eRWt2AE6ERmYlR1N3dxoS6f7QE7th0oQa88cxzknxfiCU4ak4EZ4IqutntRnVOZbvctu3gfr2i7s53EIE3LrwIPRKRALZEna38yZrJ3ZU4p+1Au2TuE+vjLj9F4tyfnfCBLRa83hZwN7ifqiyz8PQQOsaFVd5VnAlb2b+y/ue5seBkgkTmC+gGbPeH4ktNvTEv1X0x5+tgRGHPbCp245IqGnEUKIldJD9QTozbelfKjr9FDsj4yIdMJmk1RKaDQC25jurRrEAyHAEZcEcInD6JdFQ36CJx0I1bupPrfj5koyIBA60UvMq/DpX/tcYE6ICox5RAAoH1c3WavLhrYLaO5JpeAtE2MSQ4Sp/fwrL+StZYsItCQxwm0BODVsENGxNblJHoFzn4gNKkWKRN+iSLJyTP29S4oGzpyFicDJqaZgB8i7c05al/KN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb30fda4-5077-41a7-f58d-08d8c7e3cd76 X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:09.3423 (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: KNpx+joEPmNaBiqV6OK1T+VPoW2kocOPaTg9dEFcx4mSa8gWHhpnYUkME19O+RCgQkGhzaP8tEH6QfpldpUZGbpmnmvDHX6OSwrBpjW2/cw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 Wed Feb 3 01:33:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 375744 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, URIBL_BLOCKED, 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 047A7C433E6 for ; Wed, 3 Feb 2021 01:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B004E64DF8 for ; Wed, 3 Feb 2021 01:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231301AbhBCBfK (ORCPT ); Tue, 2 Feb 2021 20:35:10 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:50404 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbhBCBfH (ORCPT ); Tue, 2 Feb 2021 20:35:07 -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 1131XXYF192548; Wed, 3 Feb 2021 01:34:13 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=ntd5RyymaltuRKm7WXZmH1W8CEnVQy5NjZ3SRSkRH3VR4zXL/ktvupzST1VCHN09tVR0 Dl0Qf9awx1hVGkag4SDMEJ70zZTEaN96wfAOEGbVxqv6sAw0oS25g7xQ4vO/NtFKu015 QURy380R5HzsI+Mem2PC/uKIX2gH/blXljEwTaB/2pZMEpXuLPtRnw9zLrNjXclzTs3x 8iUnPf/uUxr3EAZxKtzRvOmoXUYhFjw09m+r22Ho2XKVKItKLzbMik8Ops1gvhjvtVzk 76hhijoiEb2KpQs4mwc9aDcdtNEJVl4m1N3KUrEW3AHG2KsGY6DtrCIiAO6fSXvPU39X IQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 36cvyawtym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:13 +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 1131QD2M045065; Wed, 3 Feb 2021 01:34:12 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2056.outbound.protection.outlook.com [104.47.44.56]) by userp3020.oracle.com with ESMTP id 36dh7sfwqv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UnIDVltC85clcyTxAhcygSR6+LIvDymHhqvtBE0urDVeWoSPARN5AibjO9biymTRsepmqtwuMHrQWq2RxU/+ulzszo51AJ5IMrtIbjOA5LAYnuovh4rYAMNxSOy2CRvgxoWdIQCBl0BFxrw0yjx6Il/JUmdCbkyUkKETlufu/RiEP0UtGRkpIA39Xf5ii3AG6FVutfVzh+TBRjCVj/X26ReGBWuyS33Dyx/qgFdn6QTGsspdAorXWseXjjXjbRH9rbuDZhy1Km5mO88W+/aStJ71F8jJi0luBHbcUcagFVreGOMRIvYiAoH1OzGNTO8lKXJ3gR8oIas/oDqWjksJ0g== 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=Q/bXEl979B/8mY4+sStT5pqHR5YGRaO1FltKFzLsrt9lROiLs/EyY9aVnMIbQLilhQtPEya+lFaIZrBv2i0YWlWQ9XQ4dtcgMaS1s3bn0f9xqKQFvOI4puH7okvnllsyBNBj86S2D3B8DgVYJXaJR05ZJJG5vH8Kxh8ulCHo/JvNcD2VOBj8eF3Slv5USz6gAWT54R1cJ2vC+NdPlyvzP/1HMAWp1GcVNPh20TkTqghXbiFFqY/dCNL/KHEBly0kRNy/aTft1zlhoJsh3tPXBwMn4QkoSgGqQMcGjWHaJcQfn9j/WgMvzSsXJ/Yz8LygXX/Ld52Jo/aIEp4eyTcRhg== 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=LESmGIcY63tTszEa9eZElnhFYlc/OF9F6UOrdN5OWGfFg0mGVAaaf/k04rs3/v4pwYemK59q1mEqHt65Abrcp2sG+n0AhcZTA+l+h1By375j3S6DEo00UExUydh84xF+affSC2qjLNTNCiLL2i2UWXc9OSRxJmicnFgmcw1nLWU= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:10 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:10 +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: Tue, 2 Feb 2021 19:33:52 -0600 Message-Id: <20210203013356.11177-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 116f556a-381c-4d7b-90de-08d8c7e3ce0e X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: iSe8MyGjgVBDKDaReW6Kxq1Fv2w/ueeLGGTkenErRPBkFrBponBM01MsFENyqga2HcnN7sAybURtmBroUQb2GUap3Ikpofuo1a183L508jDyiKlu/kX5eSdfZ5I5VPq51xfbLjZ71Vne1xIpyd004R/ja01HKui5V7uxW5ICM5fhYrI3WbowmYeikEFn8J50NV9+HkqDOQsI8oHUQC1sTHccr9CMgnaSpcaxFlMffphhAdbCvQjYXns6RfZUZC8cJbtqo8pTsh58ERrM342NgVoha7xq6kjYiMWrCH/LslFUt029qWHP3ndLcowwqgWqyx8A+zZ2WdK9iBR4GMkPQvqXgwIhrLfEZ108WtxOS03vLWf7lDinO7/ZYmLsqOOKQYJO122n833JDih2jI49u+9yLvntMDvMNBNv1+xFOAVsmUiM9ve8BZDrJl7odksi4zLWLTGfadpHBYBi656bNZGRgBCA/IasLbbSgNPl2AuakWPqc96iliHeNb7Yx+dWKGs9xFLctxXE7PhsRA+QcYBK/e9ALLeIxHC5X3AJ28tbOsmFl5gS2338ai+/BzwomJibbouoH+445pPmOCOIOw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: SIA+6Lr3Zk8YH3k05aowXPaEd+hxyXVk6EQuG+Kcg4+FV4Un39iWiGFc2p+TA5VgyWW0ST/MvXI7vmr3REaUH7cqiEBhFeRO3IXK7LCa18FJiQOx2aIFeOHcaoOQaXhdBBJsj5esvWWrUdLazx5Co7lalxVL1r09C67wSXh1RgpvjdLNDQmtcEQsEEu1trP2AV+lsH8Eobfb8KCF1f7S+n0giR3yUtDHPEBaSC72nEOQ+gytiRqjxxRv8J4S4rfVDdrhml0VPNXgXIqfXG6XzPxZ1FkZsSSpUFGB+NS7W9Z7Fh0WBkGLv21Hprx3znQid2zsgOIBMTUfUhipY4sRMpLBes+/drxiU6ygzRyVx6qet/L4lmRteaCozh3cgSGFh9aBGG8Y91OkjPpAnyGkEhFUOok8g3VuS+NhB136D0PDo50J/iFmx79R+vrXB+NedkxfGMpVNonSZX0o6PGqwxXt7f3iZMQehvWdkIg1A0aiNo9z8kf23u+kgxpgW6PQp++7y5tLIB3lX4sYEiKLnZ34OKWn/3rJKx+qHxtXRhMqOBWpDyRrKsmWXWSdLaLk7hAygBe4oC25N+ySe43eyaFUvgDCMyBvNnGLZ5SKXATw3lct2ezhtFmoyHgRgFEF37nj8gAHfU8XshfI19RYrXui/3Q8FHj66ghcpuP1F8GxaI1/IOuKUj6YPnXbp81lpqpcO4YAilcJNrGvr6GnxQWBMsQu1KMcjpCVTQShS6r7wJ1f6WSXpr0n2CBqhwmetoMyjzXgaSzgWbxbUR6Nnlmg4c+VIZhPkiuzUekk6komDj+3Unh7cQUwTOJS58i90yUJe89Ulm4PdOoZ9atQIxlc7IAdJtOqhsruvDWo2uk+EzahDkWHxOnR55dcLcGyZNYdaKhNylDRZprU6Sv2Ef9Q+enKHX0gp9o9sARiK/89BcxL7FGqnhM0Tm6IzCm1/P1ZaScsGRmV6h40JoiuPyPxvVdjjWdmP3GjCTgurb/GcXEI/8dgYsIy3VLAZJwA8jqlwhvxXn4g+Ps6GAr3iUGTl1zcc7W9LZ8JMDW8xnuiUm1Ugk6V9RTe3Ny+WQwB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 116f556a-381c-4d7b-90de-08d8c7e3ce0e X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:10.3109 (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: PWAjfbuy9wMpwCbmMFY/gZG6UUsfpN7YoDmx0RokHRFbdgifyDYwYPl8uZE9nfrghb17biRv51uem1RCoHjLvQn7C41twTn94mLBwYYXzeg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 Wed Feb 3 01:33:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 376670 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 43CB2C433E9 for ; Wed, 3 Feb 2021 01:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1277164F67 for ; Wed, 3 Feb 2021 01:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231277AbhBCBfO (ORCPT ); Tue, 2 Feb 2021 20:35:14 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:50428 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231260AbhBCBfI (ORCPT ); Tue, 2 Feb 2021 20:35:08 -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 1131YEMP193247; Wed, 3 Feb 2021 01:34:14 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=sf+scpE1vm8734qyfHXXFbtGcpIlAAq+LBwVkgO+Q1yvMd4hOds5jd3k3G7SS+WTIDnZ LRViTSMNNWbfaY7R/mTutEOEysGilHxfKtQy6aGINyYYTpfp0qhW8LROUjxO8YgRqtvw ITqGxAc5lyFP43+PXy6vimbNZ7G7F23I+XgKu9utrPufcbVNFw1rL5AraK0gstKn1X4I ub7FVBx8eMcHOnIM3/p7zFTOTsTMXf71I9D2u1DxZxt3ICA/OieK4DkXe4+1sWVQR/oI bdR8+qpl3IpyayON8L0GvLgYuZ3uXPqxGPVv7EKeFWtMoIhx53TRE2AT5pI73UOQ+6Sj Kw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 36cvyawtyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:13 +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 1131QD2N045065; Wed, 3 Feb 2021 01:34:13 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2056.outbound.protection.outlook.com [104.47.44.56]) by userp3020.oracle.com with ESMTP id 36dh7sfwqv-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TUeGP+egw+bQ7qou+HRfjolQWKSr3KIo/UDbm89CrAhMoGZkYwipbJ9UGho2kR2dVd+4SeqrusUeon/SRNhez7ypbISDccML74yW2cN+QNmCYzSrP+ovilT5z8nHWJuDrF92UlJMXfhSvaxFoA3qxZXSMHhrlaMhBOBBtO9uHJnnWghF4WjIkdRJquRsFPe4jqWgCr6Fmenf3TwoFdxhZwxtFtD93V4uutWBfqx0kVeck3797PsbN3tlxnYXUPCxntQTGC1KU4uJKtpKP42w90VR+lo6jSIdgneLV2jRHqCCt2tF0AqmEfnEDo5sQS2DgnF8rlRPD6GwP2reDuhjoQ== 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=fFhhPvsb3f1h82JSve0Vm2DVZrg4BHlSNtBj1phWkCCQS8XJ9t+HDLwPOO1asRfb9fUmha3ewuYL2quwl+fylvR8VGxUhofyRTVOMNBQCRGO4T7CJd8D4rS9n6q+fwHRbG5GVzFyrdxmo60vMGCdP02/fQisx8mAfHcFqHiiz2ktAhib4XNNDGplteRJPPbdInel7T1kf1KQ21x4flZhK8rejUDrH3PtKg+FEJbSR7+AeeNVvVYrYbRWdC9d6TUewb1AVlLi3VspeI29+yDvyMYGogV6eC6ZEi67zh8lII3bacPQHPAyPMxIc3+jaHnJ8sVdWDGRUpxK85VqrcZ4nQ== 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=tvBHGVOBH2dVxY9GK0NCldUAFBNiTsbrB8BKgCggr46bYG+dxykR5MWQz/6/Xw9pkRA5+T1ETzBBpDC2siZUJA3sbJTpymDAwSdcx25yg8AmDtSP1FPQKOJnJp6fJSLYweA9lvr9nWoCOChIrhTPU8Eg+EIeSWJJ/jyTsONcmRo= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:11 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:11 +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: Tue, 2 Feb 2021 19:33:53 -0600 Message-Id: <20210203013356.11177-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e18ea15-1139-4aac-a19a-08d8c7e3ce9d X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: yyhU58MxMXqKlarPBy5jt59Cpq3S3ky3tzuAg/TX7vEMM9EidhbNfnv1JkmQuMuNncZMimioSuVkv54wH9piXk+PD6fSveDOUEXAMUCXJzOUowUc1/94m1D9b+cq9ZB+ec06ZcvbelaYUN43OrX2ang3I+VrARepJTNt6G0hYh/bqrOXmOgmsruANieJ75Qp6sVTEosZ4Q45X5KyhKa5majU2zYJDQ/J70hBS94hz64v9xduPsXZMOb6D+SJDsA8cZpW6peByndvYK+tfbYlguiQM+1qzOEx4vhAF2GaBl2xjUMlyFg4RECZzRoeoXz3O1OFU8AAj9lIdoJS7yAaoYyurXMZgCtYpKaeI72GomGK+TZccvyOTUJWwFXuh1qjo2VOp32OS07HTsmlMhDwzqPQ71kyXq6VTNmsCAtJC1SB7flnTU5KtPFYZhMqN/yM7ZOJs3B3QjY8Ak+9fv01SR0MnKJEk70i0qPkCLHbubV7RxWYBAlASHVjSK5doKO3NOvqtyfTv5dAPNzeR+5NK+V7B0SoYtwT0+KWRzcEF8e1R0JQKjF1mNlfjm2oVKTkvv8DfORKQiek7XhdrM9Plw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: wyEZH7B5wJdxkrcBWSuzXKPTqMyam7Y4cPagVNvXxfFH8sYg0ZQw3ACGyQWmCDjH4NJtoAQBe1ebrtsHxJXaTjlHW0irsK9QIU8S9Lf11nFMQD4B0m2UCIDfdICiF7eq0VkCBPwB2eXy3IwMnIEBD0BVDARuHds+q/8cqBeA8SZW7LL0htFqfxMdCNeoNes2u0PfA/5Pu+dKkof4dCiaPvmNN4Jx2usR17AmMpNwdmAkOyhXZycLemTQP1uJRKhueWWNc+EaOVQdldDnXBflId3k/UBiIn41r5xhmItQUJdq+6ezcSaJ+v+d9vWNfDYvUvUiCC0QF+WL+K7qWwQdvtOuzcAuGqI9L7TKliFGMgL5dchYPLWP1mrJSbRcMxObgA7fb66IaotFDuJLdyMHd+k5JCoqa4NabJJf2+Zsy9qWhx+wSgIMfUpvVw17GfqVa7iVN30Bzh6uduDzZq/zhj+tJlMtTefuwJzQBrMclstOpgKobFbdcYouuviE4Wil5nU1jCWN9dC5jMVxpuJJuP+4DbiWYCZTCjVXHyk7E/Kur+7dxW6FTV0vE5nFXpKlWHhNK4pO3j85d+Ugje7sSlSztFdTCSiFWIZiZEC7afEbeTVbGtlDXkHya9fV84viXOkgs8IQuq+QokVgfChMtZKlN35BZ1NthWEmieL1aikYknf/aTKPdGEaPNyRp/PSBHDFK7veHsForlCcrIO0K667OIt9z2TTigr0/2I5aMR1RFtBs1qjqnXPLxT6unHADtLq3gnCLrKQfRpBcl6X00UJ/vZHyimrpaO686ov+kijPe5bIw+16YlSD/pfSvM3ualMYWYFh9sIe98F8JFo3+0a4abhewEdkvDkSkWey/IkS1ecRldoIhgleuuX6FPV1zv6hmquQ92wBZe1m1Z6UkOc4CFJhrWj9yfNBobm/3+fCmA3US3EyofmPP/YBb49ZQQ/Mi3hcQ5VY/6uDhP5Mp0441EkR661TjY1aIpWONrHg8v+cLqyVp+2BjHgiek4YwQxgmrFtAN7oiSS33CwvBeB9pYGUv369u+mXlQNz9WaT0IwD/RpucgEIz28EfDJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e18ea15-1139-4aac-a19a-08d8c7e3ce9d X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:11.2685 (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: AHOZFW3gXnJIzEeDfJ3YRUeXOClgpa9yRWGSCwBAaEPJmBBppF88kd+mmcR09hkmIy01FQcJu7sXDoWMRRSjq1sbtHdUyWpaIrMIV2vaF2s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 Wed Feb 3 01:33:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 376665 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, URIBL_BLOCKED, 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 5716BC433E9 for ; Wed, 3 Feb 2021 04:23:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E2A0614A7 for ; Wed, 3 Feb 2021 04:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231143AbhBCEW1 (ORCPT ); Tue, 2 Feb 2021 23:22:27 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:55382 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbhBCEUp (ORCPT ); Tue, 2 Feb 2021 23:20:45 -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 1131Xfp6175739; Wed, 3 Feb 2021 01:34:14 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=cNo2YZSLVFsHeWMpEQtcwFkO8metTQlyG6HkxB69hnmht1HhkOpykFkHMhtEyhxO8Hsj qLUkY6HzLnLW/Sqrq1dxvnxF3RYy55+YiJ0zmjtg0hItytNHpPEHbt+7zE+WoUXIowg9 uTRnQGUZFMDNNy6bl2K4LglOgKYoTKAkivP114HTWPl4kyH6y2P2VZg2m6jMRoX/LKTy CaF6nrg8T4gONKTk/wI1wR4ajJ0NMNt2wOwEasQvN41aQIy2dnfeCb/j5N//Q6ei12JH /AVi9U/dXUeTbt2/qrMZubYWsf7Q8+obIwnVwXTOFHBf4JfnxCiJ2mZ3e710qsJi0Uwa Aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 36dn4wkggc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:13 +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 1131QD2O045065; Wed, 3 Feb 2021 01:34:13 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2056.outbound.protection.outlook.com [104.47.44.56]) by userp3020.oracle.com with ESMTP id 36dh7sfwqv-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMjNlc9xokalIpWqFX4z+lmk09noXnWCUhcJN9vJC7YAE6f671Gy+6IX2pi04/hygszOM2q3tnNP5HnOS4pANwDmCl32HveSOdeVI0dGMAUI7jfJz4nABPSjC7CPMzUzYO3SyqAcUm3URThDLoXY3CH/MF+RaXkj9ZPsZJyaXgy3gE6xvb8vdYnPc6+4HxILLEiV+hfabs4OMoYT2TTkwxY8gOnVdsCQLdj7VrozEMGDUx4/sZfiULNnkBxW5eAQ4n/AcBv45wn5OyNfzWRgvRYCR1Imu7nSFtavliNPb4lg4ITRSZuED38N2wReL3T/CfyfRZDFQlmPX8xG80paPw== 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=SxwmoGIVhmOUrFBtqzKE3MVKRy0rQlDLzlPEmtgBEj2bTdUKW3PNJtcJZ9g51BU6UT2EhOzFfXefjZGeZMWGvzbzYOUuCxwGE4ptWjY2lPOJ3/MxQp6sMsz91ka2OvO78ZYh5/r7yuEmgerBv2oLA1usGeBv9ij4fauQjVBINNfq9TSPkjYqKCqvb+mZJVw62N984Hw51NNzdFHkCo1QeWf9MCJSUy0d6/ufNzLI9AdQgovZewB05H9674fZ45NQ6tYX07wUX/vAUx5/zbZAtK39/0IvdB8pjB1FpuSanB/RQAYlL5+VOCy6koGAikpztCTzB7zP4iet0YLPRfLnqQ== 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=w5IVkynkTcwIrMz0w067qaDU1BaW9UlFB4C6TFu8c8KoO5QLLAGvwhqjbqYoMQyd+IcXJXf1IYpNr5Hc26gfP/9dP7R2qdBvrmzoAsKJgerFdAFXigeS2kRK3eP8o7HF6WG7khgG2e8dCHuApS6rVDZQYAkjmyLkeuXBH2LQQuM= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:12 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:12 +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: Tue, 2 Feb 2021 19:33:54 -0600 Message-Id: <20210203013356.11177-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9174f71e-1b5b-4225-937b-08d8c7e3cf3a X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: bMsRC5L6qdlMVp6EIo7kIDdfb6BPn14/r170lL1DxczyWN+jJakBLqQTkZwWnmu+K0esoY+lH71cmwgQrnk4AxOrFOEhRzyAz1BniA9QC2vap+AgriTEv4rKZrIQBJpQirrKcOEu2syTylEkZyPOO7Ad5JAg/UUbuY7M2+xFRnGT+J59MLqdyL7HnEQiRWufN+CppJdvIueKmWgTJW1OEjiNfGaFujIzmPSxCXWGmpLOzf4uIc9Xov+uIltWiN1U/en+nKngwJGGt+kgoQUDoAFoMSJaOwal1DI6xBDLWvsNECxKnQ1zFzuy8WzG+LcF1lVHKLK6dSS51oDWjt9z9xt0eVhgAEr2OfP/vYxCusWcU0Z5pvfJQi+eehsE0NZHka3KpDnY2QJ703DmiOBCeyPfVnFo6Qvk1pnh0bUuHm1zmn8nooliO+cJ1ihTVC+N+JINJx2houazcdTFxPZnbtJx1Asfr2ODEGmU6mOCMZHTgMdvukHghAidW95YQAgo/lCqIVOIa7rqk9XFVfKYQ0dlunXRaq6JhriTNMuzGTtmMKv7G2O8amV5k+oNzRZvuRYLiBLmG61flMEwzfGF2Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: wbJZkSUIpihzYxaCjlpUKJMCfEdDTEFW1bLqfZ7XfibjvXtVH38IplfkaoGWVgm8QZ7WlYzKuWEjW0fubjEvL153/FBAo53fiOzKREvhf45wrxsVPAtfTQaJfWdZJKDlplzl0SPCamB8IIYWVcipKSIFnC8ir2OLIErLNGdrtu+LMWiTRxYAhddA619rIswk0nMQka0o49Ap8gOObwuicxmMMhSCb//E6uXZwe7JaLmhRg6egvxBoO+IxnSuvEbsoya3hdw13+aP6uJ0EhGxUTsgPuhRwOLmzlxK62LsZ67+z1KnnNKKlUeESFSL6n8IMt8E4ixxu7BZevEz90epHZ0Q6Hd+wyXcrJIDaL8fsexnMSQ+yq5HviajXxkI77E2qHWU/eUQFu2fSloVH+kbz1nB5Oz6Kgn3IBUocbjU0xM7+7NfmeSXQiuSaz1HLDaUW0ZhbrFP1VAt/gZPZP18Gz0dlM/q0/I0UJCc7+HEs+c4HaHWBPVFfKic1ZArmAsZ2IUoM0JoQKLKkeAf0zoKLJ6xH0my3QrI2WOmqEqy+tfcusfXwI5BLzc1L2oad+zoPJikC60DbLhajCv5DiuOafhImXZeqHIBxDgQHoWHlOQOPVJCrQhW9jM/JGfe5pl+NowfNOW1PdzFWeousCIyG5aUIKFv30hm3SqHSscwNa+dy0utEKe/3HrIUJAoUDyvsfbjjsVXOf82wiludpxIHpvO/wNZjJ87l6LgmHUdeNFhs7RvHq3t0at0hAbiHeQWPVlRM4aMAa+yIn4HXqqU7C7vdQYXExkvmxrCMr+6QGnLspHlub2CPwXvsM1zGQp5WIj4uIszdG+dZoX/JihlqtpEgWS/iwcF+ouINTmJl81Oay4D6TsJzeZwS3QIofhgPnj1YGI0nJWDoM1zGpL3OnPUyPWd1kAJOhS08OJ+gdmoX2+yMRGQK4BWF1SAn1B6uX0Jz3a1PiLKdm+BH/LmGfyiU+fAKdcQFMEaSlYImb/Iac+OXXwRDhaO/6bHMWyCAMuLnU75WMtGEAiqVjaYacuwlIz+HNA6LUALCvryFzrX7uMZheaku1LwCZIUC695 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9174f71e-1b5b-4225-937b-08d8c7e3cf3a X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:12.2850 (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: 8s2eKzwxU3R82X1yNLR/CWgJCh7OZL1Sn1UzjtatJSmckGbBEE4aAzXvm7fHH3VfVv2VDGUC99FJPw5CDo2LTMWr3ooZdqDuAsA+oWRZn9M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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 Wed Feb 3 01:33:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 375743 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, URIBL_BLOCKED, 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 2A2F3C433DB for ; Wed, 3 Feb 2021 01:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E23F964F4C for ; Wed, 3 Feb 2021 01:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbhBCBfM (ORCPT ); Tue, 2 Feb 2021 20:35:12 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:48838 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbhBCBfI (ORCPT ); Tue, 2 Feb 2021 20:35:08 -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 1131OwTt149843; Wed, 3 Feb 2021 01:34:15 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=Ov7YoL/crJ28FMr8htWKQqUAtm+F7RfMAIgxoefMEKSTesKvBQxKHi2OZssuhcA4Hqbg q6Kq9GVSF3zq3YRABTYWUPvkePS5EtaSQxHOPrjkFwMtUdK+UFmiLW3e1L5bX8/EJ6CA G1NykwpoC+2TU2DYzSfrWW+cfNmt0jDp46G9fKCnKI+BdUIg2i06YJ6t69RSSbMm37fF 6oU3+hpOo168LpG2VPNl+dW7iZaKTpbAedgg9EeT4TveBbOWGI6rCjKL9Fw91jrV028J yOX+v8OYvaiuyeYg1z/vwgrA7vX9PyRmcuLHo9q17vps29nsB3fh0tgFJhLa1zKdJ6sk 2w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36cydkwm2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:15 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131P0tC139770; Wed, 3 Feb 2021 01:34:15 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2054.outbound.protection.outlook.com [104.47.44.54]) by aserp3020.oracle.com with ESMTP id 36dhc05qhs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LCV459bfm2m2BtTwi1vYbvNdvXFL/r344RI7Eq5yYOyqbe5luCBhcFlY2XOtIRAjrKCfNi5AQaj04WLOIinCDcl4GnPnT9m/NLSvipj1u0HrBFDxjXUzzwGJqHs92/dxfbxOR7BzuM7IXvILtiua0hyIdXuAJwGfiwx/amxycrIJw3gRl0b5jA5ouZL5m5+2daYmbE7mOFdgrle3BjpixGi0lHspiGzzG8nItvVEADnVDCPXJAwTJkln88PjwGCG2LrupNoMn2ahhBLwXL0Ou0tuOJanyY3ztkoqLPwOnISFqrvtCYVJ5B+XvbQYRWqjJibLyzvg4JXRh7eqFK1++g== 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=H+sti1dPSiGjACZtEH5dyfZCcN0ZxodlRaz3gRrE9YIi10mu+UerNZYX0/R5weslg8Pa6B4bhrtKKxbxWX+7YSSbZcG6lE9E82/l371dwckbqIdzwSIyJ+mMwLUX81knsJ1t78rzl0k8GryA6FuEwLaEv9feYgr3bCkgWdeql/goNls6Xp/v8VKi5PLF1UfB4CoB7lQPHvqYapyDPlELVMasp6RFiVwXOwSUmpP0ftJDTa97SGnb1lVWPtiYhvY8UF+yPwNvflaTc73eFRymSsYtXmI41rM8XImVtCgWU1dlkikickghELhbBNlSh0J/VnNicecckF19XgPwUy2TuQ== 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=jIygVhn9vcKgd16fBmeespoOdKp5zE1yh+IovUPrZ/LLDllnvR+RWyQCCcG0sChUobZriVs8NPAAB21VqSUvzstDIfavvcNc5ki6VkD7adYrOtivFLAp7jLlQUN4RtsXRyBugMkqT4/3gN5A7fwisBW5dq/sU9KW9DQSSNGXZRU= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:13 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:13 +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: Tue, 2 Feb 2021 19:33:55 -0600 Message-Id: <20210203013356.11177-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 925f4bd5-e6f0-4f35-d82d-08d8c7e3cfcc X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: 5rdyVn2pqqw5MTJ3oEjYXBIEdLUldwtC8K92X7VAUi6ew1SW9K91ySzWp3Pylhe4UnofnWj8sDbvK22TT/Feu4ccxfkQS02T0sNj9Y6goTOIO3Xl2QOvPd7RAjtlhj+t1lGZUiN228tU93eFF7bPTdZzTgTc7md0YeQ0uLDhMWU+IWT87Faf15J5HiXUyI2/W1lzVsZawNm58cNQMTAU1GYTqyFPiEVnuNEtfadtVnVYr60YYiNcZY7Y9981JeYJiNuXi2TdOQmJiWIZrGl1CyDNSi9PIgbmP7/G6qyHc0wEgKT5V0kM3/840KCkide8M+UHkaqRTd/zErFiA+x4/bEVeZVjbqAIXc6s4Gfp5kPrpEvjsYcJ7f9o5O4hsvmwTs6DCtiIYpsGKcVdkvxf4JLfuJcH8y2juZLTveJOcplKHe9tSRXbJaWcNykyrokCbpCQxYogGI3pz+TbVZU8QLkXRy62fOb/PVbDbpHCfYaTTI5PO0wkzwEXdPbbcpdHaj94nGLniCtKueCBHqb59WwnesG4xQvn8oWRndBb6SAFTkMDntBiJ9Mq3TxPcPjllCSgN52R6S2tgNMk87SqCdeIbWRlBfzfkgcg/OmEItQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002)(4744005)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 54TaMRadhUAAnt+XMlvFYNfDmoIEf2Z3l549cUv7MfKtFxxFw8ZkKRUemVyBGPTW4QiHlkiHIGvi3Kcw6ViP7XjUfJJp+IfJrO/eOTFdbENsrPt+/laWD56IzcmZ3xQkjMPDqWfw1wd+mYHA+xWD54Z1cfUIYfPZ5x8pBLjVe6UAvi7AXIIE2LayeMNic/XH6UsmeLZ7yEHC1A7BrJGbsmmNT4SueUsWiibYgFAgVatj9t54YVNI6GHPs61LTCR5k3dY67X0XlNGaNOQZDrOp/JZuO3hEdfkIr3cupum7I5BzFhbRA3ZJa/soTJlEVCFJFrZXpeaqHxFLBuWP3fCkA0UrUzvv0pTcdzTT80FuaGKYGCbyEk43udQ5tFjMaBR0ii8lc4NJmXYRnR7kvoAvuyCIN71EkXKf2t31cY3/rn69CHUEgVNUL+i8t8tszRsuECVHvwBan2YbNcCv1exFyiILLj87tDIBxegp7F0icUmo7LwDEqPfwCbypLgLO5OzomU7CYa75QugXJFSWwiWCpJtkrtemlwDYmtIceDxoeKjy55MeLZlO+YkZqkbX2G4G03SgsYPppKG4fWvmx/o4NXMZ8uSs1aXKyAdZfWELSxz2ZOOnzDc0eGQc1ElTb9N+e2EDxqoCfWA+MJzOdmWWWucXCeftbp9OMflDLPEs+cyH7EEvC3S7kGKjRgOOP+O6FAU9LjqUFWBoiZIJQdPAIjwRxZJc2j8nvc+J6qXeWOyS1NK5I8boAvJ/hPszS7/8YOMchgKoeqjhPtE/XIaDfQM9F6cHN4yY64u2BKVtr8Kyu6GMJcFkxtbQZImdbnt7GrU15XneGqQlCGdSdAYjlQD3XretaRlZYbPbMSi1lWhEQf0fb+BDJGbKbq5GqJ/HrD93KKO/MmS9GGUuHbx1K0dcTEwp7us1uA5wRtt8Ly1Y0X/hOv4o5nsjHGJyF8Flz2k+4mu2UewYljGy6IwCz77g4rv/RMOdlwjcFZCXqHSWWYNtd4ziqIwU2GrQIioSAG17BrMgYNKOg0tGWA5V5uESqhUnw8oDtsWqGpSDNn7tmpswURcvivKqirBOq8 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 925f4bd5-e6f0-4f35-d82d-08d8c7e3cfcc X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:13.2886 (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: o24exVen8OyfhbdmGfj5a9aHLs7kTuttqxgvsapBsapBNLuHMJ4jQv4ylWMzjRNdYxjmPWAAj9ednt9rZFbR5n8BXF+7qM8TMJZbwsZad9g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 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 Wed Feb 3 01:33:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 375738 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, URIBL_BLOCKED, 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 31B93C433E0 for ; Wed, 3 Feb 2021 04:24:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9EF564E4D for ; Wed, 3 Feb 2021 04:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231633AbhBCEYX (ORCPT ); Tue, 2 Feb 2021 23:24:23 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57982 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbhBCEW2 (ORCPT ); Tue, 2 Feb 2021 23:22:28 -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 1131YGX6176450; Wed, 3 Feb 2021 01:34:16 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=lhuarnQvidk8P0thXAco8oAVqVUCy1ANRL1lDcoJIFMU7R6qwerLtA9QXdBaIEUmXYeQ w0ym1jt4W/ZHnGLGJcKtpC0rOTtOYCHETOH8qdLuGwHo9YSL0fdOYy5RSG9qhpI/RV/o ePJvKU2rHE3DuO4iBITzMzJ3NWz/WxnuCdfQBpiI/Izncv3nI1Co7Bww+IgWnjpViQ4D 8ph4RDV1Jl86cA1lw9KRdlfZBREktvShuw4DHMdelE6jz7Hqi5Ey+PJr3wxG48IwXWVd B92DXyM+a5QKc3HeQ2bB+4ehQFhsTYcKjwQPyUljP5QCfhAsQxEltThpRwPbn0Azx4U6 9A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36dn4wkgge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:16 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1131P0tD139770; Wed, 3 Feb 2021 01:34:15 GMT Received: from nam04-sn1-obe.outbound.protection.outlook.com (mail-sn1nam04lp2054.outbound.protection.outlook.com [104.47.44.54]) by aserp3020.oracle.com with ESMTP id 36dhc05qhs-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 03 Feb 2021 01:34:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QwKS4TA7SMAplN9IHVyIketGeK5O84r8e1XsmeiGsc4uh1rMyM9AsD17wb42ryQxUh1ujnV05jw8uZ6NMCEsy+nOKieHEV5p8MWUplNHD+CvZOgN7dxXdOxohoOVjt9R4YzG+qaVN474/Soqlw/FwxFqh0JEjXMyo4dT/fcSGLuFQk+mtwLA3cqEu8H3DIfCUTaV+D5vkUdc11KDNyOzDPPMugtxc6CGUen1ja9zIGXrCVFwaDBksBnvDyGiLoYmkNlvMo9sXaIr0gnD+DmPSk8MnRLcniVZKkOdUxTr46S4s4fPPiyj1wo74M+jniVJfDlh+oMjiYl0Ep/KG2rCMQ== 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=kfELyhTYbvTBrDI0QtkVrYFAtpusN+LxY1kFYTio5r/u0GTaYlyqRNb/8ULPExdLkl/1CdD2fQUukiWd8aJjKwwYlOi/6n0iDcE+PPUBPPo08VAr6QDVdaIgfzCSSfm1ZjN8RYzVWrazjnzi4+mrp1rfh+pxnJImSXNN1ux9v0+c+x+6OtRr85NdOx9Rupw640jd18tAb+6fjuCT7mE/IEL7F4d9zKKEbojs0fEryAJLYSHX0J/6YYFwzc2e25XjQ6IDAN8sLh6Meypr9vzaXEFpwdKMBInO9FRmtNzGcacocFgRgsuX1L/8rlVXIzmQdFbviQzgvERNMecEv9sDrg== 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=jsITV2qewtKw6NBFfAOQXgCmmof8QClHSvio8PRmwzAFTAASRRPoJdRzy4cUJsWGnXF+fUORw3LnZmSYq8QGXAH2M5IWESD0qLsg6M60HCvPremBGapSXhYy/m387uwh+U0mdi8IXA1Qqocxed8/7VUdHwun31FLx1rgEyArdkg= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) by BN0PR10MB5320.namprd10.prod.outlook.com (2603:10b6:408:12a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.20; Wed, 3 Feb 2021 01:34:14 +0000 Received: from BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86]) by BN6PR10MB1236.namprd10.prod.outlook.com ([fe80::f5ff:ea98:43fe:3d86%4]) with mapi id 15.20.3805.028; Wed, 3 Feb 2021 01:34:14 +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: Tue, 2 Feb 2021 19:33:56 -0600 Message-Id: <20210203013356.11177-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203013356.11177-1-michael.christie@oracle.com> References: <20210203013356.11177-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) To BN6PR10MB1236.namprd10.prod.outlook.com (2603:10b6:405:11::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH2PR02CA0012.namprd02.prod.outlook.com (2603:10b6:610:4e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.19 via Frontend Transport; Wed, 3 Feb 2021 01:34:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 24966eaa-2979-40a9-2567-08d8c7e3d064 X-MS-TrafficTypeDiagnostic: BN0PR10MB5320: 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: Z48JUHQvVEMAd86RaMG3DvHMSO3TOW6qRih2XYle21nuUJ4tPhIiXPv1ryM86imQ1o0sDC1BT5SwnismOk8szGIMbsVFP5xdqNpqB10tGOFzQSTvRh/IUS+wjx74AOMY6b3frWLpov8GvZECQaURokJT73pKfr6OnkRMnnMjA2g3x4q5EcvqkhLtPQb8iLO67OXREw8fT2RIPQryNi3vAPnK3uEcDGe0NaB97Oa4ailHsbgea8kLODUBkXtR7iYlf7rovd/yplFgu3Nxs8SsHKog9HfbulGpbsGqqN7IgBbjbozYGUno3IHb0C9F0T/eXQllXGrfbzPgoIMr+07LepOAsK7nmydMF096mn8pkVqzbRptJ/DBBXR42dfBDg9ZPyoVEdVW8K4SvridCxNJJnCT6AifTZHaV9moKAem97sXP7ceRLD2ZCeNfvatkEmVl6oCgqAXibCf7qrr/LbMQZkFUv9DrW5skX8kDAguSkJ9R1xxd97RZyUwMYhFg4UVEUDzj3q78s/hX9RDWTk2ysdxgr/J5r+a8Q1+AihWcQTiagbRe3HcjQ7x3TGdnmrA4DEtbhHOkmV1r/eg2F221A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1236.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(39860400002)(366004)(136003)(376002)(346002)(52116002)(316002)(6666004)(69590400007)(956004)(2616005)(2906002)(478600001)(86362001)(107886003)(4326008)(66476007)(66556008)(66946007)(36756003)(6486002)(6506007)(16526019)(186003)(26005)(8936002)(6512007)(8676002)(1076003)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2rxqpXWGA+rTRyKrQEy013CcS0wmc5ils/eyF105/ZvhjM0UMo7lcbumlt7CpitBsRdOkvYo2PQmHWDobn4rxsWcFRb53IXYBNV92rjKYrd42LxkQNxyZE+4xK7O6WZIKgEjqawP/yuoR6s/2Z08hVihIh3pxinosbOXLNNYVXZd5TSbeokvyWlZsfdP9iQV1xuYJ6EDqwYUDxmlmtTRBXwX+H1eBarh8GJHpYnfKIfIJcSJFa4FeOVzsv4nPmNc1kgmEDu5PtUCHAYGVzsaYjJsS/z/b+fosFCEdmh7M8RHghwhQUCnr7V1dCjU5ltyvkO/Z1tyWhapILB9KQWQ0Ip8c7as8WH6wp/Qurezsk0+OiXD/aX724TxDRQWFpfOF+J45pY/KNNl/IRL1dHIl84CGc8pj2RfPbq/R++T7eRkgDRqcJwucic4fuLdMLBGGW5Le2w+biXVQDoo+/KAM/d+43dfkVherk4wSUv8FbHdjA3B6wCCCRpZxiBQzd4W1DlXO+EkZkW8jAD2eN9PUfJjh6bj6S+vEfDHGxowKwjYQRJstLchMhcLx6/CGJF+gcu78XVFPgMuK9ajxPWwpfn/AmFY0sg0TkisLtJ3fvIpMbVhXbLNyWyobo6FKr/sv6N8ZO+g1EW1Nh0SpA4wfos+sHtDO0cmU6VgdUdCe3W5tfKQE3sMgxqU9P4IL2ODZdGScuLFRZ5R/6b2coGHEMLTJAEN+y4JY/r9T/WXoJmCryUH7n7cxEImYe/qeNJ+zK4OXkWNxCNq1M+vuUfuBgwePa2g7WdsKmNuBsAm8EjpnlAGx1gUDIl1G174Pg3K2Jm8JJ+hTU1oah+RkDcyANFQRWUas16howNYTFRmh1ARy9efVaigwS9MQ0EUZrthRrbNnAUY0pxVCLo5Bqd4G8LbQIxod4MX28NDHvVMwEQrPHRabFkFukTtjYS6CvITgcv4iwqXUFdsEpQ9J3A7/HgZUBs2bHhTobnhsvXsz+aoVhmlmXVy2IyFJNMsKSwIsM9YRIUW0aPjpfXqR+/zgkcVtA4lIZ3yCVX1JpKvrfC8gmKntCUixLgnUGs9LfmS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24966eaa-2979-40a9-2567-08d8c7e3d064 X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1236.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2021 01:34:14.2452 (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: VozmzEAWYkbXluD+IVLXIUxCmoCam+IiHGNWHP5INTDHhczPboFz2z288PyHNov4OZVRgeeTcspLzrFp5c8nsIBEFTZx705vUHkUCiQBqbs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5320 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9883 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 bulkscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102030005 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);