From patchwork Sun May 23 17:57:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446356 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 E747EC47080 for ; Sun, 23 May 2021 17:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE3BD610A6 for ; Sun, 23 May 2021 17:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231898AbhEWR70 (ORCPT ); Sun, 23 May 2021 13:59:26 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46476 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbhEWR70 (ORCPT ); Sun, 23 May 2021 13:59:26 -0400 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 14NHvqrJ164810; Sun, 23 May 2021 17:57:52 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=36nlTOlTLMTxpspKVCPpHxZS/J4B44QEijTKxwhPzsU=; b=U4Ms3F+NznRH8s95gcyCajkkQ3c/mBkQCWr6DlQUUTyliqaLvK/mTLORmFiD/21A2YPs Q8P8qf8Qov+i0h5Y0joYV0BiN8NAVrxlzztlAAm/qUzdnJszaA4DLZCa975YNyjJgDZy D/8RVyVZqrsZv9VHe81GyGghe2ElDD9Orv6yOAta9/pAk3Lfx/enI3neZ4XibsDk3cIu aXSFm6Idb/bOzesmoMjpWvWQCjKkDXAQoSHW98uLgRKIWxJbkbCJyA3Rp+SqBZuTFU0c T6Nyaox87ndt0TvRJoPqZWRQK3AFOgKx0G38k4m99kYzy5KayjdfYuSvBgKpCUg3gWEC 1g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 38pqfc9ja4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHtqYo081804; Sun, 23 May 2021 17:57:51 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by aserp3030.oracle.com with ESMTP id 38pr0ah1fa-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QXHwaACLsHr7nWtn9lKHobUrQI9RK5woPTzTj3Hq0Wqjn7ffOVmvfe2IbSmC+s3tf9sIQ4h/oUi2Dz7VI/PDmWIAsroeQraQaT4SlGkb8u4yV4UcFMgUA/XOzd0/TUMJnjGb16jKAsLWE0iUbLpiqcr3/x5WNKJLcoH9dRpt+rj52NLc7fF83K3q3PVa1GD/OFVsXIN9+006XRbD+ULTgjM2X87xWh/5vYBnMVyUlyb8C8VkUe2GtVx/jekepRLPF5BPEIhD/3TixsFnSLP8zIWCYjEmQp/jGNTeD83+FIzYPv0oQHDcGhIcZIEvc9OqKzCZFpjphvU68htKbXWsQA== 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=36nlTOlTLMTxpspKVCPpHxZS/J4B44QEijTKxwhPzsU=; b=gExurHjPAaW1qg8Mvw1tRNfRDaCGhjRf62ERBxsC6jOmLdBOGU17L6GBnaXIovDxltsaOUMPo8PzxGaUvjNHmBoQIpYtK3+xRQPorgTiznjUD2RbJVrUg8CpuIWtkPLCOmIEMFEGNFd6WjMMwygYJ/rOX/+TQ5yWzOnZzLOfzbH6/XVgCTVxhgY8Jc0SH91nn5il/R+7GB4XVLhFNeJ3Gmztne0R8Dk978raVLRJFX0i3nsM3BQo6mhMoIoCt3i6Z9brVze5FeIjHoKV51yf505B/r3M6N7C02IDFDM/q1v9A539zg1whMYWL3t2mSOfItOiKtQyFm9WWGCUiSAmDQ== 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=36nlTOlTLMTxpspKVCPpHxZS/J4B44QEijTKxwhPzsU=; b=RYUyAia9122ju9gq4ZrRKnesMeRYrUEb7oZIrGk0YEo2fVrkVOWkflrB9gfB0CIlIUYb/gUN0/+hCl0wFoyjA0OGRqAjbR8SCrhsWvkS+yJo9Pfiqt3rF7pT1NGXU0rMhNjfYZo19jAaOFPW6wXR1s1Tf69m/N2EAo1fRz765kE= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:57:50 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:57:49 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 01/28] scsi: iscsi: Add task completion helper Date: Sun, 23 May 2021 12:57:12 -0500 Message-Id: <20210523175739.360324-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:57:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 94c72055-68dc-46ca-73f8-08d91e144769 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u3lwq6OX5VC0uE6sLlQy5ORPp4590LQ082xRCk9ke7jHp0CTi2C55nrju2dUT51X+AGi73iFBzEe+Ey/PVmEH1igEaOAQuBx1Zn9U7QZE8dUdXnWgOJ1umLdzNU1lPnwSEX2wI9mJjxIJ400gLcbQqlaSDLvNlb4WwSc+aff8iqU7zcDxfsPJtdnH1DBVMx0YKGeheVqaQ+rJLJBRAYqdV3OaW/n/OvLX6PQBguXf+pAB7Gjn0obrKeqDIg/tMQKIyM98Kz5lZ7rngATa+6U1g5ksTaA0bef04Kkl3nDH68bYksOYJe0MmXxFw72ysBCz+36kMyaeszAF+JDIU15oxqD4pbFg0s2pQC0eEHSx+ny2miQDH5YUnCLUHrjYzVeadI0UukMKjhxpxNQJACEafEwAUwb+rIGKI6b54aLe5rr7TnMTqIzBFnHNYgpHt551Q1DZiXQnTTCbqimgmza+N4DqrsD7QOywedrBzQ7sgiGWI0XmyzzSgVkpED4cvEjHcovm848SgiE6tAoDWaot3KDt9fZt2yAoM+hZ2Fws3gbNGSAnZAMClbDyozXBT3m5nCAkUUgLqtvjC9FwvNxXVGR5HcmUreqTR+i/KYGT6+Ckc4LgnD0V2I5lgdkumHf91gnaSPQNcvHARoDxDNs2n8b5lQem4yEn3Gklj09mhyGyF7FGwVOoicxf+bqFUXJ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(4744005)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Lpfym4WOOAmA6Q/8eMkqF5rOIb8uhkM1DJSlvrwCpjqBWl88AXN8MKFZnxGgWK6Lys+g9Ntid48cVH0Jd7TWPn902nFrxTJrnQGSl0SJzwqB3qRNPsgEX8vYetiMZavVixAJq+1axwbqAsM9/CEMLnBCBDWxFXWZtU3wryw7OTlHXPF+WjQ8xNJ3J4cx5UnqQHR4rka6iQXJn5MgjqM4QM8ZQeGv3Wt8rCllEvMYzykTsX9rbH0PzP1py2n0EGtdFuVY90iVwukMFEmrdTmMs1sJg6q/iYKZ+AZLibIxpze5bYPC9y6l9EnPrYcGsTEFZ6eYib/7MZH8xQCMJCOQf8iESxuyrK3iHIjiOFhbDkqX477kMW5RWK3y6oE2QSepA6A7wWCmULqIkuc9LMvDCu5+/ieEW1LhlClSKyUZGS4xNaK0vzY1o+rKECUYh3ssScR93JjGZj6RToMCscjL9fOsxcK457BQuFIVaFgOHECzVFKesx6P/dBKnik3ZiIwc9sTd8op8VtSmeoIHP+KToNmJgX2FRBo6x68wwZYniDfNnD51Hw0UTRKiYsuH7OJIIiUzuDE/xg9q40oSxXKcCZVF1OQ84JhItqC+VBCKR28sIivD4WjsmkmkcfWY7RlCux6/jxzsGP7i8lSWhGCkd8/nS3aF8s1kstdknUI5ZDuU81RtBvlteIkKR6F3NrtSe+EvSf/w1JgQ9QauNHhNCXrkAAFHQzvXB3MdFz/Uxho1+vRMm4MF/J4JwDKSixq7D1WiGr0CGdYzprko1v14NarO8zFZ0qCSKRcE6YyUnbYqKgDR1/KPq++1/1q8QJgy8hNr1nEtRP7hOC9pSt4AthCIkqAiL9tOfvMwWaOOkrOVjKuyStqeWJsFvN8ya6GTvaTWoAA5vJXr6vQQ1K8JMWw4o8dS5i/wZ3LaBydYcdHsIezF+5IWoWRrq1x+XRSfhIm1uhZKv5n6QpHuroi4SNmLo1R0TxZoHqQaMeKdGGc5ku3lzi32xFqOigAPbcKg49lkB1dA8eIEU6fbWwxpk4tGYW9ah9PcOJZ0d9+3uhKH+dQRPlyaIk9Y0484ceh0bhWEorr0SeWF78RMrQo/CvcL9KnJqN7SEQtXx52BLSkDd6h5J2/zWl+w7w94G4IEIsNIcgPkwInVANC5mFgZ/1vgNV7EBWXKTr9hgVRDYPI9xH0dgmhueMr+RwOxMG59tzGfkvPGvi/TSb8xi1d2IRGAPCemYoueLayMXX+NJ4ibaxCl59L1SuVwSwry07I+sHtrYBVRF+u1OcgUyFaD2iLnrmPKIqDNomFngyZPju7Ljm0DKs4z/EvWNkIYk6w X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94c72055-68dc-46ca-73f8-08d91e144769 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:57:49.8456 (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: zs1JNGbPewmQ2k2fTDbR8cdR8XnxKfQ62ypiANNGWev1ITr4E05EKaBR+laKUjmvecFRtwEQaPcqmrvWVtSctLqfc9DjQChFMOQGU23q2vs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-ORIG-GUID: -bOD5wi1qd0pQk1EcJxpLnxyF20sGYNf X-Proofpoint-GUID: -bOD5wi1qd0pQk1EcJxpLnxyF20sGYNf X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This adds a helper to detect if a cmd has completed but not yet freed. Reviewed-by: Lee Duncan Signed-off-by: Mike Christie --- include/scsi/libiscsi.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 02f966e9358f..8c6d358a8abc 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -145,6 +145,13 @@ static inline void* iscsi_next_hdr(struct iscsi_task *task) return (void*)task->hdr + task->hdr_len; } +static inline bool iscsi_task_is_completed(struct iscsi_task *task) +{ + return task->state == ISCSI_TASK_COMPLETED || + task->state == ISCSI_TASK_ABRT_TMF || + task->state == ISCSI_TASK_ABRT_SESS_RECOV; +} + /* Connection's states */ enum { ISCSI_CONN_INITIAL_STAGE, From patchwork Sun May 23 17:57:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446355 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 DC73BC47081 for ; Sun, 23 May 2021 17:58:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0CAD6117A for ; Sun, 23 May 2021 17:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231932AbhEWR7a (ORCPT ); Sun, 23 May 2021 13:59:30 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46498 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbhEWR73 (ORCPT ); Sun, 23 May 2021 13:59:29 -0400 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 14NHt06x154060; Sun, 23 May 2021 17:57:54 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=iA6uNZnaiKkDglyIdBApqOkWpWD0i1ZY/hgDyC5w8j4=; b=up8sKzZjoVG1DnXX6gmwg2saGfH+eiBuOBZmHX4Oy5Gqb1vSkKHvTCRO1z0E/m6ZvqYL XoofDXIkfpicMd70qpClqH0XtomCh+DZ+N3eQOQxS9BpuuN9VobsDlpnuDW8Il8xrOlS wwQvw6NpWbyKKz0q6h8PwrBFaR/xvFarQ4J2qSePIpwLZDeODFABfKZkVNMjxoDCNRVn pJTJr5WZrWAih3Pro+wh4pXguwnO2o0iaa6PPkPeRJnbTKXXgRV+maPS0hVDUXi3p1PL wpCF5fXvn2gQLL9JdrU+/yeL9UTMLOEW3SVQBGDgToNCxeyF95HHUc2+YuGwLYSaFJQg aw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 38pqfc9ja5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:54 +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 14NHu0G6119789; Sun, 23 May 2021 17:57:53 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by userp3020.oracle.com with ESMTP id 38qbqqjg5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f1clrdh1YVRG7zf/1FbK7MOuB1OFdXEagdt7ktGJ39VZGIxbEwHczHQ+5WSj+xCKot4MLJDl0nxRAX6OlCHEzwjZW4d5RK/WYC60Y0VdsqqAc5jSYtZlLQ8pV9SqRdCaFuj2buznqM9AJJ1P9BSyD6ERQb0bvh9ITP/Ec1qS/xboW9KimhXv0xoQz9n9qMXQSvkefJWBxBiiwUYyEL956tZW8ASMLW+OLnIvvgHtAWSUGQ3MvOsVt4hJlPAxEG70kLIHZFyEWhvAjZMGwK+cEmgG9N9bmgBFwtpVcTP+Dsn5cmdYnCq3xy9QJwojiw+TGpMesavgtCAEH6jHiqlzmg== 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=iA6uNZnaiKkDglyIdBApqOkWpWD0i1ZY/hgDyC5w8j4=; b=kTfAqzIZUMe0Q5b4J6VHok5J8m19//A/9g2ZOuLj5tL01dWuEhAlOkIiFZGt60Mici0WBIFzn3Bfr7gpK2eOFpwGVp6cgO3OT0to1hUgIKjt+Pb02cliw63+Z70TT+9MFqDIyevCX6Bp7qdQHK4KnFGB9ZNCKsc2jGqgU+AKFIrmhblhacqeh00uwkoHPte+h3sjuoGoQ2pAbW4JBTmz3AY5BtfeH0jjWYYwEfapfl7E7Q945TT5VRU3onoknt37ZgEq/R0+EwEyolpISU4utB1WFrNqczLYPp43IDk1Zle+8vMbwzi0aYcK5Y4PWkm4+9TloCug0tj2QYohwCtuSA== 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=iA6uNZnaiKkDglyIdBApqOkWpWD0i1ZY/hgDyC5w8j4=; b=qM+xa2ldim8B9x10SruYzoYQCO7USdGTQnMv/DK5Jun9cTMYDO3BLZ/oXwObIijkQ7VWto+GE9fRpHSXlvW1Q0sLdZbLCJHZpQyg2iAagaHW0haQnEcXFdxZQoBdnQFRgRqvtjvIMl+ydUwkHSNpWGXMCo+A6qn9tDgxKzYVOO8= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:57:51 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:57:51 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 02/28] scsi: iscsi: Stop queueing during ep_disconnect Date: Sun, 23 May 2021 12:57:13 -0500 Message-Id: <20210523175739.360324-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:57:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37dc5bce-c7eb-4d9d-40a7-08d91e14481d X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: 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: K1fpkDmx8ZdjaxDXVCyGgcz3pZW4Jvl9/SDhuHxaxEBAAxNxDGz4uLN09Vtdi5aWHA/0zya1W9QBg/qw3bBftPPjDwsY9MZImTz2S3KOl5GnvU+3T/D/YRr0lZzUYmWkmS7Nblh+E5QQ7PwfV761gw+VWt3dsEjNr+2J1fLJ5YKbvblang5+1drJ2Cc7wXKns16DtzISrsiyEYrXu0VsD6YnBBVycEczBrj6yS9kAfe0zQm8i2bbKA9CrS/vdTHsrEQrfmCibCBbW/rzurOPxT9jF+LNVLZkwv5R1NI7Z/hetJE4qrHA51JvA0whh/0PqfJs64iW8y4rORxaoxFYauB/vuJj+8CgfCS6j8hY5NHwNJXOGK1WcFah55PRlGKGSryaA8nO2GEP8r1gORjS7fLDVlHLU6OX53bqd5TWBqxYHdpdJ9AVszuAAnq/bwfQjgqlzp3djGnQleyejN+OrJaA6gUqKEtVQ3KBjx7BT8BtUHJ1Ovb7Fx92vY+2JKFq5kLytV1jUxs75d8EE+gDOXM8ufflePqxuOnc+00KkANsrbJZnXvpoAEc8tzQhTN8fPyZoE9bA2OtkmjzHo9nSvNgcOhM76QF2r55okzv21VqLeOWTeCCxi0wpClTnaQgA98NPYXEM82ZPou/r4meK2sK5SzgYzlg4xvzlt/834Ddp67AjZ1LH4uC/MQdgBX4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(30864003)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MEsjnqiKJXMwQJA4vl7l0jz1hcYK/+X/SyGgLC15piAYDqeG1bVyPfTgmW2BN5veVOI0a/rjMfrKJPhKV8ARAhON7149s0zdTFDJDpVShD3UnHxLH1nXxLGyvBcbNlOE6nayySzkmH6afFu8UNQmhPA90i94J+L5gn9yQrrgc7rsIU8vl3GOzkq2vAfKFnHwO5w47Ux0vo258qZpAgAeU9JUPcDrq4kZWPMfOtGg7gKSkfei/ptSyqfhj2O2qtiAu0H+f2brdUb8BT09M2Kg9rH11F4nT+RUceNoNp8QaPuF91OkczB/V/pfpLTHiTHOUJyvRBFYnhE8+eB0Gxh8fSbtDz6M8p9Z+4oTPi2TkbuZ++LMFkJfM8Z1YeRyHFez/CCoEKmPPOlR2uPBtoTKkEAilHwsUU6V6WRsx0L5+LI+u0bfkB8MNL67eVZqS7aPQTmNOo9gjqmVWc8jPBSrkY62TrtmBztaTIEOyxYhCtSQudL0vmouj3f5mjsz++zcWp125hpQ5zmc0OPkDWHyZIePFoOwFsr/N31BO2C4tlVvMbfu9pvK/OV4cfiHzSy24cTFXr/n97f9cLSHeFyzJHUPb5vzLSdcjk3I0yiAlNsDPrT9opb4+1zF9zVwyCpWjDsJzGrf/MNso7pcp+m/HWIBuPg5mzE3qW33TjTs+W+JEopPvmpcMTQkiSDlH/UN5DsgDRcUomYF9VgjRxWIQZfVqPXAsTd7NUy3ahQil/5yCbTXyxXCHM0AHhnUPX5+y46hEYtILsDflbRMguSzGBQAJu60uEI1GjtqrPUL6YjgmD3ERulASMLUZDikHlJPAgbBTd7n525+3vKuFx94+2A8VVC2ythuK6xO/nZ01R2zD6OfIj+kacFd3QrMuQhLdvpGQxokzm4oHXsyAki+Ap1Hnjo2XoyTRCfAm/Wau+5GVNl3+LJah2wDMf1Z4PJboVuCxYDAP7sAPaCR/8i/BP9nYl45Q+2Lsgb95kOW/LqEN8YBnYJCQIHWVm1vtCntv3Hd2lBmw+XwTzuBLbQf0HnOWATYsab5DX8nlYgAEMdb9u2lOqvZt6rirrGZqDeFQX5XjfJTHl4ZWTvDI5VkqUEjMmYy8ye9ao1x4dI2D/jl3+4oDY8gdbUhwFlrRCxiVMYJUxZXP//fkxCnOZsSUDSrCjBOCtZy6oA7CYiyrovYSenDow9nPxSDHRV7BafyQyUU56DH6eAnE11CmVYx+yVtbGLvH6sUXt5NGVqdKZSqLuhKlDp1wLMR6I00fby6Jh1FKA6ds8MYqqZrgCZtVqs5akcbG/HghU9L0qQwZFm3jN+d+F9z1F8qfTL65U3d X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37dc5bce-c7eb-4d9d-40a7-08d91e14481d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:57:50.9620 (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: 5uQpw2xSpenKJQZvT6sPTp7+Bc+4uhfjqQUSBT5cRU+QUbMvzuN/AFM0izPpLNJmI3O5AYjUVINqtn0Tu8jdfdWscFDA3mqN4oJ6p+1jRW0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-ORIG-GUID: pdhQKhDGF-e5Zns3KV1QR3-MTUBOAkW8 X-Proofpoint-GUID: pdhQKhDGF-e5Zns3KV1QR3-MTUBOAkW8 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org During ep_disconnect we have been doing iscsi_suspend_tx/queue to block new IO but every driver except cxgbi and iscsi_tcp can still get IO from __iscsi_conn_send_pdu if we haven't called iscsi_conn_failure before ep_disconnect. This could happen if we were terminating the session, and the logout timed out before it was even sent to libiscsi. This patch fixes the issue by adding a helper which reverses the bind_conn call that allows new IO to be queued. Drivers implementing ep_disconnect can use this to make sure new IO is not queued to them when handling the disconnect. Reviewed-by: Lee Duncan Signed-off-by: Mike Christie --- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 + drivers/scsi/be2iscsi/be_main.c | 1 + drivers/scsi/bnx2i/bnx2i_iscsi.c | 1 + drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 1 + drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 1 + drivers/scsi/libiscsi.c | 70 +++++++++++++++++++++--- drivers/scsi/qedi/qedi_iscsi.c | 1 + drivers/scsi/qla4xxx/ql4_os.c | 1 + drivers/scsi/scsi_transport_iscsi.c | 10 +++- include/scsi/libiscsi.h | 1 + include/scsi/scsi_transport_iscsi.h | 1 + 11 files changed, 78 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 8fcaa1136f2c..6baebcb6d14d 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -1002,6 +1002,7 @@ static struct iscsi_transport iscsi_iser_transport = { /* connection management */ .create_conn = iscsi_iser_conn_create, .bind_conn = iscsi_iser_conn_bind, + .unbind_conn = iscsi_conn_unbind, .destroy_conn = iscsi_conn_teardown, .attr_is_visible = iser_attr_is_visible, .set_param = iscsi_iser_set_param, diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 22cf7f4b8d8c..27c4f1598f76 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -5809,6 +5809,7 @@ struct iscsi_transport beiscsi_iscsi_transport = { .destroy_session = beiscsi_session_destroy, .create_conn = beiscsi_conn_create, .bind_conn = beiscsi_conn_bind, + .unbind_conn = iscsi_conn_unbind, .destroy_conn = iscsi_conn_teardown, .attr_is_visible = beiscsi_attr_is_visible, .set_iface_param = beiscsi_iface_set_param, diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 1e6d8f62ea3c..b6c1da46d582 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -2276,6 +2276,7 @@ struct iscsi_transport bnx2i_iscsi_transport = { .destroy_session = bnx2i_session_destroy, .create_conn = bnx2i_conn_create, .bind_conn = bnx2i_conn_bind, + .unbind_conn = iscsi_conn_unbind, .destroy_conn = bnx2i_conn_destroy, .attr_is_visible = bnx2i_attr_is_visible, .set_param = iscsi_set_param, diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c index 203f938fca7e..f949a4e00783 100644 --- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c +++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c @@ -117,6 +117,7 @@ static struct iscsi_transport cxgb3i_iscsi_transport = { /* connection management */ .create_conn = cxgbi_create_conn, .bind_conn = cxgbi_bind_conn, + .unbind_conn = iscsi_conn_unbind, .destroy_conn = iscsi_tcp_conn_teardown, .start_conn = iscsi_conn_start, .stop_conn = iscsi_conn_stop, diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c index 2c3491528d42..efb3e2b3398e 100644 --- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c +++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c @@ -134,6 +134,7 @@ static struct iscsi_transport cxgb4i_iscsi_transport = { /* connection management */ .create_conn = cxgbi_create_conn, .bind_conn = cxgbi_bind_conn, + .unbind_conn = iscsi_conn_unbind, .destroy_conn = iscsi_tcp_conn_teardown, .start_conn = iscsi_conn_start, .stop_conn = iscsi_conn_stop, diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 4834219497ee..2aaf83678654 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1387,23 +1387,32 @@ void iscsi_session_failure(struct iscsi_session *session, } EXPORT_SYMBOL_GPL(iscsi_session_failure); -void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) +static bool iscsi_set_conn_failed(struct iscsi_conn *conn) { struct iscsi_session *session = conn->session; - spin_lock_bh(&session->frwd_lock); - if (session->state == ISCSI_STATE_FAILED) { - spin_unlock_bh(&session->frwd_lock); - return; - } + if (session->state == ISCSI_STATE_FAILED) + return false; if (conn->stop_stage == 0) session->state = ISCSI_STATE_FAILED; - spin_unlock_bh(&session->frwd_lock); set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx); - iscsi_conn_error_event(conn->cls_conn, err); + return true; +} + +void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err) +{ + struct iscsi_session *session = conn->session; + bool needs_evt; + + spin_lock_bh(&session->frwd_lock); + needs_evt = iscsi_set_conn_failed(conn); + spin_unlock_bh(&session->frwd_lock); + + if (needs_evt) + iscsi_conn_error_event(conn->cls_conn, err); } EXPORT_SYMBOL_GPL(iscsi_conn_failure); @@ -2180,6 +2189,51 @@ static void iscsi_check_transport_timeouts(struct timer_list *t) spin_unlock(&session->frwd_lock); } +/** + * iscsi_conn_unbind - prevent queueing to conn. + * @cls_conn: iscsi conn ep is bound to. + * @is_active: is the conn in use for boot or is this for EH/termination + * + * This must be called by drivers implementing the ep_disconnect callout. + * It disables queueing to the connection from libiscsi in preparation for + * an ep_disconnect call. + */ +void iscsi_conn_unbind(struct iscsi_cls_conn *cls_conn, bool is_active) +{ + struct iscsi_session *session; + struct iscsi_conn *conn; + + if (!cls_conn) + return; + + conn = cls_conn->dd_data; + session = conn->session; + /* + * Wait for iscsi_eh calls to exit. We don't wait for the tmf to + * complete or timeout. The caller just wants to know what's running + * is everything that needs to be cleaned up, and no cmds will be + * queued. + */ + mutex_lock(&session->eh_mutex); + + iscsi_suspend_queue(conn); + iscsi_suspend_tx(conn); + + spin_lock_bh(&session->frwd_lock); + if (!is_active) { + /* + * if logout timed out before userspace could even send a PDU + * the state might still be in ISCSI_STATE_LOGGED_IN and + * allowing new cmds and TMFs. + */ + if (session->state == ISCSI_STATE_LOGGED_IN) + iscsi_set_conn_failed(conn); + } + spin_unlock_bh(&session->frwd_lock); + mutex_unlock(&session->eh_mutex); +} +EXPORT_SYMBOL_GPL(iscsi_conn_unbind); + static void iscsi_prep_abort_task_pdu(struct iscsi_task *task, struct iscsi_tm *hdr) { diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 08c05403cd72..ef16537c523c 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -1401,6 +1401,7 @@ struct iscsi_transport qedi_iscsi_transport = { .destroy_session = qedi_session_destroy, .create_conn = qedi_conn_create, .bind_conn = qedi_conn_bind, + .unbind_conn = iscsi_conn_unbind, .start_conn = qedi_conn_start, .stop_conn = iscsi_conn_stop, .destroy_conn = qedi_conn_destroy, diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index ad3afe30f617..74d0d1bc208d 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -259,6 +259,7 @@ static struct iscsi_transport qla4xxx_iscsi_transport = { .start_conn = qla4xxx_conn_start, .create_conn = qla4xxx_conn_create, .bind_conn = qla4xxx_conn_bind, + .unbind_conn = iscsi_conn_unbind, .stop_conn = iscsi_conn_stop, .destroy_conn = qla4xxx_conn_destroy, .set_param = iscsi_set_param, diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 441f0152193f..82491343e94a 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2964,7 +2964,7 @@ static int iscsi_if_ep_connect(struct iscsi_transport *transport, } static int iscsi_if_ep_disconnect(struct iscsi_transport *transport, - u64 ep_handle) + u64 ep_handle, bool is_active) { struct iscsi_cls_conn *conn; struct iscsi_endpoint *ep; @@ -2981,6 +2981,8 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport, conn->ep = NULL; mutex_unlock(&conn->ep_mutex); conn->state = ISCSI_CONN_FAILED; + + transport->unbind_conn(conn, is_active); } transport->ep_disconnect(ep); @@ -3012,7 +3014,8 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, break; case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT: rc = iscsi_if_ep_disconnect(transport, - ev->u.ep_disconnect.ep_handle); + ev->u.ep_disconnect.ep_handle, + false); break; } return rc; @@ -3737,7 +3740,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) conn = iscsi_conn_lookup(ev->u.b_conn.sid, ev->u.b_conn.cid); if (conn && conn->ep) - iscsi_if_ep_disconnect(transport, conn->ep->id); + iscsi_if_ep_disconnect(transport, conn->ep->id, true); if (!session || !conn) { err = -EINVAL; @@ -4656,6 +4659,7 @@ iscsi_register_transport(struct iscsi_transport *tt) int err; BUG_ON(!tt); + WARN_ON(tt->ep_disconnect && !tt->unbind_conn); priv = iscsi_if_transport_lookup(tt); if (priv) diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 8c6d358a8abc..13d413a0b8b6 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -431,6 +431,7 @@ extern int iscsi_conn_start(struct iscsi_cls_conn *); extern void iscsi_conn_stop(struct iscsi_cls_conn *, int); extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *, int); +extern void iscsi_conn_unbind(struct iscsi_cls_conn *cls_conn, bool is_active); extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err); extern void iscsi_session_failure(struct iscsi_session *session, enum iscsi_err err); diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index fc5a39839b4b..8874016b3c9a 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -82,6 +82,7 @@ struct iscsi_transport { void (*destroy_session) (struct iscsi_cls_session *session); struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, uint32_t cid); + void (*unbind_conn) (struct iscsi_cls_conn *conn, bool is_active); int (*bind_conn) (struct iscsi_cls_session *session, struct iscsi_cls_conn *cls_conn, uint64_t transport_eph, int is_leading); From patchwork Sun May 23 17:57:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446354 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 05985C4707A for ; Sun, 23 May 2021 17:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC9AE61244 for ; Sun, 23 May 2021 17:58:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbhEWR7g (ORCPT ); Sun, 23 May 2021 13:59:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35746 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231933AbhEWR7b (ORCPT ); Sun, 23 May 2021 13:59:31 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHvocI121474; Sun, 23 May 2021 17:57:56 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=gkm8aFgYcwofFRYfvEAYGtr9YTXEIVI8gwrAumMpexU=; b=OQkl+eOFHJgtyvPLVHnAsHCOJg6UvYsaWu09bCbQlub997HzJ1g6NAWYudsZUHPz7Jm8 tSE982YkO3bqvj/dzC5D7+uArco6MCP2GrI3UvCnUSQANaFEELbtOL3ELPCqXUpnpub2 E8w3XGe2A9WowXtDo6tB+3vQ7NX52vTnRu7+SatiGa9EvwJdQVqXdPHSrIp4hDs414WO kwK7QmkCCLP2f2NSOavFjM2GpNHwpCNwMgA8unQgZdduy0FtcVpGKndBRgd8Te8cyK7q B+QnrKV4GL7TPIUax+XpSgsDLHA7CPZfXCaXA+llWNjSVS4mmyJ0+Ib11DvDcY+67m2L og== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 38ptkp1erh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:56 +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 14NHu0G9119789; Sun, 23 May 2021 17:57:55 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by userp3020.oracle.com with ESMTP id 38qbqqjg5b-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ANXN0vfi9nb2hyYr7xCBo9wevtoRHRZk+T9FbSiFKvP8kzmxz/e8mhqkD5qY8MXqPwYj0DpqXTp13D3Zf2CPXe88tMXkSyy3p3eMWSdS1xgxwM6BYPs40PuGXWLTcD5COcs4z4fPFHy7uLtJDH8K7Fnwyn5n6SHe6jmgNJNNbWXxXmhQd6ei5qwDJQs1+BP7c+0Scezo/t0AJhJC4kOC1jSm1S+0KquigCBx97zYhiDcZzYgG3gJYla5c8XaXOFYQKQfdi9MiMJZcqB5unchi7Xu9caZkIorzMCHQHf17z8q3k/TCdxFocmqxk1tDOIwbyxzxy/MMn+K+IiXuY8SPg== 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=gkm8aFgYcwofFRYfvEAYGtr9YTXEIVI8gwrAumMpexU=; b=IBiJt1MCao2/o+SUHqjdBTdulHxAgMAbyKVkFKApzxw+dhvP4fl1KbkQ/hIUsn1qdnrLdSYqvmV8tQHepUYAZAiPjX9uF5Xu8q05iRwYGz3IF46I8FWPe0e4K+1l0/nN9fh1bb1ik+goxaPO3OGa9Q5WwQAxvHQXgFag+4WcVkETguWmDTgF5QAV4FRIuxSM3X8t3IYeAJMDZ3kXXoxFm4o2b6oXNPSefuYQykw0H7D++BMtBbVsAdhGDao05InhanynY+Oh+7L8CJxWSGcQ5uoiUAJ8+yv530G9lkTnTnQZPdEtKlcufzLHDZ3UEiVzwNJIgKuEsep2UpB3Xbo1HA== 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=gkm8aFgYcwofFRYfvEAYGtr9YTXEIVI8gwrAumMpexU=; b=lY+ilAnb3tDOGm6R/t8ym+hRLwh6+a+KBhpppRIY1jGoDDE7/gVvJskFERsb+3xbSfF0D5uG8f+KSv6B4wpuxwIcrJhm/DxRfOWuzIVJU+Ep0mdXNWaMxb4KCrhJX0tUstJs3707KGLjzogwMM+pAHHZfxVtkqYiqV4u7Rvrrp8= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:57:54 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:57:54 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 05/28] scsi: iscsi: Use system_unbound_wq for destroy_work Date: Sun, 23 May 2021 12:57:16 -0500 Message-Id: <20210523175739.360324-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:57:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 439521e3-b74d-40ff-c690-08d91e144a21 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Aw51blHgijBn9HB3M+aEGgJaftgVyNV/eXwSvIE2PuqWSCno1XWN0gNVjKKeJMB9cfIZLCd8dJuflPuOWty+u1U06qWIEXAadIEQzaLRtREOPRY5MDQbRI1/aSKZFMhFuCsUvaT4CBSw5AYbf8APOvmC34VF0//+Z+HFdH3NUG0FcitGT/hldzh8d6+2rNjeMijaZO1PUZgA1fdAQiwcUgca4d08FV1yYmKfB/U1jdvbr+DzXNYDk4XSW3NM2UxGyLeFyP+hVit/ItkhuNo8WXj8+Us0+9A5IQ5ulHUQBRk7mKQSLRtmvqG9z0sZgVKVyxHhNQfEbSzZ0btPDOL6JsT1eKEBq+MusQZa7DJtajX+po5+NSC+AicsdcLKFEqPIoybGyCfS9EpPX3DKyIjbsNi70eH3BZ0y1O5OtDm2YjjLudEax3D5p6aqCvSFzp8BfPu0GCOeE3N7fFJ7Wtgz/TG4Dmantq9hQGIct0GEBiD7PVDwuqlvJXQlGymyqk294f4CEJ7guMAjjfBqw8DquukHOxVJ2QfeY7H3ro52LO6oozGmwe21B/iRFNdK1TJqGN6uPYfcpPhTU/AskqGnsT/toqf5A16xO45GEid/vorwUzkiDwyEOZiil+oKPSjOzj5pxdJRJAWCFmSguQhbZzFZIynRFkGeDOkuAcA4pZddjwuCKMNwAklgNkbrZyY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cS5flpdEZ8Rk23FHbwZJc1le2w8j5Tz8Vgpk6cm+0JFMqYVW/qZVtvK/Y+wTTWhU1EOtoZIJ2RlYTQobzg5Ps9ztZKqUwrZwZoxOOYd+xWiupdKM2WbBzTdB4R+LlOLE6Cfmqv7rRwmFvyZlfLFebvsAtrJ00QYsWPTrnlB6wbcQm+jGavFKm16yanbqRzkAvg/M2mzNtzyPbrYHtoQaJ58CXyAo+TY0jkelTkdxbxCKKvogMWwI1ZScidlvHE0ckBEFPjsvw9iSiEpThj9EKizAWkZOih7S/Dny51MzFVblve64I68r+VgTMnOalnxr/k3ofQ1oX+SteWaCHNLeFA9jap6tW8wypXmuHf94Z15mzLLEi63woocGFA1W7SSl3Agk/LQ8+Wj343v1fGu5wnsM5n49pj6v9RnCllLEVvwIim66WoNTSptmrvFGwetP0fAh0VC4JkHNKOUjkcmNlOR5Njcq4G6eP+bRE9U3XHijB8TfjiL7ve0DJTj/EeLAe+D3h+/kJFaSvuMOyKK7YcuMHuSQlg5/voNV46la2Z7dOHgcxOKiDnhE3HqaoKm7GNRoj1stS9W5M7CwEl8Q/W9acwv/z1hNHEJqzk7N6nMb0PvNbNc3rnslcwSMj5Lp6JX5xUYGC0VLV1C2F1ScwoSCTZG+3z73AjjFaTnKwzktAgcyLUsEfWnhWR4PXtAl1g2XOuCDGvw3lWSPDbULthFJ+yXwrkRWVAAz1ie8P/SqBJeSaVWuUAdxh3Hoki3LDRTFYnQpDjPPH7up8R8bzdXUJZFz1BRhMZj2JspY+pvkQ8KsJlN1DjsPsbA1eNLjNwFv7/+BR28kGTeJTAYkTwi1PD/fV8Ych5tNjl7z5tGMeVjvHf6V9jtTLWt/DQ89ekhAPPRcAgl04OcZyBProwX68Y3joqfy32oEwQcd4myxbk45yE2cfQZGh0jvZpq9/YKbE3aUzEtffVXH3EHTY+UqmJeB//rfYASPV+v7RY+ndXDgmYeXrjCb0afoNpHWIWU0LIQy5IRGoNgINgkE9v6CXgzQCeN4CcXNlMcT4FLXalpGslZvQ1tQE8u5IIsgFZicvBm9pL6Wd/CJPJCbMWtGtBGhq8FANKRqnWVJOD541NlQsrdTQiRffNUWFf7T66XQdGXLp5ydx4H2PSw98w7RkrD0zcSEwTbXeEPRQ4VhT7bE/rZgBZWmpGDOXgV042WGFbp8BttE79Y1DCs8agCiOdTfuzRrtcubbTIub+Lf9z+xIFSfTl0UwMN08eRvIX7TPXReqxPMsbcfFk/B3xeszxet0IRXvfJKapAIHB6c4VoZSFINFJDb47+wpuX/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 439521e3-b74d-40ff-c690-08d91e144a21 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:57:54.3921 (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: hHChr6Q3qGXt+MYRMBj39vGCds3dD4OODtyNORbA5R14mCA4vSCG73ILNbQuyyP3Sk4pMebF00GAY6p/uAzx0LXQqXIWc92RPvRSOsC6dG8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: 24zlfuTqVTHqOs-WGd-F-fma-H3meVTe X-Proofpoint-ORIG-GUID: 24zlfuTqVTHqOs-WGd-F-fma-H3meVTe X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Use the system_unbound_wq for async session destruction. We don't need a dedicated workqueue for async session destruction because: 1. perf does not seem to be an issue since we only allow 1 active work. 2. it does not have deps with other system works and we can run them in parallel with each other. Reviewed-by: Lee Duncan Signed-off-by: Mike Christie --- drivers/scsi/scsi_transport_iscsi.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index d134156d67f0..2eb77f69fe0c 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -95,8 +95,6 @@ static DECLARE_WORK(stop_conn_work, stop_conn_work_fn); static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ static struct workqueue_struct *iscsi_eh_timer_workq; -static struct workqueue_struct *iscsi_destroy_workq; - static DEFINE_IDA(iscsi_sess_ida); /* * list of registered transports and lock that must @@ -3724,7 +3722,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) list_del_init(&session->sess_list); spin_unlock_irqrestore(&sesslock, flags); - queue_work(iscsi_destroy_workq, &session->destroy_work); + queue_work(system_unbound_wq, &session->destroy_work); } break; case ISCSI_UEVENT_UNBIND_SESSION: @@ -4820,18 +4818,8 @@ static __init int iscsi_transport_init(void) goto release_nls; } - iscsi_destroy_workq = alloc_workqueue("%s", - WQ_SYSFS | __WQ_LEGACY | WQ_MEM_RECLAIM | WQ_UNBOUND, - 1, "iscsi_destroy"); - if (!iscsi_destroy_workq) { - err = -ENOMEM; - goto destroy_wq; - } - return 0; -destroy_wq: - destroy_workqueue(iscsi_eh_timer_workq); release_nls: netlink_kernel_release(nls); unregister_flashnode_bus: @@ -4853,7 +4841,6 @@ static __init int iscsi_transport_init(void) static void __exit iscsi_transport_exit(void) { - destroy_workqueue(iscsi_destroy_workq); destroy_workqueue(iscsi_eh_timer_workq); netlink_kernel_release(nls); bus_unregister(&iscsi_flashnode_bus); From patchwork Sun May 23 17:57:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446352 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 52DD8C4707A for ; Sun, 23 May 2021 17:58:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3178861205 for ; Sun, 23 May 2021 17:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231950AbhEWR7j (ORCPT ); Sun, 23 May 2021 13:59:39 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35768 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231944AbhEWR7e (ORCPT ); Sun, 23 May 2021 13:59:34 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHufLE120977; Sun, 23 May 2021 17:57:59 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=B2mP8b3Ak3kQ7jk6jUST18rXQme68Ec7MLUj4/2MPjQ=; b=KIpQiXehgqrNdIdeC1vTy8cInGYhU5BhngUTFKI+GPrmPLdyAW5cERBPGKx3cEmp0ADP +1maI41pByaErph6puridXXO5LpiJ/4yIqyCBgAfyyrKub+pjyOSCXBr77XbZxkO2tG6 WjqDmaptuzrANxzLo7pkwzPA2G27jOyq0ntPVznd3H9d7mVz60H2vndaGGww3sFINI7s XAULn5jgA98S3iENt7hin14yu77au47wTX0gVlhqrdIXb3yRaPxvE/KicrtpM+31wnjS 4782u+RgVZ6y/e8FCXYewk2QQ8QrW7sFfRGsIv79vREMv1KD1kj1SVZ9eyaxtW0lZsGt Hg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 38ptkp1erk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHucLQ161902; Sun, 23 May 2021 17:57:57 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by aserp3020.oracle.com with ESMTP id 38pss3qbd3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N6pZaDH8ewruiMdk/E+ulIOHWEMt2znCkvYrP20I+a9nx/F6LYanpcfWao0SN7Y8zh/NzB1dcHM52EKBNR3RWCss8wN74S0mk70O0/oWSy+fLkeLOv3ils1ChoGcL6Atr2Td2tZreeU9Lec6pCLZGOhwcAtD+FYjokVwEQ9R9/vdQiAbo1lw6t03PngkrcDb4Eu6l3Jg+AZ7FXrXjBrUogUYzL3N3Qz7MZNsNDJgEacswzu0Y/lCGN5aImh7L0hyDamkjX3jY+rU6o1vlo/6nZAOlSkbUkhxlDCO2yy+BtsH2asIsedsYDYo665hgd7a3Wuwq4+X162HW15o73lElg== 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=B2mP8b3Ak3kQ7jk6jUST18rXQme68Ec7MLUj4/2MPjQ=; b=LOOAEwY8kBVqzDdSZJ+nfJlSxubFsevTLBtrei9jNJQvN1h3SQjbRhJMtlanVjDTwpSLzch2bAaVvSxllL4V5w8r8TsZVRXRXKg6fQP24AF7OZw7HTRiXjCxim4hSu5k+cMfFnS7p5pEpo6/sq5qPXdUmU/CB2D8OVu6IMeqCX73ZP7TBM2pmyY01R4LL+I2iAlzQcPRnLVFiSiAalieqsiq1PfZCo+YsvolEfNvWOfnuChASZz2aVarJ62CX+emATVe2lOdhEue92ICEczm3oHilZ44Y3i89Bn//3UzhTOBF8Yzm+TKiTopsRhSjOwTOGcL0xAb79IMHt4km1OVnw== 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=B2mP8b3Ak3kQ7jk6jUST18rXQme68Ec7MLUj4/2MPjQ=; b=Xp6cy5ogfLt2ZghmrZtOVC/LUwGYVDkJCovafdx5beOgdNeArl6yTcBYJGJss0mTQLMkAyCOaq1uisP6cgmIr9xk6u9y7Trw5l8m8MB8gbS8pAZfp0tyb5CtcY7fzHcbCYMhjo/HovxOMOFB3mH09hIRJhBLBW3SfX6EkSIyEN0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:57:55 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:57:55 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 06/28] scsi: iscsi: Rel ref after iscsi_lookup_endpoint Date: Sun, 23 May 2021 12:57:17 -0500 Message-Id: <20210523175739.360324-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:57:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f8c4e8b5-e860-4bfb-5f5a-08d91e144ad2 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: 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: H5u6l+hfcJ+XAgoPwRr/V0aYv+0Twy0v30rV5h8iEayZNeiaK53QhdAO8ZZOD+oTabeOASfL7ZKmjCfAHTilzxKA33VAtMLY06pKrJK1ho/aGsnj6NqyL+LK9NH5F7L8IhYokfnPVaJ65cvTpMhYUn39XIKuOFy1u0he7qetz/p7VVrUbFNLiKs8r/w0lvuJguYvUhMd5fbd99PTCIRVk6NyipWjzVdRq7N4enLiIcTOd/TqFcUfLZDmycvdiMl0W/01xB3WYstKV+sQo5SG6R+E8z9jvwYjOgCUgOLABmGjumLkuOG1IhquaWbFIwrYEO5phlTeQgyGNrvDapZsOYc60MuoZ2UTiqKQHtFXNx6CER1GW5vBpsE/XYhAYsanIq/ahZT4j2ReqIOou0gSts8MBRVN6YKdP3nzvS0S4svoWsog6zxP1zNCP9r1kLZ1QyWF355011sDouPq9ZqSgHipp88BrjAYwOXn0rQ3Fvb6m3iFVsXP6qnklvb+jfj6XzigjFViJgAtBc1kIMbVeUN2C6bNf0Dr/XeB48SV7uxdyeyyCtzrZ7a68c1RD8dkQ0vYAxPwvKBhcnBu5OrTywlYzr7AEpjymDIJ03/BL6jBFanUr0bDKvr/Jp6SrTXx/zA8OEThnfJfiPwi8485cc89KR6eyIo11SBJcu0jD0/EwXcz6LbyGom8TTW4ca7s X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(30864003)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QJXL5RXhjxDlLroJTaYesGPtWBPVdOXaEpPCoCh/rxE1MHMPkJpQ0/nIx5gEo5NSk2ENFAP6dgmjTj1Ag/cTYOOKE+gFu6B3BFaLBZS1OD75yfLNamwsiYBaVKv3WNSvecuYqiSLTPKw3JIB728i3zkTR00o0zoJEN0hIxZQ0ttnIBU1J5tI7zbScdEd1Nc67ftcJnSAH4wQQUMESHkbsMnU9aGmte5bimDnSGPAPv/iPZEBfPpT1W3DKuKeaM7bSQnWeDYqMRgmpugRd795AbQ6tsF2F3PKEPyYnRNlOb5tQUURRZER8HinVmcIsLqgk+NrN45rJ0G8T+dspcvQW8gyq1s/fAYh3XEoRWDTIn0CtZxuMwNKYQE7zf5svrTdtYhx+6PhN9qYPKkMjkVMuBvP8Uu3gQUwxc63ps1HpPUwJGc5lJjzZy7iPVnUEcc+Rt3A1qdTlHV+H4FqQurj/Jj5ih8o1gZxEpU+yGZ4xqaTN1l6k9mvCxg3FMxQu4HohTsNBqtpXNILbucnUDbApTZedrRnG/bcMBX1f6Cc0Aahe1O/1xOX7OBiJSPHJRkGb8M/F+BcCeq8XuazS7p6LYa9aBIZSlFvTb5f5i08nOYqtUFAXLPDhP+nx/KEOtmoIp66UEcsh1V6gpR6d2jSPSuXwVkn6XIwaT530Kycyeq6UrHnkcoJffR6ObIo0P5wbroHnD/7xE79ANcldoP9YKf2tH/JkR7iqQa245YAJ1sEhV8725t8S/oyH+/YxHGN1dvntxJLP7MNIAeH8ljGQ0Wwz5fIDG/dxFRk4aynvlCmdWTgmptJHxBlwXQv2dLXd1NC4R3DjEzYLhNEabluIMqr+bLj/eGZWNLFBlP5l8KN9Jzyg3tBhZnFixwYFS7eqj+F86TqIdB7BXdtXaGTl6zD2tMEDwvingBS4Ub1gUNN9PX//x65h5xIU9GENMUq9xotOwJhDtzVSF390PWD+BOQX7cobCrq3WXgjT1XG/+xHvSRlcrNTCdvDkJAlKmGMUj9Gi3N/G/+4MWhB4D8849vFHPylbksnp1C1AJeUVEGw8piJQcUcW/o/Vp4SP5XNxxNcAD96DA2/dUw1oSS56ljrRVLGpLIp3xii3jtxgLkQk38WvRLO87GAc1NLXI+ujiex+SqSuXn71cxbdmj68RfkcYpUflNBcWuPHCnb074dI0uLEqwOUsIQQLy1gKAuwlUB1FXdKzi+hTuZ3nJFLNdh3NEgsK/Sxk1fZxrpxwxZOsx9S7rsLcyy6ucA0o6njUgb1xC6hv3IKeb6Aqdr6cptjKwZYRLGyVeY7b2rk7EQR/DKwA8Cle+KhWeChPc X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8c4e8b5-e860-4bfb-5f5a-08d91e144ad2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:57:55.4365 (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: qU13LF6NLl5Af5UB5ATRtczA5zJVFIyjLBaWW0BLt6zPsPe6kLNTu4lO3rntE8rCoi4HczkVX+bz7mkTVeGzrGOfSydnGOPg9GTSEiIpcrQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: vXf3TqM_irdVqyR0tY28hncwlB-FRuRs X-Proofpoint-ORIG-GUID: vXf3TqM_irdVqyR0tY28hncwlB-FRuRs X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The next patches allow the kernel to do ep_disconnect. In that case we will have to get a proper refcount on the ep so one thread does not delete it from under another. Reviewed-by: Lee Duncan Signed-off-by: Mike Christie --- drivers/infiniband/ulp/iser/iscsi_iser.c | 1 + drivers/scsi/be2iscsi/be_iscsi.c | 19 ++++++++++++------ drivers/scsi/bnx2i/bnx2i_iscsi.c | 23 +++++++++++++++------- drivers/scsi/cxgbi/libcxgbi.c | 12 ++++++++---- drivers/scsi/qedi/qedi_iscsi.c | 25 +++++++++++++++++------- drivers/scsi/qla4xxx/ql4_os.c | 1 + drivers/scsi/scsi_transport_iscsi.c | 25 ++++++++++++++++-------- include/scsi/scsi_transport_iscsi.h | 1 + 8 files changed, 75 insertions(+), 32 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 6baebcb6d14d..776e46ee95da 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -506,6 +506,7 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session, iser_conn->iscsi_conn = conn; out: + iscsi_put_endpoint(ep); mutex_unlock(&iser_conn->state_mutex); return error; } diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 51a7b19bfffe..8aeaddc93b16 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -182,6 +182,7 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, struct beiscsi_endpoint *beiscsi_ep; struct iscsi_endpoint *ep; uint16_t cri_index; + int rc = 0; ep = iscsi_lookup_endpoint(transport_fd); if (!ep) @@ -189,15 +190,17 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, beiscsi_ep = ep->dd_data; - if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) - return -EINVAL; + if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) { + rc = -EINVAL; + goto put_ep; + } if (beiscsi_ep->phba != phba) { beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n", beiscsi_ep->phba, phba); - - return -EEXIST; + rc = -EEXIST; + goto put_ep; } cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid); if (phba->conn_table[cri_index]) { @@ -209,7 +212,8 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, beiscsi_ep->ep_cid, beiscsi_conn, phba->conn_table[cri_index]); - return -EINVAL; + rc = -EINVAL; + goto put_ep; } } @@ -226,7 +230,10 @@ int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, "BS_%d : cid %d phba->conn_table[%u]=%p\n", beiscsi_ep->ep_cid, cri_index, beiscsi_conn); phba->conn_table[cri_index] = beiscsi_conn; - return 0; + +put_ep: + iscsi_put_endpoint(ep); + return rc; } static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index 9a4f4776a78a..26cb1c6536ce 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1420,17 +1420,23 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session, * Forcefully terminate all in progress connection recovery at the * earliest, either in bind(), send_pdu(LOGIN), or conn_start() */ - if (bnx2i_adapter_ready(hba)) - return -EIO; + if (bnx2i_adapter_ready(hba)) { + ret_code = -EIO; + goto put_ep; + } bnx2i_ep = ep->dd_data; if ((bnx2i_ep->state == EP_STATE_TCP_FIN_RCVD) || - (bnx2i_ep->state == EP_STATE_TCP_RST_RCVD)) + (bnx2i_ep->state == EP_STATE_TCP_RST_RCVD)) { /* Peer disconnect via' FIN or RST */ - return -EINVAL; + ret_code = -EINVAL; + goto put_ep; + } - if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) - return -EINVAL; + if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) { + ret_code = -EINVAL; + goto put_ep; + } if (bnx2i_ep->hba != hba) { /* Error - TCP connection does not belong to this device @@ -1441,7 +1447,8 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session, iscsi_conn_printk(KERN_ALERT, cls_conn->dd_data, "belong to hba (%s)\n", hba->netdev->name); - return -EEXIST; + ret_code = -EEXIST; + goto put_ep; } bnx2i_ep->conn = bnx2i_conn; bnx2i_conn->ep = bnx2i_ep; @@ -1458,6 +1465,8 @@ static int bnx2i_conn_bind(struct iscsi_cls_session *cls_session, bnx2i_put_rq_buf(bnx2i_conn, 0); bnx2i_arm_cq_event_coalescing(bnx2i_conn->ep, CNIC_ARM_CQE); +put_ep: + iscsi_put_endpoint(ep); return ret_code; } diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index 215dd0eb3f48..dbe22a7136f3 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c @@ -2690,11 +2690,13 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session, err = csk->cdev->csk_ddp_setup_pgidx(csk, csk->tid, ppm->tformat.pgsz_idx_dflt); if (err < 0) - return err; + goto put_ep; err = iscsi_conn_bind(cls_session, cls_conn, is_leading); - if (err) - return -EINVAL; + if (err) { + err = -EINVAL; + goto put_ep; + } /* calculate the tag idx bits needed for this conn based on cmds_max */ cconn->task_idx_bits = (__ilog2_u32(conn->session->cmds_max - 1)) + 1; @@ -2715,7 +2717,9 @@ int cxgbi_bind_conn(struct iscsi_cls_session *cls_session, /* init recv engine */ iscsi_tcp_hdr_recv_prep(tcp_conn); - return 0; +put_ep: + iscsi_put_endpoint(ep); + return err; } EXPORT_SYMBOL_GPL(cxgbi_bind_conn); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 30dc345b011c..80f8d35b5900 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -377,6 +377,7 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session, struct qedi_ctx *qedi = iscsi_host_priv(shost); struct qedi_endpoint *qedi_ep; struct iscsi_endpoint *ep; + int rc = 0; ep = iscsi_lookup_endpoint(transport_fd); if (!ep) @@ -384,11 +385,16 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session, qedi_ep = ep->dd_data; if ((qedi_ep->state == EP_STATE_TCP_FIN_RCVD) || - (qedi_ep->state == EP_STATE_TCP_RST_RCVD)) - return -EINVAL; + (qedi_ep->state == EP_STATE_TCP_RST_RCVD)) { + rc = -EINVAL; + goto put_ep; + } + + if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) { + rc = -EINVAL; + goto put_ep; + } - if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) - return -EINVAL; qedi_ep->conn = qedi_conn; qedi_conn->ep = qedi_ep; @@ -398,13 +404,18 @@ static int qedi_conn_bind(struct iscsi_cls_session *cls_session, qedi_conn->cmd_cleanup_req = 0; qedi_conn->cmd_cleanup_cmpl = 0; - if (qedi_bind_conn_to_iscsi_cid(qedi, qedi_conn)) - return -EINVAL; + if (qedi_bind_conn_to_iscsi_cid(qedi, qedi_conn)) { + rc = -EINVAL; + goto put_ep; + } + spin_lock_init(&qedi_conn->tmf_work_lock); INIT_LIST_HEAD(&qedi_conn->tmf_work_list); init_waitqueue_head(&qedi_conn->wait_queue); - return 0; +put_ep: + iscsi_put_endpoint(ep); + return rc; } static int qedi_iscsi_update_conn(struct qedi_ctx *qedi, diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 74d0d1bc208d..0e7a7e82e028 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -3235,6 +3235,7 @@ static int qla4xxx_conn_bind(struct iscsi_cls_session *cls_session, conn = cls_conn->dd_data; qla_conn = conn->dd_data; qla_conn->qla_ep = ep->dd_data; + iscsi_put_endpoint(ep); return 0; } diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index 2eb77f69fe0c..bab6654d8ee9 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -266,9 +266,20 @@ void iscsi_destroy_endpoint(struct iscsi_endpoint *ep) } EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint); +void iscsi_put_endpoint(struct iscsi_endpoint *ep) +{ + put_device(&ep->dev); +} +EXPORT_SYMBOL_GPL(iscsi_put_endpoint); + +/** + * iscsi_lookup_endpoint - get ep from handle + * @handle: endpoint handle + * + * Caller must do a iscsi_put_endpoint. + */ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) { - struct iscsi_endpoint *ep; struct device *dev; dev = class_find_device(&iscsi_endpoint_class, NULL, &handle, @@ -276,13 +287,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle) if (!dev) return NULL; - ep = iscsi_dev_to_endpoint(dev); - /* - * we can drop this now because the interface will prevent - * removals and lookups from racing. - */ - put_device(dev); - return ep; + return iscsi_dev_to_endpoint(dev); } EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint); @@ -2990,6 +2995,7 @@ static int iscsi_if_ep_disconnect(struct iscsi_transport *transport, } transport->ep_disconnect(ep); + iscsi_put_endpoint(ep); return 0; } @@ -3015,6 +3021,7 @@ iscsi_if_transport_ep(struct iscsi_transport *transport, ev->r.retcode = transport->ep_poll(ep, ev->u.ep_poll.timeout_ms); + iscsi_put_endpoint(ep); break; case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT: rc = iscsi_if_ep_disconnect(transport, @@ -3698,6 +3705,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) ev->u.c_bound_session.initial_cmdsn, ev->u.c_bound_session.cmds_max, ev->u.c_bound_session.queue_depth); + iscsi_put_endpoint(ep); break; case ISCSI_UEVENT_DESTROY_SESSION: session = iscsi_session_lookup(ev->u.d_session.sid); @@ -3769,6 +3777,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) mutex_lock(&conn->ep_mutex); conn->ep = ep; mutex_unlock(&conn->ep_mutex); + iscsi_put_endpoint(ep); } else iscsi_cls_conn_printk(KERN_ERR, conn, "Could not set ep conn " diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 8874016b3c9a..d36a72cf049f 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -442,6 +442,7 @@ extern int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time); extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size); extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep); extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle); +extern void iscsi_put_endpoint(struct iscsi_endpoint *ep); extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd); extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *t, From patchwork Sun May 23 17:57:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446353 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 86FD0C47081 for ; Sun, 23 May 2021 17:58:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A5E2610A6 for ; Sun, 23 May 2021 17:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231945AbhEWR7h (ORCPT ); Sun, 23 May 2021 13:59:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38864 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbhEWR7e (ORCPT ); Sun, 23 May 2021 13:59:34 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHurQL155892; Sun, 23 May 2021 17:57:59 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=ilX5dcSbBylgPZkS5WHSZzC6Y2p79IQNH+ZVqjPKU18=; b=IBlFzo8tJZ+qu+85m+bkrfTk8ObiFKo395BSOolyZOwnEcGGS7SN2BebZoaBE1GC8PsS BAeyQ3eRN9EfdJaG7EzgLEjmoTTak86L8a/tQLWZK5n2r12eeSkAmBFa7gblENI6dbvt DcjXxnehOT1UZckRHxADhHlUmviwczPJmz8PtXnwQnSXkhyROWzBcCMA4oFjYKxsU4GP 55CZMFkPDKRAPRx7cqgEQtwTvrJu+2aqVDK60AAO43fbBmN3TVThp7q7CpRcYQpxV0yX Nrutex8GH6ivGqQcGhp6lm7XCcnM2wTKQQXVuYsTdWTzSAmb/QCZQQLSmH96TmOR0RrR oA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 38pswn9fq9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:59 +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 14NHucLS161902; Sun, 23 May 2021 17:57:59 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by aserp3020.oracle.com with ESMTP id 38pss3qbd3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:57:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=di7PeG+ZxXwBYgjSPO0Ikm+y1EFHnHAxML5Ta1r0MjyXsq00DNQdNupaqFwVUZDtWMHhcXIn8g94s/6U2g7rxHxy/2HdR19sk4AmByOsghXVvKEm22xjn8jYTwGBTgvWolGCA7drOQYL+Wru5ca51HOBwIm0XfSQ/QJ03/grmp+oCC8NPcz5lxC4FhZu04KCdRIddXojUKQ6MOObyJd9lc+SXM0cWcJvsGAftYqB+k0n5nn4cVlSX+kd116IdQkHOOzReCgl+H3ZTPjljM6ffMF10CNJmyR7qBUW4azlGoeDG9OoK+lEtJsBQ4iBspc4KSPH15s1qs+WRdkx3/iWjA== 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=ilX5dcSbBylgPZkS5WHSZzC6Y2p79IQNH+ZVqjPKU18=; b=Z09k9ggOS6924LEckix800TF1q+HVCmmLaJFP5JNf9QvtWYJljFj9s2ZPY5KbWrPJncT0rpHhxKIVAWLuBp1g1lovoGlJ4FFaWUsvEifljCgy032JWZKNqLeD0+dlEIch93FaPza4VcWizWt8X+maLlZg4PLFtvKw0gXsVrT6LWETIw5CUJkj1N6o5TgsrE7t6dxkez54IM+Jt5OwIZw35E2v+Hz14kcaZSppcywQirLa8Jl1YOOkR5PWYP5BlkvKieUI3GbV1/TDGS4XBR9iItZXbJoC/jsCQHRig3/Xds+9dedtOtiPZ8BB2bBEgBt5WsoIHQFBspwJsdHlcB/cw== 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=ilX5dcSbBylgPZkS5WHSZzC6Y2p79IQNH+ZVqjPKU18=; b=P7cJrNWInUqnWm33XFTxZtjUvxeVCnY6bCiDPxi7gbGXrgHxcQ3A73l3cOI5ySiJFX1jiIFNlPV2Dq29alJ2q+16Wpi8TQGu4RC4I6dGRHDT+l2PGYuyevJxNqEG7aelS2oFezczvNFdWCSnQ++I7r7asH0gt6mdUuI7/aodSUA= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:57:57 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:57:57 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 08/28] scsi: iscsi_tcp: Set no linger Date: Sun, 23 May 2021 12:57:19 -0500 Message-Id: <20210523175739.360324-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:57:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a5a3cef2-8e6b-44fb-96ab-08d91e144c1f X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SZut/tO7ch7Z5tDzQ0E3R39xsqyvhu59QNh+zQX+8xn74cWdycp7vdVDKVgGmYPRrK98oMwFnlwHHpULbXenTWnd7AytJw9yWkQM5NQ/SW4tmmW2Slc8VSWa3/0Vpc0EOaFhZJy9mOJFnCQ4CUavSHMd3A97+G3jHXcbW8iV5KqHsAPPAGrsHkFGq2/aeYzG0JJ+13gFaLn0yGGHTp9sbI73A1ZIzqFCiiSpgcrF/aIdIbrpsNEvRtD5NMiIGCvQLEnVUFZhYPcnS0jnwO64DOJiwlB4sP2Qsks8CTiHw9uYQOQwuc6v0JUDVeUCB1ecmH4ojKPmka0pcEPRr4QoBTDYtRvG5iguZRGy0+xqfkmhzarmRDoshgSHEpZziG3dKIExd3K8/T/vDiLyS4lBzPb/XTpvjYS0XDa62uKMlQDcaoCQrJ71xc3uM5l8A4Tv2kDYCGjBOaaXBlvwkM4RQDrO+Sor4OWSt2I10GdIG9QVU4cNwbwixvqa/7HcjxTxUICBG+KSoVrzYvLYiykQd8dQwyYO0E85YmyqR4hwgiJO6vYx5ADnKMPs+ppCEdkf0ypmNZ99oVq2US/rxj5g3w2SdZM0DxWOcRTGmH5RBw14aojgc5/lrF7h1JqdFqzLdpcJeSR6vzenA/LuafhxBSfFjUn3uxQbgiMJMZq2k2UNVUOcJUozrogR7X1W95wl X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: k2eH5IJjwaAGedcjyqsVPYITXrmXevXdKWkdHPn7hldzfskEaDB8RXUTeuw7tm2eIw8QXtp03gjwm5op2duKg5ypzlwicHRvfEl7d14F3x3/B8zK4ae3QofxIIrROHmNH8BVIUNnxUbxBZSgW21nAE6o/YPJxHmOkQ9sSRFhqMLlovx/P3b2F80wZzrsIEYl5LIIcXmcFehEtyWEyK/Lww/Nnw3cjn/3nDZNQQWNkBLqLKCxZnAn+pV7ZVhs8g9hxkDoLN6LNX0sV5isjgLVCCVR/7LlRzB1c2BQOREhhTmon94qL5m4h7I+2B5jMmzJBa+dmlE/YhBGBSC6QwR9vfYkJsUcNQMwKMnIXKYeLJmXFitlhjnCMbCB+c7mkvJ/q5I4xDHcjbDDFWg92x7NWcdE/6VjALLKLsxgjUR04e20ZbbJDr+r3C0IiqE0LEEa/QMVr7g5NfjI1J3VbkawY/TNtPEssf7TqLlY+JaJ95JGuSJ2gsgHz4NEuOjWXZ2GBS7mDTJOjrEIY5SnVazmO3zwG5edx4Dq9zRf1tggYSWnIIwfUJILCyhsfa6R3VB10cqXVMg7upJh9W6UlVGNic2xUkX0HTQXFJY/a3+1A7sYjNrawlboXPTqQ38P2Wz7WjF9wazkZrwnh0pmq8qGW45DRjyvZ9XqYK2wkO63uVavZfyFI3Bm8ou+x/BQyKUTNNHj8RWg23sfcM9bebjCbhZ8D1hm3xCKCvH9fpuqgZiXzXXJvqng46hpMin55eUeIXhzIk4/FWIG0fL47VaGLMtlFNKw+K1mawLEIZqIFvigUlqP437ktLrOC9BRieGCoiCRx+47wgAsNuwk1wvAegvduBQYTlky6soAe8Ht6p0Zj3OBhEqPm2pnAhEQuUWLjy2RINipj+NDXTMeVnyE9XhbXlm1anGCHQjhwZZF/rLKBMIDcEjCydsxiwm7PavLSv27UWndnTnwJxffLURD6rd/S2KPvwzVqWioH1HsbW2gdCNMiHFxY/8dD4pMGTIW3euYV+R2iRDqS8+8b0CxbZ57ts5XrcwWx3T2uIllmqrqgIyhw/0XjwQ7GAtAcUYA0trWJl2o1Tko7yc65A7MXGXIG2TYe/DdFpTsySm6OSLlJs370CA76eWTvO2iZrE8ENZ9MDUDAeR7+2Wi3pjGIs+YCtPtb2Bvk0aLdDQ6qofATpBz/Q73u88rNIXDfP7HJqjWu9hFsHZr6TZ9K6XGJpJgksaM93bBIrD1VRtX9HIGvCAn/4lnIpZmZpJxyKLbFHnYbMl1EPQRchLr1hjV8mUNngveoy/GVeo2S7xVNR1KHvXLzjJIMhP8wcffIFFu X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5a3cef2-8e6b-44fb-96ab-08d91e144c1f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:57:57.6952 (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: K7mqT6RGhocYiM3uiEwZBcZfmo3dkfogSjvh10EVJvnH8AnvJPGGQaFxH5xfO4G9xSINMqTIcA5JDQ9YVzU0awDwXYOYJHbkXgx6Kv+bDRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: -dzpgUy2E3Dxtoq0kqoXfiwQtmDlPd0p X-Proofpoint-ORIG-GUID: -dzpgUy2E3Dxtoq0kqoXfiwQtmDlPd0p X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Userspace (open-iscsi based tools at least) sets no linger on the socket to prevent stale data from being sent. However, with the in kernel cleanup if userspace is not up the sockfd_put will release the socket without having set that sockopt. iscsid sets that opt at socket close time, but it seems ok to set this at setup time in the kernel for all tools. Reviewed-by: Lee Duncan Signed-off-by: Mike Christie --- drivers/scsi/iscsi_tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index dd33ce0e3737..553e95ad6197 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -689,6 +689,7 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session, sk->sk_sndtimeo = 15 * HZ; /* FIXME: make it configurable */ sk->sk_allocation = GFP_ATOMIC; sk_set_memalloc(sk); + sock_no_linger(sk); iscsi_sw_tcp_conn_set_callbacks(conn); tcp_sw_conn->sendpage = tcp_sw_conn->sock->ops->sendpage; From patchwork Sun May 23 17:57:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446351 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 9C774C47080 for ; Sun, 23 May 2021 17:58:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FF996117A for ; Sun, 23 May 2021 17:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231948AbhEWR7l (ORCPT ); Sun, 23 May 2021 13:59:41 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46582 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbhEWR7f (ORCPT ); Sun, 23 May 2021 13:59:35 -0400 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 14NHt9CX154069; Sun, 23 May 2021 17:58:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=kQTbcS8BmNx7KlPX4lIOAQxv1ol8AxbvmNhb2h4N3bc=; b=fgI9q+ad98pljh0zXT2eI5G/CLFoL/iqZbiDAoaoJ9yxVyaANo0kv+FIedh4WA6YWooQ FteVlPR/V2+ojySd4CpDLQOkqD5fzqRH6y+51lLiS4V2vhUe0m+QJvimOK22WoXS216J 6vwlGPtlLXtQtQDOYBe/Lxio8ZXsFJUw8vb8l14L6VCZ4+gQxuGNmfXiAhK9JgQb+ilp F1i+5lUGs09bURX7n6vHAN15BB+UlxA5uVUZGHObk1fX3hHBVvmYOwpa6+8oOw4Sxi4A hFFgCb3ghd1zEXyJS179FZjLGzBj+Opcrz9qq/WCMuJQMliUUSZ2ts/vHHcPSB12L/qi hw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 38pqfc9jad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:02 +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 14NHuctq161854; Sun, 23 May 2021 17:58:02 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 38pss3qbg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J8YXmnlQAzUollQchznTYvXB5Jin7FUkbv7HTbDVQ7IS/Ihd+CSdjeOHfHPga3AQxrQ3xNKxYXSLZ/jppKRfLiMidtDO2PBsOJ7rUqEwp1Ou9c0yhYoS/CRFdOooQvWZFXIJXKcBHBJ+L/92SOanb+A2AppKok+R5a2j8zaKRHck1L1BnVScMXAPUjrTodpcc/+eQuCWhKE84ZMGTscVU8jUtqYRD6cfV7CFTW8emMTW5ogY14hCHG7/R8wkxNy3cUI6o9hLUZI923zngt8PYjGNmUzOyyqPCHB+uxkCEg9gSSCwX3ukUgocN3J2Xg6uh/sPDmWHZHJgnnyj+VaJ2g== 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=kQTbcS8BmNx7KlPX4lIOAQxv1ol8AxbvmNhb2h4N3bc=; b=MR63O2HlmqGrlxlL8OOV7IZs53Lc8XIoVz8oEnvTnxk40gkwtd/HIB2yY/1p0jNzdcJK0npAVTa9fwNlPzv3/nmin1+Kdx/s28s63L6lfxLFOZq1JdomlslQ+xZyib4VZGZ3TeQnk9Z437M62L09ufEtfq8Efj37yHkkBbbQn2V6bWjyenXaZQcXvYkrspWu6QOUw6Cky32uUCsXeQ0YHMP70iaMAYoRwPBMqA6IN9sKg5zRXOd7CFs5LFZQwxWC4T//IJsgCU3P91guCnhr0SO78BBAbGCOkK4t20wLVePBceGccssS68PCjif50bHRTOJ07uKyOJSOachQklBCVw== 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=kQTbcS8BmNx7KlPX4lIOAQxv1ol8AxbvmNhb2h4N3bc=; b=KO7fwMwuer9272jiEUhwUEUDsGgqPWn5Q+KdHVHCfFsIye/nKb8PUag1ka+JS35alcehfJYdzDnnat0bawlu7vI6Vd9cvKC4odpNxQa0NqdHA/fjd26wYPM1oN2blJaChezHjEuz2sLuJL2KOPziqNYNf3/AQ0EfgG5vGIaKpz4= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:58:00 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:00 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 10/28] scsi: iscsi: Add iscsi_cls_conn refcount helpers Date: Sun, 23 May 2021 12:57:21 -0500 Message-Id: <20210523175739.360324-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:57:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3800a52-978d-4b26-5cb7-08d91e144d73 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9B9arlIz15Bshpsa+uWUqWaV7qIIUsyeu2IMoDPXgpDYNbgY8Y1PIywW1C0AHktWeUOLxIudf0bHMcHgvgcxI3IGSJMOrw1OTXWKjAtecEb0ASr/IwOBGS5OlMLuxgcjnmBybfC6mR8VDYS78/QOfIwXZ5cJ7qgdnmJGegQUd667PL5GMJNlmZf7awQV9v67r1BdGvFinmrpjQ1aXpcJPOQZsP011WDrdbG2p+K/cpvy+oG+VwrbvIl5l+5zPs1eB+RNQuVTJY9t+4BgMeMTtHAGhk/hPq2frTLS9ZiD8BGZhtIjl6PW7JSkAYZisTyggRh0L3oVYrbVaC7b2HgPrE9reOa1N1czuVjP8/ss9un9cjzamcO8M92CyZfaTRvWFtN4Cu7/q4/KzQh16z5EZwI0+BZiTjK4AymWtvvdg1mUcFr3wlKs33TdAYN0izVEDP/RcQWtJteOPznPgMGsyInMe11AWSBW76rUlHo2RRnOB6xNCeM/lzvqiItp72uzzVsVe0jtomENJeFRceRs30iCJjUVubd84ENL4rX4dBpUu7LP6yn0/71ABKNmXjlF6IrrMyXBrmHLVV6NWo6pNduaucRIh37/2n1vy2DZC8adnicTkI+D8farjaqM4YLcC2TuuUaithbvnWYlAy1vQiZF5zR2zFnphxV8OFMA+xVkg4+hUf5bv16s1G1Epdaq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: EQqEeaneC9xjD3VlMdFWCRpA3prZOsR0RJgzoHFVmWp8i24XFqURbffYkUqJQdDKVLAGFfooceQ80K6evpeC6ZGf54LGS1ncc8ST2h3I4E8FypNHm6lSy5dKFevEgnG9FEn5GyqseiUPQCy5EKThz+i9a44a6axifS9tnq/0F8cN6tm12I3cP2aak9+0G3D/bg1UJRWCcT1atfZ3g071OM3fucRWo/+2snlv6Z4G1JCLQbMpkUsp4w8EZJxA9f4cM4+/WA/1QFUJv1oH/2Cai6sPmxSto1E1v/RHIFk+jbumX5l6NE7kbSvgDuaMDaKlpL6P2mXgx5I+U6ksohLJT1oJgD8WtUQ5AgmbUM7dndbcwbG0lxJFESWLKsD+8KKWfkP125uJvaQLSiz8vumoI5QKQqZUPq3nS37FbEbWFx8gU6QIEE0Z1pIemFfQ/IYvNE0X01bpk+LGcRqZESZU632uaiqhOyskJ/AjM9R8kOVeHEw27d8v6LCfmpqE8hQBn17ztl76w5LC3WahUfIW3QiVQH/rGYG1Un8JrAno13df3y4If8npX4h+BBdx6cb6I2TKJzdX0Xy4EGd9QCPtLWhZ/k42cCzkCbytD1jUbT0YrgBeUFm29RkKaVZ2WMPaLZvjYbgrw8kKv3t/2mfzn/kCFqedMzZ7J2/9iaJQ+LkkO0JqROML3UnpG+NxvQCu3IuPkWeWy541wAdqbpvGZpD67QgUkBIChxmKMkw5SqFX1e+W+ToTZ6uev2kUifyqd7OKJSmHWoXSKlzAEBD5aCjJg+anOLmJOFtXSFFxmOWLeL/aCPFK0HfEFLT5gO9O5jZLhM53Vmn36+oPp02h3nm6ZmW5v1Qp5IZ1TuL7sQeZUYf53Pmx9GzNzP63iTj9WPW18QRlLege7i06OAyImjUWXeqeiHKzXYvMclihM/9tJAJfFWQUeHocnh3cVJjPU4FtKeblsGz4DMz38A4FmpJENE1nQKvuCe5KQFbd/ne2d8gPKdr6tdPlJAsSHF1xypi7yNRm0ziTIuifFtVrAT/Ak+xhOnMxdL3aMPmGLg15VnndsUyHevIxx68HsZoPqtkdjuCvZJgw6Q0EajfMswf44DodWLfcOaSZGREJNcpLcxDgBQZhJmo3wEEFINb2eZ2ofRFwh61mgeQNxdWkvjDTUJHiIH7FZWJciM2YBDrVaLxAMjkUAAgXy3m0cbQFTt8788mSM4b3oaHxRug6VI4C41YAjv+fj+/wKFumktAZgbVMbBa2eXywCJ8g2iBBWt5PW5sBkEqhYIlxx/DoMmYh3N3dmcz/ElHamy00dnz0HaydsCc+Vrf4wVagd36Y X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3800a52-978d-4b26-5cb7-08d91e144d73 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:57:59.8730 (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: K0UOSUjM0rYvW0Admde5eCZPiN1C+GpRh5QaRy9gGdJLlOHhu56panzJU08RIZl2FdVqhKD4as2VkNuKVZJK460LzWHM3kHXy0a2OeDJECA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-ORIG-GUID: NuoZONbATW6rLlMqaoBakzXPmtNZjixZ X-Proofpoint-GUID: NuoZONbATW6rLlMqaoBakzXPmtNZjixZ X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There are a couple places where we could free the iscsi_cls_conn while it's still in use. This adds some helpers to get/put a refcount on the struct and converts an exiting user. The next patches will then use the helpers to fix 2 bugs in the eh code. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 7 ++----- drivers/scsi/scsi_transport_iscsi.c | 12 ++++++++++++ include/scsi/scsi_transport_iscsi.h | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 2aaf83678654..ab39d7f65bbb 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1361,7 +1361,6 @@ void iscsi_session_failure(struct iscsi_session *session, enum iscsi_err err) { struct iscsi_conn *conn; - struct device *dev; spin_lock_bh(&session->frwd_lock); conn = session->leadconn; @@ -1370,10 +1369,8 @@ void iscsi_session_failure(struct iscsi_session *session, return; } - dev = get_device(&conn->cls_conn->dev); + iscsi_get_conn(conn->cls_conn); spin_unlock_bh(&session->frwd_lock); - if (!dev) - return; /* * if the host is being removed bypass the connection * recovery initialization because we are going to kill @@ -1383,7 +1380,7 @@ void iscsi_session_failure(struct iscsi_session *session, iscsi_conn_error_event(conn->cls_conn, err); else iscsi_conn_failure(conn, err); - put_device(dev); + iscsi_put_conn(conn->cls_conn); } EXPORT_SYMBOL_GPL(iscsi_session_failure); diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index b8a93e607891..909134b9c313 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -2457,6 +2457,18 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn) } EXPORT_SYMBOL_GPL(iscsi_destroy_conn); +void iscsi_put_conn(struct iscsi_cls_conn *conn) +{ + put_device(&conn->dev); +} +EXPORT_SYMBOL_GPL(iscsi_put_conn); + +void iscsi_get_conn(struct iscsi_cls_conn *conn) +{ + get_device(&conn->dev); +} +EXPORT_SYMBOL_GPL(iscsi_get_conn); + /* * iscsi interface functions */ diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h index 3974329d4d02..c5d7810fd792 100644 --- a/include/scsi/scsi_transport_iscsi.h +++ b/include/scsi/scsi_transport_iscsi.h @@ -443,6 +443,8 @@ extern void iscsi_remove_session(struct iscsi_cls_session *session); extern void iscsi_free_session(struct iscsi_cls_session *session); extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess, int dd_size, uint32_t cid); +extern void iscsi_put_conn(struct iscsi_cls_conn *conn); +extern void iscsi_get_conn(struct iscsi_cls_conn *conn); extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn); extern void iscsi_unblock_session(struct iscsi_cls_session *session); extern void iscsi_block_session(struct iscsi_cls_session *session); From patchwork Sun May 23 17:57:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446350 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 C92EAC4707A for ; Sun, 23 May 2021 17:58:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADE3961205 for ; Sun, 23 May 2021 17:58:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231966AbhEWR7p (ORCPT ); Sun, 23 May 2021 13:59:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51874 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231898AbhEWR7j (ORCPT ); Sun, 23 May 2021 13:59:39 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHuCnn181855; Sun, 23 May 2021 17:58:04 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=8ux4Mx65kd/i1KInSfdt6Xn1YCS/XVlr3/BjEMLV3eA=; b=wbXTy+FzmjBn6MCOuNMEHivLk+7oXeG7ah/cvk7jiujCZ6TdogptNs0rPAERxDv0KmCq xLJ7bECqoeKeFwkm9Ir81gTkNX8Ph6TOYX1SHXwd+eTDaccOLYTkLPlpXCtQdjbtB7n/ 2Ege/YuT5Hc4qzREsfO/AxJWANb/A1StfIfT6EZJnVJZxezKUNEegy3cujsBKIVf5G3o 1fF4PR1+WkcfU5hAtXtqBZycDIpycJYMFO7eMM4mYBz/r10nX+Hm8bXzSfGoFUv9YUEi yLFFlvgXOcgSXxCTcjK35oMulGtjaA6SbiF1i9Q9D7Qh6IL67Dx7vKJeEsYEYn2EGNta iA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38q3q8ryy0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:04 +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 14NHuctt161854; Sun, 23 May 2021 17:58:03 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by aserp3020.oracle.com with ESMTP id 38pss3qbg1-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lG7NOIJrBNkOoK892qMWK9bAxbRL7mjPrtoyX/IKbWzwLcXVFz1n6sDUoOMndb/WloD2jRxmgElzI2EZ/uN2sklTYN5dWi+c0w1Z/78DSTjO6IyCDpKARcGndQ2pz9qqr2L6ufCXCoWqhXbru0yVPQK3z/1GCAbc3heWduZchpRRY96sLoNPb5FVrAgwcs64BvHkAMJTcesW8uT26sW+zMcpQOP0nbj0UpBbYxRwfkLBC4trTbuARNRBTW2uzOt0/emqiz2FWK1N3x5WvoAicsSt4+R6ZD7eNtVP+t3F87hFkaD2yuUpSVHdMxU79fbULqFyPX1of9DIK1Rbh+DrwA== 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=8ux4Mx65kd/i1KInSfdt6Xn1YCS/XVlr3/BjEMLV3eA=; b=N3iP76NsPd9efjIGKeHUZ9kc3wr6OuHFXkYtCp2z5YL0PswEkryriuFqN9Lj61QmQUJmy4J3/57GF+yzkBUvtB0f6S4xrRvd7cxp73UfZaOPSICYtbIQpLz9UKu1tqcR7S7ZMPMhnER/1FBhIPpt/tneo81XdpaQFajB9gOB1+s9y8nM/atNTdjkKs6wITkgJNfgnqY2oDJDnyhujANd4NFzKnhkGmCeHkArx6EjBNrSv6IZYJe+2O2++hRa6xdKOwNs76vw94ZRpDjFClF9IzbwGdFJnKEHi86k/BcokINuXPANyGLJQqG3Ux5qvqTGniaIsom40ofKGEv6fkDJnQ== 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=8ux4Mx65kd/i1KInSfdt6Xn1YCS/XVlr3/BjEMLV3eA=; b=MbxGBk2kF8yxsSkRG0+bn7ZoLHsqSqehEhUX5rww6jeCJDZWTb2zGWfm612qfjgTw9u0P/lPDonAVfPeUxFOQnwmENnFpoGsypnAXIJ5bFuQrRz2GSGQvm3gg4Neli6q8QXE0m61ucFPC25vj0TeQ/BRCWsmzzvLVu9TMAWi3KM= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:58:02 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:02 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 12/28] scsi: iscsi: Get ref to conn during reset handling Date: Sun, 23 May 2021 12:57:23 -0500 Message-Id: <20210523175739.360324-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0146beb4-8d3c-44da-ccfd-08d91e144eb8 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yn7WpqkuRZb99yTaUbKI2NVexg8TFFxyWvCqZeoAJHJd469cmexSqZEvtp2E00zqPE9rCdb47MXQQkQ4rDB3lv9ik57ei8H3dofHTEIeBlwCysfJC/5r2HvddrUbTCOtVf2oAa8hqOcWnwB3tRHHZ+W5yoofn0+bhrf9odyAeBIE956DAGcZyaXkTQJKJzIEn3SN/gyrySFH7gqkm3E18GhHeKeTKqOYbd10JAtuT+xzTwO+y9H4UTd428kJ0kq8j+MKFTJDTE/y8fnxuJgSZOgFr6zP8Rw1rekpQDsLzP4Bf87hruKJ4MaxhwI4TcfyGuIhUa2NdYnD+cbQ6Sujhvp1vCZix7NAE+2r3YHiQXStu42J92mzm+NfffYHZEkfxR1DO0espaHwjp6Qt0EPqQ2+cRIH2LPqbeoA9OD8wX5sxYXf45fv5Ftv7KKZiHq/BoysuQNQPJV9G/y3YpBQFifo0K/IvUlYOcaH6jq8o90T/sls6J+TSpzLcV7lUmQ1E8w48j6iaSwFE3OP+U8W+m++srdCUUkfF9u1S828w7kHQI+8IbGLVCEt/eXULFpdpngba2NeYx7mhpUTuAtmweloa1jyWGoSuM6uiDKax+gRqGlxttxi9MZB+W5NrX8Pxa4USp8Bd9OskI71Q2+zSG7/3xv8dmTHDDV0XHSMpd3jUL4BVmhpkif/dUjwBbvM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: d6Et8YHntJFdbql+kVcIVYgPsKVG6lMi1fOLYgWrVc7eLl1SNGkKuB5woKTG9OlNjaWk8iy4gMd2dsX65YbaHum/KKpizlUxvQ8cq7gwnQfFSs56Fnrppze9vYgblQHKeYj74BYeKL84+Zl/zw5o+MdTrN3ysGxD6bffPZPQo7jVi427Th0eYtJlOc5mxy5AFXuLyPUnXuRxsjRGIW7JY+v0FKNl+bW2puCQGoCbCZe+f0KlbUJ0+XKDzhpZ2aaGZOHzISslipEb4aSNxIODRprFw5G8GVtU9VnAU2w/e/JH8x4U9DhFcDwG9AdgC+KZzlX56Vwef3EHIbe0LUcqyqO2rOJLEr9GkoFZmAnz/gTsfLjKdy3qqSpVYloMnvApYj3QHfT7JkSnaDi2IEyE6TXC9QaxW3BPYIyrOBbBUyYtDDX7KYdxzYaBqJtEQeBlaK0xJFZ0P1YOEfqHq670xDEUG/mCVcSU4uBWX4bfqtSs0Aiffc8tkYoFmUYo6NW9zAejXS1+kxTxJx2hDj5JcZuZdv46AiAOSvSwbokzqhx/XEymWKNK7+LY3vCfujnrZH35JMNS5txKZUbnTr0BW2Aj7ZBn+ArqkuHrJwZImxE+eYuee3W8oEeZk8FftZBKrHpk96ZR7gLet9BBaEibuQ08/axtqbcb8dcMSvWsQ26B7gFBVXj7Y0k/chwHDAiAE3n8Nf1ptWySSUt9uipQnql6ilE9SKJvYEOqNIiQwznv8K4dH3R11tyUhldiBDDeed2mTeF3Zq1SYiPORk6doyku/YmN2cS0FqIPLstM/uOC/xIv6aJNs1HYB/ec+iKLjuRYqL7dDrGKiBN/D05i0guGY9W2lhh1ChVttDP++/dVFyasogXuu2SGix/T+kxWR7NAW5YwN9WODj/Xx9cdJvZuHViW6N4MTJBhAYMVz8cshHwo+3fS2kwSbEizcZY8z/9IA6CmrSb8dKxVjsdM+rV7ftOZ+NI5KZ6Fxxb9MfJoL/y7Kx6JRnR4AhSIsyz4n8tA9M5TO0H6hsGc/3Gy3+TagWt7k60tmlu4Lnbtgnzc4WM3sDDe7M8NPk/HZ3+iUtnqDS3ovFU47fgZADgzSbT9feHyp3FvyJnj57tYn3uqr0bBeVSNKOesDvWvqhKz25bNGh85iAzDvp81J/KdFJ+gi61ln62Q6GpaYjcyhVzNUatXzrFq7jj5ET2J3x0oo9nvBMqfFavDz+H0FCoZwFMeQ95De//FlYHEYZ6FyWADRHOUd5TfjgTOZRHGt2uUq3wRLVNB7iN18lagc1l4LE2y1l/wH8ZOymY/wSauP1KraGL/ahDlGMWPcJS43XlC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0146beb4-8d3c-44da-ccfd-08d91e144eb8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:02.0068 (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: 0opX6S7scZobGSJxHO2ydn4BfSDSH1kvVo5uOW5XmF+YO+r6PEI06HZ7SlI+PHupdP+2Jlx2P5LDVG63AgRtcupJZiMkepzuh+NPFYg+eaE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: Kp7qyCJqsC6KTm1ux1F9wrQrCNLKHkam X-Proofpoint-ORIG-GUID: Kp7qyCJqsC6KTm1ux1F9wrQrCNLKHkam X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The comment in iscsi_eh_session_reset is wrong and we don't wait for the EH to complete before tearing down the conn. This has us get a ref to the conn when we are not holding the eh_mutex/frwd_lock so it does not get freed from under us. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 6ca3d35a3d11..b7445d9e99d6 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2492,7 +2492,6 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) cls_session = starget_to_session(scsi_target(sc->device)); session = cls_session->dd_data; - conn = session->leadconn; mutex_lock(&session->eh_mutex); spin_lock_bh(&session->frwd_lock); @@ -2507,13 +2506,14 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) return FAILED; } + conn = session->leadconn; + iscsi_get_conn(conn->cls_conn); + spin_unlock_bh(&session->frwd_lock); mutex_unlock(&session->eh_mutex); - /* - * we drop the lock here but the leadconn cannot be destoyed while - * we are in the scsi eh - */ + iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); + iscsi_put_conn(conn->cls_conn); ISCSI_DBG_EH(session, "wait for relogin\n"); wait_event_interruptible(conn->ehwait, From patchwork Sun May 23 17:57:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446348 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 A4EE2C47082 for ; Sun, 23 May 2021 17:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 873AF6117A for ; Sun, 23 May 2021 17:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbhEWR7t (ORCPT ); Sun, 23 May 2021 13:59:49 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38942 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231964AbhEWR7o (ORCPT ); Sun, 23 May 2021 13:59:44 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHw8Zt156619; Sun, 23 May 2021 17:58:08 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=/20VdN96OGP9PforO94u6WY2E6ORWpDvXUX2rKfJpaI=; b=sh2s/Q2WbA83K8l/qpalS/Z1quCfFnkDYusKsFeQhUqcIdZ8uAoW6DBDBvrQc//sGj9+ cVmATSHJJivn8vHJV8qFaLwly6Tes2mQVDo/f9QmZ285a1VmF0Uym+ErD5VLWhSruD8x +CJUNbT08oI0EQHYEToc51RcDrt7nMUekp+1mD2PQSoVuOkgSfj82Qh9RcBrdaDm+/IV vnwmf2ptMaYf+QmvsmhnHdZPKlweMw9glwX2H4k3Ap1oif6JJUx4dD4I9fbHVc4moo20 PwvVRM5Z8uYfr+0EnFm8xdFi4MTWLyzMwKwsqpr8jUmc2CNpbMaSBNPJSvdGSYip/4Ll rA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 38pswn9fqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:07 +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 14NHu15T119800; Sun, 23 May 2021 17:58:07 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by userp3020.oracle.com with ESMTP id 38qbqqjg7e-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lyDpr5HJKO5CcM1ag/jpDE5LccAakv8acrZY0jT0HlrG7afWSoiAxw5mWaLoSFGbOoualm60AfUDk2R9uERZwUmwHQfTVzgJ11YVjqmh/c3sakS5ecBmhVPLFPNtJNO9G2Uj/PClWqBtDXqn9/FNiIpaaiXehnqDLhMgk1VlwNkKAM2VkinAnWnSSnGJXvw+WE0R3Uead/i7RHNvM5dIRDXJie/pfTFBZp8oZ3dj82vpUmzh1Z5BQ36ECSkdoK4LhCX+U5rXIC/Ezwc2L02D2ZrbW7htdonKM9XLnCzH0ygQy/J5GdoX6e+F9Nqna5KNMGsPdfm1O9vljB1mgaC9JQ== 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=/20VdN96OGP9PforO94u6WY2E6ORWpDvXUX2rKfJpaI=; b=Ec3v8zfVqFB6N8KSwMGWiBXthpytxKjssx3XECioLQ3q7dzFPcoXAB7d97cZnHukSoeBh3w07QEFgzhUR9lUyvbilO0DNaaG/WrJ4qrBrq0j9Wf7AjAzZVZ54XTUd9eUA1avXNLQo/7jYW9GfVGi7SE3GVT3JHcCFXTBNQOnD0p4ql6lpPJbNZQdciiJKyvqAkNLnIOvliSntf7nkMjuTnH3STviumuhyw8SaEbXOXAsAAX8lHrgIpTFqiSLSXsJ7Vxd0G6t/apusBj2inPNQKykPuNGm/TYdQ6yPn/aprMJ9GbNo2sQuuIsyIVTRyj7b600voi511wyvW+9eyaN+g== 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=/20VdN96OGP9PforO94u6WY2E6ORWpDvXUX2rKfJpaI=; b=yrVOD8Q+CFlxP9OUVi6zU2q+lu8lBb8xQ8V2hIKWsIE29R4U0XaWVBeOP4LhVldL/V8+tlItVRHMXgB3vkr/em2D7Q4tGskYAKcnjjqs1DdO9B80UNNhCTwJK0/Cr0xJ2JVh4GLSkSaANPG8z9Q/ACHSWmqfAXrPBiqJG4zoNj8= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:58:05 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:05 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 15/28] scsi: iscsi: Fix completion check during abort races Date: Sun, 23 May 2021 12:57:26 -0500 Message-Id: <20210523175739.360324-16-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f3b0289-559a-4221-f4c3-08d91e1450a9 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P/TmowlLkTE4LLFKoD/B9/812FGeUTcbNPvrMlfqTBsJ6qXQL7wGx5TLvkTKT7KFVhkUVLVGlLYhhU94A+C21xNE2/37bS9/E22NuvyrLtcY6zASq78fVRuphzIP0tVWcip3FSZ4O4pxoy4FRBSsAY2vOHaa1R0B4MscndKZyIClOBFT+HDkEZEpehj67BeXqhWE4mGFIZHnnC/XNO2wJv8WXiCapSRz5Rw2gSkfySb93ggNsGPojx79Ywu0MaQIaFWkFQge73R6jIk7aaGWnUyPX29XNMixJ5scXBbFZinfHTQlW3EpaDZ1Ud8DetFxcn1ZQM4WN8HMMHVJQdIiWBjujbUNhr/19HIGX6M+56Z+tC6U5vsMVrn9zcwaKN3K1dB0lxvzfFc9RjYt1OBRLoqzSBbogUDaD1H9IlPcANneOgCgluME0F8mWUD/05uHP1g80i8Dp1ZNGlSmKhsfqW/1izZglQxRNih0vOtnVXl12d/tFTsJiAG+myEPhRfsQ62Q/e1YtGxtKtMJqYWf2Y3P9DIJg/u52n8WFtxAKaSJ617iQNeH7edGD2VqNEgtjUKgwxIeRH1GNytrEGqOYiPVWzSeOEEW6RxP2mNLbMaLwtnJpv3zH7V+ZcMCQ8xms004nBRnXV+ncKIuRYx1FjBRSiAzQAKqxRXwTxDVLW62F9yZhpf7ThvYJFXTKmKa X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(4744005)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qFuEmfRQe/rm1mXwoKBTeYM7h5ww+Exk1iqEZWpparVM4EjjMh6aKklf5jLJ6yd22cDQePbp8EximHezlzPAOXwpXKbllQ5VSbKFWmPgfinID1dMkp3yc+ZKd/JDdtNhk+rERrKKnhBItpLYfmR3oPOon0ZVKgyoqI0f4bGpeANMLDGJOfVFdlEq+xv05bzj+86qeOPIEy71uKMoLu8s+0aJ4EaXzGBKmok8C/clOQyNMnLAghVqEAu46TlecZOOxnazBAg/AVYFKoMK3sHdrCEMps7fcqZ6ZEemyS0NpKYijjMeTu5MYeXhIq42Lb0ZO9eA9rs+fz5pMkj1Izx0g6jtPEZSceQNkg3eaA5KXtRt7oo/d1lnv3uSsuIQI4z1PDprKDukcYGsXzw6lapzolxxV634x2m0sMH6G3s1SH2s0pdoZiR49XDdoH8NPi7/OCN06EUuPYf28x5LUa/zeQ6ZuO8RgL8k2dotY++7+/GDuI5XF2Oy7b6pubkKSQC/hbZt7bLRpuJ0nfnykGaxiF6f9JvaWpjhtrWlIr/sJ9OkYXVuEASJvlKcuj9w1HRyj2cPqSL2i79lrRoMEMDdR6KlBYklaC+oMzzuxO7R7k5eAhCQmUgLZlNkpVDW+zURb+lCK22JSa15haZTaVJg0D9yH+zllSlHM3X8ARfqWeiyG3f0xlB9uRUI2/a2gt7ZQPjD8PVvCZTbHHLFYW5OXpLcBPY8YBzNEK8YO1MwUhKVx6EZ24ujxXyh9eb9cxOa3qAgF9MbJ88U/t9p1/jz9DI8WwTVg8OKHGwMx7RTPh0GUAsOVpkCU+fW6ozBPClRR9MKxqCKcCqOzfmm0h7MEL/9WZEQwDNlbhtqN+L3dkUfi2X/qFN89BaUvnDfAJLtJP09fC+QoRO/O3ebCJEwLw+uFD9MhdpZcQyPz3+AjgEZjeMmXnRmTqRIM9anFmGQLEyWWfM3KD2jPPCtZYXxSadksRWq7Pkl4ZwvMGEuXCUBGKkDiea2PL+C1+hr0Ccy+nFU4oPHpSZEp49pBLEA0tdINHCdZzxunWpKHumpSPFtmoTBadXEbkaFzXvxwZozJOk0/BCcihhAYOpTuzZgXFvcMco0t+UCc5f/MZ0Mpn398e+Vjc7G9YJBSqLTGAVi5Vz+l9tMQ6zHp5UL7iWPAogB63QsxOmKmBr/2p9J8e15OVcsck8T+WCZITrmY6bq0CRpsXHCf80W5Hiy1UlaT6IFB1/R5fXd9rT3yaDd/e2JfksyBJYvV2xiC1CREGxuNUOKyR+q6p3OyCPnvo8LTru2IGMiyK+cHMx20CS2qHpKIXh10jWa8jF90KtKIsb3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f3b0289-559a-4221-f4c3-08d91e1450a9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:05.3219 (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: 05KvSkVvCmhs/wooHFAgWCohmkiVuU41Jugu/lC5rzF07x6jFVwbakIdXzhfYaXgzrfasXg2BbT6c+X6WsTBAhhEHJrYApeH54ShB2rdBOY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: DeF5iz9vTSiqubwFeXUyALl5bpEEm1ZN X-Proofpoint-ORIG-GUID: DeF5iz9vTSiqubwFeXUyALl5bpEEm1ZN X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We have a ref to the task being aborted, so SCp.ptr will never be NULL. We need to use iscsi_task_is_completed to check for the completed state. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 94abb093098d..8222db4f8fef 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -2338,7 +2338,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); goto failed_unlocked; case TMF_NOT_FOUND: - if (!sc->SCp.ptr) { + if (iscsi_task_is_completed(task)) { session->tmf_state = TMF_INITIAL; memset(hdr, 0, sizeof(*hdr)); /* task completed before tmf abort response */ From patchwork Sun May 23 17:57:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446347 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 CCD65C4707A for ; Sun, 23 May 2021 17:58:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B30F461205 for ; Sun, 23 May 2021 17:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbhEWR7v (ORCPT ); Sun, 23 May 2021 13:59:51 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35860 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbhEWR7p (ORCPT ); Sun, 23 May 2021 13:59:45 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHuWVc120959; Sun, 23 May 2021 17:58:10 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=yXvDvcSucPU2YWH/vVFxBio3rnH3jgORZPLMOzQD2jk=; b=YFkWmBANspdhbl5vDg1Yig/pPkiOSH8NkhH0Qykt8V/UoB93owR5H1I3W/tt7JIYkkML R7LBCeH+2ujwmgI/YFMNAce/ND0tBOvdjrgmdBQ9vsN1osTPPsz8OtVttKG3E++JgH7o Vb8k/jrYmSwtt3cBdE9jqSEGTa9aH9y8OBuEmTfr28P066TQHV7hLctjHm3em4e0Vglt XBnGWPlbCQPs9p/nHiB/HBXsrGZbLCjeJ1R5lFIOHVhweBQc0WQnU//w/RR47IMNu3Ax SrEGCjCZ/6fsmE2lAeC4GxuOBs3TaxZXimkXkkYeSHlTeYHf5NzvuPVhMtmDU5EiM+nb BQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 38ptkp1es0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58: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 14NHuctv161854; Sun, 23 May 2021 17:58:09 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by aserp3020.oracle.com with ESMTP id 38pss3qbn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GtdSbrpyML+/URbgWuK1BQYeVQW5Eku26K5QvDlCxl3wkeiOkQKhbl2UsUYdg6d1lMkdj5Sp5Bomf+SAQK4fqWjKFZTfNwTujHwPgFPKlH/tmVR8U13JyRELhT/uw/Xux3ExQWsphAMUljvJsbTFF06215bGOPYSlAX8gxYYIWFeHPeIQKaIKjbKL/ROD6v5wtOAuodGq4SnyIq0yK131vhpLNcDnKhEohstqvj4eo4mSfPNp5u6B4VCFHRfRGG8hyuN13CZ0wLF8YeIFp0lPRIs7BqrKAJGGxPxeJYq9pviSccItGzXERHcbH7uRV/59xFD4iGFtnal+3bx7q6gDw== 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=yXvDvcSucPU2YWH/vVFxBio3rnH3jgORZPLMOzQD2jk=; b=POwElUPHuO0sFg3x7IFWdcO4uNbAr4kpBvaR8PfE/pNxiQRgABMjWbL5eQhCl0D6GMdX9xlmCgOEHHEFfBj/pzDoZBd4IET5vMnUD9OyCbGd1TPHHm3H+5hmrNPHluhXUz1Xs7HFJGkPEPO6Neesse/h+RkPIp+WgGV1dzVSgeSm8P7UZ3hEUhY1uEcgMhH7v4E/M0wb45iQYdU9fiFGz79OzswfKCAI0Ft8ZaWewuX8ScJTpnqGRSby/h4+6+lt83yQ/mSIZIs4chzYNt8dhwEi/b1iswiqYrOmpmOCuBqkJU+VqYQilaZ+n/UnzcR6zZiVxy4O3tT5rw7lft5ISA== 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=yXvDvcSucPU2YWH/vVFxBio3rnH3jgORZPLMOzQD2jk=; b=jrGG2qOM+pntMuM4fsERtMBajZP6P1TLyZHI2jwmK+ntxyyOzzT19Q0v/o3Wr5UQe+DFspzkXDfYlSGDyrh6KzIcDJxprIEqZtIP0mApztDrdAASRolPU89qnIjGu6/SFJ1ErAnuQqYmtXFt8zyhmnIaBZlU9z1Rmsx2YyoPdvM= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:58:07 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:07 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 17/28] scsi: iscsi: Hold task ref during TMF timeout handling Date: Sun, 23 May 2021 12:57:28 -0500 Message-Id: <20210523175739.360324-18-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a92568bb-395f-4499-b5bc-08d91e145208 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: 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: DGs9qeLob/zsSqqmM6NjDFg/wGZu9E0GLyampAAIEzYUANPMvyxTZ/nyrmipc4LeY4CxSuHy27ullxrDRJ42NJ4jBANqJl7VIuGPYjRKMA8PbcsDb+j8Vj+vbKWX9CmRzXAeH5hPojb3HiUxF79YwHXlqFtjbPMK9BTWDl32zXnXfIkpH7X1cj1i3TS9NPbWh4ChUCF4ivJASYUAr6MR3Q0ivFwYAZkrVLA6CMy4EOghvWdLHvVI/+f0m4mUcC9AB6RfXw2yW60eq/sHqK90t4Y9OUCB82JLRyrL0fHzmeveJMxSJ+wIQZ72wiwJ/31UQA8FqGFR6q0LGhpuBVI7JvQs/RhUiyhj5CmVRwxyECGiArwgz+1FdDuCby/9fvxdD0UevqvOqvYL7nIjfmk9a8r3kxMNMsfYw4F8+l6mxWvlq7hCvIxiyz+FBOHD3BhTHxqJ3Ogshxlub0IP8BQ4rI0RDrBwqK3Nv1YAhrMV/4AK8KUo1jMQSyuv4DkV86BeKMyJMeLuVVAq2FJXUl4kxU35JzHDPceKTn3ArMCA/fGarg1+ZUKQ2cvtvCWqYvV7Pt5qFMoxaiIONFUzFGMy26j27pJ2F4SJSNT41t8N2MAg8nhiBRJjOZg5EId2Dc/4V8wG1CEqY66cPSTVXYIRN0s3833vBZiP+R+oFrzhJO5OdqJlUNx3RPXGXpALf2Yu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kCBCgM01duprhk+y5VMy51FR64HmkOpzC1lgX0vRM79h7FLUL5lS0GKqkChcrAs7JlSiSLq+TNMNnJp78COhGQlkU1gfGQpVC4obHHCM+H+uV6EFHYtdX4C4HbeJLSyHgad4XxsRqxrzRzlQoRAmVzmLHBkQuV4rEFYNS/WmiYURF9EDW/aYW/2OBTWV34AD97ev2eQ9FHHf1xXSdVAyw4OV929Jikw+cPr/yUvF4XwpGLbcc3k1en6ZWsKengCcFlpZPL8HXoqtfcRYaPnJRF6i7oqbta8zqA7pZefB25S/yM+NP/V4w5A9dTSt6ybgjld2cHcKNeiPfv9dN5skEfPNA05CxXxbJWeLn4breSe8iiC/l+cYctHNFz4FaIM2Get2oqWliSEMXbHgCCqGSn1gXSA704JuXVkz0P+j4sRg7NpUgYn5+6VPqtCLuufLwpQsTQA5Qfe8pFIyE/0bllPZOyj8sSwoG+d5Viy5GvBCVyry7siCWmMCkJslHA/6/nN2Ev6fWLO/h9v7t4tewY8fv7ffIh/uCVx8+XGTuVKjEHQgxNStGPPTaLvStV62m2kdY+YMDncFvOrjh03waPXiF8nDA42VksopuTgMGPAiIa5hEdp3yPqDzQfPbYp0sfd+eFnjXLm/l4EK7oUIVbXSh4dLjmVWQVZpowqTK74QzhNoytadEYbkiKHsO4c6mkrEq75+Q54zW4gcYyCMvhvLgiTWIoX+4/ViD4y3NzNOjp3aXZj4fERoAYJSFZqvxIaN5afw2aQCtrfd0W8xHd/9VQdoHw3Cbo01Ld9r6tDTX7WikTwYrc0rfwvMh7XiujI4zmoW+/x5Glty07Zi0UKT8Sl4AEbjGPYTPgIaHYpzINoabFjTrjZu+iP64jmhZIf8TRJIVCG6REQ57cMfu6+KJsc3HA+dyrR2GXrIE9DVGyx17lGLQNRbMTg4DrzTdb0JykErjC8rJC/HzvX81AskkDkZTzix9nVzd0VePJNSWd1ErwyFMO18XiysRK7R6nuu5j540OqP+nhLTfUV7zRmjRZIMPKh8SEw9Y3HDFZ591Nj79BCQqHMK9EL6+MwWR4zirLdudgm2FvhkmOS4u2HsrYP+ZZGJFE1G6L64FrxW0ulqRkSJZBYHVNB3zF15GmD8PUQIkARjc65H+79miewOs0sQ0b24yBYz4dtCb+2UFpQVOWsGep+IU7nbHGmoQvUWwvek5zS3obOCEOXVihlM7pdlwcHoKkqH/JkLyY1xSbQKPIWVy49ELtZwmcPskjpHD29/EDS0C08aG4oOPswC2L/oi0SZyxzYzDmXsBOIxW0kwe2cWG5RwkI9y7I X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a92568bb-395f-4499-b5bc-08d91e145208 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:07.5386 (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: cqoNYb97Gyw8OwwlM+8IjAXxABKbHwn2Qm52mLobtDB9uI9g8E8tpjIs8aKX859MN7CoLtYQnoY7XFXtb4BFk/suABy9noJgaTYwJIlbbuM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: DHUx88w8sNhEPERpLLkwLipDUOB_tQ_S X-Proofpoint-ORIG-GUID: DHUx88w8sNhEPERpLLkwLipDUOB_tQ_S X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org For aborts, qedi needs to cleanup the FW then send the TMF from a worker thread. While it's doing these the cmd could complete normally and the TMF could time out. libiscsi would then complete the iscsi_task which will call into the driver to cleanup the driver level resources while it still might be accessig them for the cleanup/abort. This has iscsi_eh_abort keep the iscsi_task ref if the TMF times out, so qedi does not have to worry about if the task been freed while in use and does not need to get its own ref. Signed-off-by: Mike Christie Reviewed-by: Lee Duncan --- drivers/scsi/libiscsi.c | 15 ++++++++++++++- include/scsi/libiscsi.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 8222db4f8fef..9247f70d2daa 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -573,6 +573,11 @@ static bool cleanup_queued_task(struct iscsi_task *task) __iscsi_put_task(task); } + if (conn->session->running_aborted_task == task) { + conn->session->running_aborted_task = NULL; + __iscsi_put_task(task); + } + if (conn->task == task) { conn->task = NULL; __iscsi_put_task(task); @@ -2334,6 +2339,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) iscsi_start_tx(conn); goto success_unlocked; case TMF_TIMEDOUT: + session->running_aborted_task = task; spin_unlock_bh(&session->frwd_lock); iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); goto failed_unlocked; @@ -2367,7 +2373,14 @@ 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); + /* + * The driver might be accessing the task so hold the ref. The conn + * stop cleanup will drop the ref after ep_disconnect so we know the + * driver's no longer touching the task. + */ + if (!session->running_aborted_task) + iscsi_put_task(task); + iscsi_put_conn(conn->cls_conn); mutex_unlock(&session->eh_mutex); return FAILED; diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 9d7908265afe..4ee233e5a6ff 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h @@ -276,6 +276,7 @@ struct iscsi_session { struct iscsi_tm tmhdr; struct timer_list tmf_timer; int tmf_state; /* see TMF_INITIAL, etc.*/ + struct iscsi_task *running_aborted_task; /* iSCSI session-wide sequencing */ uint32_t cmdsn; From patchwork Sun May 23 17:57:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446349 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 A2080C47080 for ; Sun, 23 May 2021 17:58:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83703611ED for ; Sun, 23 May 2021 17:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbhEWR7s (ORCPT ); Sun, 23 May 2021 13:59:48 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38938 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231963AbhEWR7o (ORCPT ); Sun, 23 May 2021 13:59:44 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHw405156608; Sun, 23 May 2021 17:58: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=Z7ZbLnM+B++0OKzyUlOpgfFUs5xglmUncRUWYRecOfs=; b=JP+Gmz3atzSS3GcgXcoIOQ8pER0k76m23C8pu/RbgPXsWyFbTynHAJglwXU3tduP+NAm NST7sf+UjO43PwIitex53eY1ndv6pOnbbie039To9eAEp8IYuu9R9P9+9NiI9H3b6v4O F0cvCkW1n15UZ8/RJiw99d/LLulbjcVxYf20vLNefMw7qh/cehYlB2QA5n1ytXgAgN1h yMw2gtbQv9WuQWihFnJ8wyh9viObqs3Qs0HCFBOLT1uS+L5X8UlJZTyoyu4Ghe5yXFBc 3Sroazm8GWiu42dX0ON8zzGleCC/YkWVBVxpfRgY3e8ygTQfSHw0jP42VAYOWIEvTAa3 2Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 38pswn9fqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58: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 14NHuctw161854; Sun, 23 May 2021 17:58:10 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by aserp3020.oracle.com with ESMTP id 38pss3qbn6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQaMsscgzOGH/lxC4Qrl0WQCxGLCEchgwacDHhXfSRRn/vW2n9A+HahGn7ScBESAwKbkKMPqPAcqChgvD/poldDyBpJS6y+sJXg0X8gNGkmmVIHl2k2AAjQc7riBwEnho6VHkzHC2p7Y+7EwsGJxbkD3+vE83cBFDW7BZzkIDB/XU+3BCZUKvbVgWgDsTEpch2/zA1p0FJDHfYbUS95mQXwXeeV3mcwMF+fQ3ZzoPWiYnNVV+kMJNwSTahxDxtmbXxp2SZyLhZx6+06e5qjl/zaXgZ584dZlfJYMyWXvQ7u1F12wNM0d56v8PtFOIiDpJxL3piDOZnHcD8Dofc6+2Q== 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=Z7ZbLnM+B++0OKzyUlOpgfFUs5xglmUncRUWYRecOfs=; b=DEj9a8GxZpZ1gbVt06vUv7ItdcuCpV27scWcsWXyJLi4ih74yToZmnwKChV+o6KiE3WW2muehSUvUz1ppv/ZyL7FAFSfshLKqLWWlpvRAGduJB+lo14qWy7uSMHLBo64XaB+Y4T76KDoce/FiThSo97gDrdXyvlGVNeY4W0WCuU2BK/+V5Ef3lP7X/AKi4sUBedE/GqaDUJD2jqpRNqhKvoiDYOtlhLIjfBSpx5XSGCgSag6cW0a9IAp9eZTgqhyXRGuPcR5QlJEK0go2k4/zkuG3/ANT6/IEtnCZnlSkRqTxV1PwQTHEVBUhV9cb7IXH2DvmAa1VlDz5Y4K1VgqmA== 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=Z7ZbLnM+B++0OKzyUlOpgfFUs5xglmUncRUWYRecOfs=; b=PERAYv9r5UwDSKN1yZu8pJn5SbV+Jqyt97sUWi49hXYjC7cdHZ4hVmf/sdb+sRrZR9Ai9olsxNShizHw5+ISTiZAk4WlqzopDZC2tlJGftobgUQxRBHrbkmP4ItrVkZfZr+JzUaZCVnlBtYMw8X0eGViyxwFKHvrLdz6IhG5cg4= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BY5PR10MB4004.namprd10.prod.outlook.com (2603:10b6:a03:1b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Sun, 23 May 2021 17:58:08 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:08 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 18/28] scsi: iscsi: Move pool freeing Date: Sun, 23 May 2021 12:57:29 -0500 Message-Id: <20210523175739.360324-19-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7437c61c-fbfe-4328-3a02-08d91e1452a8 X-MS-TrafficTypeDiagnostic: BY5PR10MB4004: 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: GL9Cwr4qCut8gupkBOYWy7NPHq3oKS/UFzbkeY0LuqYTWHIIfDYpcA+VOtcm/FXrv+deYx0NvmGnelgGTSWWSXiBpZWINUsSM0AutfQpg4JWKuoBaGoyCtW20+zHfR5uumQIlRPvmawCSJQ2ZD5S2zC3uhAbdtpCdMnkv1TPWW0U8wc+YsPo7jO5IRfcoOvk+oM6yRgA4VOM3mGtky7I0liBumLbVOIFJd03kx4e5jmmnBiQRuVb/ITFNt9sXw/+Zn3AayTLWMz5FUXj6IzYd1d7Aa0EbrkIwT/sFYjfSuPYFCYKxg5o2Ka41iCqmxr1LOduiO3O+DhK80rV5bbvcMEbrKvS98Et3jEN2smIrwOPn7slLmBxYWVZJqBHx94yy53su99+7+571BciLXlA3J3YvP/wyz7DXS56vqaOodsSIUNVGZ9kmfyIJ20pQYrBJOdu9EBIMUNAl3O7GJbcI8mDLQrGNZLh1ZVgGF9L7z29uJrfUyz4Cj/ExKfmAuk3FYB7q87SUBaoR2LXn35rlM1Oca4fhmsj5aO3Nd6/716X1bw+jP6mCzODbzPTzRz/blp/jVcMOtmfmQZSCyo0b3J4HWDaEeUj026C7GRh+S+WBlNV1Zd5TC26pAlNG/Qh9n4IGtCtHnhiC+WI/HTOjYdL6y7JlpGGodwXPr8xAsmBKcDNFlp/+uVVcsUG/r1Q X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(366004)(376002)(39860400002)(346002)(66476007)(66556008)(4744005)(956004)(2616005)(66946007)(16526019)(478600001)(36756003)(2906002)(83380400001)(86362001)(5660300002)(186003)(6486002)(26005)(4326008)(1076003)(8676002)(6512007)(6666004)(8936002)(38100700002)(38350700002)(6506007)(107886003)(316002)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cejpfBKzMLvEJ1yhf33uXdiJ0htwkxWb8/3ELDo7AUhVyRTmVHdME42JnC1Dvb5CuMf5/92eKf/W6rk+eo2fMLfOEzPMJ4nsWVjW/8e3uxS2iHBKM2w2heuHreBDMSfr8h2YsccRUJITRftiqQiTjFhXBD5hWamuxWWLK+42SwFNcNtP+TVHNrN6FHl7A40hSBm0EbtvnJBGjQfemgf7W3zKv6uNJYM6xCMhkd+WOQn2H5V5044yviT+GnzhlvUiQYTvDxDQb+gMlCKbxcicdsWoNDMPdNUlh57XMzurp91ArmOGKpRDIhRzG89VGyLncjSzYnXFhFzuIAUuYGzkGWm69VK1Sob/AjW0FyWdQa0QfT6CVm2Tq/U72sGDi83TZTh8NQCKi3C/0RxM/4ZI0p8+nQ39xnAc6D46M6xdhiymZA+Ag0deX2LxG9J7vYbwY8fz6Xl6fiyVOss2OhNTyJBf2hY9ify3b6lJh8qD3njsOpP507Rk1Kqx6YO0fTtHKJsv1QMkt3kfl22RO9m+SKJJwCV/X6E3vh9b5i2SGX3s81wJdb4u1IXgM2c/Nib4aioKZ+wXyu+JnlFQ2y0BuGHXBeUSMNxM1BBRqTxLE9KGemgEXpsnsCNDyXpSs67pPfrKsuKwYQDkOfnw19QVCRSKDucM8/To0kKWYKG+tnqSB2V5B6JRHIUnOyZFvoJ1UxwFHYX21zy5Z9CiCzcATM9fWl0vH3uOE47b/tQxZvKiWNxEOCtT2WtqqoRagQTCO3t7yuMdBQRYkFhArg/fwPuLztgYyVXKg6AZY3Pss0vcXnEfSY5R8IpELw6gPj41MYSn5MXJwNk43iivlpVBx9POFfKaGMjg0DK998HQ7QHdFaX9pt0krpevct+pqzVO5NQVyWNYcGXfXdeJlQ/f/7M+lcYpXvaH+a+FZEDLWEuH1PrIyrW/8IOx2KIZsid6/gObeXgzWrxE/7OE7VyjatMoex/Yx7eJqslCyxGjSUUxIr7oSJON4CyCf12NPc/SCErOKWJX4cMTWtqB0QaMJvY9E/w1Ntgagj5nePUFjYCA+iXLcaTxrVh/7mdB4Ei5t1toRr9DqD7pOZ3hvbI2bm8/EvHCjClt060tStF0x+nyLO3wJF58d0D/AR2xRAoH/vVhUNcgURFewjIhFbg96RkjifOZ8i3TZa8DjnKN1IbwsutD5gLwCP0EcNIkqnGn+WMtjJvQa0eiu6GNwX4I94a4mMCErU9WdTMFXOYhDtr0H2JaTAJOP2Uyj8Iuyso8I77qmw9hPrl0DrPG6JLdZp9hRC+HS7qJUTOqYz8gE1nBizS/wP362v2i5bjOTIJs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7437c61c-fbfe-4328-3a02-08d91e1452a8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:08.6590 (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: puovSZhj1EkkJpMOo94F4i2E6Xwc9yjAZjxnOe2qKAFzjDTHODG3WbwePzc3VcU472tOydPJlJ53j1fautASdkYFELe3QdwoxaALwJamvy0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4004 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: E135UtxDJkoaliYbOfqdswxaflVhsxva X-Proofpoint-ORIG-GUID: E135UtxDJkoaliYbOfqdswxaflVhsxva X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This doesn't fix any bugs, but it makes more sense to free the pool after we have removed the session. At that time we know nothing is touching any of the session fields, because all devices have been removed and scans are stopped. Reviewed-by: Lee Duncan Signed-off-by: Mike Christie --- drivers/scsi/libiscsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 9247f70d2daa..baf2a6838c90 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -3001,10 +3001,9 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) struct module *owner = cls_session->transport->owner; struct Scsi_Host *shost = session->host; - iscsi_pool_free(&session->cmdpool); - iscsi_remove_session(cls_session); + iscsi_pool_free(&session->cmdpool); kfree(session->password); kfree(session->password_in); kfree(session->username); From patchwork Sun May 23 17:57:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446346 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 DE21CC4707A for ; Sun, 23 May 2021 17:58:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3757611ED for ; Sun, 23 May 2021 17:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbhEWR7x (ORCPT ); Sun, 23 May 2021 13:59:53 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38982 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231959AbhEWR7s (ORCPT ); Sun, 23 May 2021 13:59:48 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHtcuk146108; Sun, 23 May 2021 17:58: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=j/4EsnZfW0heAm92Pw5JPuZaTL/JoOg54DIcYalCQ4s=; b=ZCTILIZOj2zHi/2V2CpvK3WroMygX474E2UrcOzblZckmhWQXx2b0CFyhcAoI/BUfAX6 497Ux7ECXTwffsxRtqW0L7EJEoXgYyrcC+8TGpXVTR3Df74CWPsRKbGaXVGRRDusCcIp P8saNFIpgTInz+NbKodrI1WcDJIp095H80Eh/1BrlRVp9eOt5OLzKizDNLiXphsEVhT3 rhChubd3VBb8HVx57k/NKDOjrGj9dS4uKerZA0fc+xl3Ckyctm7iuWXRnkF38dpHvZll lLhw0i91EdQFc3wG6vujZwDKFRKKk10asbiSSzSoT0K9rvcxz8ZjOGln5sWe6LemAoSC Eg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 38pswn9fqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:14 +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 14NHubDl161766; Sun, 23 May 2021 17:58:14 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by aserp3020.oracle.com with ESMTP id 38pss3qbsp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jy3qbsz5eU7xCPbwXbk+vpw1Nh9iIp2aFq1iHA7/fgWf3Ze2oO+4v7nlWvt6H51xJ8+FCspi77yVr2yi6tVCqjW4FLO4rTAK9lwvRhjZ4aWl0a4whipqaqcDFQB+ZQkVTeBolzglkqRPLpe+MqEjSsuZo3jTUvpKaGGMe881JC6rvYF5PQ3B7rHqjARDrWMMVZkcWdNn2rnKYF/QiWj/Iw5T8H9fqDjumPO15B+k1XYWwBxQPB/pxaXwyDGBl12ZwegmffcPneZeC/V/ifx7W+jEUBC2bKGV+LI+xKCHWaSZPseYtR5ZyeED9tvGgI2UFhv+4DMDAH9SXuBXwQxLEg== 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=j/4EsnZfW0heAm92Pw5JPuZaTL/JoOg54DIcYalCQ4s=; b=OhoemgBUh35TyA7BOQB6LwuqXVQ3GQBYibTyw9zmzrO3knRafRXXybmWP3xwDU2zGGTtrzICKQQfW4sAgA0jzYBLfcJTH+iWkh70NoLpElXKUM+b4O0BwAMe+DWp7nzmHj03HdWaCwwyR3Aib+JTnJpkjTbT/cez2PHo/inQzACIq2fN8yqAsviAMmtqWWh0qQbVLHVVwDuOVoSBhHpy8tGO0iAMkVqJse5HgKP5bt9DCfqcpXTJOia0ShaBBE7CX9PjCeB7avdG+xg9lMpPmSjLpA9HXB8SMVytzO3OsDKLtucJEPKMy5FmW/7PkD1WhwAMYjJYE805jXJYB0DUZw== 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=j/4EsnZfW0heAm92Pw5JPuZaTL/JoOg54DIcYalCQ4s=; b=XPxVfZ9u3GfmsPaQl47XDMv+tkCeWuaZ567OzPepiEFLxLzvrw9OpTlagzbwMhbeLgOYLdMhaOdgfTXyWvVIe1uRn9C9RAwAxVyOH5kvp0dD8AlZcR97Oz4UUKUeVJD2h26+3TSBnq1X67FWIgpqf59shVabRoqGB6/SP7W497Y= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3239.namprd10.prod.outlook.com (2603:10b6:a03:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26; Sun, 23 May 2021 17:58:11 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:10 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 20/28] scsi: qedi: Fix race during abort timeouts Date: Sun, 23 May 2021 12:57:31 -0500 Message-Id: <20210523175739.360324-21-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 597c08da-dc2f-4044-ff6c-08d91e145404 X-MS-TrafficTypeDiagnostic: BYAPR10MB3239: 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: h5PCCBz1uLyXQuEaBvkHAQiFEIqXdkZVM4VN/oE6E4+yKTfKUIcdf6UYoDQDgjOA4bHAueH6086Z6zAUTVf2UPhIiWSHGs3HQ0s7mjdRqEHExCIEoIZ5mLHmBXrGkU5u0ZvfQN02LdH2xVVufOPJmfvS7cEnq3F8pJJM8GS7VnFe+mlXdh8qP+JV505X92J+wKitbFJFoNVfRUIKaZfzTfda26sgkHqNSFCtZYdSNTAMhIxVikoCJRCMYy0h38PcU1oDoVT+uVj8xgepbyGAYX7GAs591tDW47dWSIBCnzKVArddqd4eKFocXcusGVf+GIxkjhdh3AKUIVH/OGnCWiZ7TcBa6+Rn4zUCyT46D7oMThpH3J2jcsz9Skp8oFQlJFEqujXCiP0Et/z1/Ik46Go8aieMVHdk2UF2JiVuwiiM+M7k0OWhDZvPR2k96LNMrzV4ouu58E8yDNyTzk2GlDlMhErsKAxVuvX7Xo1dueg+NIo98vXMRgnK0cBMLjwWbdmJBrCiJFDI0uKQv7sYtJZZZywUTz8aETfOur/l0VcXew/p0AJJC4a12RQ70FCkOlDghQ4rwYkl7IHmpsCFyrl6hQTGzxwZysXjID68v/515UspD4iOhcWc/7rpokQQAVUCk5tyssyeRViKHH2eFWw0IJTbQKBV1SkCIrDALabAnfVuHy03YQli+7tGejU4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(366004)(396003)(39860400002)(52116002)(26005)(86362001)(16526019)(6506007)(2906002)(66946007)(66476007)(186003)(478600001)(2616005)(66556008)(8676002)(6666004)(1076003)(38350700002)(38100700002)(83380400001)(36756003)(316002)(8936002)(6512007)(4326008)(956004)(5660300002)(107886003)(6486002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pT8vS8KlSCGs8Q4q1Bnz+hqL+EOVJYpDu/gx+cZ7u3/jE7RE1ZMSlyFaskyOTnr8Cu2cLm5Enn17BkRjHfIDPDWDrkiNsRbRChb7J2SCumkdogxhAJBa1tUz3Tcvswls+SFk5hYGkIo4CHLyjZeaoaJYOTE+9cCDP8jYEUVOQeF9uydMvure1zqX6ri1Ocpxn4exlArXyoAnwaXIbUTjl7vktdn39Pp0vEpU1WsYYy/3kTa+QShLTXYdJiLpIAiLfvPwFyW2ekjFoChHytvAC/TYOQuel6DXbHsWrPFLQF84E7/CFC9P7HFM5LMAIYto21Z4+05Tvb3+3ATYigaNxuJavv3gurzZddNMblaY2J6fTe5WqGTrSDCUEQXCOn9mkxY61s/BYha+a5WlzlZE8HOdJYmbHCUCXgvzE3b+R28C52A1diywugbigqsY8mSTa1bbydvCBD5k5AS7Ro6IJApTo219H1qtdn9CeQAYYyVUru0vvdN/qdR6xzJfzGAklignSrffXvpfpqSTdsX04v27K/17sfAn9Ft4GxT+VxvFmyXvJ/bWgLPmgOKZAQqSwU6tKVjqRD9eaH5LDCJmWCI9iSL0J5A2WqW540uncmBu7Yprbg2I98cpmQPVaLtZcYepxwZlUhVKGiabw6J6wGbOSrG9r+4FuOcJkhUmY8bWTogMDgpBGBMYvz5A3fW+545MYh/76yx1YfJ8YjziYrK2+R8nIK2zvmPUyKhWjKUokLiRzQJywSxNtEdKfiJHETfpk8MIlrN7YjMavP+X1bzxK+atsxqlMqC5gbHhTsqQ1JPCDPMHHSJe1EM52HD+kmZHaqr/G+R2jw5zjhPqvlUGhEtWb5aaBBS9cXjXP3OhoFnHMP9INazWUGE2cInQ7MqtegFX6vE+7gcS1sixzcmjYqd8RBxOlVIpWnb3qYwxihe3CHc5mQ/6qKPYVI+kghLjjoqAKkRCOo10Aooy8WKiB1q0parLyGzEAr5sP+XYoAEi5C3W8Lt22xtyyuGRhfUci6egHMxQ6lnCxII4sJ7O8tx8VkvalSuURbJt4BvG68Q04ShHuGFKS8E8YKtcff+C+yKdFGDMQibzk4/EiAsJ8/gmnxDv1rhBdxHKt2sCFfZgPw0VYUklKk1MvzOVyrCRmfVhIZi6uQQIkhKN2UNhxP0tASSUsWqM2E1VabFXxv/67r/ZOQesoZuncqiTFPCyghamiLBJ8CAz0PI85rYhpI5stzOnIKHQZK1dXajmvAyGAHy+kox6jzxWzHGy2g54GlDFGWZ4UpRQV4dIFmbmS0/2joHjHvz+r5Jzy1Xz17RcK7bMFYgMYfueebCt X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 597c08da-dc2f-4044-ff6c-08d91e145404 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:10.8628 (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: 9Mu2Nbqd3TXLHxAOgLTqhAh8R9X7kHEY9DAfh6OigKSLfIJtFq8q/un25XSose8QypZcXwUXTI1NdxeXTxow8y+cYEtXR3Ni0US8X1j6pzc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3239 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: UUrff4AC7GC8t96boG0yOrm459mOSorp X-Proofpoint-ORIG-GUID: UUrff4AC7GC8t96boG0yOrm459mOSorp X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 suspectscore=0 spamscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If the SCSI cmd completes after qedi_tmf_work calls iscsi_itt_to_task then the qedi qedi_cmd->task_id could be freed and used for another cmd. If we then call qedi_iscsi_cleanup_task with that task_id we will be cleaning up the wrong cmd. This patch has us wait to release the task_id until the last put has been done on the iscsi_task. Because libiscsi grabs a ref to the task when sending the abort, we know that for the non abort timeout case that the task_id we are referencing is for the cmd that was supposed to be aborted. The next patch will fix the case where the abort timesout while we are running qedi_tmf_work. Reviewed-by: Manish Rangankar Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 15 --------------- drivers/scsi/qedi/qedi_iscsi.c | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index cf57b4e49700..c12bb2dd5ff9 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -73,7 +73,6 @@ static void qedi_process_logout_resp(struct qedi_ctx *qedi, spin_unlock(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; - qedi_clear_task_idx(qedi, cmd->task_id); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); spin_unlock(&session->back_lock); @@ -138,7 +137,6 @@ static void qedi_process_text_resp(struct qedi_ctx *qedi, spin_unlock(&qedi_conn->list_lock); cmd->state = RESPONSE_RECEIVED; - qedi_clear_task_idx(qedi, cmd->task_id); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, qedi_conn->gen_pdu.resp_buf, @@ -164,13 +162,11 @@ static void qedi_tmf_resp_work(struct work_struct *work) iscsi_block_session(session->cls_session); rval = qedi_cleanup_all_io(qedi, qedi_conn, qedi_cmd->task, true); if (rval) { - qedi_clear_task_idx(qedi, qedi_cmd->task_id); iscsi_unblock_session(session->cls_session); goto exit_tmf_resp; } iscsi_unblock_session(session->cls_session); - qedi_clear_task_idx(qedi, qedi_cmd->task_id); spin_lock(&session->back_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); @@ -245,8 +241,6 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, goto unblock_sess; } - qedi_clear_task_idx(qedi, qedi_cmd->task_id); - __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); kfree(resp_hdr_ptr); @@ -314,7 +308,6 @@ static void qedi_process_login_resp(struct qedi_ctx *qedi, "Freeing tid=0x%x for cid=0x%x\n", cmd->task_id, qedi_conn->iscsi_conn_id); cmd->state = RESPONSE_RECEIVED; - qedi_clear_task_idx(qedi, cmd->task_id); } static void qedi_get_rq_bdq_buf(struct qedi_ctx *qedi, @@ -468,7 +461,6 @@ static int qedi_process_nopin_mesg(struct qedi_ctx *qedi, } spin_unlock(&qedi_conn->list_lock); - qedi_clear_task_idx(qedi, cmd->task_id); } done: @@ -673,7 +665,6 @@ static void qedi_scsi_completion(struct qedi_ctx *qedi, if (qedi_io_tracing) qedi_trace_io(qedi, task, cmd->task_id, QEDI_IO_TRACE_RSP); - qedi_clear_task_idx(qedi, cmd->task_id); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, datalen); error: @@ -730,7 +721,6 @@ static void qedi_process_nopin_local_cmpl(struct qedi_ctx *qedi, cqe->itid, cmd->task_id); cmd->state = RESPONSE_RECEIVED; - qedi_clear_task_idx(qedi, cmd->task_id); spin_lock_bh(&session->back_lock); __iscsi_put_task(task); @@ -748,7 +738,6 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, itt_t protoitt = 0; int found = 0; struct qedi_cmd *qedi_cmd = NULL; - u32 rtid = 0; u32 iscsi_cid; struct qedi_conn *qedi_conn; struct qedi_cmd *dbg_cmd; @@ -779,7 +768,6 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, found = 1; mtask = qedi_cmd->task; tmf_hdr = (struct iscsi_tm *)mtask->hdr; - rtid = work->rtid; list_del_init(&work->list); kfree(work); @@ -821,8 +809,6 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, if (qedi_cmd->state == CLEANUP_WAIT_FAILED) qedi_cmd->state = CLEANUP_RECV; - qedi_clear_task_idx(qedi_conn->qedi, rtid); - spin_lock(&qedi_conn->list_lock); if (likely(dbg_cmd->io_cmd_in_list)) { dbg_cmd->io_cmd_in_list = false; @@ -856,7 +842,6 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_TID, "Freeing tid=0x%x for cid=0x%x\n", cqe->itid, qedi_conn->iscsi_conn_id); - qedi_clear_task_idx(qedi_conn->qedi, cqe->itid); } else { qedi_get_proto_itt(qedi, cqe->itid, &ptmp_itt); diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index 80f8d35b5900..5304a028db0a 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -783,7 +783,6 @@ static int qedi_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task) } cmd->conn = conn->dd_data; - cmd->scsi_cmd = NULL; return qedi_iscsi_send_generic_request(task); } @@ -794,6 +793,10 @@ static int qedi_task_xmit(struct iscsi_task *task) struct qedi_cmd *cmd = task->dd_data; struct scsi_cmnd *sc = task->sc; + /* Clear now so in cleanup_task we know it didn't make it */ + cmd->scsi_cmd = NULL; + cmd->task_id = U16_MAX; + if (test_bit(QEDI_IN_SHUTDOWN, &qedi_conn->qedi->flags)) return -ENODEV; @@ -1391,13 +1394,24 @@ static umode_t qedi_attr_is_visible(int param_type, int param) static void qedi_cleanup_task(struct iscsi_task *task) { - if (!task->sc || task->state == ISCSI_TASK_PENDING) { + struct qedi_cmd *cmd; + + if (task->state == ISCSI_TASK_PENDING) { QEDI_INFO(NULL, QEDI_LOG_IO, "Returning ref_cnt=%d\n", refcount_read(&task->refcount)); return; } - qedi_iscsi_unmap_sg_list(task->dd_data); + if (task->sc) + qedi_iscsi_unmap_sg_list(task->dd_data); + + cmd = task->dd_data; + if (cmd->task_id != U16_MAX) + qedi_clear_task_idx(iscsi_host_priv(task->conn->session->host), + cmd->task_id); + + cmd->task_id = U16_MAX; + cmd->scsi_cmd = NULL; } struct iscsi_transport qedi_iscsi_transport = { From patchwork Sun May 23 17:57:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446345 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 279E7C47080 for ; Sun, 23 May 2021 17:58:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08FFC6117A for ; Sun, 23 May 2021 17:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232001AbhEWR75 (ORCPT ); Sun, 23 May 2021 13:59:57 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51990 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231932AbhEWR7v (ORCPT ); Sun, 23 May 2021 13:59:51 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHtWKo172032; Sun, 23 May 2021 17:58: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=63ffftDQwm4Ley7+LtqScbrVzmXMfQyceUkjv+tJxZc=; b=eFZgBbWrUJ/Rzz5tzKrvvXYFybi0yZsCg9Am+XzWbUPz1BFA+D22qTVe9N9JFwqQnZtl jqdoR991KNmb6NYattAxrIvDdNxUR0CrGTSKMf2pyqQPMBwopP6YE1p4EsS1VrSBW8hp 7RgwGknE0nTZ8wkvBwQmfrmM55K7LtTAt8Gl58m/cSbgyzW0K+ZQCo8su669XJwG/P11 pp1x+IU8my/M7p3/43I+ynx2t3FjdfmfGe+CS2MJElQooQHVX8vSm3P/nk84K+DmvLbA GGRdjgxyybVN3fpKq8A5FupbVs/sNYjsPBCU4fyZ+1suvNMLyr32+RvMIBDw2ekYfd9t nw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38q3q8ryy7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58: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 14NHubDo161766; Sun, 23 May 2021 17:58:15 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by aserp3020.oracle.com with ESMTP id 38pss3qbsp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AiFsLZZayw8MQjZRqFV6eZnyFXukCHqBPX51ycdI9eAIfG1muvb5Xv5K30xAiQmkcovSAcGr/gfojaWlAD2vGawyq+6CsZHJ1aBTf/aqhGl4/J5Z8qySAQ25i9/NS0Ax1e9s9uRAK71cAAoS4gyeqLIgXHDMT/XFn2DCBRcbzu3gXl1kg2uDjEB5AxuE+G8xMvatiRVj31u6lMzlIWwuwycxPhx4C6R5S1lRdjD+UQky0sK4Il3yWyX49z5uQy221ZW2LSUWj/8bNolnuw02DZBh0YS8qAVLc5MJoBr6hrG3F7GNYUEvOObVQx+6u6rIli7v6qs+zpaOx/Rpe7oFGA== 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=63ffftDQwm4Ley7+LtqScbrVzmXMfQyceUkjv+tJxZc=; b=SM/PFzrBPO+4Kevtdb7MN/eI9phSB2/IybPZ7/pqRILszLfS7AvqU0hLf+QjI/3TacAutDDXsHWrCcEbWNkfZ56992H5cuqUpPJmRbEygyXE7mCfLJJ+Gld9h4/wtxE9BCKoV7sWcTAjycMeIMt5sKrX9taaCh/cF0VmWdPfOCJa3Vd/LSr/YmyJAQdUigLOsUMJS9xx83soGPT36G1heoHt2K9RjBrbbWWXVdzIC7uZClLTICpETQhh22dexS9YjeibBUo3ge0Bng9lab1TyOm5UupQ75ohPkNZpJ4yvZNjkTf0sBdoif5mfyhFN2+6euZFkbT4UMT9+E6tc3dWyw== 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=63ffftDQwm4Ley7+LtqScbrVzmXMfQyceUkjv+tJxZc=; b=zx7YSE63I67Q18KF4QHyOA3jxrEtDsR6l/+f4HVpxMz2ZN7WgwsNYijXnN94Z/E23gEKq10nXT0aAD4wkYsxYy+qbEn2Kp2+THU9oJwuTairahOxaIqHEeiOVyEHFMTefz9Z+m+gpTzbN5PR0BwLuPNss/4l761ZLqxI4anJkXU= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3239.namprd10.prod.outlook.com (2603:10b6:a03:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26; Sun, 23 May 2021 17:58:12 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:12 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 21/28] scsi: qedi: Fix use after free during abort cleanup Date: Sun, 23 May 2021 12:57:32 -0500 Message-Id: <20210523175739.360324-22-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0c8f064-072f-412f-3a17-08d91e1454a2 X-MS-TrafficTypeDiagnostic: BYAPR10MB3239: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rsWhKDLb78fiboV0im3nrN0AC1CTYQOpZTaSEecPCaTDYCgjLdPfB3l6iPbEJgND2BLB4msQr6V086y11YT5Hu1jmke7e4bEHdDV1O5f4YB103D4mdTt1/rjCWkqdJLXDNIixsObiukyXCiLZxLQJRSIWE02flC2rfkklN2oawkr9Pi5X6IIP7bcLjELJxNYteORDaJajGxlpmcBHAlB+h35lvnWosozjvnNWzmsl3vtfCb7DnxFWWu4Iuxk01yMk2j9/IZFw8uWvQFXbm2L4z7yIchEPUSVvjq0SeJq5llIx/L3aLlhct4/KYylKH+jzLKGpjaFKfDYui6qbKnFWwvLRydyysjg+Alo6qT8XtLgp2ogxxMCRF5cppjPafVbMHKIKuRynyorbLMG8k3P9RxVzxcAo12HpM88kG77QWU7iJA2U9cObNQXqbD7iua1GBkP0+htG/PR4fMoUoDYx7HWGKBON80P4qdUdIdjvkzvDwxmLiMHiL//u6IUOy89Rm1clyfS8vEQHQGI4mC0bh1NTj6OPxDDIDmOmnKCEHVWUBKk1F9O8zYmNp4E+lMiYr5t/3/yF48IafaU7q4w7xOKlDrOK8yNLBzLqapP0j+vT9H9woAeQVNmx/rWcVdG/+7sIy31zpLbWVUZKzFqtV3Uf1n1sbiqw0GiGyhWvRdnr+G5xX8VbdqzXfTMio9g X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(366004)(396003)(39860400002)(52116002)(26005)(86362001)(16526019)(6506007)(2906002)(66946007)(66476007)(186003)(478600001)(2616005)(66556008)(8676002)(6666004)(1076003)(38350700002)(38100700002)(83380400001)(36756003)(316002)(8936002)(6512007)(4326008)(956004)(5660300002)(107886003)(6486002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CB9IILeea9lzjh/63XP4vFVAV9jhmXY/6OWoOpV3TQwN2Mi/iIiLC9kkoRmtf58/e8A7cVkzv+y/MVQ6FKSnbS5tdiaZI2hoMsRcvWuTPBgzYsIyYX/PXJAo9gBx9P0lfoIIqsZTaxz/neohze4bYMekQNVrn3r408ud2jvmfipahmf+PS3CIsqZnqq5EBY/ZvzeUEOEmJYc95jdt1CHI0bRnSJacncoOiAmXxjPkncfZfitqv5quP2/F14Gc+o7WnKTap3UBUWhtCMpNTrMup/8iz5WeOXnqiPL1KYw/M+LQ359SG2beW9ST50hJhfi6J0VHW9ePn9llX4XCJltiM94MiroHxs7Bgo6cmgCsLaGehPm9j9e45AmLVQzDmLX+mn7qboUt1lyOY3xLELqH1feSyROaSx7qT1QPKB5Q4zzY5rQo0ND2AAXdIGnl1+zqK5feoY2/uHrZst5OMYpjVdGxWUhhuRsj4Z/MnVBfM8uLeLzMYi12IByKoE4ZoX+ZlN4JXZmbiKXI02gS/1kR59X4kFE4pNl7XeivDsvS/tBzv/5HE8XKa/GJab3ZdRLPlo135rG74Uhrw8yiAL0PbPw3gDb/ETsdb5OnPK/G6McRVPgHELivm5+JoywBdMGLFqRA6jp7m+Mw2B8G/LgO5wVOEam2QW48GNUvc9VTj44KcH5sJK3cWZvk96KaqYwsfIGPzAHiuhKT+c4lLXsUwGhBWUS2+UpQebLjWcivi/GrpZwFndyXZGrKnxMYKI4juH62tzV8dkgTW+M06TDgj8eLJKrwzEXnYmo0ymyFpR2W3GUUuuLPzbwEPyCEGxjMFMVe73hfVWWE+SpUx1ghhgWmKOlRFf/2xf2bDsErzt4+qZU+NP3+CMgdziWuKxEP/sAI0X5gBTgHE+SFeCcnK2wCtdXtA+trx6DktkhFwR3yFKkN7vJJjKi26hUI8wOFQ8z4hcDVUhndTKs3HZG6Y1+8XgSbrIVie1BGfxI1MsJ9JtvUDtMisY8E5G43aspxqSYMNbizdR7ZYipXa8Xg3cx4FbXPP+MMT5EGKOsN95u7fkCFtVcTu0xn4nZt5dJZsx2Z1NZ4lxxL2YZUXXaWMpgaq3zZE5KyhRp20nMAp1HQdT66GC1MhN3sABzgg0HPlPwu00BB3YeirUuTyChPJ0+eTaA47b6r3Aiw6fx2dYld1axDKENlBY70bKQOCewpiOJY3AHX3W7+IjkvC+D0D6rT2/Rug8kx9zfb0MJh87KpvQMd+uDeRrezYRupbHhsYWNmLzXnNxtNwPHXjcfmXIg8Ikvrzh9VK0P+rBNcibG6Ps9Aan6cjyQg1rMJ0eE X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0c8f064-072f-412f-3a17-08d91e1454a2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:11.8992 (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: G++TJLzdNt9rzrqJHbiuz04gQGouKedO6zOL47RJd1m3E0eyRje3t7NpuAGSYv0eSA3IeUAttpjH1cK6w92wOrcmbyb9Z24CXkK36AjDJiQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3239 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: 7ukMT04u5G2NFM-lHsV_TEJ0KSu7Uepe X-Proofpoint-ORIG-GUID: 7ukMT04u5G2NFM-lHsV_TEJ0KSu7Uepe X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If qedi_tmf_work's qedi_wait_for_cleanup_request call times out we will also force the clean up of the qedi_work_map but qedi_process_cmd_cleanup_resp could still be accessing the qedi_cmd. To fix this issue we extend where we hold the tmf_work_lock and back_lock so the qedi_process_cmd_cleanup_resp access is serialized with the cleanup done in qedi_tmf_work and any completion handling for the iscsi_task. Reviewed-by: Manish Rangankar Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 113 ++++++++++++++++++--------------- drivers/scsi/qedi/qedi_iscsi.h | 1 + 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index c12bb2dd5ff9..61c1ebb3004c 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -729,7 +729,6 @@ static void qedi_process_nopin_local_cmpl(struct qedi_ctx *qedi, static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, struct iscsi_cqe_solicited *cqe, - struct iscsi_task *task, struct iscsi_conn *conn) { struct qedi_work_map *work, *work_tmp; @@ -741,7 +740,7 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, u32 iscsi_cid; struct qedi_conn *qedi_conn; struct qedi_cmd *dbg_cmd; - struct iscsi_task *mtask; + struct iscsi_task *mtask, *task; struct iscsi_tm *tmf_hdr = NULL; iscsi_cid = cqe->conn_id; @@ -767,6 +766,7 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, } found = 1; mtask = qedi_cmd->task; + task = work->ctask; tmf_hdr = (struct iscsi_tm *)mtask->hdr; list_del_init(&work->list); @@ -774,52 +774,47 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, qedi_cmd->list_tmf_work = NULL; } } - spin_unlock_bh(&qedi_conn->tmf_work_lock); - - if (found) { - QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "TMF work, cqe->tid=0x%x, tmf flags=0x%x, cid=0x%x\n", - proto_itt, tmf_hdr->flags, qedi_conn->iscsi_conn_id); - - if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_ABORT_TASK) { - spin_lock_bh(&conn->session->back_lock); - - protoitt = build_itt(get_itt(tmf_hdr->rtt), - conn->session->age); - task = iscsi_itt_to_task(conn, protoitt); - spin_unlock_bh(&conn->session->back_lock); + if (!found) { + spin_unlock_bh(&qedi_conn->tmf_work_lock); + goto check_cleanup_reqs; + } - if (!task) { - QEDI_NOTICE(&qedi->dbg_ctx, - "IO task completed, tmf rtt=0x%x, cid=0x%x\n", - get_itt(tmf_hdr->rtt), - qedi_conn->iscsi_conn_id); - return; - } + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, + "TMF work, cqe->tid=0x%x, tmf flags=0x%x, cid=0x%x\n", + proto_itt, tmf_hdr->flags, qedi_conn->iscsi_conn_id); + + spin_lock_bh(&conn->session->back_lock); + if (iscsi_task_is_completed(task)) { + QEDI_NOTICE(&qedi->dbg_ctx, + "IO task completed, tmf rtt=0x%x, cid=0x%x\n", + get_itt(tmf_hdr->rtt), qedi_conn->iscsi_conn_id); + goto unlock; + } - dbg_cmd = task->dd_data; + dbg_cmd = task->dd_data; - QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, - "Abort tmf rtt=0x%x, i/o itt=0x%x, i/o tid=0x%x, cid=0x%x\n", - get_itt(tmf_hdr->rtt), get_itt(task->itt), - dbg_cmd->task_id, qedi_conn->iscsi_conn_id); + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, + "Abort tmf rtt=0x%x, i/o itt=0x%x, i/o tid=0x%x, cid=0x%x\n", + get_itt(tmf_hdr->rtt), get_itt(task->itt), dbg_cmd->task_id, + qedi_conn->iscsi_conn_id); - if (qedi_cmd->state == CLEANUP_WAIT_FAILED) - qedi_cmd->state = CLEANUP_RECV; + spin_lock(&qedi_conn->list_lock); + if (likely(dbg_cmd->io_cmd_in_list)) { + dbg_cmd->io_cmd_in_list = false; + list_del_init(&dbg_cmd->io_cmd); + qedi_conn->active_cmd_count--; + } + spin_unlock(&qedi_conn->list_lock); + qedi_cmd->state = CLEANUP_RECV; +unlock: + spin_unlock_bh(&conn->session->back_lock); + spin_unlock_bh(&qedi_conn->tmf_work_lock); + wake_up_interruptible(&qedi_conn->wait_queue); + return; - spin_lock(&qedi_conn->list_lock); - if (likely(dbg_cmd->io_cmd_in_list)) { - dbg_cmd->io_cmd_in_list = false; - list_del_init(&dbg_cmd->io_cmd); - qedi_conn->active_cmd_count--; - } - spin_unlock(&qedi_conn->list_lock); - qedi_cmd->state = CLEANUP_RECV; - wake_up_interruptible(&qedi_conn->wait_queue); - } - } else if (qedi_conn->cmd_cleanup_req > 0) { +check_cleanup_reqs: + if (qedi_conn->cmd_cleanup_req > 0) { spin_lock_bh(&conn->session->back_lock); qedi_get_proto_itt(qedi, cqe->itid, &ptmp_itt); protoitt = build_itt(ptmp_itt, conn->session->age); @@ -842,6 +837,7 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx *qedi, QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_TID, "Freeing tid=0x%x for cid=0x%x\n", cqe->itid, qedi_conn->iscsi_conn_id); + qedi_clear_task_idx(qedi_conn->qedi, cqe->itid); } else { qedi_get_proto_itt(qedi, cqe->itid, &ptmp_itt); @@ -944,8 +940,7 @@ void qedi_fp_process_cqes(struct qedi_work *work) goto exit_fp_process; case ISCSI_CQE_TYPE_TASK_CLEANUP: QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, "CleanUp CqE\n"); - qedi_process_cmd_cleanup_resp(qedi, &cqe->cqe_solicited, task, - conn); + qedi_process_cmd_cleanup_resp(qedi, &cqe->cqe_solicited, conn); goto exit_fp_process; default: QEDI_ERR(&qedi->dbg_ctx, "Error cqe.\n"); @@ -1372,11 +1367,25 @@ static void qedi_tmf_work(struct work_struct *work) tmf_hdr = (struct iscsi_tm *)mtask->hdr; set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); - ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt); - if (!ctask || !ctask->sc) { - QEDI_ERR(&qedi->dbg_ctx, "Task already completed\n"); - goto abort_ret; + spin_lock_bh(&conn->session->back_lock); + ctask = iscsi_itt_to_ctask(conn, tmf_hdr->rtt); + if (!ctask) { + spin_unlock_bh(&conn->session->back_lock); + QEDI_ERR(&qedi->dbg_ctx, "Invalid RTT. Letting abort timeout.\n"); + goto clear_cleanup; + } + + if (iscsi_task_is_completed(ctask)) { + spin_unlock_bh(&conn->session->back_lock); + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, + "Task already completed\n"); + /* + * We have to still send the TMF because libiscsi needs the + * response to avoid a timeout. + */ + goto send_tmf; } + spin_unlock_bh(&conn->session->back_lock); cmd = (struct qedi_cmd *)ctask->dd_data; QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, @@ -1387,19 +1396,20 @@ static void qedi_tmf_work(struct work_struct *work) if (qedi_do_not_recover) { QEDI_ERR(&qedi->dbg_ctx, "DONT SEND CLEANUP/ABORT %d\n", qedi_do_not_recover); - goto abort_ret; + goto clear_cleanup; } list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); if (!list_work) { QEDI_ERR(&qedi->dbg_ctx, "Memory allocation failed\n"); - goto abort_ret; + goto clear_cleanup; } qedi_cmd->type = TYPEIO; list_work->qedi_cmd = qedi_cmd; list_work->rtid = cmd->task_id; list_work->state = QEDI_WORK_SCHEDULED; + list_work->ctask = ctask; qedi_cmd->list_tmf_work = list_work; QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_SCSI_TM, @@ -1422,6 +1432,7 @@ static void qedi_tmf_work(struct work_struct *work) goto ldel_exit; } +send_tmf: tid = qedi_get_task_idx(qedi); if (tid == -1) { QEDI_ERR(&qedi->dbg_ctx, "Invalid tid, cid=0x%x\n", @@ -1432,7 +1443,7 @@ static void qedi_tmf_work(struct work_struct *work) qedi_cmd->task_id = tid; qedi_send_iscsi_tmf(qedi_conn, qedi_cmd->task); -abort_ret: +clear_cleanup: clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); return; diff --git a/drivers/scsi/qedi/qedi_iscsi.h b/drivers/scsi/qedi/qedi_iscsi.h index 39dc27c85e3c..68ef519f5480 100644 --- a/drivers/scsi/qedi/qedi_iscsi.h +++ b/drivers/scsi/qedi/qedi_iscsi.h @@ -212,6 +212,7 @@ struct qedi_cmd { struct qedi_work_map { struct list_head list; struct qedi_cmd *qedi_cmd; + struct iscsi_task *ctask; int rtid; int state; From patchwork Sun May 23 17:57:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446344 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 56583C47080 for ; Sun, 23 May 2021 17:58:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 354E561244 for ; Sun, 23 May 2021 17:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbhEWSAJ (ORCPT ); Sun, 23 May 2021 14:00:09 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52002 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231983AbhEWR7w (ORCPT ); Sun, 23 May 2021 13:59:52 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHttPh181508; Sun, 23 May 2021 17:58:17 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=6TT9MKGyAYjEnfdOdUJ/rY8NH+1aB2ZDLGKA4BgqzpU=; b=0iIViU/6YGC+PQgLD6uKwD1SW5ePybSf/rrSoq+62UTJuVYGlEcZDhQbLDbJFOH39OW0 ZI9KqP0INzm1nh1Q/NRiIjVFEDs8hmiE8dI8nQMPscl3pt676O/BkdEpf2eYFdo95LDX JM/o7b5mVIq25iyBmZ0PhzIrBaEuwfuDV3DJ1LG7ChH0FkybzmNOLC+OZHAqwVhwA2jQ 4mVBzP+AZbQFAi5SiWU2kzmHE7tvwLbZ827kP4SCInjk0/Ll99cDmH1zFL0va2wBLxO8 Pmb8/Zy5hg97bV3w/eP6mQQkPuthdc+qWoYpiAchCfbb6ke52Mraxm51tSTEoX7HWmaU tg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38q3q8ryy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:17 +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 14NHubDr161766; Sun, 23 May 2021 17:58:16 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by aserp3020.oracle.com with ESMTP id 38pss3qbsp-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KK/l2vhJYe2lB2S4bx7p4HbBhFuhkrj6mtD9Jusfj/VIj7SNVtdJNuAzHF/Ui7JnA+DICoplS+f+FeAoKuM3MYGziK+MKPvaaqguIG3y9kD3M/xwBAruwCsDFZU65t51DiLauMMA1X5WJnSGg7HYWypL8Ho+Nd7Lg8vCO5o6zbGvSLShu0exxLBoehthj7xN5jlQgvAlStcMEQTHnlbgehhXgmV1WoNK4ub3utQjk+wFut+84b6U1RQ/4cOHmhGkPIcZJDEJnxTkmda05+OAbBSgub2Dg13Z92HKqEM6T5HDNNZs/KJk/tdfEzERDTYUfQHnbJx7J859PM2qWwZJBA== 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=6TT9MKGyAYjEnfdOdUJ/rY8NH+1aB2ZDLGKA4BgqzpU=; b=WQcCmTqwwq1hE92tGRNg5+XGnG9LYzgUpYht5HqWKuohBDpA351kXzZgn5PhS9aHyWxg/Nefa0kkRDizzk+G2DhkOkBCmah/K8Mp12t1LPj9gyTGRNJJCVnkx5CbCgWITgwGTP0fvwlXfsbpjkcwxnwZFG4gchuE5GSTaIKysXd7TbYQZReGTcTmN/EYjlHiLCM/FQMiLUc0F+WIuc5HsXFesNzTjj2su/vf4yOXbkW4/yhPigvh3bU7EVPM5veB5KRJO4mUzGAptrKRxX8Mt94chjg2OGnFymqBaBgExFkgLRMsD8sOIVdUxWjYCd4to6qQuPkrNDg/EGBy8gNk6Q== 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=6TT9MKGyAYjEnfdOdUJ/rY8NH+1aB2ZDLGKA4BgqzpU=; b=tGxltFssTtof00IHSq9Qhdlm6hhyNrNT+37QnGGG28dWsrPbTRb0wCV5efcYrtBt+uOtxyp6WyQ4CL5nboB3YOawg6xW3xczZgOgz8J/rT5XgSk7fY5WDsFvHbe2HVHIS7sruE8cZyBCfeWsDfX6YEakS1ti+pafyvgBvvz6YgQ= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3239.namprd10.prod.outlook.com (2603:10b6:a03:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26; Sun, 23 May 2021 17:58:14 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:14 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 23/28] scsi: qedi: Use GFP_NOIO for TMF allocation Date: Sun, 23 May 2021 12:57:34 -0500 Message-Id: <20210523175739.360324-24-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28d936ec-dbb9-4508-7681-08d91e1455e4 X-MS-TrafficTypeDiagnostic: BYAPR10MB3239: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:404; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MTIR5Gnu4soSibNJW28MaGWJYYum9PoutehkiR6v+4mmwDzUcOSy1rQTsQdWf2TyrevzgJB2DOIIwxc1gpgynBB2rzxXY0DRp35jYyTXXQFWNvfz4eN7jgbl/D1efJFdx0sODX3W+3y99aLzUM4/8zlGVrD1/pY8IH9XEMRS+4yB2qBPyvrkLpwfoKGL/jldGaSx96sf3UrcDz1Fjv34CgL70n8aSnVa3WqACfYzpM5BwfFr70/VTzXO66qKYgvJ4cBNd2jmH1j81UAec39ePzFs8Fso72LBxSgp5Dg3JUGbTbTMuGdRgmqce6ZvFR1WUajn9DNZLZA9XBFv1NvsbcrUhgUzD+d/CyOob3s6hN/ePJpphTx4QN5SLrqQqDOWh5Jx/7P9YBbJLUtG+fsgb9j0dG1n7Deo4AxtaIVWQSjWDnkz6MoLFf7JCUTrjQqxUqESbKpGeOXYrAU5H3nmHR1sRmCbK/c6iwuJh1aM82BtGfLx/YU89GHJ8Ne7DFxL+zjlGNUFBT1sJYJGLYck9BU2gh090/ZhWLIb6KsH++Z9eqbIzyfi5Ru1N0Np9H6jVHq42wLhG9ryOsWULTWa2Ci49eIspJIsliMcQ9apT1s7cfnVURnZHdqn0T04hkUdEQ1OTlhuc2qIlF+2EnRPwe3PI3AxIYCJbnaIy9RsB4BEvtytdrF0qCXspgtxsKyE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(366004)(396003)(39860400002)(52116002)(26005)(86362001)(16526019)(6506007)(2906002)(66946007)(66476007)(186003)(478600001)(2616005)(66556008)(4744005)(8676002)(6666004)(1076003)(38350700002)(38100700002)(83380400001)(36756003)(316002)(8936002)(6512007)(4326008)(956004)(5660300002)(107886003)(6486002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Uxa7Vo55acQ+BOz2QMxMV7rADwttg9m9xqYnt85As4HqUN/vuSkuQuy0UIzlQ+dSsALmxsD9wt1CWG52NEaacRhEJUxO0lXrDfJM3HUj8uQiotKO6KC3j9SdRKggVbSed8eSXYKrmp3SYu1Uu4Az2Zb+BjZU8i/glxiIBlSWtZtEwJhdTy9KFPlI0Tf0lKw+z/9TdFA4Yh3C/Uyh/8IEb1FefjE/vRHrRd9ejRZ+d1h3KTU849JB+OAkPHVdRwc4cru1ca9tczCJNS75cVG3twnQba4yAk24LbzFHQfC89bqTFW5lJgjBuRm7Ethf+GOOGS/KCPr6+bvR4tInZy2LFVE56d4ssmKRhZVaTot6QwmVhq/d/O0w8KAoYfa8hpJT3430VbXZk6A8DoGvtP7NiSb+fgSIwu4jpX5uf8dvd/VpWj0VTIUNLqnwbcqRWO8Oc9Kq0upLhItwp5BuJxXgTQsLohQHIVCzREDOtU4fmzC9g6EbWWi0xNgEsVbjL2OxH7Iv8uQdstPQTPqyvfnObsl+04+V9/IxZZc+ZwmdnQLgoQDdMkKTOBpFnKXYwu+HbJ+Nik32aPqsT3AtKx6Ky2WpAPwPtHYQ6B47ToSujpVAxDfLYbsdHDm9u3NyC6dNW020igY7steYqOnMPqYK5X0EiEs1LOrJMM5ZwHtWMIbY/mgRIMevD302SimfIZIcuY2XExuyQD6fWFMsGE/d4v2xlPoJSHCnLiQuJ5b0qYMN4qUFW9PIRD2K/r5/+jTAy5+xN1I1rDB8i04IcOMuEsKRuIPQP28l4vhFS8yYZLiT7YRVDeSc80Qat8AtAIofwTFlPsMlydGpSmC1fvPVnZJKS+F02B1n1CjE55zqst8au2qw+UEQ/CoYbp8veqmEZ924z9tNWfiOeDrMf8cY6HSHmVbLxaLT+UO85I6Q93X2fvnxfQoJIGw75q4aDpXOGJSRooE2TFGX7jfc/Wy/m53rmJotcFdxQ5TEbAtX0StK4fUEjsL1E+gdYysuDN5NXy1D/NAeA8E4LhM4mro/3gAstin/jIJeRS6hUedgl7ejCw04rYWUb4iMEfTVdZ7DKtB/cDesZbDKPQh/1EdmqKtvSsz/JjHxGQqxrmTMWAvnr6J7LGNCWO7+2QX7KeqfJrkCxt9fwhQpDyaQiyYV6zwAMD7PxC5a1hXwgfct224n9xZtlzerlDZUvY/Tv7IYpM6VUCq438Cra3DF/bHSa1GBqrdhCAdtw5DtB1bTLHTviCu6GwVZiBNQnp3f/S/7hRma2dkWWhQ/cCoNJ8cQA5qqSEHnGE2Gmn6pIu98hJEl1Os5Z3YAXmIR6UZTyjJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28d936ec-dbb9-4508-7681-08d91e1455e4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:14.0729 (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: uL+VUGUYDNSO62vBtFK/pvjlB2+MMo81MB6OAj2YX0ixpgg0tOOAx0tWVqyduqX/yx7WeX4P79OyRm+2UK134O2WJC9iiFFBJByT+JxJNKU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3239 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: F59vOxfhs-4u7neX2aAS6uKOK0DJxoWk X-Proofpoint-ORIG-GUID: F59vOxfhs-4u7neX2aAS6uKOK0DJxoWk X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We run from a workqueue with no locks held so use GFP_NOIO. Reviewed-by: Manish Rangankar Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 6812dc023def..e82c68f660f8 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -1398,7 +1398,7 @@ static void qedi_abort_work(struct work_struct *work) goto clear_cleanup; } - list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); + list_work = kzalloc(sizeof(*list_work), GFP_NOIO); if (!list_work) { QEDI_ERR(&qedi->dbg_ctx, "Memory allocation failed\n"); goto clear_cleanup; From patchwork Sun May 23 17:57:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446343 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 15C09C47082 for ; Sun, 23 May 2021 17:58:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E929D6117A for ; Sun, 23 May 2021 17:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231993AbhEWSAK (ORCPT ); Sun, 23 May 2021 14:00:10 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52014 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231996AbhEWR7y (ORCPT ); Sun, 23 May 2021 13:59:54 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHusEV181997; Sun, 23 May 2021 17:58:20 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=/b0Y6QfZM5snDlg/YJiM0Da+Gu+sEC+KOLn7VIp1KCY=; b=p2eQsB0qS1hD1gznkhdiH1vRPiEFAgeB9VfD4eLNXhvUGny7DJJgy86J2hDzlKL9Y0gc 2raH1VLmE9BEwqkHtxN6nXgw8y+H1jIz2ObhxiDvQ53sl1FOmSAHzJ0BGVDLLQtuks2n tHKr4uMnXyx7O43gK69tXChPIwjO8g66TPESRclCJoiGLGtiq5UORBdE8Cj3HyrRDSfh 6uaRomMXY8Yhes9LmMDS8tLj2xCVbtzL+TzrFfJ8gAGmANR30YucDKQSdzjCCtBZUWh6 3nXJqBfvMnw1yg65rjNi5/5ad5AgQhNeTvqdj5rfMNQJ9RDaw7zE2gIJPPqwMbansghe WA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 38q3q8ryyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:20 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHsrMf188648; Sun, 23 May 2021 17:58:20 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3030.oracle.com with ESMTP id 38pq2snq5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RbSferluhuZV80hcBIe1L/zA6wGVrrqeumGU7bnJLoJc92ul4dMT+2KPOuk8f+rNh5Z52fS0NXK2iBe0v5YvefG1EtB6EOihAUuWwTGgGBX3mByAse+Ui332LXfbKhdRet/X/gzv2iiXl475PKZDqypJR3XFEnCht/SvOa7IVnM9hnY51IPRineWY1IeNW2DFf9X7ZOEvZTvAw77gsPziV2/xlx4kb6gu3NoTblO2hEfVfBhugIKZR24ZeilG0SJ0xs8S9YlLluVFAUtEFyulD5/JF6vitVbBo4aZPpWLWx8G4WzecP2Eq8MnXo4DXdZCvT/rSLWMj4MAlhr4pV7+A== 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=/b0Y6QfZM5snDlg/YJiM0Da+Gu+sEC+KOLn7VIp1KCY=; b=WVF5tAexF8IETDNwXja2zB03wYj7kRwbzN5yEXjlczFJz94x1YoXZnA/c3YjibFX2SaqH3t7G85Az9/FiUrRO8LIQjgv2mi6C5myN+t0+PBlyUnamYF4zEXCKgchjNkdG62uMxsJ9xij4ZYtmeM2i8gqPTYoWqj5dkuDTsi7iqodOTJ6cr8aH5/bLZg2p/bJz0QzWU28kLpiAjRu46jo5ZckXtkOEVzUtSMW9Enie1d7VxHf4zzwhehYToV0n3A2LY4SFTDJDHr5qgsmi7jODyFV8bxlAKXTLPIYXJAzRc5pXIdGCIbkHa1o1rXFSYa56T61S7LKnBP0kKKfSUWZyQ== 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=/b0Y6QfZM5snDlg/YJiM0Da+Gu+sEC+KOLn7VIp1KCY=; b=J57sTjrJhtNpnZqL576wxN1BuAPHrFTr/mZjjf9Kl9RGIWLhBErhwInvREIVly6MFHe/uNUq5VdlKUBXEvJhFdwCi0egomwigYK+depd1Rj5lsrFCQBNCLeH/YBooZ5IyKs5wBcuSg1UtXJQDaoXny08arSlf975irB477tc9Lw= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3239.namprd10.prod.outlook.com (2603:10b6:a03:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26; Sun, 23 May 2021 17:58:17 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:17 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 26/28] scsi: qedi: Pass send_iscsi_tmf task to abort Date: Sun, 23 May 2021 12:57:37 -0500 Message-Id: <20210523175739.360324-27-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e41c5fbc-1089-484b-09d7-08d91e1457e3 X-MS-TrafficTypeDiagnostic: BYAPR10MB3239: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:962; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aofiCPMDaJkFPtCX70npUzUFIUzzFNHcsbvQvnKODrHoVpS52jU9Mb0MMeq+qkCtnF7pHQTomHoA24+1QFgUxGxVCVynIUhUDaAbUsFfGOC8HI/cvh5lnBXLtchwvxHSeIocG+2Wg0eaii7GBitDE7ko2EdnlLt3CjKdFEvjCKW0MO+yiSwLSjYc8ASwMUE+nWF8S0ok4nCTe11+hpckW+miscfRJOrm/QN3rHKhFNKvMv9/vVb6KoBoSH8m89/kWA9F50qbm3IlLXOjAXRYePRLQoFx5oTmz0a+vvofCdKBQR0EurxNv6l4oNnGN5hPjY8kDq35jWKblF94HP11AHy6X4WXlAwXBRCMlBLYwqNNygJhN0ZqIpHjwTho7yRUojacwfZg5ufXfpT7qZFM3sQTGwYMyWBzY9sNdOG6HUCnOXcbKVXWLZyHdSWwVPIUJ98LH2PFrMWWopSBDdKX0SIzCcvV+t8jV2zvyrCUmjaqboTYCHvhmQaWs5g1S74oAgfwCWv1zyZ+ef5qZ22TzWk60wlEYnCrxKCawGk/ISILJ8FoCSeE8ZWVbNPdlEsUZ9X4ssH9JtrVmLtZ22VF5NaqCKc5suwKQkPF7hvPCE/Lyo0ctqCc69Jma5CBYn5xauChK6HZJhbV8FXB5CBA1rbG12jnC7pRYK9JR+3WfZoNE0WosRwK9/m3nePG/DyO X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(366004)(396003)(39860400002)(52116002)(26005)(86362001)(16526019)(6506007)(2906002)(66946007)(66476007)(186003)(478600001)(2616005)(66556008)(8676002)(6666004)(1076003)(38350700002)(38100700002)(83380400001)(36756003)(316002)(8936002)(6512007)(4326008)(956004)(5660300002)(107886003)(6486002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jSn998ocGcBQDrzmB3w2Mjfz8+ZgTr1VWISw8qVJZxwU9yttrjPvKaTIlzSuF2DjEOvouxLuC8vOV3oNJNySa7pqnJZviEaZ1IUspu16pfTNY3m8noaQIfuFaMlVogMZBS6Y+HEq/kl75IDG/oxxhpea0wkREgj/HZVKL55LGT1B5N5YaJ85ykb1JTz701Br4fWy2LILxcJraCjKpQzpkWgWEaVv8U9lx1ROrcmSKL5ZtyaXgEzNlT4IHPBPfGEtMfP2/1Dc5iXnbhTW7oVmn20kJHfp2F0o5RzUJE7qFppNKAZWJ8jAr3rgfOB4umczDeJDegLDgsi0SBR1dlr3pqSvqeLFwiTivYqEtp+xEp7YmhG94/1btnRZreSESxLfNT1kUKJ2x4P9nmhf6WPgrJduYsNSfxbOdk1Zs/l7moWK4QjW0YxZc4O9sjxRDntHLSeJgvkXJCBVZWPV2sY0mx3KM7W24NxcQUVRVGfEph5RHsec+azmPA7acoezbz3w/NxHwF9fgi++pp+GN2WTALU+WnNcC/0fBRejyJiWXbzCnZP/AwSipl7qr5YnQ4JS/Dda47VAhloPTn/qyMe6ItyJH20Zwx7noMBBKWkQqXtfcT3L/djcUAvj3++NpNWm/7poSGjStfU8hqiIgHKja02IimVtybvyiw6Co1G9X+1X7bvDNfrC1Tv1AN/3OUkliQO7nH97Aa2BceTRWGtn4HqKD5ErroinPUdQxauX87cMXFi9rCPjuQa+ouIHyU07fDbN33id1OwsvQqBsP98BYzxA+grcLes8Qlf6c1MkMESVM4KmesAH0FZAk1z4S9ClQccb/Uu51uhVpRlIeWiqhIicrFUGLgysp4Nv1Wz2OvJdbNskMtg//cWbbalSfRyDad8pE6iI+AjtGW77kojr/mrvTeLU4vd/IdRMLfyZfTEnl00xSz+Z5hT1/h2pGDXMZf98NqjtsBWi2tQQlqnSXH3zI3np2fNGIxYw78BsSnZdQip15rgw+CTSkvd3W+Qr3g/UnDa+8gCz+cpTaQq8x6r7PFB1yAgmaYwXRblIv6OmQl/gLt6FGkGuYCEZIzOVd4dN5sUvsduN1HgF/c4a22wlOSD+U6bJd5tRn+688coEN6vOYP7u6HWyuqGzdPN503GKBTa1AS8NN1gOafYeXOYhlE/PgAxfdEfJSKQTjjjsnpV1IFhjdw0vnxVOS12zx/7jjO8v3Z73R2nwF3w1BHs1+JZ1mXxejy0SVbmwCKYBenLGZAGafDg9WKAR550nkzjXOdtwYnso1ccMCAMEi4zHtjZE5pCeynwLZ/wJTmRJ/nvBm2cm9wm5mxX3WzM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e41c5fbc-1089-484b-09d7-08d91e1457e3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:17.4041 (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: pBGPh1zy2PQvqIfluRUvBUZZjXcjt8kSeivb+7GwvU070MBADyVS+HTAj8ReYIANXUUxJlgpw8P7r4DczDwMwvie++/geGd6+mnYjxfXc0I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3239 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-GUID: TKmSPCgv2G8UWYDUhCb5iKMVzmbAw8ge X-Proofpoint-ORIG-GUID: TKmSPCgv2G8UWYDUhCb5iKMVzmbAw8ge X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org qedi_abort_work knows what task to abort so just pass it to send_iscsi_tmf. Reviewed-by: Manish Rangankar Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index f08fe967bcfe..4ee1ce1dcdef 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -15,7 +15,7 @@ #include "qedi_fw_scsi.h" static int send_iscsi_tmf(struct qedi_conn *qedi_conn, - struct iscsi_task *mtask); + struct iscsi_task *mtask, struct iscsi_task *ctask); void qedi_iscsi_unmap_sg_list(struct qedi_cmd *cmd) { @@ -1428,7 +1428,7 @@ static void qedi_abort_work(struct work_struct *work) } send_tmf: - send_iscsi_tmf(qedi_conn, qedi_cmd->task); + send_iscsi_tmf(qedi_conn, qedi_cmd->task, ctask); clear_cleanup: clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); @@ -1454,14 +1454,13 @@ static void qedi_abort_work(struct work_struct *work) clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); } -static int send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) +static int send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask, + struct iscsi_task *ctask) { struct iscsi_tmf_request_hdr tmf_pdu_header; struct iscsi_task_params task_params; struct qedi_ctx *qedi = qedi_conn->qedi; struct e4_iscsi_task_context *fw_task_ctx; - struct iscsi_conn *conn = qedi_conn->cls_conn->dd_data; - struct iscsi_task *ctask; struct iscsi_tm *tmf_hdr; struct qedi_cmd *qedi_cmd; struct qedi_cmd *cmd; @@ -1501,12 +1500,6 @@ static int send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == ISCSI_TM_FUNC_ABORT_TASK) { - ctask = iscsi_itt_to_task(conn, tmf_hdr->rtt); - if (!ctask || !ctask->sc) { - QEDI_ERR(&qedi->dbg_ctx, - "Could not get reference task\n"); - return 0; - } cmd = (struct qedi_cmd *)ctask->dd_data; tmf_pdu_header.rtt = qedi_set_itt(cmd->task_id, @@ -1559,7 +1552,7 @@ int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET: case ISCSI_TM_FUNC_TARGET_WARM_RESET: case ISCSI_TM_FUNC_TARGET_COLD_RESET: - rc = send_iscsi_tmf(qedi_conn, mtask); + rc = send_iscsi_tmf(qedi_conn, mtask, NULL); break; default: QEDI_ERR(&qedi->dbg_ctx, "Invalid tmf, cid=0x%x\n", From patchwork Sun May 23 17:57:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 446342 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 90A0AC47081 for ; Sun, 23 May 2021 17:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71D696117A for ; Sun, 23 May 2021 17:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbhEWSAM (ORCPT ); Sun, 23 May 2021 14:00:12 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:46724 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbhEWR7z (ORCPT ); Sun, 23 May 2021 13:59:55 -0400 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 14NHvhmV164792; Sun, 23 May 2021 17:58:21 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=XHUZVJZLbKxexs2JQozxMaBq5DpLnfmYpG19Op+JHuI=; b=p7J/whXtZBRcwjed3f/xGJsRi7UV/yGl4ngELOdcVSbrocq2W6IXC3c6NMTFeZE6F/Nl B5drSuA65t+CwiSVLh9ism//+OgDApaSnBt136/YrEan2D0O16O8WsZSgghSCuj1QRE0 HR9Q+EGCm9TCoKzEzQ7SCqPnX4vk0zSI2wn2vSSNE/hSFVDX/yMZm2+84pieePIUoIIw /KnPgBkjDYVagfoJDcgMbkbTVZm4Lt5BpdYNo23BMNgd1sDFDg3fLAwDEGLwkWuyyMap CsGjwYEc2vttzD74t9HWeIl6+VICwyoAQh1CAVQByzb4b0sSWWNV00KFYmxNnu4rpvtV Lg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 38pqfc9jav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:21 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14NHsrMg188648; Sun, 23 May 2021 17:58:20 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3030.oracle.com with ESMTP id 38pq2snq5p-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 23 May 2021 17:58:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SNP5IZLYC9yfp3F48CN3VwFcZKDHfa0sXptiNo1I2ntSG6HftfT3wFFs0NytygVOHzziapgFXUABTmCmo5IfWJwXltM8VWTLCDxhBMUJ/xCqdxj0Xc/+mPQr1bFduLURHb7FmCv9JYnWOZBAH2tePsb45bp8g8nmZiYOv5OLPWw0ubJTEJf2Upeqg3HZhYuGmN1fflbbNKsiODYJMRq114JSGzaTY+F5Hc9SkARTiUuoNJQ0BIpctdp1CJK0ij96L7qJGudxo/nCRTb3ZVa3LcyyGIucQv0lOAFgXvXX5FMN/Izapy4jGkxE6XkQ9Y6g8zLrFfbTbPs3U058n7c7Rw== 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=XHUZVJZLbKxexs2JQozxMaBq5DpLnfmYpG19Op+JHuI=; b=kNYumjDFdRpYysdtE5K92puTs6mK60unFDE4sRqOEBqq5GOWfkWYWtXCcGV4D4GczSBiayAstaacaJ+l3c42apMWSyPMxuI5Rm/w9zucNPz1i4kOFf3yCOxTjDJZJFI+iFt1cJtlzxAgwq6eulfh9bCTAkLkAbbViuK0yLNChuyM9V1eI8VEx1NHeFXTRYtaZzaNrUApC+3N4VYBWyJnUDlLr1ku4miM9UkUVqNacQvxX6IMX3f1OGdtPZojqex0tZwBAO9/Fx8jdbsYJYXXIQL1Hn0X82CvEN9SwBxAkf1SgqoadofhJsx/AneOxOEOSLv+6AoplYty+UJc//wikQ== 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=XHUZVJZLbKxexs2JQozxMaBq5DpLnfmYpG19Op+JHuI=; b=iGWAFR92z2KjHf4804ArGUW3rKCGXPb/61o2Wftfkip2y1A69DjCocjKsMzo4GcXLrhxIFwFWHr6AzWPucBurCNFo2ScNuH6Q/gQSOfIAGalTvAO2bUDygC6zHfqM2T0brSTm187Un4Kt3KjMEGTNr8vuH4aucOY+639OE2mzH0= Authentication-Results: suse.com; dkim=none (message not signed) header.d=none; suse.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3239.namprd10.prod.outlook.com (2603:10b6:a03:156::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.26; Sun, 23 May 2021 17:58:18 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::b09d:e36a:4258:d3d0%7]) with mapi id 15.20.4150.027; Sun, 23 May 2021 17:58:18 +0000 From: Mike Christie To: lduncan@suse.com, cleech@redhat.com, njavali@marvell.com, mrangankar@marvell.com, GR-QLogic-Storage-Upstream@marvell.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, jejb@linux.ibm.com Cc: Mike Christie Subject: [PATCH 27/28] scsi: qedi: Complete TMF works before disconnect Date: Sun, 23 May 2021 12:57:38 -0500 Message-Id: <20210523175739.360324-28-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210523175739.360324-1-michael.christie@oracle.com> References: <20210523175739.360324-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by DM6PR03CA0033.namprd03.prod.outlook.com (2603:10b6:5:40::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.24 via Frontend Transport; Sun, 23 May 2021 17:58:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae63b70d-23b3-4217-3aec-08d91e14588d X-MS-TrafficTypeDiagnostic: BYAPR10MB3239: 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: nIr1mKik+5EiS/atjG2J22ylr92kKRQyB+Cv8b/r5DzBbJSKFVx07DIAzLmcPCdhXd2WTUL1fcC6zECZce4uwQkB4VKSgryjI5CkS87JO59RBmKLle5Oyjh/5aBtc8UOEqqDzwlYX8x5RjXZnt+Lrb0R6FKg2FfjCycX78sP0ziTQ2EkHyroW/Q5HKj6FcYQZAG/2wznzPWjL/MVC/vaSWJ1dDn/Cff2B6XJPiEsegTAoi0n7k1nPkqKXqVk7MpqeLeGKRw3ti/Y0aEzxKDa6dw4ZjYrBFHuGJ5UxI55F2VPULNDtVftDPWAROHCmYUdujhXl2iNK8Zs061HKvtqk1p8KhMfhO4fYrRroS421oCojUwYmV3CanC7bkDHiPr6I/TKzQshjcn3dJcUEpjdJskzbMJoMS5uuq0+6kGl1cHvfWJ6zXbPK/oZKOl+XSH6XlD/Bd6x7o437/4xt0Hh2b6p/B+dT9evcg8kc6ud2nnHN1sFJG19exeHGFI6wj30fjZgB4Heg9K5gfaqHO3LKbKGhRnuDwyyxA49iRcbcz5+TFRnlmiWJi8nKbMeZGKCGFkf9XdEBo+W93ruP5yTacQDPE49n9TsrCpZkA4woj3v6ToV7+M+8Bz3gDkgJ1zsozri2WM2ZexosYAubw5wa725mM0f5XAWZVrU2Sdnldy1NTiQiDAY8vtu5qq9Ws9K X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3573.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(346002)(376002)(366004)(396003)(39860400002)(52116002)(26005)(86362001)(16526019)(6506007)(2906002)(66946007)(66476007)(186003)(478600001)(2616005)(66556008)(8676002)(6666004)(1076003)(38350700002)(38100700002)(83380400001)(36756003)(316002)(8936002)(6512007)(4326008)(956004)(5660300002)(107886003)(6486002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: uAnQtvPtUuhBS3HKUw5TMaveatUhddje8pr/Y55VR0GgwhbYBPls2ovUABFQl4znB0iZSfqo2Kksx0GuEt99QMKzhHsP67Pzosqf0+J5scileegKPRm852Zz9hPMbQAztViHYUCf0ArmhsneYNuwb3OLVisKtu/xarcf4P9LGR/EOkK72iX8kGUsoxKs0QferaXwBez+SgUZXh73S+r828zL9gczzMX92RVRAMiSed1ia1+yOxWc8MgCOhS3ZM32pbjhsxoh5ykIPzHzqoDIZu1hoqes6L11dJI9ocDxrFGvyAO7bYNsPItgqfZZa/hjqFtA11xnYhpbyLIn84PEoer+72Bj+gQr9QYbV0QhOO9i1wYxKu/xV7MwOTKCuVLIX8RemE5qV6rbbpxu6DesNH9jJk7WnKZjOVOQksr6lIkgH+kqsEHgd62VPlL6JXZ3BCnYMKMwDppZEffDveHGVWSQIF5hlDf3cm/3UREZTG55H4mvUZL8Z5a/7mCnsiqKkTOLFKSsb/K9KIQLvJcT7Qfwozr8VGHNhm7QqgqiOK2TXla6eud9OA62Jrrfl3MkMRyAI5L0Q7gEdlqWRzd23fP/xsGQPQ13QnHn0XuFu99BFUP1S9YjlsmIvzLopGfY8EHEMqMpd1IeTfR2oXDtBQJyuoc2rLN7itFGHQTsBnyivvmElbfzN5WPysCloD8ESlAQ6qvHJtBj/iazgYVWdUXDbk8JZz68Zmqp6vlvkb52OtS93GLjenVdCn5nzodETpEeddXEBvYIhVJ2TPU1FumjU5sFQw/45UYM3POowuZtgbJTjzwRFyHcHxWw0g2mUGd4w/BqnSJYTygOklD5VxhMZmco60PCk4MplGMQWQbx0Mf/idjvNN5GYlk/e61Spfr18vH3XwxQheUWjJQtbY5wjMOqwKTtfbv6MgvNBbHvEIzi84dPlDfg4gI57pAQfhmjJ0mK5ERNWqgaP0eIV3Oj7ayi4TftnUSO0kBeH4AZjXL5Z09aeThPT15jQAdUks3tKeGn6FHTpp9+3sKgPq3Z/mt1VfIfMov07KUXyCva0iWkpjKu6qzMUTPVpZ4aloBzloh+85TQv41zZFt9O/tghUhhTx0zARRXU9xrttKPKSOk96Q/q2Fy4jOWga7e2nc7L0GA46UYyuPRzEpgA0cQC+Y1txOwDsT/kaQjaauwDSSciU/aIxlLVjsur1wLrS0t2cIsp7V9u3+kIvOqAihlRpgpkshzmx5NDcGbk3YSjq7duy86W+V6s/Cu5MemOUeNUQE6NXECzCNFSR/T3wP8KnkH/xeZsha6kGrNPOfoYZ3lIHTwpvENMQj7lk8S X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae63b70d-23b3-4217-3aec-08d91e14588d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2021 17:58:18.4665 (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: i1bvola1rsfwI7d1DwE/ENkO5XljNmXcN9O59meShj7D6IfVe2D5oLJgN3G3p9s4ug6+MDIvQ1AxiMsJYy2FXUik1FSymq9P4uf6m9LNS8k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3239 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 X-Proofpoint-ORIG-GUID: CGJtIvrXiZ_qWeGl2Lw7qGfUgLg5ozqH X-Proofpoint-GUID: CGJtIvrXiZ_qWeGl2Lw7qGfUgLg5ozqH X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9993 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105230136 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org We need to make sure that abort and reset completion work has completed before ep_disconnect returns. After ep_disconnect we can't manipulate cmds because libiscsi will call conn_stop and take onwership. We are trying to make sure abort work and reset completion work has completed before we do the cmd clean up in ep_disconnect. The problem is that: 1. the work function sets the QEDI_CONN_FW_CLEANUP bit, so if the work was still pending we would not see the bit set. We need to do this before the work is queued. 2. If we had multiple works queued then we could break from the loop in qedi_ep_disconnect early because when abort work 1 completes it could clear QEDI_CONN_FW_CLEANUP. qedi_ep_disconnect could then see that before work 2 has run. 3. A TMF reset completion work could run after ep_disconnect starts cleaning up cmds via qedi_clearsq. ep_disconnect's call to qedi_clearsq -> qedi_cleanup_all_io would might think it's done cleaning up cmds, but the reset completion work could still be running. We then return from ep_disconnect while still doing cleanup. This replaces the bit with a counter to track the number of queued TMF works, and adds a bool to prevent new works from starting from the completion path once a ep_disconnect starts. Reviewed-by: Manish Rangankar Signed-off-by: Mike Christie --- drivers/scsi/qedi/qedi_fw.c | 42 ++++++++++++++++++++++------------ drivers/scsi/qedi/qedi_iscsi.c | 23 +++++++++++++------ drivers/scsi/qedi/qedi_iscsi.h | 4 ++-- 3 files changed, 46 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 4ee1ce1dcdef..3de1422ce80b 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c @@ -156,7 +156,6 @@ static void qedi_tmf_resp_work(struct work_struct *work) struct iscsi_tm_rsp *resp_hdr_ptr; int rval = 0; - set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); resp_hdr_ptr = (struct iscsi_tm_rsp *)qedi_cmd->tmf_resp_buf; rval = qedi_cleanup_all_io(qedi, qedi_conn, qedi_cmd->task, true); @@ -169,7 +168,10 @@ static void qedi_tmf_resp_work(struct work_struct *work) exit_tmf_resp: kfree(resp_hdr_ptr); - clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); + + spin_lock(&qedi_conn->tmf_work_lock); + qedi_conn->fw_cleanup_works--; + spin_unlock(&qedi_conn->tmf_work_lock); } static void qedi_process_tmf_resp(struct qedi_ctx *qedi, @@ -225,16 +227,25 @@ static void qedi_process_tmf_resp(struct qedi_ctx *qedi, } spin_unlock(&qedi_conn->list_lock); - if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) || - ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_TARGET_WARM_RESET) || - ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == - ISCSI_TM_FUNC_TARGET_COLD_RESET)) { + spin_lock(&qedi_conn->tmf_work_lock); + switch (tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { + case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET: + case ISCSI_TM_FUNC_TARGET_WARM_RESET: + case ISCSI_TM_FUNC_TARGET_COLD_RESET: + if (qedi_conn->ep_disconnect_starting) { + /* Session is down so ep_disconnect will clean up */ + spin_unlock(&qedi_conn->tmf_work_lock); + goto unblock_sess; + } + + qedi_conn->fw_cleanup_works++; + spin_unlock(&qedi_conn->tmf_work_lock); + INIT_WORK(&qedi_cmd->tmf_work, qedi_tmf_resp_work); queue_work(qedi->tmf_thread, &qedi_cmd->tmf_work); goto unblock_sess; } + spin_unlock(&qedi_conn->tmf_work_lock); __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr_ptr, NULL, 0); kfree(resp_hdr_ptr); @@ -1359,7 +1370,6 @@ static void qedi_abort_work(struct work_struct *work) mtask = qedi_cmd->task; tmf_hdr = (struct iscsi_tm *)mtask->hdr; - set_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); spin_lock_bh(&conn->session->back_lock); ctask = iscsi_itt_to_ctask(conn, tmf_hdr->rtt); @@ -1429,10 +1439,7 @@ static void qedi_abort_work(struct work_struct *work) send_tmf: send_iscsi_tmf(qedi_conn, qedi_cmd->task, ctask); - -clear_cleanup: - clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); - return; + goto clear_cleanup; ldel_exit: spin_lock_bh(&qedi_conn->tmf_work_lock); @@ -1451,7 +1458,10 @@ static void qedi_abort_work(struct work_struct *work) } spin_unlock(&qedi_conn->list_lock); - clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); +clear_cleanup: + spin_lock(&qedi_conn->tmf_work_lock); + qedi_conn->fw_cleanup_works--; + spin_unlock(&qedi_conn->tmf_work_lock); } static int send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask, @@ -1546,6 +1556,10 @@ int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask) switch (tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) { case ISCSI_TM_FUNC_ABORT_TASK: + spin_lock(&qedi_conn->tmf_work_lock); + qedi_conn->fw_cleanup_works++; + spin_unlock(&qedi_conn->tmf_work_lock); + INIT_WORK(&qedi_cmd->tmf_work, qedi_abort_work); queue_work(qedi->tmf_thread, &qedi_cmd->tmf_work); break; diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c index ddb47784eb4a..bf581ecea897 100644 --- a/drivers/scsi/qedi/qedi_iscsi.c +++ b/drivers/scsi/qedi/qedi_iscsi.c @@ -603,7 +603,11 @@ static int qedi_conn_start(struct iscsi_cls_conn *cls_conn) goto start_err; } - clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); + spin_lock(&qedi_conn->tmf_work_lock); + qedi_conn->fw_cleanup_works = 0; + qedi_conn->ep_disconnect_starting = false; + spin_unlock(&qedi_conn->tmf_work_lock); + qedi_conn->abrt_conn = 0; rval = iscsi_conn_start(cls_conn); @@ -1019,7 +1023,6 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep) int ret = 0; int wait_delay; int abrt_conn = 0; - int count = 10; wait_delay = 60 * HZ + DEF_MAX_RT_TIME; qedi_ep = ep->dd_data; @@ -1035,13 +1038,19 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep) qedi_conn = qedi_ep->conn; abrt_conn = qedi_conn->abrt_conn; - while (count--) { - if (!test_bit(QEDI_CONN_FW_CLEANUP, - &qedi_conn->flags)) { - break; - } + QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, + "cid=0x%x qedi_ep=%p waiting for %d tmfs\n", + qedi_ep->iscsi_cid, qedi_ep, + qedi_conn->fw_cleanup_works); + + spin_lock(&qedi_conn->tmf_work_lock); + qedi_conn->ep_disconnect_starting = true; + while (qedi_conn->fw_cleanup_works > 0) { + spin_unlock(&qedi_conn->tmf_work_lock); msleep(1000); + spin_lock(&qedi_conn->tmf_work_lock); } + spin_unlock(&qedi_conn->tmf_work_lock); if (test_bit(QEDI_IN_RECOVERY, &qedi->flags)) { if (qedi_do_not_recover) { diff --git a/drivers/scsi/qedi/qedi_iscsi.h b/drivers/scsi/qedi/qedi_iscsi.h index 68ef519f5480..758735209e15 100644 --- a/drivers/scsi/qedi/qedi_iscsi.h +++ b/drivers/scsi/qedi/qedi_iscsi.h @@ -169,8 +169,8 @@ struct qedi_conn { struct list_head tmf_work_list; wait_queue_head_t wait_queue; spinlock_t tmf_work_lock; /* tmf work lock */ - unsigned long flags; -#define QEDI_CONN_FW_CLEANUP 1 + bool ep_disconnect_starting; + int fw_cleanup_works; }; struct qedi_cmd {