From patchwork Thu Jan 12 03:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 642538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 264E2C67871 for ; Thu, 12 Jan 2023 03:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235706AbjALDIy (ORCPT ); Wed, 11 Jan 2023 22:08:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbjALDIu (ORCPT ); Wed, 11 Jan 2023 22:08:50 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 160AF49146; Wed, 11 Jan 2023 19:08:49 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BNkJn3022348; Thu, 12 Jan 2023 03:08:40 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-2022-7-12; bh=5ROmkP5rIIFt2Ere0yJ8TU8DhMzXjjhEh97DDZlwkWE=; b=nMKGmTHwsr0XiILU5A+CzIKb9Gof6YeEPsGnV78wBN23xXmFPqqORYjxNcKRCUgDmtNM 6qQrPo4SPLwTRaVXGPfIWig18ugGN4aQNWoo4HEJx2WA76oQaj81F+/HJJ4+Z39XMisZ RoTZx9OpteYFlyPrbyNkZAr6VAkhi/yjLWxJJ+6se0inXDXjT7JCKC3TrfRV0fK6tHZl Ip6aOnRZt3f9U9MQBcyOOGnp+ZTldPern9J1dOPQ1IP0s3j+OsADpoovCfakID2fMrHY SLT+2dHBX1qDSHPPziGAs6Z3AJianLI0aWv9zyJzKi2Q2LyJm28S7XIjyVKnhF0ajgXB mg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n1y1nhhpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:40 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C26qDH007539; Thu, 12 Jan 2023 03:08:39 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4bkwc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AaweiITDq+UrMKN3/IJ0u2AFO6MXar6TOfd+j27bb0saGIKDS9bXZyoVQZj0kmSLiD6Knj7yfiZJEqFqtFAdwDKrm0U8vlPSirVsBmTP7vOhNh6FrxPt4bOKhewh7EMFU8vv+pZ3tuIbY+hZcAtS374ttNsvXcnsNh/gX0LXnzbc0JAxXA1hQqUE9Hk5rGGhQiNhkdDBoTvQ1EveNSurAh5bauDpPeAewF26FWCjqcX0HS9ovLtOyc8ONm7UYfOzY3y2GF7un6evgeR6AKUIe+Ifu7NPnmLzdV+PvNLM1fwy5NsLTr9djP94f9b7fTutVdvwffayp/AMxoqhRWhdWg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5ROmkP5rIIFt2Ere0yJ8TU8DhMzXjjhEh97DDZlwkWE=; b=nzVTtXS0rbvCWYCzqw+ukui6GxaeAYZoOP198uOp3bMill54na1mMGawm4zHLE+Vq/0C6jpwWTGjwIOES0p6fChLcrGYQKes1TfIsrx5QOfTvGEbxVTuNZhJehATWvSNi4nh6IY2lXrYcqpJJ4W8elNO+FGsONoh9nQl4J0TZKHZgher63JSKqQv4QN5sIwalbyPkLkG8QRk2D6CzH0PqjjJm4C3HnuIpdTZVYiLIeP6glY5CQoMu0gJ5lbN45wUJh4Qwz3TOqIr+fSxL/2yCSVfRTUeoVtSiWh5VKoDn3GFPBwVmOFAJQDCm+/vHTRBkJc+NfO86hpxmUjTmMZwLg== 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=5ROmkP5rIIFt2Ere0yJ8TU8DhMzXjjhEh97DDZlwkWE=; b=MweQvHEOEyufxoBcSEBe2Ie97vBP7F7y20akHmVVu+OcnbvYJJww+0Nzr9Pd31GSSzdah6LaJKD1MsPQG5IctXKQ03vV/n5+0M6Cq0jwnwCixCQOM9xPhUJeC5kgOuNYp3nJDsbZMnPKh4hXOwngceF7PfiQzE8nNgcKmcJCTGA= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:37 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:37 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 01/13] scsi: target: Move sess cmd counter to new struct Date: Wed, 11 Jan 2023 21:08:20 -0600 Message-Id: <20230112030832.110143-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0369.namprd03.prod.outlook.com (2603:10b6:610:119::22) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 852fd21d-75d4-4fe7-4e7a-08daf44a4c4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7+fd3Mtw5tqD58z7jfgEis7M0wfCtIsvU3IyXpzfAFYrAbuF+VbzFWwSEOL+Cx4RfPNXzqYwec/1mDwZSvvJQlTO0f175CyKJOc88UspO13RZgsx1Tdc7boc1HBOPwUTTRSFs7gIuE2SrBO6fe7qEz4ZXNu2v0Q9JIW7sJG4Km4/KQKWWOGQxM6qnLF3yFdG6CsQPOU+mFufBWtIuQJzXYS+Dj2cNi8Q40OvlHhVxyjAkNbryRIXgiCh79o5a84GN84EGuhlpDiiqNpaDq3boiZOK23dbuEz0L1AOvu1FCt5celyMN4d5lwpbNZWRLR6TESmCxQAahUL9wrEptiO763knLVsHljhHDhGIu6qmB+D54dOUq4mtEs9HpKzk6l1FyvHzwdzOUo9KnV5WJdKRF8//UgqBvwf/EzHNBbVT9NOk/pbT+fjC7psaIox6t8IPVafEtkIIST8PXMOPmR+ukcswsGrxM/0MnTOmukMgJWr12/6hzXgkmhhgIHXClao1FRFZnedBLC82mtLo+8uQYrBlfe5FxdSl2FK2Ktm+fEIhBcPyhONuf4nbH0ME26FFoBvVr581Q7MLtAb+58SwFC0crG4sgLSi2psBYU+FYTQHhOzVeCulaNeNvuyjP9shRGjz+2Z9WF2IkhWHqeqWw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nUrDZ/L9edr+lYbl2R0bqxjia9zs1Wzd3V64onMKm9QA1WOH64G5Ut4ijGy6JVFuQbYEakBvs9OAXpSfFOmee4a9GPNJmSgMMCLOKAsT7lw3d2xnbBrJmU1J1ug3QV1xbg+LQU2TncJ/otVHAw0KaoWiLo5Oda4jljk1nl4IHhPwVZBr6FVQ2PD4NxHZORcQr6f9JPkEOl8GOsz3pEITsHEi+Jf2LC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+EXiIAVA3Sde5PF8LPnJINRKyi4IVCZ0IImhBIuq/LwCkHFnEPzPH/RUXo0qdnvvJcryqQHOaE8az/DY4Qjz10cRjpcLwkyKis1Uizj+QyiHScB8wcGv/kUSaExH0WeBRlzTWlTJWANhnRm4eA0LV9gocIoMW3YCcsAGPXysyaPg+D18WH57kLY2i80O1JUpv/XUGcCJKytmvqyIKASnqx2GTfWgmY44RihmCg3crawRqAOgl/0woALU1sjqG3u7UnnMe/GhtO00lwEfZuPqvNeY5MSwcWlV9sam1/QVnCGnMQA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: xEyacuDQdRmAQXL9taSWvBA+OfzGVy0HKrBwnPDZzuFxqlew+GSidD1oN+I9R56glANJm8zdhdM8fX9ncd7YtHdAJwS5U13PpfaJ2ObifHp9tsR1E4ObQ+58i/6eEhQzuDYMuO68L9XAJ0U62+PZqZc9cAQzz9JGM3f5TVVFYXnSjhcxvh+CWfbqgG0+40BxJ/psO/FWmVWBYi6dpa5bMee140RHaidCjzgDCBrWVaDcG6lcpbdC0j/NRmTG5VhqtBftz/sKNLie8hsEA03Ad++FcBC5KnEdpDve+z6Lf45FyVFamugzhdJ2jh/htQ1rUtYMldBfiSQNqQ39R3G+ypwl2JzRxBBlHHNmi+zmp7iUb+4d7Bzt3/WqTGDdgMHRVieelJVShVBLNdIfr0upTPBz7NGvon+IjRSn43eLgz5VmIHvpW4/hsXyqu3rZGH/L1c2Mk3fhu4hv2ztN92VnG5/SVWvTzQKJcHlPpeaQIy9wuf4pWA4HDnllXkKWYB8qJi6WbubQV0OlAgBExt8TYcoFd9DiM0vghS5FpnlNzT8ytIlo84q/xEhgBax7a25GSOkKMuByKZ4qSLRtkvBQEiInKjm3tUPSD7Ks7uBlslgoVDxKeKB5mfzDhCI1PCOLnaod+2LRTdAvBBzTTQ0QJjoRExxTt8OkHotURuAdmvy+2XRKpimtSn6UlFUsg/If+vCSWrso1c+A/VLtL7HpxCU6C1uoXDLjhfICNkABxzomS+rh5Y7BePOb6FyEtH8BiQwjMPn2qx7EfQgdF2Pt3vdAQGgC5erLzwm1jnEkvNblfVSrsQl+SmJSCn84k5d9ZthJMela7U9iZNAPjLO747sLBii2iDwI2PiVEJzBX5o3GApzENvmf1ZSGYv7RV+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 852fd21d-75d4-4fe7-4e7a-08daf44a4c4e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:37.3491 (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: RIEzOAaSVFQ5y/QFZBozeNcL6oJFEZmCfy5mfCcmcwRDJaAqssUfiRAD+wdwzVQbH6tzxe3qxap3l6zqpQ7RrkMmsQzXvZGFfWnkPhMKSkE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: 7s13glwkV4Op3RLSbIn3oBCVk1MhmHf2 X-Proofpoint-ORIG-GUID: 7s13glwkV4Op3RLSbIn3oBCVk1MhmHf2 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org iSCSI needs to wait on outstanding commands like how srp and the FC/fcoe drivers do. It can't use target_stop_session because for MCS support we can't stop the entire session during recovery because if other connections are ok then we want to be able to continue to execute IO on them. This patch moves the per session cmd counters to a new struct, so iSCSI can allocate it per connection. The xcopy code can also just not allocate it in the future since it doesn't need to track commands. Signed-off-by: Mike Christie --- drivers/target/target_core_tpg.c | 2 +- drivers/target/target_core_transport.c | 135 ++++++++++++++++------- include/target/iscsi/iscsi_target_core.h | 1 + include/target/target_core_base.h | 13 ++- 4 files changed, 107 insertions(+), 44 deletions(-) diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 736847c933e5..8ebccdbd94f0 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c @@ -328,7 +328,7 @@ static void target_shutdown_sessions(struct se_node_acl *acl) restart: spin_lock_irqsave(&acl->nacl_sess_lock, flags); list_for_each_entry(sess, &acl->acl_sess_list, sess_acl_list) { - if (atomic_read(&sess->stopped)) + if (sess->cmd_cnt && atomic_read(&sess->cmd_cnt->stopped)) continue; list_del_init(&sess->sess_acl_list); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 5926316252eb..3d6034f00dcd 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -220,11 +220,49 @@ void transport_subsystem_check_init(void) sub_api_initialized = 1; } -static void target_release_sess_cmd_refcnt(struct percpu_ref *ref) +static void target_release_cmd_refcnt(struct percpu_ref *ref) { - struct se_session *sess = container_of(ref, typeof(*sess), cmd_count); + struct target_cmd_counter *cmd_cnt = container_of(ref, + typeof(*cmd_cnt), + refcnt); + wake_up(&cmd_cnt->refcnt_wq); +} + +static struct target_cmd_counter *target_alloc_cmd_counter(void) +{ + struct target_cmd_counter *cmd_cnt; + int rc; + + cmd_cnt = kzalloc(sizeof(*cmd_cnt), GFP_KERNEL); + if (!cmd_cnt) + return NULL; - wake_up(&sess->cmd_count_wq); + init_completion(&cmd_cnt->stop_done); + init_waitqueue_head(&cmd_cnt->refcnt_wq); + atomic_set(&cmd_cnt->stopped, 0); + + rc = percpu_ref_init(&cmd_cnt->refcnt, target_release_cmd_refcnt, 0, + GFP_KERNEL); + if (rc) + goto free_cmd_cnt; + + return cmd_cnt; + +free_cmd_cnt: + kfree(cmd_cnt); + return NULL; +} + +static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) +{ + /* + * Drivers like loop do not call target_stop_session during session + * shutdown so we have to drop the ref taken at init time here. + */ + if (!atomic_read(&cmd_cnt->stopped)) + percpu_ref_put(&cmd_cnt->refcnt); + + percpu_ref_exit(&cmd_cnt->refcnt); } /** @@ -238,25 +276,17 @@ int transport_init_session(struct se_session *se_sess) INIT_LIST_HEAD(&se_sess->sess_list); INIT_LIST_HEAD(&se_sess->sess_acl_list); spin_lock_init(&se_sess->sess_cmd_lock); - init_waitqueue_head(&se_sess->cmd_count_wq); - init_completion(&se_sess->stop_done); - atomic_set(&se_sess->stopped, 0); - return percpu_ref_init(&se_sess->cmd_count, - target_release_sess_cmd_refcnt, 0, GFP_KERNEL); + se_sess->cmd_cnt = target_alloc_cmd_counter(); + if (!se_sess->cmd_cnt) + return -ENOMEM; + + return 0; } EXPORT_SYMBOL(transport_init_session); void transport_uninit_session(struct se_session *se_sess) { - /* - * Drivers like iscsi and loop do not call target_stop_session - * during session shutdown so we have to drop the ref taken at init - * time here. - */ - if (!atomic_read(&se_sess->stopped)) - percpu_ref_put(&se_sess->cmd_count); - - percpu_ref_exit(&se_sess->cmd_count); + target_free_cmd_counter(se_sess->cmd_cnt); } /** @@ -2970,9 +3000,16 @@ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref) se_cmd->se_cmd_flags |= SCF_ACK_KREF; } - if (!percpu_ref_tryget_live(&se_sess->cmd_count)) - ret = -ESHUTDOWN; - + /* + * Users like xcopy do not use counters since they never do a stop + * and wait. + */ + if (se_sess->cmd_cnt) { + if (!percpu_ref_tryget_live(&se_sess->cmd_cnt->refcnt)) + ret = -ESHUTDOWN; + else + se_cmd->cmd_cnt = se_sess->cmd_cnt; + } if (ret && ack_kref) target_put_sess_cmd(se_cmd); @@ -2993,7 +3030,7 @@ static void target_free_cmd_mem(struct se_cmd *cmd) static void target_release_cmd_kref(struct kref *kref) { struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref); - struct se_session *se_sess = se_cmd->se_sess; + struct target_cmd_counter *cmd_cnt = se_cmd->cmd_cnt; struct completion *free_compl = se_cmd->free_compl; struct completion *abrt_compl = se_cmd->abrt_compl; @@ -3004,7 +3041,8 @@ static void target_release_cmd_kref(struct kref *kref) if (abrt_compl) complete(abrt_compl); - percpu_ref_put(&se_sess->cmd_count); + if (cmd_cnt) + percpu_ref_put(&cmd_cnt->refcnt); } /** @@ -3123,46 +3161,65 @@ void target_show_cmd(const char *pfx, struct se_cmd *cmd) } EXPORT_SYMBOL(target_show_cmd); -static void target_stop_session_confirm(struct percpu_ref *ref) +static void target_stop_cmd_counter_confirm(struct percpu_ref *ref) +{ + struct target_cmd_counter *cmd_cnt = container_of(ref, + struct target_cmd_counter, + refcnt); + complete_all(&cmd_cnt->stop_done); +} + +/** + * target_stop_cmd_counter - Stop new IO from being added to the counter. + * @cmd_cnt: counter to stop + */ +static void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt) { - struct se_session *se_sess = container_of(ref, struct se_session, - cmd_count); - complete_all(&se_sess->stop_done); + pr_debug("Stopping command counter.\n"); + if (!atomic_cmpxchg(&cmd_cnt->stopped, 0, 1)) + percpu_ref_kill_and_confirm(&cmd_cnt->refcnt, + target_stop_cmd_counter_confirm); } /** * target_stop_session - Stop new IO from being queued on the session. - * @se_sess: session to stop + * @se_sess: session to stop */ void target_stop_session(struct se_session *se_sess) { - pr_debug("Stopping session queue.\n"); - if (atomic_cmpxchg(&se_sess->stopped, 0, 1) == 0) - percpu_ref_kill_and_confirm(&se_sess->cmd_count, - target_stop_session_confirm); + target_stop_cmd_counter(se_sess->cmd_cnt); } EXPORT_SYMBOL(target_stop_session); /** - * target_wait_for_sess_cmds - Wait for outstanding commands - * @se_sess: session to wait for active I/O + * target_wait_for_cmds - Wait for outstanding cmds. + * @cmd_cnt: counter to wait for active I/O for. */ -void target_wait_for_sess_cmds(struct se_session *se_sess) +static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) { int ret; - WARN_ON_ONCE(!atomic_read(&se_sess->stopped)); + WARN_ON_ONCE(!atomic_read(&cmd_cnt->stopped)); do { pr_debug("Waiting for running cmds to complete.\n"); - ret = wait_event_timeout(se_sess->cmd_count_wq, - percpu_ref_is_zero(&se_sess->cmd_count), - 180 * HZ); + ret = wait_event_timeout(cmd_cnt->refcnt_wq, + percpu_ref_is_zero(&cmd_cnt->refcnt), + 180 * HZ); } while (ret <= 0); - wait_for_completion(&se_sess->stop_done); + wait_for_completion(&cmd_cnt->stop_done); pr_debug("Waiting for cmds done.\n"); } + +/** + * target_wait_for_sess_cmds - Wait for outstanding commands + * @se_sess: session to wait for active I/O + */ +void target_wait_for_sess_cmds(struct se_session *se_sess) +{ + target_wait_for_cmds(se_sess->cmd_cnt); +} EXPORT_SYMBOL(target_wait_for_sess_cmds); /* diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 94d06ddfd80a..229118156a1f 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -600,6 +600,7 @@ struct iscsit_conn { struct iscsi_tpg_np *tpg_np; /* Pointer to parent session */ struct iscsit_session *sess; + struct target_cmd_counter *cmd_cnt; int bitmap_id; int rx_thread_active; struct task_struct *rx_thread; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 12c9ba16217e..bd299790e99c 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -494,6 +494,7 @@ struct se_cmd { struct se_lun *se_lun; /* Only used for internal passthrough and legacy TCM fabric modules */ struct se_session *se_sess; + struct target_cmd_counter *cmd_cnt; struct se_tmr_req *se_tmr_req; struct llist_node se_cmd_list; struct completion *free_compl; @@ -619,22 +620,26 @@ static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item) acl_fabric_stat_group); } -struct se_session { +struct target_cmd_counter { + struct percpu_ref refcnt; + wait_queue_head_t refcnt_wq; + struct completion stop_done; atomic_t stopped; +}; + +struct se_session { u64 sess_bin_isid; enum target_prot_op sup_prot_ops; enum target_prot_type sess_prot_type; struct se_node_acl *se_node_acl; struct se_portal_group *se_tpg; void *fabric_sess_ptr; - struct percpu_ref cmd_count; struct list_head sess_list; struct list_head sess_acl_list; spinlock_t sess_cmd_lock; - wait_queue_head_t cmd_count_wq; - struct completion stop_done; void *sess_cmd_map; struct sbitmap_queue sess_tag_pool; + struct target_cmd_counter *cmd_cnt; }; struct se_device; From patchwork Thu Jan 12 03:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFD6BC63797 for ; Thu, 12 Jan 2023 03:08:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbjALDIw (ORCPT ); Wed, 11 Jan 2023 22:08:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbjALDIu (ORCPT ); Wed, 11 Jan 2023 22:08:50 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E91DF49147; Wed, 11 Jan 2023 19:08:49 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C2upe1022836; Thu, 12 Jan 2023 03:08:41 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-2022-7-12; bh=IgzHmvphR39o3PjSXKQRjVIpDY4S0MEkoRf/Ej+4fuY=; b=uvRiuDenbiykOrONpet8Uxe6NdpJp1Ov9E3BmHAEnehC5o3c/lGd4BX1LK9ohstWVgkx llBql/5+ejmp/uGO86BYh6bBZGiA3XLAhXWqcG0dpMFdCd6UAj5IX12oHLH0Mrx2JcIN 3AlQ2ULkMiT6nC1vHEoecw6afKm6VZAuU/81xw3Lp5B5+iQLsorQ9QGpEkjxFmjdTIyG ko4Xf/whdCCcVu6sPcW1WKfYtuTtkAsTcD3kPATU8rR45LXHeC/sGEWkAjvRyvKIxqio AwKKZ7HpzGjG45tZLynLVOlawTsZZGes9+O1Og2BESuEEYNqa4UKwmNnySAV2xrSaH4V iQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n28ja82my-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:41 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C26qDI007539; Thu, 12 Jan 2023 03:08:40 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4bkwc6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMf7eo6CA54EljbVmvMZWthjLCaJwyr/RAH6LIWMHcykFYwZB7Mt6F298vyF9LUIYfXDvLGJnyiKKEe6rJqAdBmslY5ujga/EL1zGUgHTDAsPjEbIvMa5jIjQoRLSXLUI7wpS5EUNiWCOF+kPluh00dQIN04E5+FiYbzfcQcrwDgfk/l+e3pKZvB9XnYep6cxTV2D7WqgaOXAjQ0BsZ4PAuU8C3ZkAuLbDIDiz+3bHyCDjASchhj9QM1+80tLBs/q22s0+ZkAHin3f/bKz57S8V7chhuZK2EvbIJQ+kfz96x+HoPv94plKu+0DBlWbkZZTHUpSqb7klfgAETcivuPA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IgzHmvphR39o3PjSXKQRjVIpDY4S0MEkoRf/Ej+4fuY=; b=HrExJQE+nl4qJoG7ZnBPzPAm2OovqcFJ/2QlryNxElh5wCPj7O5UcBLJd50H+zPfnrVlfIEa1r6WPR6gip7tBF3YqcKYtTFmPN13XmQUiMdX8tkexdAB7DVPR0dI0cmni9prAnPA3181uGYo7qjV6W/FFXuCkcFMbsjr3/SRJ8yQFy7pI3yrfHLfpaHktCyY23bX4hw1fyWsyzGZbEqGx/585pCEX8fTM4GpdmXWM3IG70/YffDnF6ESYo+ZnpO7zUZy/VWjPWZQffSl5uNV6bVpy8y/ohcLWcdQZmRxXptfjp1bnEmZ1Kxf1kTmFOB4BmzB0Ts8h5VgPoRctk3G8Q== 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=IgzHmvphR39o3PjSXKQRjVIpDY4S0MEkoRf/Ej+4fuY=; b=GwOF87sFLHWxuhjFu9A3CU1IJ9a0pFa0JWqnc90ht60fSIF2CZWoAMYSFWyFerdTIcIn4tUnt3EFrRTph5y868qIvsj5x+rSnr4zPyqxk/k4fIvMwp7HsusvBtAMNmxi23rEv6DcOa8hPt/9iw0fM8XFQTVpXi07tMXbQ50i2nU= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:38 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:38 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 02/13] scsi: target: Move cmd counter allocation Date: Wed, 11 Jan 2023 21:08:21 -0600 Message-Id: <20230112030832.110143-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0379.namprd03.prod.outlook.com (2603:10b6:610:119::6) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: f35803d4-47f3-4b6d-c915-08daf44a4d30 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOamh+Ms3jMOjn0vbGT+HP03GLFHpFHA66r6Dq9So4jDuQBZBuyGXTti5NMfl7TIpfTww7E1rbX4+oqZ7c+L5i/YOS9jv3+//5kHNXnA2cq5N0bX+H4+czsiZuWkWTwzy9blK49uP24BVPgXqj9OVFBzn4ReWlzEMjCzXiOu0CjH5rxREadpvw1RO/y8/ay5/vDJM0+wSCOCSpRdIM+mCxv2Wse8FZGilDNfWTomNzoCv/3FP8n8TWbmgNLAfhj2zJNvc9fGkdayNDuYQhhqEC/VXTZeL9OM9fH47zAlJQHCs4wuphK1OwOO8crfFPwPzCqSIAq2KM18sOhyGPSzCRIgSngRG4j8eLAxZHSYTUuC4yA9cMRdxz5m1w8wSSWiLjgvnzvBaO0jz2KyUXoYaUAdmFoJuYZ196xK2+15WkLxgKUtv9vwXEUeNGZzFDgGJJZ/Ej1RQSTuo0C6o0Sr/i0CR3w7mheeudjIVBZ3JYHtc/C5sAzztZUXpIqlm7J9gFzhBzXI/lpKIUEvDeAuGhfxE1xMwQ/aJZqSS77wtBHasC8HCJPEI/eAZEGQxRHaa8ndRImo5UGsfkXP3Ma2Nmk0Ab+6Zh+NK+C4aEk0ao+72uERd8qQao3UDoEKfzRpgUpcO/qpi9tW/HS5or3GAg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kgemKBI0cYJssbBK00/mZsC9M8MZJIrcN1EhL6aFiBCr/qNzx07y56i6u7dxhQWGkkL0VG54+9Qfed+CCtHCec2gRPROU1CXcUFJ+2S20K+uL85AClO4/PS7w4wXajNOn62KUe0zvZEVOydSFM/2GtwdF5wF2eG5kyhM0nFfvTw9cd6dIefJc1sSOgPDgMvDXbESnBOf7zlmRxEv4HKZLyMds6byIsdlvLKqL3seB4B3bPQqkHYEREBkkM2kVCFy9JXcUE2vWeBrwBJaKmHeNFbMYWjCDs0wzUsiWlfT+WQWvRrvAvE+Ms8nnO7AcfaXIKHdSedNrnYM4OM6PuG4hG8LkOnXllY35pW13GJ1WFr3ZLVwct0lrMTuOjBjKmQAgYTDkE21H9YgA+VgI0EjYRemf5LkUHDKUuCEXQRnF/9X+BBcvhqAniTyCPR8b2nDqbGPKoksZsURHEXOXb4d9/FhRhCwfzyeZl0vFXApkVTmDvCWi1/jsWmCyiX82C2kAk2JP/m3kEnESrMQ3IldQ5PqV27cVBBVm5SRAyMnzXJmZAL2W4VYQTjjEWFLkCsmj42PT3O6WW9dtgFkQeqCnJPwAIeIaIGnk+PnbY0ZOl8kAT3Y8qpmV8YfIfCGT5C4OWZ7I68lCz4Sed52LIdbSHYkE/SAMdyGOmxffnkTjAG3dEjjJVUzd0eJ/YuA8AE155CLxYeAOygBr983kHZ3qHaI+V6qve05pTAlAjqEAkC+gKJ40821aJ7pFF80IZ9n4Grd0LgtLMwlvoq1fMY1DxCND6NEmoStM3bNPyneTJPSYLd8snez8icjmIyEEG9xk14fnjm03SaU0NQVgmoUv2vrc/lGSC30G+l6Yw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9AugSr9yqum3G0oTbCOTWte3tNKaS/np6Yy2xvl+wa3f4KG6FoQYMSewCpJX7XssRon+mAEcgLymv9mTqOdNr0UKkny6ecTJgMTfk0S2MTq+K+sPAzbdlcCIFCArfX55rI3PkB63nE3GbJdYFTeJyWzoQbw7jl5Aw7KQMoJ962DJqTxMHjfoT9uaSlV/Z8t7Qpd7XMwPiH8uVwwmoSWOuTe7ZP1umSdjykQ8F3lreGuYjTbzd1SdAXTJCKwGM5OFN0tPouwe4ORoxzR3VgGMqdWg7bLSL/FQS7AJdi+hZB1rJPRqOAqx1rhKf9HI4pqcgVf5el0ixouRz/LwM/voLttyWAU0WLe8XObR+BjApPi3iE1ghI+SAztwpsJ9qLzhI1fcFmmtACFu6XnYn8+Q19lv/ATEKwVrF/vo8j2zZt77tAiuodwSwxCMHCF/19CeveIctX9xA2ggV80eUbfknS9CVJzBMhqHdrlZV7ZXRi8eyseod/rZ+8Aiyg97e+HQ8Na14jmkbna1CFPpwOVPKI9PYYeF2+Xdp08wpw3dWwnlGSWFjf+r+2LctD4lGccgxcrLC9kaXVaUtCDQ+V8/Rz9VkJgvOL+N+lDg/CgDlZYRpFxE/6CktlZbrzD4l0ANe/4nGCCjUQR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f35803d4-47f3-4b6d-c915-08daf44a4d30 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:38.7865 (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: jn4w1hBQt4IInhrO4fbhfcot8IVQikVIM6p19YP+AznSjiD1cPGoPG1oQC1iDqYhiMrNWtyivLixhoNf3dK6uSZtIsdUyLR8Czugn6dEH/A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-ORIG-GUID: Tx2VMfpBdcSEbFuMV2FCynH58rCQ6p98 X-Proofpoint-GUID: Tx2VMfpBdcSEbFuMV2FCynH58rCQ6p98 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org iSCSI needs to allocate its cmd counter per connection for MCS support where we need to stop and wait on commands running on a connection instead of per session. This moves the cmd counter allocation to target_setup_session which is used by drivers that need the stop+wait behavior per session. xcopy doesn't need stop+wait at all, so we will be ok moving the cmd counter allocation outside of transport_init_session. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target_login.c | 10 +++++ drivers/target/target_core_internal.h | 1 - drivers/target/target_core_transport.c | 55 +++++++++++------------ drivers/target/target_core_xcopy.c | 15 +------ include/target/target_core_fabric.h | 4 +- 5 files changed, 42 insertions(+), 43 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 27e448c2d066..8ab6c0107d89 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -324,8 +324,18 @@ static int iscsi_login_zero_tsih_s1( goto free_ops; } + /* + * This is temp for iser. It will be moved to per conn in later + * patches for iscsi. + */ + sess->se_sess->cmd_cnt = target_alloc_cmd_counter(); + if (!sess->se_sess->cmd_cnt) + goto free_se_sess; + return 0; +free_se_sess: + transport_free_session(sess->se_sess); free_ops: kfree(sess->sess_ops); free_id: diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 38a6d08f75b3..85e35cf582e5 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -138,7 +138,6 @@ int init_se_kmem_caches(void); void release_se_kmem_caches(void); u32 scsi_get_new_index(scsi_index_t); void transport_subsystem_check_init(void); -void transport_uninit_session(struct se_session *); unsigned char *transport_dump_cmd_direction(struct se_cmd *); void transport_dump_dev_state(struct se_device *, char *, int *); void transport_dump_dev_info(struct se_device *, struct se_lun *, diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 3d6034f00dcd..60647a49a1d3 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -228,7 +228,7 @@ static void target_release_cmd_refcnt(struct percpu_ref *ref) wake_up(&cmd_cnt->refcnt_wq); } -static struct target_cmd_counter *target_alloc_cmd_counter(void) +struct target_cmd_counter *target_alloc_cmd_counter(void) { struct target_cmd_counter *cmd_cnt; int rc; @@ -252,6 +252,7 @@ static struct target_cmd_counter *target_alloc_cmd_counter(void) kfree(cmd_cnt); return NULL; } +EXPORT_SYMBOL_GPL(target_alloc_cmd_counter); static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) { @@ -271,24 +272,14 @@ static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) * * The caller must have zero-initialized @se_sess before calling this function. */ -int transport_init_session(struct se_session *se_sess) +void transport_init_session(struct se_session *se_sess) { INIT_LIST_HEAD(&se_sess->sess_list); INIT_LIST_HEAD(&se_sess->sess_acl_list); spin_lock_init(&se_sess->sess_cmd_lock); - se_sess->cmd_cnt = target_alloc_cmd_counter(); - if (!se_sess->cmd_cnt) - return -ENOMEM; - - return 0; } EXPORT_SYMBOL(transport_init_session); -void transport_uninit_session(struct se_session *se_sess) -{ - target_free_cmd_counter(se_sess->cmd_cnt); -} - /** * transport_alloc_session - allocate a session object and initialize it * @sup_prot_ops: bitmask that defines which T10-PI modes are supported. @@ -296,7 +287,6 @@ void transport_uninit_session(struct se_session *se_sess) struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) { struct se_session *se_sess; - int ret; se_sess = kmem_cache_zalloc(se_sess_cache, GFP_KERNEL); if (!se_sess) { @@ -304,11 +294,7 @@ struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) " se_sess_cache\n"); return ERR_PTR(-ENOMEM); } - ret = transport_init_session(se_sess); - if (ret < 0) { - kmem_cache_free(se_sess_cache, se_sess); - return ERR_PTR(ret); - } + transport_init_session(se_sess); se_sess->sup_prot_ops = sup_prot_ops; return se_sess; @@ -474,8 +460,13 @@ target_setup_session(struct se_portal_group *tpg, int (*callback)(struct se_portal_group *, struct se_session *, void *)) { + struct target_cmd_counter *cmd_cnt; struct se_session *sess; + int rc; + cmd_cnt = target_alloc_cmd_counter(); + if (!cmd_cnt) + return ERR_PTR(-ENOMEM); /* * If the fabric driver is using percpu-ida based pre allocation * of I/O descriptor tags, go ahead and perform that setup now.. @@ -485,29 +476,36 @@ target_setup_session(struct se_portal_group *tpg, else sess = transport_alloc_session(prot_op); - if (IS_ERR(sess)) - return sess; + if (IS_ERR(sess)) { + rc = PTR_ERR(sess); + goto free_cnt; + } + sess->cmd_cnt = cmd_cnt; sess->se_node_acl = core_tpg_check_initiator_node_acl(tpg, (unsigned char *)initiatorname); if (!sess->se_node_acl) { - transport_free_session(sess); - return ERR_PTR(-EACCES); + rc = -EACCES; + goto free_sess; } /* * Go ahead and perform any remaining fabric setup that is * required before transport_register_session(). */ if (callback != NULL) { - int rc = callback(tpg, sess, private); - if (rc) { - transport_free_session(sess); - return ERR_PTR(rc); - } + rc = callback(tpg, sess, private); + if (rc) + goto free_sess; } transport_register_session(tpg, sess->se_node_acl, sess, private); return sess; + +free_sess: + transport_free_session(sess); +free_cnt: + target_free_cmd_counter(cmd_cnt); + return ERR_PTR(rc); } EXPORT_SYMBOL(target_setup_session); @@ -632,7 +630,8 @@ void transport_free_session(struct se_session *se_sess) sbitmap_queue_free(&se_sess->sess_tag_pool); kvfree(se_sess->sess_cmd_map); } - transport_uninit_session(se_sess); + if (se_sess->cmd_cnt) + target_free_cmd_counter(se_sess->cmd_cnt); kmem_cache_free(se_sess_cache, se_sess); } EXPORT_SYMBOL(transport_free_session); diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index 49eaee022ef1..49a83500c8b7 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -461,8 +461,6 @@ static const struct target_core_fabric_ops xcopy_pt_tfo = { int target_xcopy_setup_pt(void) { - int ret; - xcopy_wq = alloc_workqueue("xcopy_wq", WQ_MEM_RECLAIM, 0); if (!xcopy_wq) { pr_err("Unable to allocate xcopy_wq\n"); @@ -479,9 +477,7 @@ int target_xcopy_setup_pt(void) INIT_LIST_HEAD(&xcopy_pt_nacl.acl_list); INIT_LIST_HEAD(&xcopy_pt_nacl.acl_sess_list); memset(&xcopy_pt_sess, 0, sizeof(struct se_session)); - ret = transport_init_session(&xcopy_pt_sess); - if (ret < 0) - goto destroy_wq; + transport_init_session(&xcopy_pt_sess); xcopy_pt_nacl.se_tpg = &xcopy_pt_tpg; xcopy_pt_nacl.nacl_sess = &xcopy_pt_sess; @@ -490,19 +486,12 @@ int target_xcopy_setup_pt(void) xcopy_pt_sess.se_node_acl = &xcopy_pt_nacl; return 0; - -destroy_wq: - destroy_workqueue(xcopy_wq); - xcopy_wq = NULL; - return ret; } void target_xcopy_release_pt(void) { - if (xcopy_wq) { + if (xcopy_wq) destroy_workqueue(xcopy_wq); - transport_uninit_session(&xcopy_pt_sess); - } } /* diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 38f0662476d1..65527174b8bc 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -133,7 +133,9 @@ struct se_session *target_setup_session(struct se_portal_group *, struct se_session *, void *)); void target_remove_session(struct se_session *); -int transport_init_session(struct se_session *se_sess); +struct target_cmd_counter *target_alloc_cmd_counter(void); + +void transport_init_session(struct se_session *se_sess); struct se_session *transport_alloc_session(enum target_prot_op); int transport_alloc_session_tags(struct se_session *, unsigned int, unsigned int); From patchwork Thu Jan 12 03:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0B48C46467 for ; Thu, 12 Jan 2023 03:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236034AbjALDI7 (ORCPT ); Wed, 11 Jan 2023 22:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235842AbjALDIy (ORCPT ); Wed, 11 Jan 2023 22:08:54 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AE9149149; Wed, 11 Jan 2023 19:08:53 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BLE97n017447; Thu, 12 Jan 2023 03:08:48 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-2022-7-12; bh=Z9IJ1MpNV7Ww8oAFrYQBPbt42LUUWffkJ0U4jB/bzuQ=; b=0c+OahWxNvigkcjZQo4ulwXhPg1vE77siPOIQKCqZMtDUMx0LI/9DNxBfyeY9kA3Ck1D w6mZQMVUtv6HX9ZVagAz5u7L7zPYbj2MQAAhLhlnOG5SNhbQ7pdeu7NX2eNMQWbNxKYY JWLQDH+qfrX20W+Qe2pSa7twzrHDjzbpS/EjRjs4oxvrkCoUNfKByjlO66BjJBhQYIWJ HbE80CShst3d+0LrwjA4U0WDCFf2G3mAsvYauBSZDlVNn4cuqneOlWFdlz+/Xef6508J ePmhjyDATiq8Cg+0pgCAs50AC5RU/AmrQ201MttbQ1e4XDtCiicDLh8xHKYqAvNkEuEN bw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n22x00up8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:48 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0Y8034176; Thu, 12 Jan 2023 03:08:47 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZxtVWUeFRyfR0DDyA3y59pkPwLMhVbhJ3NrpIdZVartp7x6owmH85IIQSfoXin3yqITIvekTNfclOy2AxkTZA5tMF0LuwaFGTTQ+QQ8K1lzqZVbfrSzVv3ki6rlPosM/znu781JC8Lf5bHbZOEZt01SuB2F6dgCuKHfMaWKhHyA017IrOm34CHduCV8TDMJA7elMKgst8edSsctm/jl9RgnphBL05Hed0bb9PwwP68Ke0esRT1LKJ25ONwbjb7Exr1UUq0zC6AAMPPSZUD7fBniVK05Y/Buv34j98Xe1FXUD4yO7v9AYIPgw6L68aeSaOtxnx+4JAxUO8Xz8FTxxnQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z9IJ1MpNV7Ww8oAFrYQBPbt42LUUWffkJ0U4jB/bzuQ=; b=dj40ulerbVU59KzjhYM6/jblIW4HKtq+QNf1o871HdUKhxzKoBUu5Algypd9LdCUu5PAilm+Lr9VRpWiGKy9dm4U322/uF4cQIO62CKMJypf+Y0+gfKMCu/M3cvlDr+QiSKzk0UjAqZNsnAKW/z1v+Mj+EhSyohNDrNv4ju6LWAjP/y+8mpVFcZPgnvhYe2NPlWelAsbIl/uJ98LDGBpUEW9H8KvCTB48guidbIroMhweRZ5NAWtZ0y+nXu//sRURX84ztLjlkFtI0fEjNdMi+wQ9du4l+I7LZOkp0gsbHlKJOo28DQqhdyGSAwmHQpmACHoY3icTYQefVsd6fF29Q== 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=Z9IJ1MpNV7Ww8oAFrYQBPbt42LUUWffkJ0U4jB/bzuQ=; b=hdSJghVDY44Cily9YmH3A2ANJgu1fFE6i0VxF0Pikl6bnZJpXZKAtPjyKcBFsO6PniwqZ5qdDf/hp0xHl0CkmMZnZWBwiZ9MoGMei8t4M6/JUXn2wOEK6KQFxvy3LnOYJZyht5XwPsvJnQRZdp6pZnK8V2SwD3sjeEWXGv7vgsY= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:40 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:40 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 03/13] scsi: target: Pass in cmd counter to use during cmd setup Date: Wed, 11 Jan 2023 21:08:22 -0600 Message-Id: <20230112030832.110143-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0375.namprd03.prod.outlook.com (2603:10b6:610:119::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 8952c14f-20c2-4138-1abc-08daf44a4e2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rkqzkmcZTdsbCVkhbMV2OOlXUs/XhXTJ6AC8fA0rr+CjCLhVflv3+035IqXjngF1kdXnG6ApqvGN33HNp6ENJvTJofexrEPBDP0WSAXyq5O2/sxVTuhUPCxVx1zqG+KYkW2MKfR87hWDgHCqfpTuYvu/AExEdmGujyMjhQHQhzLqrGur9H2Ud7xPAnK3NW1craXCb5k+3BcyBWY5i7X0xd2SJHLjiLW91j14zWBV+6PILIzxM8iIq/zuFf/VUJtPBPteNiHxzraFilRc0R0tnzFZivX5MUHVRXkqp/UvW/vP8YeIYe1NKifUZZIiRpYCLkTAzJVf6PSTtWGFp/EWLC3PnUcXf3YCKU1d4BRe1daOUxLvtGLm7gFR+0/D3pniM9Q6/EOcb3GQKGJbtNf0KzuBLAAgD8ecthK6/pyvKYMV4V1d5T3lRrAeatdWGbG/sBZ7Atwk/QnliwxcWChPM7tJ637n3ny+MOfLGkqlLG5ph2aE6hX/D4Umdu2jE0hjuR+IALJsRUwZsOK0dRAXxan1KrK/zwyNITNJvfNhIwNZ17SYlezS1cvKiCcOHr/tH39VCHZtn2mWcnp+WzEcMgoFuXDA8gd7HOewe+UzfZFCniYf+iTgBn7ZPGxzODc8h+gCS1w9eO7+j03QihihgA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: glVGqHTRFm5HL1Pk3YdNr1toJKJo9bFW1AIBC3rvyEaZ+DtuYqd6nRhsgPWgaD0nnglA+Be9b0grfs8AgnFszWvW3P0F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6RoYrIcy/dxZBfMohCGossOi6DSsgRnWDzLkAbxqVF79ZaoOroGOGPcATJ1qtWguK9n/o0WjKe55TJx2xIjXdgjv1je6up6QYvBIcWa7CXLpQxsQHaodDC7CcMIWAt7YRBnd/0YTzJSYC0kN9CSX9jTOk59n69p5lTV03ONBlOtD8Fgx6npYWfbBWq/WBRrmxvGXZ9im8qtmdv7Npw1SsJKB2MuW9eSi4AQqwaNm3CGWe1tBXuYatWw8q4adoWhdIxgUiuHQF3DJyoWuCVwkmovQCVb2H+NPum6ZlYnvnTVjb1g7D1L51tcTUi1pgiuia1ort7O7SOJx X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8952c14f-20c2-4138-1abc-08daf44a4e2b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:40.4113 (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: vx+if/KySe/dd/sb1sDhPcXwiu/1F18OCT5nzm7njrMg2qmE1sQF8gX/9x0nwMZzkPDnZkAXhLIJpMbi6l/jHg+LGRCGGCg/Gc0oU89H4ss= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-ORIG-GUID: ljP5-HTMsuuuPSKrJIL0KqeLQolqSsnh X-Proofpoint-GUID: ljP5-HTMsuuuPSKrJIL0KqeLQolqSsnh Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This allows target_get_sess_cmd users to pass in the cmd counter they want to use. Right now we pass in the session's cmd counter but in the next patch iSCSI will switch from per session to per conn so this patch will be needed for that conversion. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 10 +++++---- drivers/target/target_core_transport.c | 28 ++++++++++++-------------- drivers/target/target_core_xcopy.c | 8 ++++---- drivers/usb/gadget/function/f_tcm.c | 4 ++-- include/target/target_core_fabric.h | 8 +++++--- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index baf4da7bb3b4..87927a36f90d 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1190,9 +1190,10 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, * Initialize struct se_cmd descriptor from target_core_mod infrastructure */ __target_init_cmd(&cmd->se_cmd, &iscsi_ops, - conn->sess->se_sess, be32_to_cpu(hdr->data_length), - cmd->data_direction, sam_task_attr, - cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun)); + conn->sess->se_sess, be32_to_cpu(hdr->data_length), + cmd->data_direction, sam_task_attr, + cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun), + conn->sess->se_sess->cmd_cnt); pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, @@ -2055,7 +2056,8 @@ iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, __target_init_cmd(&cmd->se_cmd, &iscsi_ops, conn->sess->se_sess, 0, DMA_NONE, TCM_SIMPLE_TAG, cmd->sense_buffer + 2, - scsilun_to_int(&hdr->lun)); + scsilun_to_int(&hdr->lun), + conn->sess->se_sess->cmd_cnt); target_get_sess_cmd(&cmd->se_cmd, true); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 60647a49a1d3..c395606ab1a9 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1441,14 +1441,12 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size) * * Preserves the value of @cmd->tag. */ -void __target_init_cmd( - struct se_cmd *cmd, - const struct target_core_fabric_ops *tfo, - struct se_session *se_sess, - u32 data_length, - int data_direction, - int task_attr, - unsigned char *sense_buffer, u64 unpacked_lun) +void __target_init_cmd(struct se_cmd *cmd, + const struct target_core_fabric_ops *tfo, + struct se_session *se_sess, u32 data_length, + int data_direction, int task_attr, + unsigned char *sense_buffer, u64 unpacked_lun, + struct target_cmd_counter *cmd_cnt) { INIT_LIST_HEAD(&cmd->se_delayed_node); INIT_LIST_HEAD(&cmd->se_qf_node); @@ -1468,6 +1466,7 @@ void __target_init_cmd( cmd->sam_task_attr = task_attr; cmd->sense_buffer = sense_buffer; cmd->orig_fe_lun = unpacked_lun; + cmd->cmd_cnt = cmd_cnt; if (!(cmd->se_cmd_flags & SCF_USE_CPUID)) cmd->cpuid = raw_smp_processor_id(); @@ -1687,7 +1686,8 @@ int target_init_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, * target_core_fabric_ops->queue_status() callback */ __target_init_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, data_length, - data_dir, task_attr, sense, unpacked_lun); + data_dir, task_attr, sense, unpacked_lun, + se_sess->cmd_cnt); /* * Obtain struct se_cmd->cmd_kref reference. A second kref_get here is @@ -1982,7 +1982,8 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, BUG_ON(!se_tpg); __target_init_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, - 0, DMA_NONE, TCM_SIMPLE_TAG, sense, unpacked_lun); + 0, DMA_NONE, TCM_SIMPLE_TAG, sense, unpacked_lun, + se_sess->cmd_cnt); /* * FIXME: Currently expect caller to handle se_cmd->se_tmr_req * allocation failure. @@ -2986,7 +2987,6 @@ EXPORT_SYMBOL(transport_generic_free_cmd); */ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref) { - struct se_session *se_sess = se_cmd->se_sess; int ret = 0; /* @@ -3003,11 +3003,9 @@ int target_get_sess_cmd(struct se_cmd *se_cmd, bool ack_kref) * Users like xcopy do not use counters since they never do a stop * and wait. */ - if (se_sess->cmd_cnt) { - if (!percpu_ref_tryget_live(&se_sess->cmd_cnt->refcnt)) + if (se_cmd->cmd_cnt) { + if (!percpu_ref_tryget_live(&se_cmd->cmd_cnt->refcnt)) ret = -ESHUTDOWN; - else - se_cmd->cmd_cnt = se_sess->cmd_cnt; } if (ret && ack_kref) target_put_sess_cmd(se_cmd); diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index 49a83500c8b7..91ed015b588c 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -591,8 +591,8 @@ static int target_xcopy_read_source( (unsigned long long)src_lba, transfer_length_block, src_bytes); __target_init_cmd(se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, src_bytes, - DMA_FROM_DEVICE, 0, &xpt_cmd.sense_buffer[0], 0); - + DMA_FROM_DEVICE, 0, &xpt_cmd.sense_buffer[0], 0, + NULL); rc = target_xcopy_setup_pt_cmd(&xpt_cmd, xop, src_dev, &cdb[0], remote_port); if (rc < 0) { @@ -636,8 +636,8 @@ static int target_xcopy_write_destination( (unsigned long long)dst_lba, transfer_length_block, dst_bytes); __target_init_cmd(se_cmd, &xcopy_pt_tfo, &xcopy_pt_sess, dst_bytes, - DMA_TO_DEVICE, 0, &xpt_cmd.sense_buffer[0], 0); - + DMA_TO_DEVICE, 0, &xpt_cmd.sense_buffer[0], 0, + NULL); rc = target_xcopy_setup_pt_cmd(&xpt_cmd, xop, dst_dev, &cdb[0], remote_port); if (rc < 0) { diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index 658e2e21fdd0..c21acebe8aae 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1054,7 +1054,7 @@ static void usbg_cmd_work(struct work_struct *work) tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE, cmd->prio_attr, cmd->sense_iu.sense, - cmd->unpacked_lun); + cmd->unpacked_lun, NULL); goto out; } @@ -1183,7 +1183,7 @@ static void bot_cmd_work(struct work_struct *work) tv_nexus->tvn_se_sess->se_tpg->se_tpg_tfo, tv_nexus->tvn_se_sess, cmd->data_len, DMA_NONE, cmd->prio_attr, cmd->sense_iu.sense, - cmd->unpacked_lun); + cmd->unpacked_lun, NULL); goto out; } diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 65527174b8bc..d507e7885f17 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -151,9 +151,11 @@ void transport_deregister_session_configfs(struct se_session *); void transport_deregister_session(struct se_session *); -void __target_init_cmd(struct se_cmd *, - const struct target_core_fabric_ops *, - struct se_session *, u32, int, int, unsigned char *, u64); +void __target_init_cmd(struct se_cmd *cmd, + const struct target_core_fabric_ops *tfo, + struct se_session *sess, u32 data_length, int data_direction, + int task_attr, unsigned char *sense_buffer, u64 unpacked_lun, + struct target_cmd_counter *cmd_cnt); int target_init_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, unsigned char *sense, u64 unpacked_lun, u32 data_length, int task_attr, int data_dir, int flags); From patchwork Thu Jan 12 03:08:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 642536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 269A7C5479D for ; Thu, 12 Jan 2023 03:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235845AbjALDJJ (ORCPT ); Wed, 11 Jan 2023 22:09:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235948AbjALDI5 (ORCPT ); Wed, 11 Jan 2023 22:08:57 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F4294883B; Wed, 11 Jan 2023 19:08:57 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C33V8s006199; Thu, 12 Jan 2023 03:08:49 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-2022-7-12; bh=ayYhov2S2FhgBf6h2aTAseRP/uqX8wu3P57Ct2s1z0s=; b=Ucqm1T6kLZkVJLAvXzXbtIYUC0gaJYnbf82k1IWPQJvg7z7G3X2IIs8MbRbktytRV3/w HyOrHp7tPWfAJcaJekiiRoicJwNEGSF0EHiIeCekLee+dJ6zeRXeo1BRiLJgpfJUDoWj lU59yxF85rN09WY388N1orQqywkvs9jepIt55T7f2P20DdzErXdItrsm37E+FdRYAX1j 6Lugs6cg/GdBoCuDxkwFzJTzADgxf0PkSaIUo7ToubRTggZPjwbkKwW89u4yP0J7hP3n /YxRhPcM8xKED96XYNt0LAgTaaoViiB7wLy6Kk3xmpJXpW4Birc+6KlPLPgSR7qtQSdI ew== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n25k7gah4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:49 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0YA034176; Thu, 12 Jan 2023 03:08:48 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fiMt1nSzUxMHghb6ePSFr8WIDgu0pAtft+yODRP+c8mUqUNll93pc0vtGyRf1Rx3rnDylnws4b2TVYcTP3+wiFdiheur1qKuqbmL7+PEytpyWEBIODzVruAauKyIeKr8g4HS2iri5RIZXJsDkOgf7sEr1zPF/WbqxNuT37PjiA86QyP3jx+Jrd4YQyoqrQru+ZY0dxHjkze+KZ/dfNiwKaOHNtMKl3ZQJifznneXVxCb8YVG800Nm5MH/d2z+RCMHShlQTK2oN0awdp/TIge9Cy6Ln/Cq3KmybIbbjikzxrkgcOkZmxqpyuolM7iadPkravoRvx1pWXlpxvHKwn+1g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ayYhov2S2FhgBf6h2aTAseRP/uqX8wu3P57Ct2s1z0s=; b=PrpPKaHz5y0i2S3gLZLggPWVvundXmZoR1CenadC+RHx2E/S83KWXEEYbIH9CU9hqz6j4dyHYXSY//Zbs8s63YomVGUWW8FmaioYZcHQDsluzhH/tqbV8ptMGWCBQgpS1UMGOgv6PwS2tvBzTCy3wnKE52+jc9GdWPmShxZMM3lKN6/Xy5deoDiGbeZwjyT/x7D0YiPqABRo0NKxxSUJlb9+fvC31s8F2OEI08cgpV4Et7cG7OceGIT/u5wqaiFIDKlgv9LR1zqyeMBr1May0VhvuD/wN9s2eI+5e6TaTJfYLDfYMAtp0ZIo+SL4VOopJK5hlLYm9hP2aURPhcsChA== 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=ayYhov2S2FhgBf6h2aTAseRP/uqX8wu3P57Ct2s1z0s=; b=WuEZ77pccC6DgIbWP/toapT9Ak7+AJEG4HIDMP8btGgtC5o9DMSP+rK5STzofxEFnolUj3pAr+FUvjv/pF5dhYDRVeVGugJB49y0Sh2BBv1AqgjSFmQNCVkZscK4/vJ45vUqtM1L43eMkM9lahnb5XAAzXZNtfoxk7lSdpn7xnQ= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:42 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:41 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 04/13] scsi: target: iscsit/isert: Alloc per conn cmd counter Date: Wed, 11 Jan 2023 21:08:23 -0600 Message-Id: <20230112030832.110143-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0018.namprd03.prod.outlook.com (2603:10b6:610:59::28) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c833af1-0280-4ee7-59f7-08daf44a4f12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 29Vd4DoXgTmj39k4PYhXobA6mdpg993mqIoD65/jk5HbExvfOT/Q6O6RFE0mqa3UiwFWDu3x4wMuqhVhMQ1yK09gvere6jG81JRmfALGmOw01BjSCWFoOPuG6Lj/Z9BjuQRMd5bwsSlAtzAShha025+5MSLuhTQeqojMWwFb2xazQwPGhslQ38ni2ikxu3ZdA4bMqBr0NOV3YXyDDIJ9ORWGgBmysnWn9XlXeXdZvXygu8Sc6V/L83YWTx1bDfIYoY/C0gucD7lvF7YGUkQUX2cBfY5QiprUdetlCYOGvq0rBm8BTYghKUt2LYm9Hu+JPwFJ9bnnAZKjH9RybDRne3gbZ6k2xzWoOWo9Ho9i5RCZmxKqAK7VO/HJw514sG9Z7XwRMlANwEEIFBpXJqq7v/7tGSVIPQPEgL07COmeOXRtvh6JyZRPoDN1b/lh/v/I4/HKFRpwuyiv0uzwboPD0yiZ+D01Ki1UrT4wtGKWUQfD3cQh5vCpFrJkbYxHW10XFuVTEEQjeQfx3fL0FRixleXPc9WKaQPFaPKI8RtEAhEpd9wbjZVuTFzbgQhyCU5GvXE3WshF19OJyK+z6uQD/sm616ryJa0Uxu8DmUhFKvsTfRhE3Sies+WJGGInJ8aYAu9TMygV11P9+gYaReuRkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N3EzBiUSO8IRmM7MeK2kHMCQ/17Xn6JZGbCJgZW/c0jAs7tFBQ8moDTH4/yZKCWY10GIta2Ytzk8ed7Z1WvLDpFWw+18U1Pv2jyqJ7ZtGCcqkVAJPihuFghB0n+2mElDn8YNM1ok9m5S0hc8SrEeqQJCGgql29TYOzlkO/OkFmehjg2buevhoi9NQr7eXGtobBtDGDwWUEKkQVPIBkdvqU89GNw+uXkHO1nXcFLNVDXcs8sKupoSULdr7TrbZL9Txw8A5ATam1UJ4aa9/WKQxUs5HN5nfsvp5URHRKBLvlM07LbxjxyOguE4Mm41LZw15/I1LBulbNT1LHu+XovrWXUTK5fVkMbR8wSyw8JGanaCiBiN96RVm0YmlQGBBjHzYsRJjPRY9Yquyb3uLgd0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CjPG+5PzmP1y1qmFlWKG6f5Cu8OSxw+yuQrRCpCE04pIf+f X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c833af1-0280-4ee7-59f7-08daf44a4f12 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:41.9268 (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: xDsAurUxU0jn7fw/RtwcwgddnWfpCM8UY/nXiUpZ/0RETVhfwuODbDOc/sEyzwrBXdbEuSNuF9fvLekSGylazkJx+5nF4bLztmZahSCRCEs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: gH8SwHJi-1WhH4Bwh8Fmt0uCxMIxdDQl X-Proofpoint-ORIG-GUID: gH8SwHJi-1WhH4Bwh8Fmt0uCxMIxdDQl Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This has iscsit allocate a per conn cmd counter and converts iscsit/isert to use it instead of the per session one. Signed-off-by: Mike Christie --- drivers/infiniband/ulp/isert/ib_isert.c | 4 ++-- drivers/target/iscsi/iscsi_target.c | 4 ++-- drivers/target/iscsi/iscsi_target_login.c | 17 +++++++---------- drivers/target/target_core_transport.c | 9 ++++++--- include/target/target_core_fabric.h | 3 +++ 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 75404885cf98..f290cd49698e 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -2506,8 +2506,8 @@ isert_wait4cmds(struct iscsit_conn *conn) isert_info("iscsit_conn %p\n", conn); if (conn->sess) { - target_stop_session(conn->sess->se_sess); - target_wait_for_sess_cmds(conn->sess->se_sess); + target_stop_cmd_counter(conn->cmd_cnt); + target_wait_for_cmds(conn->cmd_cnt); } } diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 87927a36f90d..11115c207844 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1193,7 +1193,7 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, conn->sess->se_sess, be32_to_cpu(hdr->data_length), cmd->data_direction, sam_task_attr, cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun), - conn->sess->se_sess->cmd_cnt); + conn->cmd_cnt); pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, @@ -2057,7 +2057,7 @@ iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, conn->sess->se_sess, 0, DMA_NONE, TCM_SIMPLE_TAG, cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun), - conn->sess->se_sess->cmd_cnt); + conn->cmd_cnt); target_get_sess_cmd(&cmd->se_cmd, true); diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 8ab6c0107d89..274bdd7845ca 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -324,18 +324,8 @@ static int iscsi_login_zero_tsih_s1( goto free_ops; } - /* - * This is temp for iser. It will be moved to per conn in later - * patches for iscsi. - */ - sess->se_sess->cmd_cnt = target_alloc_cmd_counter(); - if (!sess->se_sess->cmd_cnt) - goto free_se_sess; - return 0; -free_se_sess: - transport_free_session(sess->se_sess); free_ops: kfree(sess->sess_ops); free_id: @@ -1157,8 +1147,14 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np) goto free_conn_cpumask; } + conn->cmd_cnt = target_alloc_cmd_counter(); + if (!conn->cmd_cnt) + goto free_conn_allowed_cpumask; + return conn; +free_conn_allowed_cpumask: + free_cpumask_var(conn->allowed_cpumask); free_conn_cpumask: free_cpumask_var(conn->conn_cpumask); free_conn_ops: @@ -1172,6 +1168,7 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np) void iscsit_free_conn(struct iscsit_conn *conn) { + target_free_cmd_counter(conn->cmd_cnt); free_cpumask_var(conn->allowed_cpumask); free_cpumask_var(conn->conn_cpumask); kfree(conn->conn_ops); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c395606ab1a9..86adff2a86ed 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -254,7 +254,7 @@ struct target_cmd_counter *target_alloc_cmd_counter(void) } EXPORT_SYMBOL_GPL(target_alloc_cmd_counter); -static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) +void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) { /* * Drivers like loop do not call target_stop_session during session @@ -265,6 +265,7 @@ static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) percpu_ref_exit(&cmd_cnt->refcnt); } +EXPORT_SYMBOL_GPL(target_free_cmd_counter); /** * transport_init_session - initialize a session object @@ -3170,13 +3171,14 @@ static void target_stop_cmd_counter_confirm(struct percpu_ref *ref) * target_stop_cmd_counter - Stop new IO from being added to the counter. * @cmd_cnt: counter to stop */ -static void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt) +void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt) { pr_debug("Stopping command counter.\n"); if (!atomic_cmpxchg(&cmd_cnt->stopped, 0, 1)) percpu_ref_kill_and_confirm(&cmd_cnt->refcnt, target_stop_cmd_counter_confirm); } +EXPORT_SYMBOL_GPL(target_stop_cmd_counter); /** * target_stop_session - Stop new IO from being queued on the session. @@ -3192,7 +3194,7 @@ EXPORT_SYMBOL(target_stop_session); * target_wait_for_cmds - Wait for outstanding cmds. * @cmd_cnt: counter to wait for active I/O for. */ -static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) +void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) { int ret; @@ -3208,6 +3210,7 @@ static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) wait_for_completion(&cmd_cnt->stop_done); pr_debug("Waiting for cmds done.\n"); } +EXPORT_SYMBOL_GPL(target_wait_for_cmds); /** * target_wait_for_sess_cmds - Wait for outstanding commands diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index d507e7885f17..b188b1e90e1e 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -133,7 +133,10 @@ struct se_session *target_setup_session(struct se_portal_group *, struct se_session *, void *)); void target_remove_session(struct se_session *); +void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt); +void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt); struct target_cmd_counter *target_alloc_cmd_counter(void); +void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt); void transport_init_session(struct se_session *se_sess); struct se_session *transport_alloc_session(enum target_prot_op); From patchwork Thu Jan 12 03:08:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC945C5479D for ; Thu, 12 Jan 2023 03:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235069AbjALDJF (ORCPT ); Wed, 11 Jan 2023 22:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235845AbjALDIz (ORCPT ); Wed, 11 Jan 2023 22:08:55 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1BE249147; Wed, 11 Jan 2023 19:08:54 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C2kfqx021032; Thu, 12 Jan 2023 03:08:50 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-2022-7-12; bh=Mi/E4IPBhZwDJoQpXvV+wqOhSfUD0AN3ezPYwIXFuIE=; b=RoruOjNMJFTmF54a1bN9FLwO+KCLMLINBsm0Ov8kH2DUIkg1qZ99pHegMOGTc2nAl/il 7zj6rRmX+ddaqluGdJZGLYpwUVKBR8OsyUzhbqn6ZSriiIGkjDe7cSMPuqgJHkIELJ6G +67+9YCQOaYs9Pq13eVCJHLbf7FZ/1gPBKY33kOFqQlawQJxSYvgNV2eEhnm/fAMY/sN H7YQYf4ch17rAryVkD3By47LanID27lduUni3pt5B3ET8+8qw9uMCSEJ4MmrcV0Jk3+R p+8igLfq4V6R0LqRwxl2wtjSzNZynzBf7m+OSM+K33VHCyFu/VptoUZhREgnhzgdf8GS pQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n27nr84h0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:49 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0YC034176; Thu, 12 Jan 2023 03:08:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K5mke02PFiefnYKkG/d9enjliWuGLbF9jm2MI0DHkxozrgmCKgpw/ZUHKacI9qvnkCEOQhLE1UbD/CIm7cgIWOVcm3Oaf9DKRQQ6SsUmdDB+i8t8UZl+ZT6rpXQ6e++o2t9+6KbuEAsPeJmgw9rQ0pyg4C75mwPQQtV9SBHvNDKULynntCXkDfH4JMjkT76u5ahaTXBpdNwxjBWlpXzXGCRYE1WyoDALjXk1F9VQh8J4zNEicCAWzznwlQZKePhvL3Kvl2bHngl9LY8Zl/CXe9zNkCc7Eu4vyPI/sDBq2B72Z0W+JZxLbWKSmPXGXa5Y2+kcCHyHAMJgT5KHuRVbfA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Mi/E4IPBhZwDJoQpXvV+wqOhSfUD0AN3ezPYwIXFuIE=; b=k8sCQIzqlb27S3EIUUxCBhR8fv/EihLpc+lyuPGVGCF5WQ9N2OPPawbJe45EOavS1Jebs3LGro8AZWacKYojj6NzDLXgE9AkLa2RIXxYMOBa5ADnRheF+59r5xVjrng5rB8XyvV2c6ujl0pm61pDokMb4U2u5hPLCcWb8YBjV8b9sJY4xAzYEAdpQuucMntxwpTxCXHljdIfsR5Wocda4APuyr2xsjUL0nTwDCIiks7mspGm81wD8Asj7LdFqBSas5SY9oN1xlqzW+m7tEycgKmgSAZqQjmFvvk/WK/fwNUaeBTGlLzZRwm5p/gzMNtFDT1wjxFBberztfu61jrwSw== 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=Mi/E4IPBhZwDJoQpXvV+wqOhSfUD0AN3ezPYwIXFuIE=; b=YuLW5pLwSjpNwbx4a6ymCoEc8R2M9miDUZ3lePIPLRoOQ0oO44W1pLg63ZEjgyCPHAl5jvagtcXHH6pb8jgTetUHjPKr82HRG63u3bWU//vJNzmlSAtVSbinpKhMGP4bCV7P7nm1z6WBc2EfGYPChEqiIjHeDa1lsWmLawLn/OA= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:43 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:43 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 05/13] scsi: target: iscsit: stop/wait on cmds during conn close Date: Wed, 11 Jan 2023 21:08:24 -0600 Message-Id: <20230112030832.110143-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0020.namprd03.prod.outlook.com (2603:10b6:610:59::30) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c6c6987-ddb0-4dec-7037-08daf44a5011 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: acxn/6MRCSyqNJyTsWsO+16YdBiZsiM09aeFXZlOIkmTlV0NYBJ4IiPzAvXp1ZxdfKnhQUQ0960pTGhXsCtswyW9pJhBB9Y//bugSZyPivyFlOw47E13N7ZFLeNj6SVGf5RKukU0D1ceDIX6jaUPEtTX85VLwhMC1b0lFPmi4EJGtNWh1NslyVklIw7bi8RjmDqBFplcM+3Uf9Hov4+xcHhpEviDc6/EVAVxeFj0mESAziPSTcop0qETQvyH3cNQIEHcP/aVYsqs9XFusTuRdaR8HReEdSOGky5xKFj3EInCIxqbcqyiYtTEL8aSN0GP5XpF/SaN1m2MhrW0RRJvvevZKLcT4jNwLIhLGusKZYVFC2VANk5zI0Aj7THXXocXVkB0qR1dr2SHx/Pl/zQ5G5lCY0H2Iuil00kOwPgvlarKMKFPrcIoHH0k1LFMt3Ie1b6wt0gZ73S+IO7l4k/hcy1MNkmbA5lVTyWxtPB1ZwalZhb52PMbRLs4LYLxF1U4Hf5m4C/jqlpfEvK7OjHnUB1HBTVWqVKXoETDzHlRHoKnLM94M09ovKqmf2Ujnl8NqXQEoh4vYDz7LPDrMG+Qf6P76Uq/YTIGTgfCpxabl4ZoeWkjFQDlvfUbE1+vNLRZr7Sv3MZ7+YlFBxHW0a9WTA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sGt/EHh3heXtsdHaYDa0y6GfNgYZ1/el3dejgbxKygNSLo6mdcno84iF+vxb6e7pRrjQtugMh9xrvOEhrSIaiocz4gHaRcJDruhG2pIvsYVc1BT6cro8eSAoxfBvmQPhY64XB9lz0HoiZikqGHrw9JquZEUTUPuPWOVUL+y2tOq7Z2isdakLXNwAchv5hSLViNRl+lRTkw8knyaPRBNHk3m/X9Djbg2DkInU7xzWCcTmjNMKgtwuU7QChC1XeWVGT/ihisjYw8tJh5AnU2dWxL9kbsmtXaxEI1ObCwJfbYOiIg+Gw8F4/U/y2ZT1iACtacYh/4D4zUUtW1XSBootvkKubgA6csd4k5AK7DMMZnzRJfoCS6SRug4YnPPRL602P8t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VFRri1ZtDnuLRyZGLgrPjHLRSFkhnYUYKAiPE6 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c6c6987-ddb0-4dec-7037-08daf44a5011 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:43.6298 (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: Dx9Pb4dsqNQZTjbijpNA4PbC6VCtFO9H8cuu+Dszfy54SEcN9xJbbhORX4BX2kI7JkJyhKi88d7LnV3Y2owH4NtWgWSfKYnBfiVV6/tycd4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: DmkWl-pH7WpR8k0UjDgYRyUTTIfOxDF3 X-Proofpoint-ORIG-GUID: DmkWl-pH7WpR8k0UjDgYRyUTTIfOxDF3 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This fixes a bug added in: commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") If we have multiple sessions to the same se_device we can hit a race where a LUN_RESET on one session cleans up the se_cmds from under another session which is being closed. This results in the closing session freeing its conn/session structs while they are still in use. The bug is: 1. Session1 has IO se_cmd1. 2. Session2 can also have se_cmds for IO and optionally TMRs for ABORTS but then gets a LUN_RESET. 3. The LUN_RESET on session2 sees the se_cmds on session1 and during the drain stages marks them all with CMD_T_ABORTED. 4. session1 is now closed so iscsit_release_commands_from_conn only sees se_cmds with the CMD_T_ABORTED bit set and returns immediately even though we have outstanding commands. 5. session1's connection and session are freed. 6. The backend request for se_cmd1 completes and it accesses the freed connection/session. This hooks the iscsit layer into the cmd counter code, so we can wait for all outstanding se_cmds before freeing the connection. Fixes: f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 11115c207844..83b007141229 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4245,6 +4245,16 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) iscsit_free_cmd(cmd, true); } + + /* + * Wait on commands that were cleaned up via the aborted_task path. + * LLDs that implement iscsit_wait_conn will already have waited for + * commands. + */ + if (!conn->conn_transport->iscsit_wait_conn) { + target_stop_cmd_counter(conn->cmd_cnt); + target_wait_for_cmds(conn->cmd_cnt); + } } static void iscsit_stop_timers_for_cmds( From patchwork Thu Jan 12 03:08:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 642537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C314EC46467 for ; Thu, 12 Jan 2023 03:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236097AbjALDJD (ORCPT ); Wed, 11 Jan 2023 22:09:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234327AbjALDI4 (ORCPT ); Wed, 11 Jan 2023 22:08:56 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D61749146; Wed, 11 Jan 2023 19:08:55 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C33WB0006221; Thu, 12 Jan 2023 03:08:50 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-2022-7-12; bh=jtUqB2MmXjEwNF+qFeuG06kaHGxGV/qOGjWff30RY0g=; b=TrP0o6PtY/1hKhPCduhd26ejcI/cl9ZmWT1xwbILN9uYeiZbMBcN3V5Daj65dk/OMWvq QgQWMBKICi0uzBY40pstorc1oCeVWUvDBuf4Csued6o3Y11ZtQOAO4gfZH7z/VxpmLTK 46d+7W25TnnYj6ZAYJ25WB/Nnd7DkyR1cc2Vy2CwlfgSOed1CVFvaTZSKUIaT9hSDyJd 4g7vZASeutrZ6hd2SPrUquGScTX/IALA5sDDlxX67nEvUXQ0Zfq/6X+e0JjGUVRZoif2 LPCcsh9DNSzrNuJANkd7THh72QBB5z4vOYQLLoepM8NN4BZUJ2bhTxuAJlYJVw2Cza39 Ug== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n25k7gah5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:50 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0YD034176; Thu, 12 Jan 2023 03:08:49 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UOrBrSvaf7b3Tv372uzAchGuiTM/QsTyfkMNCNISEL5/oJbz+XQJtUqIEgxGcGCLvoqBZ1sJ2I0KAl1JRcr2pHfksLQ70E/Ek2Ke4paAln5Cwoyzb7LqzJq/CZNEhgxaZWMTBdtMqDysnyDHopVBDecNoHQXPm+DVmZ7Y1Z3fC1Wm7Zj2Aoi/IxGKA8OTQaeiH0tzzohXsr6ApgNK8L+FFW4gZBb4ISZxa8PYEdf/72io3/Mw36SS/XLkG8mGZ4nj2reAsu5/XzinUUhjwBplc+a/hRNdnb0qL5zmrHOUNu788gc9fmYZxyzkkvpQxi4lvSZwlC/p/9/0+FKanHoTA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jtUqB2MmXjEwNF+qFeuG06kaHGxGV/qOGjWff30RY0g=; b=aa4PrrFgyEYX1an3Pf188nxoJeQ82jEzCafMSIpBIx7U4trcSx+/KmYgx9ukI7KI45x5qaTE/G2bfqKY6FxB624uwGo/wcCJDL25ouP/IJitDten8+KLZipwYcJeC1BT+PJt4xNBwvprjq53e+oPyLLjLTmd0gL8MXg9rxo5r8fMcfA8l86WUpLh8hdKPKldAgGusVuDLb1c4fCW7N8KmqLd6fH3BIrLLULqhwyvkZSRpztloJd2PK6gVPwf8Ihu4ESOO0XLVDouIz0UcT3iSqqryLBGFVdI+RQO58MjD5opeDclllMGW/enceXWPm+YMHqOt88g/j0WPBvGx5imPA== 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=jtUqB2MmXjEwNF+qFeuG06kaHGxGV/qOGjWff30RY0g=; b=zB+2IJv2s4Z/SlelSZ0dwFjtgPifHn5IEvAq/PJ86Pq6N7ekSa88mTKlPR1DxvdMTtATY1LozFYHnx/RRcAXuI12icGfj/N1zM/cBMBbAaPUufSmdJRF6j7X2NnPgKs1hdxbdsZzjaBlEDX8tP2VvA04pTzETurDHmzeM5V8kig= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:45 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:45 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 06/13] scsi: target: iscsit: Fix TAS handling during conn cleanup Date: Wed, 11 Jan 2023 21:08:25 -0600 Message-Id: <20230112030832.110143-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0029.namprd03.prod.outlook.com (2603:10b6:610:59::39) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: ddf9953c-d52a-4893-7400-08daf44a50fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B5K1igyhelZTqcAPsrb+yh3y5BneBHjP1S51G31VT3SJ8DH0A8LzEGbuDVPAMq7lK+QDnl1+5cpMmQlJlm0OT5fhZdv3Apeag/WndXTYqCQr0/QSLr7AQEck03qeu+hyS5xe9OxtJxNwBqyXRAPd6Hoz7SV7rqbURntjNCZ4JVYEeE20onPjFlzhfu1yl3HalCGG1xK1kW5zwvrra9Rr8A83oZKEULn7xpanfFK5T22CToYhaPUKNML9Bi1HPPQPgPyBOoycw88d+baq18JKOdhTG53XJ3v0mO4ZcNN5V81Ncsmjr4gGNFk1WtCpebMOnwg7yCZVRdOd96TgZbgQvW7WugqaDtQVideBZY+rVJusY9N8idfyrnzsqg+tYipE/wUOvQ/xsr7MuQgIWweiMNeu9zwRWeFwDVMzYd+xdHCw8V6qoGImRp8RF92SRmDSQ/dpe6+P7PXH02/jvn8gQ3M4lw0To01V2uA3x/rAOpi3tnaEgu8vMlWmfW5CXfcxSXyRU2cjkoSAk50Tgerw7luJYyaccBNPes+c3erukh4hvsFkEIII/SJ13QlvezTPU6JjNEzT1JFTWuujGUCMDc6ycomTdgk6t7Yg7MqJbYof8HIFLHM8AuzLqaw7v0cFyBluyI1j3FmSnQWMePg59A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AYVCbDU/mfKaT2ESWz5ef0CXpYUyFy2316VLt4L4ag2wbXs9NF5w1Oc7R+1sIzescdAGcEQhBbJWcQMj7pcWMgmlBCawzI/wSUAu+BR164yhrUmJf7qSepV5MLWIgv+xoNlxDPG7b/ejCy9nWzpFJwzyd4t0/+KO71gGYpSecyMGNwADRdScQUwfBoO8C6wBJi8tC+WyVfQeksIckeg0ofk4YyvqS1ztLyuUnD0QJvdgu+4bIZpx5vOhMRJueOB8wT5pIzxyuspm7A2sLw3OxEKouvIQjJTx8/cyRQR9UXWcA3uABfbBmJ71vLHlH1hbWv5fhTNM4JD6q4Rzygkf9RpTC/L3PDbeD0oXgWzC5eMgwt20q/4d67JOh+gfjFO/gmyQmPkSOBrsYmgEMMdJriT7MoZNkvpC7rSldzg6fxw85SXggdYvQIB0h2dfInHgH5PSL91HY0P4C5ll+kUjoIhkQesjDihO8JFxv4ITncgGKZ5DvjT3dQvO8s3Sdu6gZmZuRbd0Ev2eTWN+zJu/3j8eOxSpg0JhtUC8ZkV61sG0Ayw9hWO5fT2Jaiu0UIxtbJWB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ount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: SzVfpk24/yAp2nJQEZAqSrDZzJQN2k6SmMSm9o/F2fX+zsoklgEyCC/6m9Lonl3rTcXZfPH7zZ+DGldQlbl9/o6mQlSWxeTBEcsy/5Ir8mwWe1KpVkgISxdRQsuC6xMKWOL7A1R1HzNn4ORiXsTaR8BEynecsN4sSgCgVRPqQTC9bLLLZ6OTKRP4ZQ6dHJbCrERhQ1Fwon+ZqrZfr5vTxWaj3e9xGgfr3fc16VTCpr2koB40Wb6P1ZACo0ly5T3Yq71nuQlUrdeh44Z3CJCjkOhClgP98bPxw0W6+q8OAAdelmHbGIa9B7u5P5wY6sQx7bZXjiHdahySIVMXDJwMdgTrO2PCEEh8H/BtsHN7gbLHEgPDkZaNM43vn2OM9OtAjYYhuIFz3Q6yIgob17P+NaooKvHAR3kiJhhPyvSVR4rUQfROuLagRkacI5HJ1LWCWuyIUsD+ZrtiADiQrAUsiggigaHhNjvqIs5Hrmy6Ryo14x+7b6yVrzbF5eHR1JBu4X0WTQgnGJeKaGOd/rGBcU1R+4W9vLW46U9jmxA5SD7Q74DD5keXCtS4MajtiBTaFKTBz7k06GYa/y3UQlz/W0M4rAVj1XmwfMid+FI/qFrTzBqsv3BmKSHvJ70U2d+WBD+/9s6+mIGibrt4wpxYsjXxrpmklzWszaqr7EHqskiANN43+Ssp98iPQUvbNpU5whyvf1kqbdrsZTGeER7QXoH6W9vRD47xw85hEA4cBhldAqOlUZAMeJ9H+1Hf9auzC63TXUeIARHwFZXba6auXAENSqFkgpFyQNaXYke0vZw+iOV5Oo3cGNkL0RewojUbNt7fTc1q2ecFWJlabVCzhOFi3ovJoRLKqtRkw988Qn/qehZ/FAuE21ZH3CX3Tcrg X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddf9953c-d52a-4893-7400-08daf44a50fd X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:45.1453 (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: IvtYRJ80nsU2U9GYxfjb1M2vDfTH74FjN6yhi0LTDRsowOm0nJWuuUcW+5JL96fgeL80XiZ90Q6OwpVcirl9jjNiMt+s/RChA+V7rH0FWuo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: HvY1MOV2b891mLmrvasO1aUIjDK8oGZ3 X-Proofpoint-ORIG-GUID: HvY1MOV2b891mLmrvasO1aUIjDK8oGZ3 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This fixes a bug added in: commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") If CMD_T_TAS is set on the se_cmd we must call iscsit_free_cmd to do the last put on the cmd and free it, because the connection is down and we will not up sending the response and doing the put from the normal IO path. This patch adds a check for CMD_T_TAS in iscsit_release_commands_from_conn so we now detect this case. Fixes: f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 83b007141229..2a011afa6dff 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4222,7 +4222,8 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) if (se_cmd->se_tfo != NULL) { spin_lock_irq(&se_cmd->t_state_lock); - if (se_cmd->transport_state & CMD_T_ABORTED) { + if (se_cmd->transport_state & CMD_T_ABORTED && + !(se_cmd->transport_state & CMD_T_TAS)) { /* * LIO's abort path owns the cleanup for this, * so put it back on the list and let From patchwork Thu Jan 12 03:08:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C618DC67871 for ; Thu, 12 Jan 2023 03:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236379AbjALDJm (ORCPT ); Wed, 11 Jan 2023 22:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236063AbjALDI7 (ORCPT ); Wed, 11 Jan 2023 22:08:59 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B615A4914A; Wed, 11 Jan 2023 19:08:58 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BLE9YM017450; Thu, 12 Jan 2023 03:08:51 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-2022-7-12; bh=CDFOGU0n6KyHZRAj+Dk3rsU7TJ8ELlh2alMmYWeg33k=; b=mi9icYtL4T4irZm6FbsZLUeG3qC+gLEAl0WdP19CNagGja5zZgc5SMW+dnbtIpu1OK8x MjPHHigNExKshJv/qYWnFkZ8xzOzImgXpt0olAbceIlEy4z7ZFhM954Rv0Uqqr1tYwHN 6Op5tIRwKgH76avkpD8T7HAMtPCEuuTrzTn3gEQOsKbssvWRZA4vqeH5QOPnb3FLioBp d+gtHhc7+oDjwIN90brqUYY54p4/JSf8GuySkbBzWEMv/7/WZLSg+lk5BesFtbt7SeEP 2QlS0JCFEf8ZnTM9tTI4eKYGEXnL7NcBU3bMqMLycyBE5gd7YrvPitPhjuKJkDy/quJG WA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n22x00upb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:50 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0YF034176; Thu, 12 Jan 2023 03:08:50 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPQ4azu0JC8D/Y3t5qEXjWLP7RQZ+vr5pKIxscdBsCTm4AHvIoUA3HJPQaUDgW4XbnWG/sMoN65Sa2Y6iFC2pdS+uWcyR2CjoE3iFeX5VguvapwsvvemGpupU5MH8EiUxKnGBFJYGY3tmZDyyowyr5rTadodrGU0cCi3Aed68OMv6xnefrzbDVaL6XX5pN5kDqVj0CNqf2eOhSMv8y+tJqD+JPYlwzqVk5LOtk/ov5Zh9NfR9wUam3fsvgZ6RgBNyVPoqBXSBC+x9tuPJWp9Vb7CLoSUXoqdq2E1Gb/X1l484Su/KUpz/4KxqBOq5eQFwDHkyfyLQbpGyJoCeO6bDA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CDFOGU0n6KyHZRAj+Dk3rsU7TJ8ELlh2alMmYWeg33k=; b=AL5Mp8ncBSFqoy+NtYTyNCy7TfucsI16NRkmXWy6gaUFqVSAS7khUsVYPsDRFUx4wI5ROrBIrfEbhVJMlbkw4j9rasDoCnhRBiLKeMXyNHZWTV+c3bEMxaiARR0yTZL7m2bzD6NMEHWj11/ttuCuAwqD8trQHOMcAa/p7aBMoia2H7Ztf2AA3dAFftNpyXEU9A8cLv0PlQxqDyBt5zmpjEp0fW6Af4PZN0Ce14MxCLDo9Pqt1tUQSqxTlVL8QzME8zWz7qOF8ba3amcNni4+hJt7bMnp4tIjOB3ZE9737Oq1c+RA3NleEeks8WTqxQOxRnUwyrpvGAU6eQqo4B7pxA== 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=CDFOGU0n6KyHZRAj+Dk3rsU7TJ8ELlh2alMmYWeg33k=; b=SHyb4ILal5rJv6ZTbMqK5KWQXhbRN/c2LBsN6x8LxBIj+huit0rfsn006yIlHlN36ZF3UJJFQuyCUqaLhTICS8trMiU83Fvuctla/fNM3DHp/+Wlt8i0e9y4WpKfEeBbwWaSI+NlconQDjZvl0ejQBzeKoSyouXaAgHOUG8uGl4= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:46 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:46 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 07/13] scsi: target: Fix multiple LUN_RESET handling Date: Wed, 11 Jan 2023 21:08:26 -0600 Message-Id: <20230112030832.110143-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0022.namprd03.prod.outlook.com (2603:10b6:610:59::32) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: b09d183f-f367-401c-3c6d-08daf44a51ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1cbC2xEVp0PMdgrcarYbZGl1NpN7iTqaEe218Ug78Oz24EInpiNbqMDNQHlIiaIPEsngEC4R99z9MiIbuP1x4IQYcFNyfFlTrvrjMeuvKlVdMAuMw/ZzIGs8l+UoIMzwIr7t40C7gHvU5jvN4S6Cn0RY1+1yfHrPAq/NS+Zl13LjKguClmMQiSOdtrDVMBsJU2v+yp03oCXMX93lFMmWjPlvWVRaftwYbacYPPojEbZLUNG6JvwzP82sB9+vBR+rWC+8USXHuYTn+EkG0inTOmNwi1Jo7jkAzt3Qgfqjy+ipZ2nak5OoqQPzrQtHDOAHv9nh0Fe3bpJPFPZ3uOuwSxYu+B9/LNY7FiEYHGQTvcwFIFleaBS7RIXUiYcvIAbmcLwpuPSw+xpVV1HB5u9fbqMR+pS86zc4DHf8SzvOSkBJXSg8jz1YWaORR+1GmoGsbzvZpHUg56cYZhcKkPl+n/Q2VTjITljjuO2zmo4RBmLtd/eNBfJZ3ySIrscQmt3jG3efqh2igMQPQxfb3GjV6Tzi4wrxyyCVLv32EziLypZBD6OSTJ9JxGM4nhSSnzKJKVCwYTV8GcczL+FnSukYr2cI//bzySBphHlytmXx3A4t2iA3RgVoRkuILF/DT/6aZa+p2tnXZZjDjyhM0PS+cw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66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8q5KfVFKMfF3yDhZIHMgC69a9Q2AI07oUBhYQ0wrra7LvdE4+2qc6op2lraKQGxq3PO/fPywIUSkLbuKXa80cbfiezN+kCc0sZfTcFyrGTYpjC4MXYfugqTREWhMhdovNo/eRVGyhj1/XLitNqOjVLd9rFfK/pCxLjAjgJkmy0RR2c4i6Do4zXQk56Mu4uRQhiSukP03zu/5lxgxQnbYzw0kq1mPZOr0btKmSAY8BxWXuejAfPNMsIoumeiI8DFXU+5CwRNrtK/gTm/whrXniV6kh8/EeH6pzmJ9pyQaEfnJOtKS2r+OxUPlht1/9nx//z4GH6aKytqWILzU6bzlTMX1d/XhEPEegn3XySsW+GqdiXJx/zqVBGsqmt/5wCmSQeKLhgASRmxjyFexsKSND4GwFvwldl6eI2ZlVyUGPLF2RCCkoB8KMNqFBYp+U0Z04bUhNqbmTvADel/Nc89a3o5cEGw2EnwWyLRNar3YTP+B3ScS0fTkQ0o38zY+lyw5d+5+47OYQRSxm8jhQI5BPNzLpctL8rPIlynaOwaYla2R22dluDcVgYUkmOGAdTW0/IksmWDqaY5BD0vm3k/H7Jk3oxdzhuDSQydYK/W/J5qESA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zldM+exm67iMDCINd+h704BG73+yVkwgfXjl0gIOaIWrPmqBT+fV5G53Y3cxdBOLP5cyMS/WH66eJJPUhhoz/gq8gSnxAesvDWyGO3WTZ7UAnO8l88Y8kIsWjQM0UHarE+EIUYUsb+b4ffN810lHt8fgccIv+hkvIScKwES2iZR/hktj/ERjWOAvYBARLFDNC1NfswFHFT4OnsU/qnHYh3rx4hbiatyt+5N4hsZgPywh4r9EbFhbTxnxI1uJ0ri1WPMAmbxWLvK9q1aYxnfgBcZmC9vD8RZ0GI9V6VjuV7th+2XZSwz3bMT5o/uGYqbJAO2Q81uU+XSFmqunqSbymlnJv0QAT2lQMvvEQbMv07OBKxm3NZhyFvrnefGb90wO63QgDw7tLkXS0iGGse0bkulZAN1QoXHtDriPzNQAYCLPiEvhhjGCVEpsghK4Uf85F3lLkP9NmH9aCvfsjc9IsqmJtf7dR95BUmrSMWG03bAZydS/tZP9l9MVondMkq28vilkVJ+OyIFlNJmSIx0kYuPzg/0YxI6BAaSwLBkrJg7KQivI1eSdchcVBNtRyFDFMDwMe3VusZxLO4L+jjNUDT5G5xpuspvVuio/6+mTto7YkOcMyONUPQybKeKEnPWaJwvgMjqay14sJtovrBj7NNe06MDQzVpI0ekh4Pyd9O+xGRr4TuL/zuEB6uld8SvSJ9qTlvSJia+T8yvvudYShhdN0cvMhP+QOSjmaXQ5DdyZkwZW9cm1qA2tcGRUM8+3ii8N4WrMCMIx+zcdZk7KV6HTBetfDFiwQgIlHxVQeuc01ZtFbYnbdm4G8YjdMK1rK3933cU+kFCWpD0WUBM8PQRx2ydvvLDOVNCHAJWFk/ICMnqDi43qD+MLgVRc0S1K X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b09d183f-f367-401c-3c6d-08daf44a51ee X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:46.7389 (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: ruIzGM5XbkXKNUmlBcGsRRAacqsZpR+wyzgXTrm9MIDyJ3ys6Tm/vY3A0ASTA/V2sGim+0jHKHf6Jf1CT0WuJlrqRoyd7L/UQykdVV3BQuw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-ORIG-GUID: 9yYfu4BxJla-ka27W2de938aPPgjE9ge X-Proofpoint-GUID: 9yYfu4BxJla-ka27W2de938aPPgjE9ge Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This fixes a bug where an initiator thinks a LUN_RESET has cleaned up running commands when it hasn't. The bug was added in: commit 51ec502a3266 ("target: Delete tmr from list before processing") The problem occurs when: 1. We have N IO cmds running in the target layer spread over 2 sessions. 2. The initiator sends a LUN_RESET for each session. 3. session1's LUN_RESET loops over all the running commands from both sessions and moves them to its local drain_task_list. 4. session2's LUN_RESET does not see the LUN_RESET from session1 because the commit above has it remove itself. session2 also does not see any commands since the other reset moved them off the state lists. 5. sessions2's LUN_RESET will then complete with a successful response. 6. sessions2's inititor believes the running commands on its session are now cleaned up due to the successful response and cleans up the running commands from its side. It then restarts them. 7. The commands do eventually complete on the backend and the target starts to return aborted task statuses for them. The initiator will either throw a invalid ITT error or might accidentally lookup a new task if the ITT has been reallocated already. This fixes the bug by reverting the patch. Fixes: 51ec502a3266 ("target: Delete tmr from list before processing") Signed-off-by: Mike Christie Reviewed-by: Dmitry Bogdanov --- drivers/target/target_core_tmr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index bac111456fa1..ba2a2c18dae9 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -188,9 +188,10 @@ static void core_tmr_drain_tmr_list( * LUN_RESET tmr.. */ spin_lock_irqsave(&dev->se_tmr_lock, flags); - if (tmr) - list_del_init(&tmr->tmr_list); list_for_each_entry_safe(tmr_p, tmr_pp, &dev->dev_tmr_list, tmr_list) { + if (tmr_p == tmr) + continue; + cmd = tmr_p->task_cmd; if (!cmd) { pr_err("Unable to locate struct se_cmd for TMR\n"); From patchwork Thu Jan 12 03:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 642535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4890C54EBC for ; Thu, 12 Jan 2023 03:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235945AbjALDJk (ORCPT ); Wed, 11 Jan 2023 22:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236040AbjALDI7 (ORCPT ); Wed, 11 Jan 2023 22:08:59 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E6034914E; Wed, 11 Jan 2023 19:08:58 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C2vI3V023849; Thu, 12 Jan 2023 03:08: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-2022-7-12; bh=1bbx0DXywxyqmxDZclxxw6Rx/sNJuqdY7ell5Ce3UZI=; b=bty+t90rAt/wa5N85bI8AOy0MOS26uen1RGBcM6BXKK9+E+JJIS3hW0UbeJ/E9K/YO5l W75QihMBVhiYPF4PxubfSXJJIu07mo5lBkvEX/y5tle9zehyKA4/vdeU6dLXMO7Uf3+U j+gVLxcKqHOXcgPSX1eCbEITgnsNtkatDiCLxbPjAtB27569jlvhTCo9PkTK5mXsHlXG MC4jgyFe25hUKE1bXOtSSrw6E5Gfa2zxz0cem1iTzqaLRdNZmpnqTbJ1iTjwP5kO4Jw3 hn49PwjR9vEmQqjsj/r3bPChuPOLtVSTBu3Zcq09wjknKjIDmR3uQcKL1ILu1RyoORLv 8w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n28ja82n5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:51 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0YH034176; Thu, 12 Jan 2023 03:08:50 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oz5ZRYn5hcoGdaT5rPU4oTBAqT5KXqDJd5U7ONzN5bFQIlTGbwVGieIgeG9vQUqxJmq3y58/wJvRsIVuWIrpCPM7L25eLoPELib8Oe4YaZi9fwW3e5+5lmAe/dOsGDkJjQf+0ryE572GTvtixXIKLO6Mn1B6HJsPJgb0OsbjhKOXhXza3bSB0PFZbaUnwENpO8TypuMN/btlvIbCOek9rb/aw0gc2Ur4JcDeqdMbViQ25gsVFzHAAG4uAd+Hp5Q/3Ffv/6h2QSL0hqeHD1NKLSmyJUpjm1vCmISxWWYXi38ZXSpbUG8Fsjzn1tTX1EhZaL0PNOS9jlzBlipQOH3onA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1bbx0DXywxyqmxDZclxxw6Rx/sNJuqdY7ell5Ce3UZI=; b=NMrCBzvt7dTN3Gb+0JmVP0B8uKSn2GpH6jf25MTwyw+SIa3X48UultC7wnElXpwSCd0aaum/ZA5YRmhh1C+kBXKgRrTQEb7zwgACcn6OEezDvssy7gmdj2B0qJMpGPN1X6HUPFfFeb5OWSjwj9FEzULMl5sqLJaDGysiSoYrLv3X4L9fnamU0m9q3c4mNso/Cy2chsAgi2X/4/o6P8dMfdOKKng3djzl9z11fzmDWNmWEIBuF8yUIgshLBJO9apotfwYmF4pFgmpTM7medt4koqMKLKGCHf4gXKurDHUDTRvuYMl2pajy7MqVTybt8MiPko6jKpjNXcVA2CbfY4ABg== 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=1bbx0DXywxyqmxDZclxxw6Rx/sNJuqdY7ell5Ce3UZI=; b=UEOXz3GH++bCndupdZ2gXUTIh0ci8wlxmiIclPK5XBadCb2z2m9B+q48LHNHufTQRckMa6SQqmN0MCqtR+9+IBbaPvsYHDCujKmTzGtK26JPViPKcEvqSdDplvjOwFxxbvvYLy+hS9pwJ6p9t91ZgzmUvPfVM82eQoulM4bZoTo= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:48 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:48 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 08/13] scsi: target: drop tas arg from __transport_wait_for_tasks Date: Wed, 11 Jan 2023 21:08:27 -0600 Message-Id: <20230112030832.110143-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0015.namprd03.prod.outlook.com (2603:10b6:610:59::25) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 14b1a28b-1339-4f7d-6939-08daf44a52c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ATN/5mwgGzSNqfK0qN66Q1ABE4uDpJEjL8g1l1oWLbbW79PM2+1uNtRU7bSF3l/obHZuMimpNfTrkUd1i59Sv3Xfwb8ng9XgF/pFwJguE63gotRWagNNMYMcYwuZBvf1/Z+L8tA4rnxsHA0XlddZH611241q4eyGODPhA5JYjVCCtAV6Y/kJQlrj8BzaTma2yFpEoPYSFsrvbELUcY8xVst7N+L4XcW/z13tGn3YJHyR4Aq3upQMBuB65zqhQ4y1o7ne1REPbYRMUjwzAswI+UsXEWoGV5AnsHSe6XWUR6VJPUZM+WHL/xab7ZNfiMWjQ7bI7xWdPzV/4u8RoK1/Bc7hM4eQ3sYywSGbLARZRwIr2G2NB+tDgAwGQjXEFiJKLxg7kn9gaYbSWi3Fz+OelI+Yjx84pwdgadffWx2Wb6hzJf+eESXHnSs3vkoL6mRUz8e4eddEM1R65v1hzLn+O4ka6konM7cJ0vqqZ1ah+rlK7mK+VGw2XEST7v2qjUZW+faQKnmgQjLMy5an/nj8yppwJk6c7acYbT499mQlMC4pLSZ8iP3J56EdlPV1qw8rel9WyKrK45AnGcQoze2aNi4/7bNnneZ4FpVV8f3w4+gNEJs3fSWSFjodc7EoF6k7S1SgI4cmMfz5vJkgYH822Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7lkJn8piDB2VClzU0QJIfF+cCH/YjaZLLfhVXEeKzy+KFdlT3FwVMcWLs9jL1p4lEUeAOjBYCD0mOU4thjn3SapNdDr9BH/BDxnFt7faRE2A/v4YOwMV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SVvJI+AMRUjPlKWSDmTzOqRBmPnAsZCzwpbv8AKjsO8swlIe/LDGQ4GniqgwAPLIxxNQaDIQY+Ey4VukQpimuW3KecJMC1EXUDx1ybfif3iyBQ4HKyd+9fQx+UoOXXda56L867jXIwlZxaarK9U1E+xevkQWqPE3z2kV7UB2evIF4378KJ9NpR/PtNu7vR+htPAT7mZPg9JMdOEmFPOUFk3sTMODw9K/j4d16SfpXZ6VLAAjNIuJDhrg5VNg6AqxaBSuQEjgm9Q7z6UThsVlmMwFEi1nqS3Hs6jvXYXOjorwdIwNY4izsZVw2Nw3k4Zfj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14b1a28b-1339-4f7d-6939-08daf44a52c2 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:48.1138 (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: kZtSt8MFnekW/HR/3ckk4MykEqDVDUvJVAKJ9Ux9p+FnQzNdESE1rxl+hBPU5kAqvPNa7DtLEawYL923nAaqDi5NviIzcP0rb03QdXI0DKM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-ORIG-GUID: YPxzUEr8FFzG-ZWreeahAV58A5GMGyvz X-Proofpoint-GUID: YPxzUEr8FFzG-ZWreeahAV58A5GMGyvz Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The tas arg is no longer used by callers of __transport_wait_for_tasks so drop it. Signed-off-by: Mike Christie Reviewed-by: Dmitry Bogdanov --- drivers/target/target_core_transport.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 86adff2a86ed..cb3fdc81ba3b 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2899,15 +2899,14 @@ static void transport_write_pending_qf(struct se_cmd *cmd) } static bool -__transport_wait_for_tasks(struct se_cmd *, bool, bool *, bool *, - unsigned long *flags); +__transport_wait_for_tasks(struct se_cmd *, bool, bool *, unsigned long *flags); -static void target_wait_free_cmd(struct se_cmd *cmd, bool *aborted, bool *tas) +static void target_wait_free_cmd(struct se_cmd *cmd, bool *aborted) { unsigned long flags; spin_lock_irqsave(&cmd->t_state_lock, flags); - __transport_wait_for_tasks(cmd, true, aborted, tas, &flags); + __transport_wait_for_tasks(cmd, true, aborted, &flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags); } @@ -2952,10 +2951,10 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) { DECLARE_COMPLETION_ONSTACK(compl); int ret = 0; - bool aborted = false, tas = false; + bool aborted = false; if (wait_for_tasks) - target_wait_free_cmd(cmd, &aborted, &tas); + target_wait_free_cmd(cmd, &aborted); if (cmd->se_cmd_flags & SCF_SE_LUN_CMD) { /* @@ -3234,7 +3233,7 @@ void transport_clear_lun_ref(struct se_lun *lun) static bool __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, - bool *aborted, bool *tas, unsigned long *flags) + bool *aborted, unsigned long *flags) __releases(&cmd->t_state_lock) __acquires(&cmd->t_state_lock) { @@ -3246,9 +3245,6 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, if (cmd->transport_state & CMD_T_ABORTED) *aborted = true; - if (cmd->transport_state & CMD_T_TAS) - *tas = true; - if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) return false; @@ -3289,10 +3285,10 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, bool transport_wait_for_tasks(struct se_cmd *cmd) { unsigned long flags; - bool ret, aborted = false, tas = false; + bool ret, aborted = false; spin_lock_irqsave(&cmd->t_state_lock, flags); - ret = __transport_wait_for_tasks(cmd, false, &aborted, &tas, &flags); + ret = __transport_wait_for_tasks(cmd, false, &aborted, &flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags); return ret; From patchwork Thu Jan 12 03:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABCC0C63797 for ; Thu, 12 Jan 2023 03:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbjALDJM (ORCPT ); Wed, 11 Jan 2023 22:09:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236007AbjALDI6 (ORCPT ); Wed, 11 Jan 2023 22:08:58 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3F6749146; Wed, 11 Jan 2023 19:08:57 -0800 (PST) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C11mlZ003876; Thu, 12 Jan 2023 03:08: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-2022-7-12; bh=WVqFBgqXCs+lXYN8xWaYWWhoNYHGE8jjtPprz7NqGKY=; b=mH8zmmj7njgVbPrpOp8gd/wIEr+REKLjLeVkjUusthtrovrBWv1/uFewJt8EWr5Dzadu PI4N4ipZqR+feCWmZGMjy6tfQzUGFNcfdoNIUdj/FgOZBNFmXXBTHMzQQEjJpSH1pCLM giGuZw0Q0JMWGFiHmJKbEYPxLVKZJXePhM5stw37weVC74Xcc5MnZWnuo1UH9N1t1hY1 g+lWVAMo5e7vERwJ3FVRG4AiPgb+mSpFRvZ9VMN6J12sbC5hacdCyqfSbHmi5/QEswpP AI9ujPfFrXqbK1g2j3nVQQxhxv2IX20gw2Ip+ePMlb1Mee5OTePItxt3TqE7jimCSsDT WA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3my0btsd4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:52 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0f0YJ034176; Thu, 12 Jan 2023 03:08:51 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxp5-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZoRDv+psimyCSZYkw7XNpBvLbSWdHT9UMDFL8y+VGcww9sx1WU4UUKC+xdTbMUonEgpseNmp+wNQHCcQl+Nt18S0R398JoydHRdP0KF5+OQdTQUyltssi3wU2gIZJQMDeJbPUVKHhtR57xDYrnNzUQtLNno1gr0OlNLc7Ii9Ym5hG8NHv9OQVgWCxFpargW0f0A7+taXdbW7v4x/c/+xu4K2mxeAhJrUR0MfiRhzGeWgXe3M3ubBqdVaVvTLeDYqQfFkCh9M/mYVslhVyzKt9BR7J17/wkwPW90mID/W8BVES0W733P8LVII1s+hfMSf03zfwgTGJW3A85R30Im1Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WVqFBgqXCs+lXYN8xWaYWWhoNYHGE8jjtPprz7NqGKY=; b=cx4Sw+JcnFMJRFDGYV/WMTW4nzGtHvKqxpVPkSDDxwCNCHr5qzwgZEkOY7072xYEXe0WF6RoLYjYZiZUR0Z8dL8/XsjSiU/cgY1E7LQhwOykFeVK2LP3fFWMH4rP7wZviyuitjguiwFCtJzBISWdB6tJgGcMFcf84WKr0anFihvuRTuSiAFk/UA2MG5+zBv8JdKuPlCYDXore14Ail77iiwliNVA8nyBXTdYNnf+rWVgTENwI5Z1sQvZB0/Eq7gCiqSTbIRVir3bvwAjS5fjdeXyeV3htWJfIzg6ZicIUEfRchfuQR1KokMWoXTB+HIGcifrNdu0llLs+y0FhaZOSQ== 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=WVqFBgqXCs+lXYN8xWaYWWhoNYHGE8jjtPprz7NqGKY=; b=vFTizhpyDmGENqieh8y29+1ZECl8Bdjsr4puTpzjX4ttG5XxObIYk6PyzIFqaPL9/oK7DJPArEfwOd9IMKTUMBEfOAVSF1TfjXiE06SClp0gD/vUGjvQhNRDTJCr4QvWqToDcmo80wFtSZWgJNG3Ml7Lh1uw30/Qa1ZKc75p8Sc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:49 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:49 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 09/13] scsi: target: iscsit: Fix isert disconnect handling during login Date: Wed, 11 Jan 2023 21:08:28 -0600 Message-Id: <20230112030832.110143-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH2PR03CA0027.namprd03.prod.outlook.com (2603:10b6:610:59::37) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: f3d5e088-6e90-4762-1d29-08daf44a53bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tb5i5+Tb2Kdqha5GX6+ElgnktL0sDuGmmwaTdZhxe/UaTu9hPmLWGQtP7L6Xxl3P1INrJ5m2r+LPmm6LhSCjqjAKbKvRZuzkAMynpj8IPiMSbvYdXuLN9q6zKFdwy42ySgitmK5BAB64+2vCb8PDzOHQ5UGfM5Vjry3HHaG1uSEcWJgYrpKh49ooskveRhm1IjQZXCC8FRtOJQ0keYrvqU7gOtpGgNafK2bGHLgTJ4Tu0YgU0PVr+OXU/6JCjcjt6tQo8IhduWwmzOgZVc2Um7DngchnJuITLk5pFEydo63390VOvIAbgSHP0enfUuj+s1ExiEHJmym9sfPJBlBPlYhPG+rJu7U3Tzwajx0Rkd87VSrfMdqbr7oFdFTPiUw3uEP5mkQdeeH4E2MgGq1S09cvDH6V7BnI+sQYniRFh0syJRXGI0V7PBZc+Qr8Jm4vOFgEdsFCZc6d4GU6Kzk3sRCvMPXI6iWlFbKQiWoGQS9lJkLi4aOzOc/uqCjt9NInEERNvT/OJf8glLvPE6Qfysfw4N6hxBXe9uJGQesgZvSx8vR30lXVt8rL9pym4aX5FrGmy4m+/r3wed3YLIvetL2UBPT5FkmcvSHOrjZWejLVlwlB4BLo9+I5Oo5Ll1cRkBaRRkjF77VT3csdQs+LMQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3yv4WPuCoAT1wKGP0v7FM0zoj+EcP7MLZfD2FXibkCgCdsM/cMA6rsexAhDHFkVFISCZ9bxPqnViuMu6zTC18g9lx0AwE1521NN6FTChVMa+WPxJKCrK65cpu0Y70MJDTthtjBE2UBdLmKhfBqtvWC5fZe8afhl5xFtPRXsUxe+SilC7DV0fI34lwWFCOrZtk2/Wn2ZF/C5j0OMP2/zYtVrV/+hU3wgMOKhJSb56lUmUUvqkwD00kIzdiskkQ4OTvc1EMz0JKlertwyckkXYh9uGAn7LJW1kVDH+fe049oedaV5klSQRcK2NuVTVS73mWUh91XtmLisfjqq7FZ+TIVrzax3ZnXU0yA7HRN2B2vDj1H1OknOVIB/ldNN+GYM+adnW99B5vT+uRI+vOOXXr0Kf5br6x6fGLZF1e5h4MKvFoQx7KnzvhBMZf8wHS9ouKcFHBtKTeMLRuev4wctDHz66oZS+rZBelWIfX+NfEt6kyosCZ/PzlntWd6DgX826s/k7rAx6uj2d4M5tAnxTzphRGEKfBorAWO6ovJTLfGUcgmJyfdx0t3wCr+pM5/XuGOcmZOe5f3x5yz4E7U0OVmkCjE292kvkykmD+Z7W258s7MpxIZ+kPSgFfFxonZ3qeEyobE/FV7FOv18PhFhqKRutS9YJY9xXQf1vqXLnGmhLTPTjnKYxtIcDaA3S0kfzczCOG8ac+ojdRxqkUwQu8mdIVKlRyLL4ZhLVBHNINkC0xBDie3q69yFlkLlPrH+XU4X2NLMniAMrgNbEgtAjP1NQ70tIL6y+fGiSVONciahTaVCudX6Nkop4RYLoreB8/j1eH4IUvLRshTGXeWw/uJVLb+TA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iLB5o+ig0mooGbYxEUaADKviyFr1TiIJ+3GoZbpChMA4tVYJIikQmBg7NSifTR3Ab/2KdCYMvBljQpOOs7DcOGdOjIgY0x5Y0AGx8QadCckF1Y7zDPIHnbKvR9CmWSDGYUjkssPnecNu/LRC5LeXbyrsKz2DPcc+cjRskRNdXdqax8zpX7XHy2/bxvplmiW765VjM5H+Nm2ne70zwM0uqEtxbIjGOTSahYI17r6rwPNqiK8zk0HOURBIg5oWnIAgUrOG+MuuxtOcCWzmI+lLKhZpT/tTzgphLY1JUA8/RI7ivGx8/zrhpn1XH/MFCkZ/HF9GsaroV84yDZtMmaDOX5wsSBy0EPfzhLtNvyHEWvu9j9b1CklmT9ChJw0ubOz8beNOV/xU34u0RJX4izD7th71UTziIZjWoSf0kxYY+fGxqGNDJXqNWugWUKofPLxqEpBMv1Gazhmqpud/2VWSqYzbHZQUv4GvADtd+lNCU/zOjhiGq68fajBoYypZUpM9Ylg1ItqdE9vqYyaf4qePh7BhaRj3Kdmy8nWEz6cyUm95pppK9BdNdl0JEDqk0r/1q0AIVVHo/S1EryDhPN9/U7JYHpdvxkdJdlzQ3G6ZpVw7B+waqwy4/hKATmpc0Anw5l5V5TmNaHTe3bOTglwOE/f X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3d5e088-6e90-4762-1d29-08daf44a53bf X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:49.7856 (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: PXuJItLb1qzWcSQF8k7BiJz+sqLFfkVPO2kjsRFieOIpdoFIDgehg4W3ciWcEm912FJ3HfUkbFcLy0lstU1bGDNaFyYgb0o+3g9xCLzMmMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: ipSIryJmQINkMgYYdfrLJCRCOzR71Ran X-Proofpoint-ORIG-GUID: ipSIryJmQINkMgYYdfrLJCRCOzR71Ran Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If we get a disconnect event while logging in we can end up in a state where will never be able to relogin. This happens when: 1. login thread has put us into TARG_CONN_STATE_IN_LOGIN 2. isert then does isert_disconnected_handler -> iscsit_cause_connection_reinstatement which sets the conn connection_reinstatement flag. Nothing else happens because we are only in IN_LOGIN. The tx/rx threads are not running yet so we can't start recovery from those contexts at this time. 3. The login thread finishes processing the login pdu and thinks login is done. It sets us into TARG_CONN_STATE_LOGGED_IN/TARG_SESS_STATE_LOGGED_IN. This starts the rx/tx threads. 4. The initiator thought it disconnected the connection at 2, and has since sent a new connect which is now handled. This leads us to eventually run: iscsi_check_for_session_reinstatement-> iscsit_stop_session -> iscsit_cause_connection_reinstatement iscsit_stop_session sees the old conn and does iscsit_cause_connection_reinstatement which sees connection_reinstatement is set so it just returns instead of trying to kill the tx/rx threads which would have caused recovery to start. 5. iscsit_stop_session then waits on session_wait_comp which will never happen since we didn't kill the tx/rx threads. This has the iscsit login code check if a fabric driver ran iscsit_cause_connection_reinstatement during the login process similar to how we check for the sk state for tcp based iscsit. This will prevent us from getting into 3 and creating a ghost session. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target_nego.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index ff49c8f3fe24..2dd81752d4c9 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -350,6 +350,16 @@ static int iscsi_target_do_tx_login_io(struct iscsit_conn *conn, struct iscsi_lo ISCSI_LOGIN_STATUS_NO_RESOURCES); return -1; } + + /* + * isert doesn't know the iscsit state and uses + * iscsit_cause_connection_reinstatement as a generic error + * notification system. It may call it before we are in FFP. + * Handle this now in case it signaled a failure before the + * rx/tx threads were up and could start recovery. + */ + if (atomic_read(&conn->connection_reinstatement)) + goto err; } if (conn->conn_transport->iscsit_put_login_tx(conn, login, From patchwork Thu Jan 12 03:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 642534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05A5DC67871 for ; Thu, 12 Jan 2023 03:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236137AbjALDJo (ORCPT ); Wed, 11 Jan 2023 22:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236117AbjALDJD (ORCPT ); Wed, 11 Jan 2023 22:09:03 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC25F4914B; Wed, 11 Jan 2023 19:08:59 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BLE9YN017450; Thu, 12 Jan 2023 03:08: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-2022-7-12; bh=mBn7HYt/szGA3aK8ogj25vr3Hh+/zFsJkicqWkLdXso=; b=TBohDFKfidh2ZhvI2ijyKuJ0O2GLHvwg5FVmZHYyNhGGn2TJCpZ4UvNgt4OP4/UKSXqO vAnfqeWk94ig+1XByl9P0TTzteD9QMr07CZaJPpoTtPj4UHVSdzd5/DsANqDCRDohISk jyLKfK/fJSH38ypMb9DzLua9kFTUSxZgv2ovl41uyTd+KOnHV/g6cZgSfT/lPVjh48fZ 02eerIZIW+RJgC3auCy+1c2um0TUAshigxNjsPmPV29f5rCwy0eWPQ96WBv/TComSKgi duzVuvk7La5Xc/GUjHn+qBFNBZe79TDqMdMQG0oOdfcssgMlmFNP66vAcP802DDI8flp SA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n22x00upd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:54 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0VJu4034149; Thu, 12 Jan 2023 03:08:53 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxs3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDC7ZxeYRB4N9dQp7UnfXRXNELVAc4vfs/3DgH4v6wgsCem7QQvpV5C2SpXue3RjO7UMflsX3JnnX7ky+fWWUXZGGVO3gZwhQDSDF1BX9ytrVVmzO93bXNjjG3lY9y2kn5x3MzvwBaTt8A5PME/+K+JgI/GkEB5bespw1K2CpNbOh9WZC8fEMpw8NG588FemQ2ZUwcF7rH2I4ZTMv5+GKzjYlsrAIZn6k2oLp+UGXN31GhFDR5nQYKdlqwP+qgDoNhpoeRYaNAsOuf1Bq1VcFL+dWCumEmjoLTfM/1GN9ORDXSRCtBIJYb+viGhMunEFZSfzQGYovkTnb7FTeED4Ow== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mBn7HYt/szGA3aK8ogj25vr3Hh+/zFsJkicqWkLdXso=; b=hDmzFmqq12yH/B5lr3Hy+dIg1eb2YhlxZOSxNid/g/VLQaxiKcmteYomF+osOSQijwIK8C+sBa40JhWS0CfiAucxXm0/cDOPyYY9cFLobB/MKZtlEYZvFZLfpPw5tU4T71uv+tfwHbITFMtXF7x3xhOzNtIAbA9WdZGsoyY/abZvgMNcWMTxFOrWxWxMiEEdYmVTQrBhTgdAfQZekj/B0HAdKC2ivUyTQK+YXNZWAjvskuTxBR0Dnbtc76SSNY7cESXuPM4Hpjfv4UznrVHLQgf6pye/1P2dg+NIuEiXRDiPFn974KzHDgaY3AajRdxqm/168t4LcfAq6xsYvmRKPA== 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=mBn7HYt/szGA3aK8ogj25vr3Hh+/zFsJkicqWkLdXso=; b=WEETdgaRBp2awAhpZKoMe9Mx+YtqrwaHTOc8cMH0aoQYjnpAFpP7uPRB/fzIDydhVVpYlhK1hUo6UM1b5RrNhng52UOYhvhQHk6FXtNlOZGBGdjqkoQZqq4hW8U5DV5gS453OgPFR+GML9WBUB/S/rChC7WqYwgkSujZItJSe7A= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:51 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:51 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 10/13] scsi: target: iscsit: Add helper to check when cmd has failed Date: Wed, 11 Jan 2023 21:08:29 -0600 Message-Id: <20230112030832.110143-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR03CA0224.namprd03.prod.outlook.com (2603:10b6:610:e7::19) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 1711ad5c-0c22-43c7-0c7a-08daf44a54b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: frNOUzh+A+GRYK+FlEcdXzthQw9P0MVLXj2lloU/c4qwLgY7qpUYsOcPk/e40fXBU52mNRwKESh7bHA54OyYcex9x+i1i9F/u8TvUZOKVmIeBC9zWtQD9JpVqN94s8qYwo8YfW2dnDmtBTxQbWW+zDz5UnunmKHqLFA/g71vv7qwJn6vhXP/101dgb/mfdFBp8MchcY/rXO2a6ZKds+8ob9sFOEcPFEetQRdKlzFRZLyNuNq6hEXiUivGen1HF82deyeO55yfv6HzCjE4ndiQpDuL9v5GZjRjFSi9gXStmn12+BX8zz4U7DvJxvVM/b3+viVIk3TTMw0EmyDs/a4cHrcDCNM0G748Nep0wz5/pElhc9CvpiiwCiJknqFHf3nV9ZNx5EwqGz80f70bH5GrKeVXrQxCFGhD6RbegAtDtKcAj1D+nZDYtinUd8xCt285BP9wRdm1vasSDbQ6e3/Fkpe3zb/Eba8RZkxTp9Ut7VFg+5NkeIheJ/579SiHlSph8qp8ZJeq90wiydYFbaZSAB9dQYlJFAHwcPWeOfcV9uwE43gvxnXQcCyI5prP2jAHDgeKvbfSpovDTNDfGG16AcPa2SoM027WJ32WBrJWlvAzVDRFFZJ/mpteQ67oa2mFT9V4t/BoIG1a5t83OOvcg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5ofoPhQZTwY2VhEijYx5IecWzB5G2aG05vxsp5y89HNEsLAM2g2wIOKaFYz5eiYuhFr+AVSZerOybWZgIMy2193Y4he75wKNpaE29N2mYinIdLdLFnxwBUPWRz3HScnxLGkg5AweU4aONZ4ec/8fQgbBeL9kY6N2caMne3i6P8Eu5LhlOVqEK1cVAy0H29LAXQ7XuuMLbZlseJtfjs/S8vBFh0uv+/zbrIRTAsqF3LChmGBwU2pbG3B//nutX6iWrlo9hvYwRr+2coryUPxnOua+cdZXS89p5YzUBUrFNinhTyp4cF/gpQ+kHUzBQrfYqYyZGbDZLNbyQB+rpkRPBZlj4t08nVavPzFgFkXhUsfKmo8Fb7mR9yiHGwstcXu84qZeijrdVVj94r2wLcHHdpkRTfxN682Dk1q5N0eqozOVrey0J28hqtavngmdSbYjqqzpLkbL1tcAtgFZmAJxDnlXKxAtAceRKMvq/9jtCFXIM+PkK6o81nejz5PpP0Gs2Eq32WMnE3fQdxuQUqwubyj5qrb2aQ10wPEeuM5RlT+F/UrZo/z4DMmMyJrHWK0udDYLg0Pa8C48x0RXyukB2OYCY/4SBJYvp4FxrAilooquLTwVDmeyuJFHoFBGI+JS6S4cuS9vkaL6lxzV14ShQp6NRIe58bGJRqKZtKzTFhkpJ8SP3UamQlvoy9bk0ZBZ1IeKsm+MYFUMKHTWOQORPbMZgXTXO5zwKVtIjkCBRs7lvoJwLb/U9CIQ9Ond1V8/ViVow9N4nb+1FVAeAY0PzuxHV1XhO2IPQkzFr7tQP8O0Ym4mBOHqJuDLSynGd50Eu9o1ciW0oncMAss6BXM/wM6MqoN3z43g0kxj2G9RLMDdEI7Ex+NFdBUZ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qWC2QZnHbcECAX/4S4sJhjYV/SZEW2SEplMHm9Ao5r9qCqp7cXyO91pMg0ZcW0f7aI3Axi0AWAB8Zjb2xu2qNI4qGEFTMCsbSl0QUMedjArNHqMw9IOmvqrtybpAWCeuBeF6qLIlZUWorPyuJSnLGfcPG/+QHFIxvc3ANWMeLECCGfrhVupONYokIjv19Dd/2+IeMjBU4g7PuEInMVD+ENKKB5/Ra4AFkyMZMbSoR7ElhOfBmEBOiC9iT+l8Ob88pS26KtcwfH1sadMdgSaAAAyOCCKvmW3I1UuhDjM7WYC4eNz2w+ZHtQ8DKqmJTgOq3cQJotxyLeTQdQNbvj6iZX/KXDer6cxXcNBLN6rF75R9MGjntbHVpG6uFsNM9h5NGClMyCr8gmjvTzNEaM2PrlNy+AP0pamL3CO+jsC09zp1C/kHlhppSz/PYZR4KSlL0xelewK7yupnGzXIb5beaf59ABVRR5vm8V+lir3viHTXCv7/3B/xsUMQs1JL7u71aZoBEEBAS2OOnebIfzj3jKhCiDabKnvLhRQWpetA+HVZQJVjI4knJbtN+sRx1BcmAFYhHM86YYqFlPDBnIUMXHRsHwNmL5jMn14hs0p8542JW2jGhKzi7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1711ad5c-0c22-43c7-0c7a-08daf44a54b7 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:51.3948 (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: 7ciPOAMQqeGbMydbd6H1lfG4E4CrE+hSYm3iyEkyf9Uqyb82p2Na7orby8ckT1YlsSgy/f0P8jllhjKW3u74SPKZZ0AYCs9YBs1miobJSCQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-ORIG-GUID: ko9tv56ygx1siEinmC8X6o6O9XYzdbX7 X-Proofpoint-GUID: ko9tv56ygx1siEinmC8X6o6O9XYzdbX7 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This moves the check in lio_queue_status to new helper so other code can use it to check for commands that were failed by lio core or iscsit. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target_configfs.c | 3 +-- include/target/iscsi/iscsi_target_core.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 5d0f51822414..82c1d335c369 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c @@ -1411,9 +1411,8 @@ static int lio_queue_status(struct se_cmd *se_cmd) cmd->i_state = ISTATE_SEND_STATUS; - if (cmd->se_cmd.scsi_status || cmd->sense_reason) { + if (iscsit_cmd_failed(cmd)) return iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state); - } return conn->conn_transport->iscsit_queue_status(conn, cmd); } diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h index 229118156a1f..938dee8b7a51 100644 --- a/include/target/iscsi/iscsi_target_core.h +++ b/include/target/iscsi/iscsi_target_core.h @@ -913,6 +913,11 @@ static inline u32 session_get_next_ttt(struct iscsit_session *session) return ttt; } +static inline bool iscsit_cmd_failed(struct iscsit_cmd *cmd) +{ + return cmd->se_cmd.scsi_status || cmd->sense_reason; +} + extern struct iscsit_cmd *iscsit_find_cmd_from_itt(struct iscsit_conn *, itt_t); extern void iscsit_thread_check_cpumask(struct iscsit_conn *conn, From patchwork Thu Jan 12 03:08:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0738C46467 for ; Thu, 12 Jan 2023 03:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236208AbjALDJs (ORCPT ); Wed, 11 Jan 2023 22:09:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236142AbjALDJE (ORCPT ); Wed, 11 Jan 2023 22:09:04 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB68749152; Wed, 11 Jan 2023 19:09:00 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30BNl4fN022693; Thu, 12 Jan 2023 03:08: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-2022-7-12; bh=7thZjMwxCJl9nGbKjWxJ9UcfRNDxh1hpW+g5TgzOWoc=; b=MicdUemSyahOKY1MOaxVvPDTsh156WbhFz9MAbQQmfV0lEhZVryty1ao9+tVjTjSuhkQ IdybazOT9v7WQN054KFqgazudPK3AYvHg+cRV94HuypEvIISpAAkECbcong+6z1u4LxF OwcMvzzRRR95LCLfHU9kaCrHu7XGdqDIiI1d1ht4QL4MbLWp/susQ1NH9glKT0DawJxo TXuJlWx4JypFgv3rm2i35pOajEsE/x/1YzjkOqtHydBU1x6RsnBW3KMGWzxwMOcmeNMx f1aEREbKH2Mw0KVW3LYp0x4to1L/yXQJgZDHwx0EVGREYUUcESdvvgDL2W89TBvm7Dco +g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n1y1nhhq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:56 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0ZZJW034175; Thu, 12 Jan 2023 03:08:55 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxsg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lQsGXAMgyLkYC2t6vXF0CSZsoM0JVCOli3r5hSweJPurgJFCuMZt7sw/O/gNO88YtO2Ps/dvpwYa3oIPeqT5/cOIOmVC1UMItag+G+nM2yoQVl6MMdSFH1fY2cb4MNN4NXu9IWG5mnfcu07Wli9rwRG7v1zyzmFJjPdbfHiu7eypnKvToqYRIsTMwc0HNdFBhWObOqNk847ew8+BPHiwADmmiVECkLUDXAEZxg88PiVk5UObSqDoHeatqaVM0aQQDcY7cF1tcTMQREkU/WpZbYk0V/6k6piuYFoFt8/4IiSA1uBigXJSlOtHAvNpjH6Cdcf8L0yeKraGMsIfr9sC+w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7thZjMwxCJl9nGbKjWxJ9UcfRNDxh1hpW+g5TgzOWoc=; b=im7D+jDm4pRnQd8lUKQL4O6iy7tKMxW9GaLaHHIByDhhS+gfu50RvDh4O1TOTByjrcSKOmUayQHGOlbOazaxnaRbi0/Lhw9DiB+3m34+WDA8p1bD/auPQEViBMZWNypS1ZUnenaGqHVgDWrFKQXCJiqD4MwduIwN+FNx93QNmLofNEgePFxHgY3ya3P4SUns1dV954IKb6KXMf0eOxnw2dUdTHzx5ckQMl4I5Cllh9Z/fgJB6y9qb1QnAfzWFiKUzhcYqpjoIGfZ4wrpoC/qkDsFaslkauzpHrsDI4HWRoQqdpP1XuZIL0Ayu9uA2vV1HlFHr9s/IJeB69riQ6ZoeA== 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=7thZjMwxCJl9nGbKjWxJ9UcfRNDxh1hpW+g5TgzOWoc=; b=FcgvknSQvHg2Wa00C26JtkeakxRkXXVfv1z7HTJXxCJ4ybBCiu1WXja9iRXSUEk9oyPxDsyHcyc7nhCJRvmWRVldy4O4x/n0WTGIJjBh6Dcrc2ghwpTpeq/RDOAMAkdTbG7Do2PKuRAEVN0WZrJan/Tis7uK6/0u2FAQO7yVbX4= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:53 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:53 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 11/13] scsi: target: Treat CMD_T_FABRIC_STOP like CMD_T_STOP Date: Wed, 11 Jan 2023 21:08:30 -0600 Message-Id: <20230112030832.110143-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0P220CA0021.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::11) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 40d5802b-464f-4154-0e47-08daf44a55c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q0M12QTFhXcUGhpt9iN3KuA6uZiP3scajIUuf2lKuB78K35GfvgjVPzT0Pq41sS3mEbtj0tYY3OrJHBWrJb5YN20Q9GAARaBAfeuNokV7Ch/UpVdFWXwIFrHcmYx2PaIMQ6y7xigrYBQnO2IZ0siBXTXL2ThrteqWN6q05P23DiwoQuibavFHJBL1gWkNiY4xaE+iqVctF6gXryTAABZm7gHNp+JJizwBEtT29Y6eo/OazAvAwmP/tJl4SZ4t6lnWlzNe+HEWMZhV3A8hyE2pk4n5c1OgfvAsZv1OWoFufn3iMCRW3w9V+iqUINJIv6+Ssf04Nc2rqq/k3xd+axV0MHrXyWZ2eaylJ34UV44hsDkzhxub6HGaC81drGM++0QR3hRy/RdImM2+SxnXhBGBzc5bs/kIdgHLwR4LipwLJrHzetv3W9uubbofICHHDsAPVxN60uTzBAdF0PEnI/OIoc3Rv4Dpl73YkGN5sGh/dTsS2MqGAhoCH77HO/JbWwzsaxK5+irh8B6vdAntndJyHvyUQJQN7FGpMBXnlz4GcMLb7dPjKsZo00ux9PIpoT6h9xFlt7OMuwsM5S65JhFb3VBKH9IeFUZaNk7GfpVy0I8yAEA7vg74dEQK3O4kMmUti3p+TFkDcMU10+/n8k2zQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NdhS1z/bu2ZCqEWd/OP8/2S3+W9MHHF9KdAp3Oc7dOg9t3dBOK9tIEx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YyJ9AYNYD1jSnYqIYRGDa7kQgyreQc6PEX3kscOUAcBKq/GS+rIbBZV+Ba/IOlvLHf9lwWgDEwhhNgLY3tcmOfYypPPKuedFllV/TWUtBVdUmDSu/eS28bqkSaeIY2Cor3lYc9S9dBvJdE+1QYfZPAUpUYtm89YBXTxbZ/h4tsR0BOD+aFVS0XSmCKWVD8zYio9E/+Gp3Vq8XiaZB6Uya6jDUuRsVAvQbLWEc+71O54p5g/lwaXhOZNn+DgPO2JLNjxYpwfe/JhRhhxrG6wJtMk8YfD+NbgFWO9VIcxtMseJCoWS8BcdtivThqJo/q96mEgzmTJkZV+eL+7djGrBfZyRYugeUjwRH36fbM5ryYZ2IgavzoVILrHFh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40d5802b-464f-4154-0e47-08daf44a55c2 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:53.1759 (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: gFM1B/0jwD8QDQNRF+dB3lLss+4uZahkE16mdbHdJhhbYAMm5z20W7WQ4gK6IWc7OQG5sM1BrOHcymseY/7leLcFAgSKoOUih7c3GmO3rcs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: IhJfbuVqvXb8hExDyyufFbEGr1KuTnTA X-Proofpoint-ORIG-GUID: IhJfbuVqvXb8hExDyyufFbEGr1KuTnTA Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org iscsit will set CMD_T_FABRIC_STOP on running commands when its transport connection is down and it can't send/recv IO (tx/rx threads are killed or the cleanup thread is run from the one thats up). It will then loop over running commands and wait for LIO core to complete them or clean them up if they were on an internal queue waiting to be sent or ackd. Currently, CMD_T_FABRIC_STOP only stops TMRs from operating on the command but for isert we need to prevent LIO core from calling into iscsit callouts when the connection is being brought down. If LIO core queues commands to iscsit and it ends up adding to an internal queue instead of passing back to the driver then we can end up hanging waiting on command completion that never occurs because it's stuck on the internal list (the tx thread is stopped at this time, so it will never loop over the response list and call into isert). We also want to sync up on a point where we no longer call into isert so it can cleanup it's structs. This has LIO core treat CMD_T_FABRIC_STOP like CMD_T_STOP during command execution and also fixes the locking around the target_cmd_interrupted calls so we don't have a case where a command is marked CMD_T_COMPLETE and CMD_T_STOP|CMD_T_FABRIC_STOP at the same time. Signed-off-by: Mike Christie --- drivers/target/target_core_sbc.c | 2 +- drivers/target/target_core_transport.c | 27 +++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 7536ca797606..56136613767f 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -459,7 +459,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes * we don't have to perform the write operation. */ WARN_ON(!(cmd->transport_state & - (CMD_T_ABORTED | CMD_T_STOP))); + (CMD_T_ABORTED | CMD_T_STOP | CMD_T_FABRIC_STOP))); goto out; } /* diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index cb3fdc81ba3b..02a9476945dc 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -737,8 +737,8 @@ static int transport_cmd_check_stop_to_fabric(struct se_cmd *cmd) * Determine if frontend context caller is requesting the stopping of * this command for frontend exceptions. */ - if (cmd->transport_state & CMD_T_STOP) { - pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n", + if (cmd->transport_state & (CMD_T_STOP | CMD_T_FABRIC_STOP)) { + pr_debug("%s:%d CMD_T_STOP|CMD_T_FABRIC_STOP for ITT: 0x%08llx\n", __func__, __LINE__, cmd->tag); spin_unlock_irqrestore(&cmd->t_state_lock, flags); @@ -889,7 +889,7 @@ static bool target_cmd_interrupted(struct se_cmd *cmd) INIT_WORK(&cmd->work, target_abort_work); queue_work(target_completion_wq, &cmd->work); return true; - } else if (cmd->transport_state & CMD_T_STOP) { + } else if (cmd->transport_state & (CMD_T_STOP | CMD_T_FABRIC_STOP)) { if (cmd->transport_complete_callback) cmd->transport_complete_callback(cmd, false, &post_ret); complete_all(&cmd->t_transport_stop_comp); @@ -907,13 +907,15 @@ void target_complete_cmd_with_sense(struct se_cmd *cmd, u8 scsi_status, int success, cpu; unsigned long flags; - if (target_cmd_interrupted(cmd)) + spin_lock_irqsave(&cmd->t_state_lock, flags); + if (target_cmd_interrupted(cmd)) { + spin_unlock_irqrestore(&cmd->t_state_lock, flags); return; + } cmd->scsi_status = scsi_status; cmd->sense_reason = sense_reason; - spin_lock_irqsave(&cmd->t_state_lock, flags); switch (cmd->scsi_status) { case SAM_STAT_CHECK_CONDITION: if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) @@ -2277,10 +2279,12 @@ void target_execute_cmd(struct se_cmd *cmd) * * If the received CDB has already been aborted stop processing it here. */ - if (target_cmd_interrupted(cmd)) + spin_lock_irq(&cmd->t_state_lock); + if (target_cmd_interrupted(cmd)) { + spin_unlock_irq(&cmd->t_state_lock); return; + } - spin_lock_irq(&cmd->t_state_lock); cmd->t_state = TRANSPORT_PROCESSING; cmd->transport_state |= CMD_T_ACTIVE | CMD_T_SENT; spin_unlock_irq(&cmd->t_state_lock); @@ -2847,9 +2851,9 @@ transport_generic_new_cmd(struct se_cmd *cmd) * Determine if frontend context caller is requesting the stopping of * this command for frontend exceptions. */ - if (cmd->transport_state & CMD_T_STOP && + if (cmd->transport_state & (CMD_T_STOP | CMD_T_FABRIC_STOP) && !cmd->se_tfo->write_pending_must_be_called) { - pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n", + pr_debug("%s:%d CMD_T_STOP|CMD_T_FABRIC_STOPfor ITT: 0x%08llx\n", __func__, __LINE__, cmd->tag); spin_unlock_irqrestore(&cmd->t_state_lock, flags); @@ -2880,11 +2884,12 @@ static void transport_write_pending_qf(struct se_cmd *cmd) bool stop; spin_lock_irqsave(&cmd->t_state_lock, flags); - stop = (cmd->transport_state & (CMD_T_STOP | CMD_T_ABORTED)); + stop = (cmd->transport_state & + (CMD_T_STOP | CMD_T_FABRIC_STOP | CMD_T_ABORTED)); spin_unlock_irqrestore(&cmd->t_state_lock, flags); if (stop) { - pr_debug("%s:%d CMD_T_STOP|CMD_T_ABORTED for ITT: 0x%08llx\n", + pr_debug("%s:%d CMD_T_STOP|CMD_T_FABRIC_STOP|CMD_T_ABORTED for ITT: 0x%08llx\n", __func__, __LINE__, cmd->tag); complete_all(&cmd->t_transport_stop_comp); return; From patchwork Thu Jan 12 03:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 641923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 885F2C46467 for ; Thu, 12 Jan 2023 03:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236265AbjALDJw (ORCPT ); Wed, 11 Jan 2023 22:09:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236007AbjALDJi (ORCPT ); Wed, 11 Jan 2023 22:09:38 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6C4F4883B; Wed, 11 Jan 2023 19:09:04 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C2GNDg014082; Thu, 12 Jan 2023 03:08:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=f8bmtVqW3GrJMaLwGXK6QhY8whT1Gy+3lmPvpwY3Uqs=; b=quuGv3x+akpAYEpJTfUU3GiECH4IL80Oa759FhGT9cZtj/4Da7MYU+sBfUgbUgtfUquy XZgnnaN0oTUPeKPNFQfp87x75kp3aNwbeRr2bHTkXu1s4nKivpJHnqI0/NQ5Uftj4ivS uELOzUSLgT4/7vomjOIX7i5PC3thVmF5D2Sllh2VhlpuX1jGhyBUj8Cwhgag2mfOECHW u0d9dSL3qp0104qlzCq0uaahtJ9KcLb/8Ye8g2L5e3XcBAebZMKZT/DJaNLsvNz29ncd Rbj5UHzCtlYaXqSrGuNFHw2HPxxXeKhHUrMF/rAgQwFvtm+zAzCU+VTsFgEX6sXo0c+9 Tg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3my0schdjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:57 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0ZZJX034175; Thu, 12 Jan 2023 03:08:56 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4fuxsg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CeioaIO0fBGoKtJtsoCwd0BRhbLsT2VNujoDHFUygADZaorHvyvkCo0vA4P904RR7ep3WXAYTVL/AW7DDJDNLyZCAMUgPz8snWOpG5H7/kPIv0S0OkjJnPkvV8AaGV+y658yq1t7w2jnt3mUzjo2kr1ypUgQmukDB0sbg1Fcd6tOaJgJk3Q4NnHacettYs1AA26ryYTVfLLMcF2RaF6GxaK8bIqyI6woOuKvNHVQF7orrxlzZSx9FhzyAvfL9L1GvUApk/vUdfgLDMzHTVWlpF4QQrA9Qtgd1pMyJe0nCdJ+l+owwdTN+5xUI+HgAMwGEPpJJ0kuVIvoVVZozKvfnQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f8bmtVqW3GrJMaLwGXK6QhY8whT1Gy+3lmPvpwY3Uqs=; b=ZBC1W5lxgRNsCp3hKyH7BQhGsyWcHFfFtUVLnOcYL7ZK6D98Stt/O0SPCO3NVVxTk+CUvzIi4G49szTaMxi5BFM2k1iMEfO2YrnM/Sww9pVrl4vdRXqJViX0MHufFYT/MvBcbWfrp0G9DZW2ZxP7ud7PX2dWqB6BmGyToY6I4/hMeRGraGIu9uqsuljSR8l55DTuiFNrLMExWh0ZlGBCb+fNTfBvz/j30cL9NNMMEJm02r1U3iU3vdUhbWOkYKWukTNE5HwYgJbwSv+pL68EwGN8/Eas/U4AvPaviYGyYCJSMoWXKme4e6WAGPD+hRiGs9cGBMBg4ttmcINk5sbTkQ== 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=f8bmtVqW3GrJMaLwGXK6QhY8whT1Gy+3lmPvpwY3Uqs=; b=wEOjGIou63qVVx5ssM5B3OenKz3LAJSl/fHP8tAprtPvAfpEVkFL7G4Y2A8za9u8iTXBmxHigXTwo1Ic9FP81J501PSHhhxm67qxLAfkmfb5aQiPVsGQxAoUxcVsOD5jiFlA6OlPFE2T2EJ/U13TVeb7Ze3/FBVbYCN2hEdw2nA= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:54 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:54 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 12/13] scsi: target: iscsit: Cleanup isert commands at conn closure Date: Wed, 11 Jan 2023 21:08:31 -0600 Message-Id: <20230112030832.110143-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0P220CA0015.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::35) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: c07d5d7e-eb10-4014-38ed-08daf44a56b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BwESFqZNB5W3vX6XhuDZi4uJZEqG+PYNWe2x8Ls5GwnKnuqYk1tv+WP+HYLkgbif9ZSyw08rCcbwo/gyykNq2cyKO3ozSPsv/SF3U+9xkPuc9Xk1GKaPm89AUxizXWicrgB0sYNt7/cffKhYRwxhQX3wI1lLOnk92rQyGBd4Zel7Dp7lfQooY4AqjYKZcIOXfNfadB6KFVvPUjiGV9oJ8WhWr7pBpUITETAcPtkv++x69Ocm/JBTmKW3r1aYkPkXmjPQH02UFQXiQr/YZw0pmV4Fw8CA7FTCTNfjfOpkaOtS54R5014uU3CMGU+/0XWJYoQw7KimmHzjAK9EB6PY0z4WzcWcI4l2b5skg6xRnlWKCkrbI98QEQibsEpS/a5aOj0TwlgBko8+lBnQ7unKFtvflTk8h2RbaJtaNlolSat6wC6HTR5he44f7KNHALNMXfUyjoBTyYmVHm2ShRO36qBIyDqiObUYuYhw/oeSMa0veVhWZfRrZe0vdXamYQ3gEuU5yAfh6Y/ZwS+Aq6JM/Ny6i9P7ZivGDUWAQ9hhO/7udXTBzdNsKPstzo13/DlZOCnguaaU/mWDDSRdMNtF2vUZ1vnWtEdTS+ny3gVF7llFMrVx0XUC1ZQMNVvFDJ9lQrJY9XUv891o21bLDPwUYg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N9/NPL9f8QTCx2wDnswkzv8nGsykSLZna8RBgOjotwwZdVI2yl8Wj9xfqRaths0PY6anYUawdA+O0imO3N+1jmWOcPCCV0GyvPjnYy+Es0qqrPY6pzmqot3utZ4VRBX5Nw6J+GVOqdrLtJFlHleJnJYGDBdv8V8Olg5yIgxXcQH44WBAbNULkvW1oLA7CF5YiiOzBG+dIKilxUXhJKbBG7Div42FMZpK7d4bTK3CEeaKt1ZjIHAz6GgyOe/0tr/nf0cuXQexmQb1M3fcb4kdk+I+VkRR0g3M+NG5UDz4Jnc5DtIKK20V0qcWF6CxjxSfpW1eQS0XKkA8LaT7nstEErT8foERi8LwP1bFw8v46ELkOaXrEzLfMs9Roav75K1vpDTEK3K3fEYr4HHFj3JAQi4I3x6pXAqq7wrOqwhpOOyTDi6skZzKZANvYtq44ja41bpHbMdCfBH/wDnK8CsbmDErjhWYV2pzBvLEc4jNDg7SrUzTpoGpkxMn7wyhXBP62fGp5+JRzqxwW5VxIhaKjknwQL/2e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X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: F968XudtofMHqld7ZRt0MrJrlX1yQdW3UUvUwCnlYL0uwrzEBMW9W0+cLxMUuTX+tGgtHuNA5eFGr1h/ZGPCdlq1S/QXjkoaS+0lL0zdvWF9de8dEekYnpyn8cJBVbHzXx1HcVZNHGSO6ruM+p521mEIjmoNd6cODJgUA94o6U+/jwOfdBw8YIQe8/j4z9C+wjQWtDKREDx7+oN9KBIdbi64hjRLkAbsyDF7jw6Sm42WpEqZ1ZZffNPcoE1d90Q3MBPUMEjy9SZ/Bp3YXrwgrCpoEQSrgUeNbjClEPe0bghEJnE+bXlGKHfBcenbZ3ny2RUp6wuw0kDaQJ+sEusQHl0ivdqlrehrmoRsw5i4girzVWFn1urCjfec+rVD8RvE6mNwNuOEN7REgDE7xe2dv4Z5jN5y/aJpQejRGjlysWBi8BjMNcR93KMYoF72Svf1eE8nxRmzQ/VZ5wCA7q7Civ21/0aEs4dSrp0ZDQPQXbkqAe78I3k3Z1LHNtvuNuQdhHboFiOlUCVS3/2/yil68HULTBS5LAsy7DfcfaABqOYLu+m+QUUNSr/FXcTAMzXZuEbbDlPLPpY/Ul+VznxuyjYUSCtqhZ0oUQBYRL7mxtJ17E/w4uzeDqM7CKI+fKPgQuUYKj9Hh7z/MMve0YA9u1YagN+1DpG3eYFavhS1eQ7w0WEAJjn9JZjlmFdoByH3H0I9lU7Nerghzl7irGF0BU0J7xQRTogIiPBfA+cvFUHPjRBAn/kgsM5ifLk4sz/+wxuo0R/aXrJ/zWJIcAYR+e6JBQC18bQL4hzq21nxSvM0IkQUObmwsxbiTER+PcVNIa8GfwA5+Gc3PJjJtl7/iO9Q6oYRoXhS+jhURVOy6i7/Bh7ecBBwHoZS7vub0juP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c07d5d7e-eb10-4014-38ed-08daf44a56b5 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:54.7539 (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: E+IGCiKkp5N3G4fBNwvHnNHlV7E5wz7+F5Trb7IYUkDjASxh3myvls3d3q8NXt9ffgg5ivWzdZ0wOX0zd43DtA9DnyBlfnPu4IWrEFhewmY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: qeHfQc9__YKKe702k5tsbqFbrdhcTyKa X-Proofpoint-ORIG-GUID: qeHfQc9__YKKe702k5tsbqFbrdhcTyKa Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Currently, isert does target_wait_for_cmds before iscsit calls iscsit_release_commands_from_conn because we can race where LIO core calls into isert when it wants to cleanup the connection. The wait prevents isert from freeing the connection while trying to post responses but it can result in a hang during connection closure if there are se_cmds on the iscsit response queue, because when isert calls target_wait_for_cmds the tx thread is stopped or we are running the wait from it. For example this is hit when a command times out on the initiator, the initiator sends an ABORT, then the connection is closed. When the command completes it will be placed on the response queue if TAS is set, and the ABORT response will be placed on the response queue. So at the very least we will hang waiting on the last put on the ABORT's se_cmd which will never happen. This patch adds support to iscsit so it can now handle isert and iscsit running commands during connection closure so we can have a common place for the code. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 33 ++++++++++++++++++------ drivers/target/iscsi/iscsi_target_util.c | 8 +++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 2a011afa6dff..a57527beb340 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4231,6 +4231,15 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) */ list_move_tail(&cmd->i_conn_node, &conn->conn_cmd_list); + } else if (conn->sess->sess_ops->RDMAExtensions && + (se_cmd->transport_state & CMD_T_COMPLETE) && + !iscsit_cmd_failed(cmd)) { + /* + * isert is still handling these cmds so wait in + * target_wait_for_cmds. + */ + list_move_tail(&cmd->i_conn_node, + &conn->conn_cmd_list); } else { se_cmd->transport_state |= CMD_T_FABRIC_STOP; } @@ -4243,19 +4252,27 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) list_del_init(&cmd->i_conn_node); iscsit_increment_maxcmdsn(cmd, sess); + /* + * Free cmds that: + * 1. we have not got acks for. + * 2. are (or will be when the backend completes them) stuck + * on the response/immediate queue (failed cmds, TMRs, iscsi + * reqs). + * 3. completed ok on the backend, but hit the CMD_T_FABRIC_STOP + * or CMD_T_STOP checks. + */ iscsit_free_cmd(cmd, true); - } /* - * Wait on commands that were cleaned up via the aborted_task path. - * LLDs that implement iscsit_wait_conn will already have waited for - * commands. + * We need to wait: + * 1. for commands that are being cleaned up via the aborted_task path. + * 2. for isert we need to wait for iscsit_queue_status calls + * that posted a response after the ib_drain_qp call returned but + * have not yet called isert_send_done. */ - if (!conn->conn_transport->iscsit_wait_conn) { - target_stop_cmd_counter(conn->cmd_cnt); - target_wait_for_cmds(conn->cmd_cnt); - } + target_stop_cmd_counter(conn->cmd_cnt); + target_wait_for_cmds(conn->cmd_cnt); } static void iscsit_stop_timers_for_cmds( diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 26dc8ed3045b..b0d7d6c73a1c 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -753,7 +753,13 @@ void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown) if (se_cmd) { rc = transport_generic_free_cmd(se_cmd, shutdown); if (!rc && shutdown && se_cmd->se_sess) { - __iscsit_free_cmd(cmd, shutdown); + struct iscsit_conn *conn = cmd->conn; + /* + * The command wasn't aborted via ABORT_TASK but didn't + * reach the driver so allow it to cleanup resources + * now. + */ + conn->conn_transport->iscsit_aborted_task(conn, cmd); target_put_sess_cmd(se_cmd); } } else { From patchwork Thu Jan 12 03:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 642533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AE30C67871 for ; Thu, 12 Jan 2023 03:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236224AbjALDJv (ORCPT ); Wed, 11 Jan 2023 22:09:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236161AbjALDJi (ORCPT ); Wed, 11 Jan 2023 22:09:38 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FDAC49159; Wed, 11 Jan 2023 19:09:07 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30C33WB1006221; Thu, 12 Jan 2023 03:08: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-2022-7-12; bh=+Ze1DNMsVU+TYK9w9qjmcx2srMLpuvIpmIq5z1QffKY=; b=cN8CLUxsvTUAnVLTr65m5Vl81MbNnnksCNyVSZ8lokNuassvnI+ogh2MvwWGCmyBDTBM wJ+GIcStu+BUZA4h/VQxUXOCUZyY7WPO1CLA2bKwhqi5sx4VMAm+c7ntUajQW0sj3zy2 wPApBAvRznHomc3HyyBty36n+eeIRtVuQ+1BH+igsrtwA4ODdHYDWCeq2mYXR2S3skEL zSBdKTehwrN67lfIINhzIQ0aV7ML7PDsvASZR+91R8h20xxXkmb86cQ896KEra4dD31u O3O2hAefhF+xqHe0Vz5ffG7ypteU9BT10bne/t2GCV7lUQlUVXXzcfsmyBgZ94S+wnmW Vw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n25k7gahd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:59 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30C0E1mI021731; Thu, 12 Jan 2023 03:08:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n1k4pmkes-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 03:08:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=neHt/ijHUfmPbpL3W4GPvI4So/FZS294azdun8Uz+4HFmMjR02kZ4+VWGkv3fH9aw0635m6o3XMoh8PvIdoI7ldsz1xkb5FzmdQbsv2RAJijHBfxL3IjrBghkfPTbDlDTzF/Z6vXVIjnxsvqVPeDfpgzCQ9U/XD9iOI3TY32kl1i+jpI6etyjurC8CsEZ8X3X3jenmkmIrpJAobzA4RK1OdC19TY4lFSUQuFv5g8LVPoAIJKyVw3Di8ngKx8qI2/2xTkZTRXSnF/7D4dAW5DQF9cLl9D59Dei8qJXzJBDd9I8WGOieFhLWS7cDu1GMx2JiHCVw9+q7BkbLV3Nn8smA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+Ze1DNMsVU+TYK9w9qjmcx2srMLpuvIpmIq5z1QffKY=; b=a6jmiRuEDo9K0HtSWKyV4059pSwgRHFnYVgZeLM//ZNSWcmr2uO/JyIfl4ilY1dtQ730cbmF/U4Q1832nNW7eJlrzGEfF+gs7oe+lSHXJ+WFrPrRpTSC4UVBigP7Edui9kZuhM0xJKKkvzJumMCfgE2fyD8zAzM2+p3dUbJaMvNrv5vbY9b1Yu124KgiraPdG+YML6cfL7oaGI02eZqCJo2UIMVIW4G9XW4Oc4kyK/4Gy0NSeac6jLPiQWSZIbynBx6z+jn2rnpAQc9e6GZc+W5SFFXr5o0ntZ8gbx9Ntlx3cqVBNpNZIdXs/mks68IEwYpcxCbO9gC3C1jHhllnHg== 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=+Ze1DNMsVU+TYK9w9qjmcx2srMLpuvIpmIq5z1QffKY=; b=y7SGaw5RnPKt97RHCwKCZjeyRqQtqG40QLf8Sc9WxpK2lPC7rff0YvUBy+6Pq8GI3i+R5JW+tPkuPDLDqqctxjRi1rU2bBtqbiVCEYN2ispL3dI/wkA0pKCgvy3LP8U0v12/+uDvY1sk9luGm4o63mq6sKU7P5voHVdUvLzDtOI= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SN7PR10MB6595.namprd10.prod.outlook.com (2603:10b6:806:2ab::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Thu, 12 Jan 2023 03:08:56 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::c888:aca:1eb9:ca4f%5]) with mapi id 15.20.6002.011; Thu, 12 Jan 2023 03:08:56 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH v2 13/13] IB/isert: Fix hang in target_wait_for_cmds Date: Wed, 11 Jan 2023 21:08:32 -0600 Message-Id: <20230112030832.110143-14-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230112030832.110143-1-michael.christie@oracle.com> References: <20230112030832.110143-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0P220CA0004.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::10) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SN7PR10MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 68daa74d-cdd1-46a9-eef3-08daf44a5792 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E9Xr5EXy2xBI3b3vRxoReOKnYZWzsAgWebODxa9GK7Ooa4oU0z4HS7GnNuyOzRpmKXpDuJZMu0Pive/8SyPDAyM+GUpI4xcZBU5TQhRtBOY0WtFedpupaQU9YKKjYTTWdxdnGNc6Nct20Z7fTwe4cX2oFqpANBOQ5FkKTzX5qUXBMLn1cHOvHcQdUEA0H2FGaHG2GgRUGhoHrB/NRioH0kDRvS8hG+Q2K27D+BerVQI9lpqAuvCRKt06naLMRLmKCX/mVpYyGVCNwTwVkNRQzNCk3LM4q59KhWrL5cEmwnzg5DSDptZ9N3dQIjTh3eyfQhDeKqfNm94SRpk3v3t3njReiD2NHztBc6n1nYxtWErLHKT3j0adjuB2PTLQ6sGmriH5WabThykt4EhQmPxIcGOIETPsYdUX5LSX63bw6MmPyCaX9mwKv/PYIlJIGpiZEu9aY+aBzRv/42LeQIbZ3CAMPdnD59mhlQbhuae+VXRfF8Tm2AJ8UsN5SLx5j6sveRtTMIJttf0kus2kUgOwugy8PtCiW9AJVaJAdz7qHobiqnWmgMMclrsAXt1ForXkdCm+DOR4kyHiiJwYg8QT6bYv01C4Mo2p5WlcLdBXi9GgPXG5gTzr6sauI7JEE2qUUmqhC8LDViZEt9ndp6IjLg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR10MB1466.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(136003)(346002)(396003)(39860400002)(366004)(376002)(451199015)(83380400001)(38100700002)(86362001)(36756003)(2616005)(1076003)(6486002)(316002)(478600001)(107886003)(6506007)(6666004)(26005)(186003)(5660300002)(8936002)(6512007)(2906002)(8676002)(4326008)(41300700001)(66946007)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ro8RLn4B/5uRokU9HE+NQPW2utQJSWmFfSRZSR+/wtGW1PnOiNiZAcz3Mf0l7IRtO4FGE/ecE2vcaFAWsvs3ld4Mi9Jev63LnxEw8EOD+j7TPVAR2GCIt38RiLDFWwjzAy2Z3Y/hPUF3Hsj/b0EJePCPk0EyQm5Lu6FLHc5YxSxZYcXBCwLYsX8GMau6YDrJAL0RZdXCK1jrR3G40VWb6nas8mzXj3yTEyogMhzNaKV9SPb7St1f1WCrL1ywYtzxLEoBsIUrEbDelPi5PwzgIG1CdDiitGkrgwWvMl/0f/Sdr2OJ/zzOjdrkOqP6/4om7nFA4jwuG16KDFSnRTS2FfPPym1S0LWLsD+AkEjAAY6kbevDOnURUQMgtP3FJEm3B4oXqF6uRI00gspQILb6lfVnWDPVtDuKZNb4bZrScy+0W3m9aYhNB2OBOxYTCrG27pCTErO6EQsFiEIsey9AqWSGHIFwJbHI9zZygvPYhNZPGFXJrWaUQskHOQyVoEzEFTBVJwbzlcp81Cean7pu+zei6XVmvL9FKFd8hbhVpRobzOUS/DXYvzlBZI7pMu7eCXb/lX2yFVE7qsuet4PjGLMTeIMSPwpd3VZNxXiP6zU3weH9JLn+sAe8RVZ4ZMxzg+uAuinI16xy3lgUWCh02kxCHXO1mrMJinrjE/W+L86TWffA1OdWqGbL9i0g5iEMq8dMnjJv1859NoVH9mHJ+d/RxsuuxHq4wk4/vx+PzVoXjMPseBfo+qOWiayGmFKniB/5OPPMK1Grsm2VsyxgeXfa6Ka6+VV7nHAQD4V5keeSQET2LQEQzYkeTMNMv+jKx8LjQEAT0aMvAsS1Shpd3S6y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YSy6fOUpsbAz7ZUbMHXWo4mcvG5cQrKxvvkQ6MOhVBkG29duxEP/NmOAqRTqOuVPuUKX1AeVhtJL7BhttMfO5hI/+26BXe/EQx4CbooDzCWP6xod9GVgWgqPgPazaWflw/eQ3EDYqLJGiniBpSoBmh7S+s3x62THeE3q/ZcDy8SB8sBt2OEskGLn6+uOhgiJbQfctXfY/IuP84qnpRMHOAeHcqR+5YGCvvnlkEqA8JUeCatSkKDjdbNUfe50FdqyVKWuVGrvfN8LKCwWQTGB3zSVkjhgHSSWB+NJwoKqBgrmJUkmabU57ag8ZwIQAC5HuWVNJrQrsNPmoI95HguUzbC8o8Jd+f8RWsbwACHics2Bk0zxFFIGakaEDcbvXdOsFYc2OF0vLTJbeHZqdtixtTPA+v1oKYp9FNQvIbxEHnJpdHbTUOWg+jxpaUFcClbyr70SAJGjPJXE8HZDwHEUgt3srlHv6t0vMrPdIsiwqCO0efOM7rQkR6trouI4/oocgpCp/MbuwnEgcSY1Eec+r/pCKpUzeXB6ti/YO9m9xnEmzJ64+QE/AKiaTCqr1P5gMTpgjZRfzrX0YYoNhj4Ree/D72oVPQpgcY9e68IYg7QDc1HLiIMnNcULiUImKB6BmWVJyhvLBOjhFw3n3iOSRkAMAV X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68daa74d-cdd1-46a9-eef3-08daf44a5792 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2023 03:08:56.1913 (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: tbSAndOkj7/g48nfsR7s04UEV66OKAAGtfEOybjkN1ALu9sAB2GzvNvBVQslrkJRVlZRmg7eY6FoO94nnwUXqKXIn9uk4ccI3dRtyu4KMrs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6595 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-11_10,2023-01-11_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120019 X-Proofpoint-GUID: juzF5H1072cnRCUfrK5ljOcaMTzj8dki X-Proofpoint-ORIG-GUID: juzF5H1072cnRCUfrK5ljOcaMTzj8dki Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This removes the target_wait_for_cmds call from isert, to fix a hang that occurs when isert's calls target_wait_for_cmds to wait on running commands, but also ends up waiting on failed SCSI commands or TMR responses that are on the iscsit response queue. When isert_wait_conn is called the tx thread is down, so the response queue will not be processed and the target_wait_for_cmds call will never wake up. This is safe because iscsit can now handle cleaning up both iscsit and isert commands that are running/completing and stuck on the response queue. Signed-off-by: Mike Christie Reviewed-by: Sagi Grimberg --- drivers/infiniband/ulp/isert/ib_isert.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index f290cd49698e..516fa37494e1 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -2500,17 +2500,6 @@ isert_wait4logout(struct isert_conn *isert_conn) } } -static void -isert_wait4cmds(struct iscsit_conn *conn) -{ - isert_info("iscsit_conn %p\n", conn); - - if (conn->sess) { - target_stop_cmd_counter(conn->cmd_cnt); - target_wait_for_cmds(conn->cmd_cnt); - } -} - /** * isert_put_unsol_pending_cmds() - Drop commands waiting for * unsolicitate dataout @@ -2558,7 +2547,6 @@ static void isert_wait_conn(struct iscsit_conn *conn) ib_drain_qp(isert_conn->qp); isert_put_unsol_pending_cmds(conn); - isert_wait4cmds(conn); isert_wait4logout(isert_conn); queue_work(isert_release_wq, &isert_conn->release_work);