From patchwork Sun Jan 29 23:44: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: 13120293 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 9F0FFC54EED for ; Sun, 29 Jan 2023 23:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235170AbjA2Xp1 (ORCPT ); Sun, 29 Jan 2023 18:45:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235161AbjA2XpX (ORCPT ); Sun, 29 Jan 2023 18:45:23 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265831D934; Sun, 29 Jan 2023 15:45:21 -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 30TNQdlM026353; Sun, 29 Jan 2023 23:44: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=UAOM3vcZf58l5wnwQL20hV8PvS3Q0Og+t3+1eeOawxw=; b=ZAe4KVbYaFiO5arFcDXEb0xykt9Bw/wY0w5owr66KRypBAOkK+3I3RFmaiuX/W09hVbN WPOpjk7gMxhbocHGxHnLzfqSEOjcQ5hPJMl68SQVRzJsZSjEoEDSP5639Zt3ZPI1sHY2 vyEKlUoOQzk3Xd/J6tv2DTpniUaQqWSwtH69/T2jeCuNtoFGeTg3ecO1gYen+vnCOhds IvJXNj77lEuK2kp4i28/k/pUq5mS44EumYpiB/05pR/N5DEoL7fl6y3gbbSu1dcqPZGt jQUNm0VNCFghCUiwc4Nd6cRZE2K1gvvw2DIpbvQR30gQSETRql6a9gzpYHGC1c+lQ5r7 nw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvmhhrt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:56 +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 30TIZL1N019074; Sun, 29 Jan 2023 23:44:55 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53n3c9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aDXjVyqObAmxtmBISNd4TDfbo+nMqu6T7XFy5vIXWNvY4fGHQVg4o4tJQfd0EhmaonjsEXQO85Vqw4KvxN/uUujRSQ4b6z6CItyJrDR6bjlYiYBlbrEGBIFOWlwW8ZaHFanOUKFZ7SYzbq/bY4ZytvjmXGiIJ8nhWbqQgQHIJM2JMFRqZ4j9Qj4I7OcjJ8AvtmH6IcRuHITehehwN/gVavkqNFqdMXfxlfRgWji+XXyditclpzRtv8N4ulCPoGEC9n4hjYsraoBuFowX9IQX8BpPvoTxRZZ8dOy5qvw70U/vs7lLk5ahKz0PoMjv/bNDPO5wsJtzVOLh7/INE3xtsw== 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=UAOM3vcZf58l5wnwQL20hV8PvS3Q0Og+t3+1eeOawxw=; b=PiBb4UG0VhmXOSmTk1oLg4XoqknI5b+2gfgA182+sPmm5nU76P8n0gRzwqewhzZhNF9YnNIByqJ2lxVyVhRfOCeYmyo+/mgkgLE5gxDFRunf9cO4FkgJ3QGlFNFA5NiIXEEgjrn/efeAZtqRS1ilzkJQWTgsxqxML97418SOcwuR79ne+MT8TE13ryDKA3ehpeYQTG23zy0aa4g6yDUuDNPDqew8nnfxCBl/2Ies5poTVuds9jziqhyyWHLsvYDZGibqo5xwuN1UqTRL24iaYk3nqKzNUFd5Q5KOgJ3WyL1WNBgt85U3MEMpsz1NZ/QXFqKgEKh3Q7Gqi8WGNsR53Q== 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=UAOM3vcZf58l5wnwQL20hV8PvS3Q0Og+t3+1eeOawxw=; b=PEzXfcX8cm9yNsybobpWT08t3/I1tNwR8Aobt/KipBLL+tDcOqbuAAuYtKG0vzVjktsHiQB/BhwLWUthyfPmW+NuQrpb7uadcK3wat0PKoc0cai/VaIJj6yotOxe49XIohPU652BZNBC5iR/eSiAq/TURrtZB1qLC8/AJ6A5C3U= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44: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.6064.017; Sun, 29 Jan 2023 23:44: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 v3 01/14] scsi: target: Move sess cmd counter to new struct Date: Sun, 29 Jan 2023 17:44:28 -0600 Message-Id: <20230129234441.116310-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0147.namprd02.prod.outlook.com (2603:10b6:5:332::14) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: ce05efab-0a52-40ac-1289-08db0252cd2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oO4yrTEByia1cVvaDhjsBFVsA1zOE+XhMZA0oenzFNKWgKwObf14ynUSmJvWQ6VpDRI4ijyqvg59g41Ncx7CWdX7HysZspqClwJFJnDKz2EYX1FrPpXN5VbPMFPOHGWye0L81dPpm0BAiUrayPMQMxHfW2OoxsmcwkyNsrUvkBVIkpVjTZy78rSoDBXAYUTS0SE6HuLjiydbAMMlvQokf9cATC+qDa+iYeMJ46zbJpZ+yW+mrzMQhTiTlMg0avDjbIss7uMAuBv5LcA62cyKrVNlIqZvrDjntDNHOyQLXAT+xalRfz/xIJQqlDTJlC3WLkzV5wlUYPao6qHlraUfOVL77Sc8N0EPeNfzKQ0w6hw4QbWQJK4SsxsMsnt9HI+de1TfJveuJJ5DyRBjWqrHxlV4qzceYMdjp2RmoNE0VxmIOJyF2a5l8LdupOUxnfD9nOs5nYQcU1VELw58jE/kws6GeCHTMC/UdOKhhPELS5LmUJas/WTU23Arhi6q3CngyqA+W6zFYkwU0kbVGpCNMwkex/t7ggb3lW33BzCXUrQMS+0J5uF00u63mwDwahmmEBfCHPKcO8PR+khO08UcsxLyD3OimnPOZv/UQ1sAiVEgqRSGfyw+lYfILqan0fDjzd0FbXY/4dBlaDbSEnY72w== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /rpbL6EroER01T25LUPoRtqmCcYQ4Adru3Pv3N9SWOb3YxEMIYhxe0NsLzGmoUnmFa3DXWhGHRfuF+RUXflAiK0CxxGHDqnnhk2mRVxtTOGDB8RU8QUhtPUPZkq3632G5ANYeYAmWTOJotwJoBr7Xiv+DM8A+tL8feq2nd0v2akOIv+lTy38IvCZgq9EIpzJTMjCnjxcZj/yqRasvVnC8lKlGN6gDzu4J0T1/Zn4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WXnOW7G/U5LfjrRxjH6FrGdugI1ARnCX7mayylAzg5gvyizd/ZUSg4109u8xObRQWtKB3rEs05cOrliBo+KZser6DduoT5tpSrIZdwMoIQYWewK5jo/quoGuS5IaJGMquS2GOlqiI/oXWiZH2n8QUz8vyuzd6cmOQHPCXfT0e2KNA+I/5WLQqhGq2uf+WiimvIuuUe4Q2yquw+Vb2AOq X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce05efab-0a52-40ac-1289-08db0252cd2f X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:45.7607 (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: djdwosTCXEEw3PvLmJH/ZDkIVWuJ4K/Xh/OYWmy40FwIA6h+9MwoVT01qwt2LjMsP08NqTCUyafiDvwVmsyOHG3V2CcC18slTe9bVHPDRHY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-ORIG-GUID: bsclvWwFCK0tRRHDU18WLDH_uS8o35dv X-Proofpoint-GUID: bsclvWwFCK0tRRHDU18WLDH_uS8o35dv Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Reviewed-by: Maurizio Lombardi --- 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 Sun Jan 29 23:44: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: 13120289 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 A9698C05027 for ; Sun, 29 Jan 2023 23:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235132AbjA2XpW (ORCPT ); Sun, 29 Jan 2023 18:45:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235112AbjA2XpM (ORCPT ); Sun, 29 Jan 2023 18:45:12 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F22F51D934; Sun, 29 Jan 2023 15:45:10 -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 30T5NTeo017122; Sun, 29 Jan 2023 23:44:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=kB9mEZNwxh58CQvvF48mDe3zuRREcqGmFrb6cvb3Jtk=; b=BvSNqEaMwmuNSdkBydOu0T0pOOun71fXIZGWN7Rl1+QWFUnbP4lnum+Rx1C3chyOORBk JpCJADBS4bP2dKXwv6vdTL+gm92YY9PfEcHitnEe5s8iZbW84nAZNCyjQDqiRnK7BKIg 6pib/Khcy6eHyoN77UcU1ZZzseYdq7553fBz5jNbe0M2mbihnMAIkrYxDPua01cdSao4 Nh/0P2j7gT9WUMsAjmk6FqmGBKgC4nnqGhfZywKTGnB/ygcVGQC+2IzfGtk8RbuEOtVi 8Jhc2HCOlRmw74Da00NNLOg17LIzJMdRGHerh7oY9oURaPcueKxgHEIPTlWvHNOawW1i xQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvqwss65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:58 +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 30TJ5qYF000798; Sun, 29 Jan 2023 23:44:57 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53dr1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+BDf+Slapjp+vO3mhA2Eapdzg7PG9EmQRfHSynWiivJmZ664s2c9KwT8dr0dydfgfplBKlvW/8QIqHHNr54qs0ChCEvJcaHUmKRzelktWti8vH0R4xqb8gKjoU/nKyspQEoIItMRJVmnu+qiDR9d0et0LTXLN+2n7wl+OGr1QiBGtAh7jGem2i3enlQSNA2Vop7gOK9ubxOGvZ55VwrlkemQsP6GH9NVbXmyHj3vp2SS6ocO7TIPLF8bj9hb9ZseX7eoq1vLhk03TGkyYE8HZurH9HsoFg72M62hAd9xcItYCRW31WAkRh3waGGbB7Apab3ufSlvvJCyQmruZuTdA== 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=kB9mEZNwxh58CQvvF48mDe3zuRREcqGmFrb6cvb3Jtk=; b=b8UmAIWF+XCaNxJ/FJDgNB9xdOXmSdDRtg3Pk+ComcY6lxHC5F8vJixgHbTFiGuS31yLN5aR+k/so+OsLnJrfrjfckBdZRUar9rwGEb2CQ/zqYyxj2LaUy41R9H4ffbUrpoz1bEMtPzTGJelYfObyij+y4p247PgRxzBBgIOPpyef0I7jgHjjofu+6JNkUWIk+QA4ybuBmpGXRcb7quZ02tq1sV9dREqV9nrk6PZy8/wetzqEHIz2OSNuvI2cVz8rwIrdZhMIQx5E5LamSStKj8HqnYHaDUiTzRaiTPdPBTcE0F0EMWQdbhe4yF831dUykhCSJVNYP4+qQryqkUN6A== 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=kB9mEZNwxh58CQvvF48mDe3zuRREcqGmFrb6cvb3Jtk=; b=OtjqBfWd7hHTAD8G9+7k2svQTL6mmPv/N1odTUslFbLy1Eoq2YYROQlMEi+27FFZgB429dAB85A4m1+LD2ljY+Qo1Ijmzz24Scrz+iZKUfBRLJ8tNyTsqnQHRGPCUh7bnKg4i1TESjkHcp+IvN5mJZH1SZHXIwBSSM11h5f9Rx4= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44: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.6064.017; Sun, 29 Jan 2023 23:44: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 v3 02/14] scsi: target: Move cmd counter allocation Date: Sun, 29 Jan 2023 17:44:29 -0600 Message-Id: <20230129234441.116310-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR06CA0004.namprd06.prod.outlook.com (2603:10b6:8:2a::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_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 452f7033-18fd-4b8e-b3f8-08db0252ce18 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: glKzpfT+ZJxetlJtQ7V+GOomoDn4QZVUt768LPBpz6YN697y4EVXKRKVAh0gzaNF+QBqGFKM4n/mCTgfE4PgKLwrOiX8h6Xq0jdUoT3a322+AbE2ZPX5DwmDkiy286VPJhq5SdAbDjHeDFCgt1ZPPXZrk7EKXnXXdYJ4JvdbKRVUl9SG2v/SGlOtv+260ExgRBZ80hhjMS30S+F4VHjH7W1dFXlPq7OfdVf/KxFxBo/5G7JjhNRKzgwAiGQN4cOrjS1yuj262lK8UoARM0TawDfrM6VBqvh+xK04g37HZEp8xK9wJCVHJF4/C1ZeQv9osj+N4LU94g9Mg6Gj/x1eNxw7yVtnfCsFwNGyrXhhVVIUWSWd+5t+l3+PF8mrCJCRh3ffTxHLMrpgyabOS6b0JIHiLSzeScsa77j+Tk+BEt4FvH3BH0Wknz5LnekTd12wNQa/AXnRBpn4EA6V5kcHTEqB5Pnf3MYzXt2JbRNliso3RZKu+aeykfzIP8Z/3IKa/n6qgokIOXC+F346xJoJ5e7/8N0rLduqQEQBRkFbfqkyCqHaqNcf2C2SPTDEDCW+VSvNmglN3saA1cGJSjM6TIvod83YTpGNf5Dndx+VdLZVBNNQ2LJZ8ixHm7rCPQIWQ2MFTJtm4wrYl07EiGWSdA== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LqyScY6dhgehh1OXGf4IX6UcROKtb/SnTtX2fd49V+Xow5F9iFrLK3n6XO+l1NUeVBciycT7pqT9h8uKnf2HX3nCiv/IGaX9YtxM45ZY6jk5mADgpk2Us/OwXFJND+qMmQ/nFYa3y2DuzyHT8tR2Ssv0Oy+cIFq6/nM5CFcWhjmf3hsWsrC3kSSVxvo8LG322R9DiWvxMqsUoWq6xKnUgisXx15wAoEma62GIuP4UZHSBM19XN31hbdkgvm9wvCKchbI0a2DkJMYUByf8Ks0m3KAhFcHQVtu/96hDYWuyWYW/eht5TE8m6VU+mddTyNszRLUsdOKqHSUZ8QbsUk0s/Xc5BuZ+WqTZHdK97xVKFanWJlDBgGhdDfvAjf08oIyqyOPi1MI2Qo2uBi39YLIRua0sIx98/jvUK6wswWemL1CcvQvBELkc/7kxEOKU3uuE1LRtI3z9SAySBSKGxQr7X2C2QnfjGoydbkmydrMBlN/6bDM9EGXJVs0ezWXQ3p/8S9C84S5O2DIjtgrwpIjX8zM3q14UXvtu01aDwLy/Z7pGgvNtbEIZObOpht3WAYmY4fj1qTa+5qdeUWlBcxazvwdGVy1ldzEDgTPbRFiTVKoFX7Zg65iEc1CW6Gjl1H9JWnEqWAb39t/WumLD3EaKfyCxQhTzc7byWQuOLlcjlRO574+kFuzVHYpMqFdAJu0Qjn2Sx/H0kDvYlztKmxRtiSkpEvVzUJglE7tUI34LKbdL4lZb8MCsW7/4YUVDzZwNlqCJkqm+EQnkKNooKooSTMRXwSycUTLl/ED3nwTkKj1nU7kVUV8bg4AytBOAcIq2SQ2sNmthtq/sJIlLVd4ct0KP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afv5NSFzAve/pacZfoFWbN74a7CezeN5rCblCACfafpRlinIU/26ecc1vOPQFmaXv0CbquRZmRvdiwAP+bs5lc0XkpagzR0cFzQSMUxZKKPvt+KAL+EVrjtolOx43eSHzZ+SMwHZZefz1MnVBUF7grDQaJZ4GChhhNsXzuva3dvZpzren/Id9BPkfIzCPP5IrdsesE4gOSAG2INylgXY44qMt6OthBnwzFNTQwUK1XDubXGomz5qOGN//UUW9Wifoo/yRxFBaKdfnIu9dKetNdgUWZZamCWJDJkJkPJQFMJNqbihg6Ixbo3D7vzPPJXLMSQps3g/bUn51kmJP0Jl8N4e13XqfBhvXHeu2TCap20xpyffGOYZDzh6z3/d5VRd7fk+RgIHgmAVs4H0AgI8q4oVKF0X6waWjvG9M75Hpy1FGqrmw7AeObI3UyfXJsjq+7dqVFDDSaQBnfw/ks3W9k81NZlmMn2nddoBCR2XNgJ69HsgdutfrhOZzzuIZAOHDDDsURsJmlzJo1crK3YqyhXJPiumirtuqYQPWu8Pq3VDNJln5VqA7DlEWCoCSOUpO5H4WJAiJwY78zHYvw0JiROfwEhrhtlJNwcoMcyivyhkYXapG5zLNPkkkmsvDoqozl1G0o+Npm5STTcLlTpKC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 452f7033-18fd-4b8e-b3f8-08db0252ce18 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:47.2762 (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: QIzp3EY8egtYvPJQweJBeXHtPyp30+Ix9zcHIF0u201NY0g+iR9N1cC0W7VgFbIFjD6Yaoe3QmREJUYmnAy18tGKGYGZZgXTnYaC5qZq5Gg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-ORIG-GUID: uI76MPv2laormRwIfKce5PdSj_ijZ6RB X-Proofpoint-GUID: uI76MPv2laormRwIfKce5PdSj_ijZ6RB Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Sun Jan 29 23:44: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: 13120287 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 8B5AFC05027 for ; Sun, 29 Jan 2023 23:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbjA2XpI (ORCPT ); Sun, 29 Jan 2023 18:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234659AbjA2XpH (ORCPT ); Sun, 29 Jan 2023 18:45:07 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C64B1969A; Sun, 29 Jan 2023 15:45:06 -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 30TMfjJb015535; Sun, 29 Jan 2023 23:44: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=keuCnTYWfNUQYorkCDlFE6ZRa5IfkVBfsJkrKx+DgJI=; b=3Iu54p3GMDu8FlsT/nrDGLqGFYM3tUK8hyBCkzlFUcATFuTQtfVrg+UF6AknA+IEsYN1 nPAfQ6YdEtm4fzsd0CvOx9dKH+ESUiSeP4iSi7G3Jb962rDnAyIR3LwrTkO2r/2IAr5W 6AlUOiBnDrzb5ipU7sm8NTE2u2suSQQHRbrYGSTF8pV3RxWJ+tDrhDpf2OOvsgcMwKwT xxO8yT8oakOfI6X8xP/oxZhFEeMmdsiu77yHVU1J6cvsA80R/BlVGanqIctw9VSEK+iZ aypRJAG/XbnI/hpli/3dl5XYsgASDizi9Qip46zpEZUrDnd6zapZCcgEb3KlNUZ/yY6J Ow== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8hrxy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:57 +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 30TIZL1O019074; Sun, 29 Jan 2023 23:44:56 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53n3c9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m8Al3ZtEgrpSLKu4vwpl/kQAgvZgzfeekYmFfVxDPmuRph8MnQfFEj3RFx/jCtErMO2zWauqxOIK7MN7PUp495I2GCuvsA7oyxHnuCjQwyBtjoAXIsgUGSCnxVyiHU6aNx7/sR3BwL4Kevj/focpqXTiEJRT33InDPjKp+ZsoEmV3joJJDGzl1nLH8NgArl0fT3H6lt80+huV73WsTTzfueYnVr0l14AuS4mIwU862vE3ne/aeBKW/P6T4oiW7fMqyymla93+RQl8ag+VGnPznW1q8oCEG5oh2wIUM+z/MW7aoypPLU+7D3LV4/NLJCAYjfL1kDaORpo383sMvv/Pw== 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=keuCnTYWfNUQYorkCDlFE6ZRa5IfkVBfsJkrKx+DgJI=; b=auiFVc1+GX4MOHk7qibAtdbkbBR903FTGGvVpKSpdrFr6DhN5OFNQsv487rOsHZAOT06FX+rWOLmFMTrl/6TwCdmgmlpUtOJzPfIBW6R1UgmMkZJUclq2+AqFntIEIlOGUPZ6mJxD+PXJ9Pfl7E60AAXQao/OlvPxahW1t4DNJAunzKRuT0Nt9XFDqIsobFg17+lPB9TBXsVBldvk8EfHlyLivTbarcwbaIzjL5iLHJGXXhR28UTeENbg/qSWe46nJG9Kwib5lA5KM0tHTYG8b9Ykcjk2tlQyIgfPUtg2iU6EpRO5vG4r7kSBRcLuMUCKOAFBEZeooc1QuD6UcYeRA== 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=keuCnTYWfNUQYorkCDlFE6ZRa5IfkVBfsJkrKx+DgJI=; b=uPErZV0BBm2HennXfEXavFuCoiSiZnRUmO23KDfxVelc1l6Rpx/OXRx49VrTvi70iWS+7WCrQvi0S4vV67aS8XQ2NU5xpqRl58globI+PCJjZfVhBlxPxABfJ/XTg5djoIAhC5h7I9IDsDPlc00co9eg3s5L336+teeMcOtlPWA= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44: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.6064.017; Sun, 29 Jan 2023 23:44: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 v3 03/14] scsi: target: Pass in cmd counter to use during cmd setup Date: Sun, 29 Jan 2023 17:44:30 -0600 Message-Id: <20230129234441.116310-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR05CA0070.namprd05.prod.outlook.com (2603:10b6:8:57::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_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f3b571c-b59e-4ca8-7c53-08db0252cf09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lMRmu5xaFQc9XS6I+8SCh8dqPa59jFbwG9BqO7X85S7ggnTH9+k+A+G0MgMB0LaAflBVT0QLP6zKua5Ghk+t0SIa7zmhHAhCgigSu6kQzCxlpqFg/eQhDX4IUaxd7ggRGRguJ1y4BM1nUmUtLD5IuHnp4LW3nS0ed1Kk7HvzS2BwlzAUxJFzbjLM6d/eRMQH/oypS1CoePZnWQ9QaJoDJpAqwYECSQ6pdkKmChtqAA4rfN14sXpCEVaF2t3JCkR9Csd98ix0O6bu+CHxfijk7ZqLMtixv2D95Sl7+H8H+3fl2HKkJEjgmmTrh2Kndoe3pd9PZLBK+it9gBCQzy4dw8Eu+S2WAA9YjSb4hN6RcqjXDC6dZruSj0nT3I99WR0kadeKQJuYbBhgDiwLckas7TImXWaUhc1HnX1rFbVSxXq5s8JDlOB1e/gbZsIQm/NBjmeYDLsopLbOiVDOAxatUi/ls2pzFm27uCDkcbk1TDrvmpaJ4Tvb9nc3MSeCD6RPWdh5s2uuWU6+qSjAIFaBoyjoLt2LMr/fgH09y7A2Y70Owk/5Web0nH2CGgM8VkWQIvLqBtrmtWNK/UBwcOHZnGfqAkHwfLt/JZ0vR/5Aq8iU3IOAJ4SZm+RULj2eKyO7H9OktHpjGbCn80pB/R+pHw== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gN2Dk6TK9gCzKksAuX/deGiOxrTmc2X6Xj+cdGknee4i4nV/jA+gtFQh1HuFXrZe8qmH1dUlf1R27R2+Uq882SnIaCrPG3uUXKpfXeyF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n35lI/wes0NgS9jvWut5iFD68IeBeOXZNi0dnCUV3Clqw9V9jqDcyLs0QV1nYfGFM2ampbFaSOGnuOpQyrL1q8RsXm5qdau28rgSFyhQVKUW/i9tY83PMBiamGb9QroQL4tdL9nzVSdzd8FdyR0AssYFdMdWNxDdLURY2THHcSR4fbF90Gm69fDjElWOvvNv4QDEUPoeEDryoGdE4qnd71I2rmrOr+qAG/yHwj5PmkBYC5jzfIoZJ2RPPeHerJwVlAhOWyTa8mc9wbWmrcaa0PBO7bSTfs9z4gAS/Z43Pg94FDzbbzlWDQaSqYDQCvA2ln354O+JgrYB8peWpUO8V/HJGrJAktWfUD2MPsQ82Rojnbnkn0O+QGGrtm9rp3QBiFCVtv4v+xrFPwzrUsSnbTrgYcYCJI6xE+mhCuDaoWOVN2A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: HWDTbBX6C7G04tIUcmRarr++EgY853VM0od5aWhUfuwn8ChChnUnZWSER2LpYlCmT3C/9duIQN112wQ2hRdfxL8iV61FmO5duiWQ8pvB8nP4cWqT4bvdypWBqnk7hBm8SoFHpHGZel6JZR925Ea3RsrMPeFpVXxxOV8EFIx0NFfbkf30xsBgDDPFhmUzCIAvlqJNwmT02OtGMoWClZsbsKlAv0TmZFChbBj5DkhHV5JAuzcxfjQmgui/Sha/nEejnPL4q3cznhxNmtFwbu2aUZcyR+M8RCcXG9hJxlSrcq0oEu7Mym3FdZKNwAhixjVVei/CJdmpNCzy+44qnMvVChVc82DL7+BzGMrEXIvbnwxK3Ur47gakAq/ECLu3BehIphlapgnuOXaZY8n8Z37Q4R7Ha8IanUEgFr9YdfkGYuBF8O9fzBgaBebFgXpspOD/DpupZuPg8xXMasdP3UhLAyOVjhD1dKwl0BGVUpG8geCNgujmf2cRKclKFrqVzb1Aq830/Vl94PLy5nLS5zn52FO5odFJoaMTcxg2f98m/4Or4DiE2NGswrk6CuaPu69rm6r6QVzDwNMf4ukeRz9rwhAxSZDv8nslYyL0xV+Ls8SvPORCEZc2iFPKppD4CNvP2UYkyrwc1WiD4tENE8+OydDi/kqw2dSOnz0C1+82sd+TPWlRdBF5922w7ilRnMiV7w+cq8TBaOWsN9G0AavVTqhlMgBWpnzMOw7ikkomb3ICI9p0xuKZfMdW+VSOUrgAzxZ3sR2cYIQcksqP3Ls5r/F8P+AHA9MnJuqdR+tjejgrvHQXPIZ13uL8ncx0DJ5lZ5tQaR1sKrW/zfwzm4LtqpbUlEkz6Ff/cUfaxLDgLJYrZQeToJzcon2sx0/s6Csm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f3b571c-b59e-4ca8-7c53-08db0252cf09 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:48.8386 (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: LQ38jY3QTZiG/Ipy1nD1SYMgj+0oXJKs7ZjTya08y8NqJ3s/1uLo1ZS8koyyXqLA9FjT6Prg9a66uKhnZ/h6f57RwL4JpduX0GqY32lmZqE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: q3P0xSSHZ8w6O1JEA1TNVGX4AcYKnYxh X-Proofpoint-ORIG-GUID: q3P0xSSHZ8w6O1JEA1TNVGX4AcYKnYxh Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Sun Jan 29 23:44: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: 13120285 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 60A0FC54EED for ; Sun, 29 Jan 2023 23:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234930AbjA2XpH (ORCPT ); Sun, 29 Jan 2023 18:45:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbjA2XpG (ORCPT ); Sun, 29 Jan 2023 18:45:06 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AB1218B13; Sun, 29 Jan 2023 15:45:05 -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 30TMkTq9025111; Sun, 29 Jan 2023 23:44:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=j4euk1gcVE9ECbI1zFtyWPtER0ZZeTvaCA+w2iILEP0=; b=WUHGw1WtNUijOFUwdOc9CBRcME+upprifAy91CFDGl/S6GrnOgfP+SNaSNzZgTKeGV2p IZ4nnTfi4GsIXyUH7KP2bI8/gTJvQcoPgaaspCbQlDdhebvAL9zwtwsoWm9Z7DXpaxAl gwR3oK71hWCfLjGn2GPFCvTNKQFyLyXAXodwp+BGzeM58pfqVoMuJ4ZqdC2Ge9P1RKdT Inw7zENk7L4RvKnVE1tnVqAYkwiEBc2liue2KJX57PyTNE6gJT3N9YdbParLVJNT2Gat VWl9gII5zX/hHmq0EnD1fpQjtFibFJGVuqD2pnsjsmuvS1DnxnXBe967JWvM7WJZq5lP gg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8hry0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:57 +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 30TIZL1P019074; Sun, 29 Jan 2023 23:44:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53n3c9-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jCq51CZ0DFNjI7cob0gNIlKVvPG+1Q/uxORGDuGSzTP39ud/tQTh52+VFcCYJnhB62zB14heMo9Ovh8A6amKciNM5hDstEcWSuojmiihFjZBrK/8EwKfCoPvR0hF7hZ42vlxmWCBq/KOX8OFkrniKCv8AmkxyX9zSXe8daWM1rSQhDYe1Yxh4sPt0q7UXLBnaByfy0oUG2W8Ts/MaEzfL9tT3S2HKt1m1Fe9VEiJqh6EdErt+YAVhnQ05sgVQcJr4ldkx9MCcFKBCCkuiq88qabe+SxtmCVtWm4YMpXSrSa/zn+ZDoII2RIMA2fg+Uy26ZclOa+nWo/tGXNCmNNUlQ== 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=j4euk1gcVE9ECbI1zFtyWPtER0ZZeTvaCA+w2iILEP0=; b=OrLdMXISOzC6RI9SKc0QyKcnJWLP8GeL/D7lzxN4qDUBf2gp4YkiMntNeCXhL+oWPNi+rQrzpTOqAk9AQhDBOg1P0o5+mpLoGb7m4AJf6bL11nkXt0lmHAjzw9nzpDJScBuY/EA2U0MDu4cuQk6RJ0lvTrgYhTqyVrWoWbnnErsmyffQk0HtwVOLaN+YxjcfIefGBy15u3Ra6h+gzRulfbhXobYtO2oGI8NJpbOa+sySRc0TF6ZyLsUCZ87fzMVlYIsVFG+5116yKv1ypWw+PQgII0Bt9GOoknLtXvxzUzWC0CckuaZQ4niPLkF+WrgwmEVUQFDOPHeifSvVYo68Cg== 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=j4euk1gcVE9ECbI1zFtyWPtER0ZZeTvaCA+w2iILEP0=; b=I0T5ZMbjfTfVoDmGaUXewMhfs5iFzs27bdmtfSh+UsCn64aZ2zAhkveY3tsG0s1KEzT7SzjFYNAsn94/PviHHPvRg0dtPQogIxabUmpYHXruFxvE/jFiZgVpgpoFaL43Vc/Mnfm09QZqaXurxPM2vhsI3xfNWONLWGgKyjm1sYg= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44:50 +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.6064.017; Sun, 29 Jan 2023 23:44:50 +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 v3 04/14] scsi: target: iscsit/isert: Alloc per conn cmd counter Date: Sun, 29 Jan 2023 17:44:31 -0600 Message-Id: <20230129234441.116310-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR05CA0069.namprd05.prod.outlook.com (2603:10b6:8:57::21) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: e901d4cc-8afb-4768-f908-08db0252cfcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FTDLiXRvSdC12xCY8Q78b26r5/x+eMuNT+4DvqSiUZnbccrWG7if6xxlwPklGkJLm0ZGsXTE6f8YmcXd7R9H5LPU/JDhAGKlXK7lQMmEGltX4FyA8EgCnpoNuXapDwzrig3jvbMpZOMxO9VWGRnzixRjSju4Otwf/60q85NW0KST9KjbfGWcsRKwX7X1K7Ovxbe1XimK0/3mXnV6W86SpZGgbMtqEOuXGx1RRr4kblIlbvzl0uqdIpgFh8Ki0+vnmCuX1v409PWIrq0UAziwwd/6ljytFeOl1YQ13bXS8yKsgLRctWgVb1yMmmmCduRE5rS1nnO5qgAfy3C1BApa7BDtMxn3D3ik+YDn4KV+m2Gt3VcQsBMJq1hfMfaf2bMsoTxAPLXPypytwHqHKIt5QExARWY2pcExLHW+fBBsATEZvkkTcE7KB2jA/OaWZOPsrt7O/sNofnbgghYNG6W29OjGoKYTdjbv7q6I6aFN7wR3d56Pqfou4dE8QMpTzCAEylbkZb9xm6//atKcOr+lGdXPirW5C8MVqUjhM9CGCZp7q4WTpjqr7VbLO3paIMqtIHSY7SZuum0qgRuHS+hzCzc734EelcvBtPTxH7v/jVLgu/WTMI8m48nVUp7bn+9UUpujFOGSKvSOL9ntPj9h5A== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xZaliS1ta3tCCkGU2MVEpAQS0tG/YSrLoe9BVOuzZ4OlI6LcJ4ekeDz7StxjTFq0wsaGz6SA1Wvgj/rCrc2Jv7KGzZusu5vb7cuCLXCAqfLzAfCxjgW+PJ5PcXVrD/9e/+Gd17TBF+3gnY1oVwR8DJWPQY/MyKmamgZirNr0s0FIOpjksebhTrRNrdzkZMGgg7gjELyL1rP/ZNX96sMYVRXLsdAyywQ8mLL1aEbYZwfYkaEIt5uHcfN+jqXxTTaKC/D+MnHewI2/aOacxIsCpnWvkZSUvg90TNsMAUTcAIsElTXpo+acZKWliWT4USaycAl3kAy5nfDpHQxMbIyDpq/1/OjrJHonmwiwtm4lgHxDsEMFswsJ7GCTp5psmgn7+ohZq6JL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rbEcSoGNkVbaPuhMMWuKAjpjByYH7W0exgH7Y869FxX4PBahPc9oeOedyYQK43JcfXdDqbQ1ZwATPgGCB1Z1tIa5ZjMRPeurkYYANOAzYg54aYV1n0FN7GMvu5USRDcChGqbP+BLGGcngImcUnfpmr/J9LCA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: LVoQFsOAA0daa7KyT9DAfsUVIaaEtoKOPXZl4VMsqb0eCapjDrycIaflHdQHg6yWEjUGDPFRaazEC1r/eGJPFVr6vUnqFjNQxrq4SsM1t5u3xndAleW67oWoPl5BURafYztVN4TK7EV+zXZgfsb4cDbWewSKmHYXe5imRHl7y/EByUrbQot83cVglqUb3rB9cw/JrImEvKTj1omdnXPpI0ZgEalcz7uNAa1ya8dk6GS6wg8mAfWLSCejHVUPDUoU3nEv82PRR/iTVMTaEezCCSNp9Nf7BrSCc1hXpJZzXXh/rJdjmOeDayYoO15WpH1ojmShxp3Q8xfG/CJndGH2tts7RKq5p6XAFM+BnN6OaEMBK6oiKsBtZv8PqzqwfDuvWrbanwe32DXaQunXvOx93Se2AgUz/SmxnAY6W3qeEWLDe8k2TZ6+yNjNiatr0AXSMKLUdFQGTJ/gBY021+EfSgnMbBFU13XpBtalRHXKUlyA2SS+4aZwbcfM4pKlupXzADJrrT/rba7HZhEPQVvkyKng+OnGmIBeX6weJOftXZSlDF5apWQIaly96rloWBGRDkDATLcmYAfO7NXiOZtzz6UepfnIRdsmbhXrq9tRmfdfYE0RG5NBAojOdidscMPil5ituc35l/DbRuoLO2ItW0w3SWbjwyW7QNw2hJA7OvPrv9lrIRdg70x6NoxanaxTi3U7qKIse7pGFdm+/QhLeCAsFpN4D5BAELOGJl5w1z3gzD47CluXvWEqT+SForGwbLoffCUD0YNFiEfbUHJQOZ71y+B/o5eX28K0xQlkMTmN1Ew2oi6Yzrq7xGewwtgmygFJbtn9v2u/O3CMyUa8wQyhkwIHGpfv7q5ZWEKp56pH83CXgCK28i2UPax99Z4L X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e901d4cc-8afb-4768-f908-08db0252cfcc X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:50.1510 (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: lP6992greWw1rCecEcVH0WxSHfiYX4ph7RWmPPT6Hw2Vjgs+ez83bwa9XPhFGBV5yDGIuA6zO3H5HHgGd8wiVsFgWel59SQz65kAq9uMKJQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: wt5NmwS3NRijG8UrhwgM7Gvrfiwwa9sS X-Proofpoint-ORIG-GUID: wt5NmwS3NRijG8UrhwgM7Gvrfiwwa9sS Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Sun Jan 29 23:44: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: 13120286 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 05998C636D3 for ; Sun, 29 Jan 2023 23:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235075AbjA2XpJ (ORCPT ); Sun, 29 Jan 2023 18:45:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234936AbjA2XpI (ORCPT ); Sun, 29 Jan 2023 18:45:08 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B58F18B13; Sun, 29 Jan 2023 15:45:07 -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 30TMgwgE031612; Sun, 29 Jan 2023 23:44:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=QRa3dZC51XS/Vx0CVtCSGweRxmgtzP9jpjq3Ph4dULY=; b=VOdCwjML+yomrmX2B+qs+bcJjFYviMtxVrViII2v+fwrm/cQ1hWPmXsNO3lwkFvvGi8K 929ELDNOKVOf3Pu7QCwm9SerFp9DlAWGAkKO5wZOhosnfYk8Xkj0OhmoUOHb7xR2i1tU n7f6TD06s5U/qDetj1cImXTVU06CUt1OTlH1KStQoS9i4Bg/1HwVHudwuQQG57rGxSO3 ccogQjO+fzbBfaJFwqWP0gZziyx3pjRdAaq9to6O/4eN3wAsXtsUVcGFJlPKJuY+9gCa 7XJt6KEutnZe+cRTNsYwls4HenW0+aOnNIuWshf1/C6kIj3v0D+VI9s9DFpOtxxQS/eu Ow== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvm11sbp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:58 +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 30TIZL1Q019074; Sun, 29 Jan 2023 23:44:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53n3c9-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PHcc+fAajyqH1JOpx3dB0kyLEnUh995AbXAIiZNFviRvGBkIQ7EzhzfyF7mBbXkvrbkH2I4HQeKl6nLnNVQ3HwJJq5cmk+yGqp6UrBpIzBx0iEY3E6zN+8viuce22RP2GLMnHuUsp1WHaRkesAgF4QPFoQKK1csKpG3I5z8oY1BErbPX3UQeBXzAfrws8+1Ieipe0lvtFQW4MrKRA+VtRTQj/U1x0COE40aAkwYUHyQuX4ASVXrElrarZGR7PECMKFu6/bTSQbm+CadnAyzfsi2GM5Z9L33syheowsgzoW3vfEKb5S0nX5YbCStc5YvpsOzwTqlLPchcNgb1As1bAg== 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=QRa3dZC51XS/Vx0CVtCSGweRxmgtzP9jpjq3Ph4dULY=; b=Z3PYECp6tXT0dkwTDHltNTexjjSp1wVIGTor+HMDhgC7S5vswgHLgRfFYam6Ij4i6jw0O8PlD2o0Vf7xRoZS+l28FV/qi/Nj9YpxcuziLRIyu1f2sHjo3rJp5Ej2sQk9I7vA2HcMOQwvSwsPXKeuSkP6JMOAsG0l+c92TdsUxJbUGXz+GCtv0XK7xT5JayqsvbYYJnaZ3Rbtnj+6l3exZ1WBIQvQio3jocYDQoLAhcoy7/8ouBcM/XVtd040bk7pdqezGSuEmsVjv7DCYdxHOw8NDWf3CWuMOy9/KTx9fSnIS0TKwzAsGJKqoNY/raLiFXqawPr+6OHqMTE0ViiUxA== 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=QRa3dZC51XS/Vx0CVtCSGweRxmgtzP9jpjq3Ph4dULY=; b=os1wBk6Vln6OZcbRplaEmdVgrjwasZwq3Domdb1dwmuzY5+ZIHN5BvL/eAFwG9QyYgX4I1eoV8S3F45bSzOP1363Ltho8eLHRn8BF6d6cYKi8v4Kw4mB3jLM23KLEoeJtXjqUDL3O5ww9QfQbaBRvWTwYlcI07w4hkjOpHMDr7s= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44: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.6064.017; Sun, 29 Jan 2023 23:44: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 v3 05/14] scsi: target: iscsit: stop/wait on cmds during conn close Date: Sun, 29 Jan 2023 17:44:32 -0600 Message-Id: <20230129234441.116310-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR05CA0073.namprd05.prod.outlook.com (2603:10b6:8:57::27) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 196e78f0-e309-4b33-4cae-08db0252d0a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: syKOSax5vcwtCTvYbt06KVsB99vDsWj4StjVq6M61um2A5bfKWsblINFB8+dcTGZR0b7K68peiGNPbwWYFJS/L03IhHJmxK7wimsMPzFJXureDYUNFBPEq5Ix6a0rsyyYxZUVuJLCHPMxUerSv0xb0NB3efksy+QPmceOsG/QVSMOueNo3kwABIm0rL4jnzLEBKcb/KXYJUJ29fqmiN3s9MjZYmLt/MECZmXvRG0zKVVwMNSlq4TGvdEOeC0Y+vKa06l+I1603LbM9FqBYRyRRzbzdELvqW3py7w1EzoK2MwBRIZpJWsLh4MxrkjifbKckpARU80uFE5utvI5cygHhp2FHHmI3q7qGTw0SV4v9os2rsMwomuaz276iP/tWLef/kg6VEwgSn+Gv0DlSMGQN9JvB9beiDJJlry7Okc8M78/fHTsgaKpeiCp1gtnAlPPKfFwr1hoAZi2eAfBnzJZpdSFM1RdIrx1puaBmWYlc7uGJllVuDZuwzJbz39mksnUUNaWGM7LLMH2eklzJ3EE0l1xJ4Z3q/iwORLmLf8KAxd1SvaEZb6XWMMm2NzlNEABbu1ndknecO1Ue2JrLLG2tQI2xj4RgCL9+WyV6Jzo6T1pXpMdcE6WvvgC6HU/1JwKxmD7v6WQIefo87B3xmLnA== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FMr0XOdyawbpmks1bql4QTHmY6Qj+vf+DaBbDpWkcDx9ie5jcIVByLiBHq52ioM0W4D8ixtoP6KDTQq8sAUQ+AoF370aWPnwR0o+meWpLxqet1NJhAgwyKAAdP+N16JLjHXwhiPZy7Gbi1WR4GJNFkkqT5c6lBZPGANigPnFEwgd2ZHTnPqFx0f5fm9M5vhq7fuhEhVzyDtSzYndGM8oFdKPz+H5XbZU6BrFpZbHqf1mXcFQ5PuZn6EXkhX1njdEu63F49wWUTrKI9LUY/sk9VNR82Qm5EIngFCZYIpxeH74nO6ibzSHmLIuxef2isJQrz0rsZedqfql2Jq81daNbj8KvfIbWHLXopGiUfMW/CGGqTuVl8jDE/NrRCI2HJEuWGMIA2q4BgkaoioFddhIJrW+ywRLODOgm40fuDJghAHmZJS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7OtvJDZHNo6rJj3v X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 196e78f0-e309-4b33-4cae-08db0252d0a8 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:51.5727 (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: 2rIle4gUoBFv/wA0fcYE5Lq9LuOs0rWbvKQXyH8do0OHQbm8lid29U6kiqL9D+fWxjJHmzUPuWYVf9HjyH69DML5uXH9tA+h+dvcEbgR87o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: mLH3WYgWERV-z2DzA7rWubUJEm7lorO2 X-Proofpoint-ORIG-GUID: mLH3WYgWERV-z2DzA7rWubUJEm7lorO2 Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Reviewed-by: Maurizio Lombardi --- 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 Sun Jan 29 23:44:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120290 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 E58CEC61D97 for ; Sun, 29 Jan 2023 23:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235112AbjA2XpX (ORCPT ); Sun, 29 Jan 2023 18:45:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbjA2XpS (ORCPT ); Sun, 29 Jan 2023 18:45:18 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 435441DB8C; Sun, 29 Jan 2023 15:45:17 -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 30TKxIXT010697; Sun, 29 Jan 2023 23:44:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=IHmSFhWT26lGahQ6EeIg0QpHBXD3wY2GF4yhxmDprnk=; b=A36UQ+B68iT1pUezj0zpa2sQN4qpr/v7yrjSlSkuY1Csk6sg20IXsRYtp4AMYxmg8HAf pgBg7jZYlPdYdIqyJ9wvCwA6HvoGB5lK/xdX/MQqac+1G9CVSp4PzcpSUjAJkviA5t5O hbKCUn7L195sYURmXKV9mLqkzTJ0utUwquv+nQWHjekMJFkJXHloV8BdyfKp3HJ0yH4x BvKke8g8jXco/Lp8XDhnxE0oVjst646V/aOlXST9IbuVilk4FLkeexlUBzMa9YtCH9ai JAhpH93Kh1H5VHDFc24z3rAiBgfp2rH/Lq7X7QYNEkA/Nv3vYFDW27r8fsh2xDK6+VPP 6w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvn9srpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:58 +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 30TJ5qYG000798; Sun, 29 Jan 2023 23:44:57 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53dr1t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hj0feAN4XhEqjxM6eBWt9nwwWymp5bgLe55NNqGTvOp5TmcdXIf5j08gCJXvmhdmV86LSSTlfjC/y5iveBESCNRBv0pJ4wI3M4fxQySD/S5ETM4pT8ZTsL9+eaL74tl9uFghU/O9+b2zSO0E7OgogRSuqQogBWQ2x1oXuYiZq4uMRyd6ZZ2jxzFV946wC2bdvzPgsqggx8VUI1x8Ze5dBuIth7yPApkBeUDY16snCDO7dmmH61i48Jhv6pVVuZ6WQZgyyHhGoOhqn4ksC9saEYkpOAYKREDM6u5ea/74zOyBtZLeGMji24dumMKQjjCsvuKoRWC0qSN258jyLKYgTg== 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=IHmSFhWT26lGahQ6EeIg0QpHBXD3wY2GF4yhxmDprnk=; b=A+vDNWxHawUt2y9v/efnvWsaNffOz14Fs2ALG7fzv7Qq76uWOrVOTwSl/hg/2NSR3JqyEqIPiTvyIpBLlqSCUB6t81JHbBO9zGj+GP3jQ2hil3JpW6NJZ8h8VJpgZB9jElywdnXmuwPl9AD7EBGn26v6q8Ozu+L4fUED7IadCoLOC3ToNneef0FHDJYqzAVDecoARNDs1IUHhwC0y7LzG8BzItJBd0kBF8Ydj+rDb94L1I0vFQsaO2SFZZobp7Wk2w/+zuVy43WVxxwKo3qf1HPYP5wDDPPe8R9gakslGhJ9nuMb228q+2TZHiAQgTiQ+tNkIlcy080ZLJmnbAHgig== 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=IHmSFhWT26lGahQ6EeIg0QpHBXD3wY2GF4yhxmDprnk=; b=kwm9HzghIpIFTrfLRnNeVtmkawtMfWwK8ancDOBTwwj4ARIIu7J19o7/8kXBDsL+5vrtPeZqHaepf9nQXoovxAfNxkEM1ZyRGC/GmSYaJLt8jcHQIHHkq431Nmp8eJecPZimbZq+pB4oQ2xERsbHwjN09Jo6i5RMAOe50vwW1Jc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44: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.6064.017; Sun, 29 Jan 2023 23:44: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 v3 06/14] scsi: target: iscsit: Fix TAS handling during conn cleanup Date: Sun, 29 Jan 2023 17:44:33 -0600 Message-Id: <20230129234441.116310-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR05CA0068.namprd05.prod.outlook.com (2603:10b6:8:57::20) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: df9a8f2b-62a6-4108-b4dd-08db0252d177 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SE0Kp836EefNhYlgf7phCTaOytjGAZAJwIlOFG+ngEb4bPd15GW0fJRtvEqn9YrCd7Dza7Ly7APGiqWksAUIwrhhUokD6RaGNuFyaatFqcKX9y+a3nIdhx2uIokKPXVSy19qKXtCvAssTml8ruX8WemHXVZn8+Wb4HashTn0BB6mE5ORHaWJqD2KWWusPtJillKxFrjrzqsNMYpJ43HogAHDtAMgc1Cdi8rIF4Fl/KYmDt5NmBo0BoBKgxMQ6/xZNLoO7RgieAeBZrN+8/TI8EDY88fA/x+j16NBmI54NXplVudDFtdztu/6mUT6vsqt8F31CfdiEmMRdrS2xi2CqutvuysEyZQF/To+lcGc4/Q+iaa33/daBHJ0zVok7yg0/PJk88JJJR1NJw+Sf2SwvlS/zqQuFDR8JpJeXU8jTxmgTMTB3P35cw9m9wJWQkWP/o7F5TKTGDJEe61QxY1rETBAFNrp9U2Q6+Z6+JXdIBUlpYgbEYE9Jr8+L98hmtx49sAR4pN4mLImJAWSVwQAUhvrj8dleJgPKUhag/52hlljlyr6ImhcvaFjmUSArbYsbZ8UMugpjHPT3tSMndGskf0RHsbPeAfZ1iUt4tjGtJU5MOfViNbmHqtfBRiFUPNCRgI+gS7/uzIyuDzYUG1D4g== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: STOuZ9CXbadC88BFXWVlv+rVi+B8kc/vRh4URUwpImbPbink5wbsu5+AodxAv/7WkevKV6BeHV1a54L3CQImRH4yLeBRplm++2JN0UhVRNk1ziyqTsOuY5VBjNQt9UQfbBgpasxNB7vVhs0oZy3b+7BEnsr51ghinN1+pXTGrT1aMVIKQ/xaRn7g4GvVOO4fUFhP62/Ac6+wTC8jVboKBAcNC0Mt92DQYEH39sL1/Nd+nJN71+vElTVQx3X/56DSWAKGuXRRQ7gyD2e+WMdHJvvUakWeDe0x7UO/c4149MKDk8spM+GMS00yq7SRpyiNi3FdbMjPFlRibS6sXzbOQgA276cXwc70hGXYWRc2w8ZWM5xwrVUDZtzewMRgi1cdduxA1XmZdMGb3TojgYseYpoDlDI2BAuHC7j9SjyfZfKvCbC5tWv1ceeAxfeVu2ZcZAs2CbI7+UL2A7S4P59YLtJgjwxunl4i3JwNmP+D3NkiOuJOEHwZz+2Q0tVXC2B5LSDuQ7hVCDYTGzTozq3PWFN3XFEZ7GUu9qTO8/fQAqgJ/YS+5bz8LjNLZyvDwCH1eukVryu2ceWHh1qdq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alHop-MessageData-0: bbx2LwaawxSUVmXOYD2CSiuR+qM56oz/aTdhyHVj5DNJAc7UOB4MQtZOSWlInRFYt+CqHdyrdYaq7RdcD0ms7WU0IwJrNzC87J3uoUU7ra+VpBwwsygM10nTPXOnx7/QZhGAFxHisufXfW7qXgRjaiMORJ2I7v+kuoSGXDCUdS6V2zsqw4ELBSLJUJLvCKMUwUdTZ/qoPF2uCn2qGtIwVz9w0EFNmmTu+BKJBW1SH1U7BvKbjZ545yhIlico7nZZXUq/XDfcvYQ1UatRHHCTAm13LvtNYcJant/Dgsrx2FVpsQ+Kbm+rleOkyvLc5OKyuysQehNFxsnU1O6kBshR6mgGbQS6ZzNRi5t2eWk8o4QKGj9dJzCoekkd47J2hJ+h+4kzIbahVMPE52kIQww2th6zYTKZ25gRXOqkOgZ/CV9mEFzaylrCfb2ym7wUEoAXnPXdDpRzGWM3QXktIFAPZS9K0Vt4wLpDGpSxS3OSMOFh4BM6B2/XgA/f+yiggM/1BX/End2EaIlhAM4xTwArogbmyHwQneIBre5Sulf7Q9Hc8uJmZwd5J0fEH9HRF7r6hyZm3XL5hq3LIiH5paCUE5/t3SUkqvgFVlKnz8NCN9CB5YDx6F2UfaKFGoTWZ8rRMlDB0Nf+fFy2nmncuYE1nXCJ+y2pnEAMGubfi3YmgZTFb5yDWbSGN3s2fZ0pxQh8xyT0fw7VcFkkGblB4+0QHT/RTLbAp814U/07iMfSwxFww5Okqpr3eEKZ02b1NH7L81c8k8ZJEv8yFZLGLcmHtXprUdC62jugttsvLJTeqjMdQf7lFOgN8ywGtb2O+HN1PfjNNTx+NGcE2m3oJzwPmORp95386lxVfzdRfvVQ0WRa+fbjgBotuUkF/kx//W5J X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: df9a8f2b-62a6-4108-b4dd-08db0252d177 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:52.9320 (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: mmS6wDNq87qV1E1r8eFAZ67Y58sEdYKNoTuysAUfyiIstaGLGitNeOsseP6xN63M7pM2A4dtJD9sRuLv5JzkcYRvrZBajJ+K/WoU8FqO/b8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: 2TZAFASSOTbenvut17pbfHtJibWmCXVW X-Proofpoint-ORIG-GUID: 2TZAFASSOTbenvut17pbfHtJibWmCXVW Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Reviewed-by: Maurizio Lombardi --- 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 Sun Jan 29 23:44:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120288 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 C37AAC61DA4 for ; Sun, 29 Jan 2023 23:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235097AbjA2XpK (ORCPT ); Sun, 29 Jan 2023 18:45:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbjA2XpI (ORCPT ); Sun, 29 Jan 2023 18:45:08 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E38D01969A; Sun, 29 Jan 2023 15:45: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 30TMkTqA025111; Sun, 29 Jan 2023 23:44: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=65os2/q0SY3M0+oYUPVnUGW6BnDGO50L//Ndy9xiPBE=; b=PMeLP2LlrVjgfSl/GPSTFysHxvEccO5ZCV3NzXEW6oSRfZRsViIteF+y4lJ4dTQDYYnb qtg9ZDn+vf0vI11nQbkzB6uflmXYzba6eTWVWZcdutWiEzWPkpxEi566okvh69qrWhbD QVqg8lUdVSkQDz2zuD36/nqO1FSO+dyEPgXvJ0zjKT4FZmPylgyYgeOvYMLOu3CxOZvc vOmsFIEw4vK50Hz3QI6dhwziXllN88Aj6y0UUpGuRg3bM6qhgdhuzLNgg/S/RxkmLo1b DFj+/SaqrV67Oz3fyERlL70a/qo47KURrUehbZPv6MNWS8W0mMFpl3ufRh0jrxZfy90a Cw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8hry1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:58 +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 30TJ5qYH000798; Sun, 29 Jan 2023 23:44:58 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53dr1t-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:44:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d+JgLE/wPxY3TG8dN25yIZx9y+EL4S5ggty/TFhg9tSamweKBW2OC2vIQHdYkZLaLrsczB4YTWS9WcoppMQKDpXrQpa8EVi/SQVsfJR2BimMwTPb34Y86x7ZYTncSWLSRYk9Dh93H+7cHPUug/R08X0Cj5JygLLgVEUX+FAygirSgykLwvfSx62hDOkM3/SAVAvRtANvOag/8PEO8ABEoZ7qzGc1FF0ZNDTd4UtlkVIbpYLqjqjaB5Nhdz5X8BVRdcKd+WkKTPetdRgbpBjeB3qfu5SoqC7Gs3ZCdLFDPUfEce/6Q+yTSxBe2HH507Uz72GI3TvyivnztsIFRO0Mfg== 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=65os2/q0SY3M0+oYUPVnUGW6BnDGO50L//Ndy9xiPBE=; b=LF1pi0ccWHf45nkqEFx2OhDgAiGMcwMyMc2Nout5m57x+MufLBZL0aUtYG0dyQIXyxINVpA731SkW6LA8cX4DF2Xay51najdF25eGToifTpwRBAHZjCSdG/qdiwlqXnoZ98nkT11Oabaxrt8tMg4ZtqxZxXMPTJrihnNAsxF7Dk/ftp6GSUWaLjbdmLx4KjQ79o2dp/YILayxS0MPyuSrYmXAxETBwNXxeDqVq8mm7ZnivOJWdjbw4Wl61Ag4iOtq3U70ZmS2xi3A34heasoftg69uTeGBumk2VrBdIHioJhTpSb4DHp5VXsqry3WXysMFzBFVh+4khb0Ul0Xdq4/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=65os2/q0SY3M0+oYUPVnUGW6BnDGO50L//Ndy9xiPBE=; b=hFsHXtLOH2W5W4V+bbffvuwNJ3tM4HuES6N4sJYfxT/sSV7UStdMIC0p3OOSFfVl1MP6ZXY+DEhwEsNvKwl5Tq7ByiieRchBT07NOJZMUitsxHdRR7RpSH0IFXhprqwL4qIwaBTngZ1OcrwlGor/WPfNZl9VtBypgrXWPaS6u3c= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:44: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.6064.017; Sun, 29 Jan 2023 23:44: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 v3 07/14] scsi: target: Fix multiple LUN_RESET handling Date: Sun, 29 Jan 2023 17:44:34 -0600 Message-Id: <20230129234441.116310-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0168.namprd02.prod.outlook.com (2603:10b6:5:332::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_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: bc478893-a1a6-4a63-044c-08db0252d291 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dulkZJtoWY6BukGOaL7vu2BQT2hDuJONWwQFR/20VqlvIFrbGO0rlIsyXV4l34ncM2+BcGVq2NeIn59MIAsOB0PekhzPSBlvFOcO4rwiXwAAklPu3AhfDMEMuAZm+VObPLyFo280Z0a1wgtG86GXTj1W764QMgll4e78gnrqY3YyUnClgr+9tOlppFm/Hb/herKmfVSkyqtljubLfw0fhRA2EZKQqHmiGLhOjWGSvIC81t04BiEOSjSSzqq18thuiVFoFl0/8W+ihcMx6AhJTvJ9ya6x0GHgTTBop5gxOF/TC0FY9Zdb51sgiKnDFx3yNOb8PgThKd6qjLmZWWxmAOdaH0QXqw0pGZqhlfTwT6/BWpkqL4+OYrhqAkf9iXtt5yeOfi3zvjSkY4jb+17oyZNnljrFkz8ZfGQgF+NQd+Crbp+lOVt1jTDedMZM62JPCd/6EaiXtxG5ZUMJ4N4vygdzxeZu+OPMaGVUrxNxcRI/asxj253MI4iqg6vey4bD2mHjfETuQC6PEj6kMv7WkOgmJYuD8WYv7vnxIC07ULjbxVJvR0cARXg+yblOHAzUpnmGrIt1/DOKFP9CSW88Mzcglxz1NQTaMTJXA1NXz6P3NgUP1Zf90y8AIKEd67AZrjl60m7pjLgv/wMXY7Nq3A== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1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OJalSQvjPSDXZ3vWy7HlPrB3nFoGA5hMkT32PowaUzvwJH+GSE1EdB/mwAu+QM2Y46AGczZG7hSCjixcc43Ew6gAAyBdpKuQ+o/zZHjmXcpXv3CKI8XL1xCMKAGNmQrps5UEbGPs1ETozck7veqTEM72Z320fJVlLRGdy+/HDWSgMwe3Y0qhggepp2nR6dWIeflNtN1l5uce84HeTelU/VFukAYTBqrl1smLv0FKP1IfbsUQKtH2QuDaHJFieyR0jG00VFb78TKV5HOSWcGJ5qfYbVaKNSxRSwDTo6v3P3+a8h4lX3iK66bV5IvLGfGwjkK9J6z4b3PZQdG0Z1fEB7wr/ImNMxeKaPcKAXem1vi5K30SeCNaEZpUNGeQcPczD34s67qolEUfYD2C4g7/UUtxmfaAgcILVEuER4CaW5dPjkCz8OcxG7AIRQOlwmrgLXVL/kttur3l/+tM4+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc478893-a1a6-4a63-044c-08db0252d291 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:44:54.7756 (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: eVIz8FZ4ZGjlVtJoRiI1n6Vu6adBcREFnQlqLarXDdjABWZAuTsQJd7C0JqJF5tEUj1gH4nNZNPKbgGG8lejpkcFjyMpHv+3t9gaGBm4+YI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: sU6TsuyDWd4GrnbT8XDtO_MeuOdd5tE7 X-Proofpoint-ORIG-GUID: sU6TsuyDWd4GrnbT8XDtO_MeuOdd5tE7 Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Tested-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 2b95b4550a63..a60802b4c5a3 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 Sun Jan 29 23:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120292 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 689DDC54EED for ; Sun, 29 Jan 2023 23:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235125AbjA2XpZ (ORCPT ); Sun, 29 Jan 2023 18:45:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235140AbjA2XpW (ORCPT ); Sun, 29 Jan 2023 18:45:22 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A566E199EB; Sun, 29 Jan 2023 15:45:20 -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 30TMkTqB025111; Sun, 29 Jan 2023 23:45:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=FjjQ+cE0U4bMiqsreXfmdkYYZ/11SL9odquxoIlzM6g=; b=yODi8n3WIlLWVXvjkKmg5jjxgL8Pb6N4ZhPzIwygkHtoPGfdtu/3ZyFBJXLANKpl6Sf+ xHpwPIQmldVdEQ6CEuIAFROUnAoyl3l12cgSO/+4TXmcbtdfvubNFz9o90l/yyZ5DrEF HldqBeRqZ8KLRf8fXIkj2zZVdXrS4cEpMXxd1+YYkTs68wSjEVH9KbkUkPnS9eAqtuon RjiDyQvFOTd6saklEAiJmDMCJZqX9Yh2Ko0GoUjJCVpZR5D4EjJ7Lo49FEj7G5/y/oJg s//QZ7z7aEwJbcEqpdT1yA7YMWKT9ReZ3mvFBK8yJjCWIgAHgF4+dACARcPnIGidM2kw DQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8hry6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:09 +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 30TJMDrS019007; Sun, 29 Jan 2023 23:45:09 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 3nct53n3k0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KMPJlJqtnxA09k+1ZPTis7Y/87DUwrCc6EQjaQZiYx7WjcLL+o8nV6a3E+F+eeK4/bXSYgfb02Ua+OMrXac2HW2C7+PE2UFgLD7TuRPn7EM0a3SVhhe381l4WwTxJZaIQzhD2/eaj+JXpI7tNs927zp2zg2FxI1Tb8GQ27fx/LNxdofpEJd6R1GkXQsZTxd8trKY4VziThX5r2pmaVueqVfjJsW10zMbWogEnvBfXnS7FTWO/yLOqzMrmn4qp6x9hMt9XKLUyOYfrpCHktjYaGSe8ceVTYCVffyI/1q1pV/OKsB1zoSs3qTXT6/bko/kIbQbhVwGKpBstdtQ/0GV3g== 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=FjjQ+cE0U4bMiqsreXfmdkYYZ/11SL9odquxoIlzM6g=; b=cNM2oI+SZf4vUqVW5xjUM4+CoIpMh+dHAFfG54tO5UMGkJ1PHP021wrjDGHfY7pYPqH2Ki0E5QrrvBUaVHk+Py3tLpjUmcCmYv9q2fwVG5HqLHre4PX2s38Sp389lm+mGosnA0rJP+8SQoiURlQRfTVTGVVXal8R3M4SMfD3/k8DP6KBOA1scwlMWXeGWgMx4zJ97F5pt1cjLCNbw8CaHP/fuh2EZ9qaBsHBYp7XF9iP18cI4E6WEpvul2jqWekfypjg+w12rTB/MRlpWGeeDO7mbd9PkLsn8KFMg/+FIAsVwVfQVpyd4LZavWeN5JpdFmnYpEoMj0i2LrIloyv9nQ== 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=FjjQ+cE0U4bMiqsreXfmdkYYZ/11SL9odquxoIlzM6g=; b=wkJGanO1qnpe1zX2BALnBGdW+h1LQXB3su2R9BgI/Iipt00SvFlZKfaepMZ9VnxzOh9VlSaajBkNNwV3xiF488mnJNdkx2Z0ZQo1BbDtdXL3VHBn2u9XOKYJOjS3ITGatXW6zSe42dyeh6tCxwK3GpInxic3c5g0auBhhy4E1MM= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:06 +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.6064.017; Sun, 29 Jan 2023 23:45:06 +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 v3 08/14] scsi: target: Drop t_state_lock use in compare_and_write_post Date: Sun, 29 Jan 2023 17:44:35 -0600 Message-Id: <20230129234441.116310-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0007.namprd03.prod.outlook.com (2603:10b6:5:3b8::12) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 039a22d7-1c8a-4d10-d8cb-08db0252d9a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T8oJede+R6N+pcKJjcy1+zTLvitMYYF3f8gJQlhz4tck0aak6woUeQF40iOqkH67vgz9FJXmJFF8xZzCEZksQSEDl7uuipuc4YXgbbwZtm+KMbKKfIwFYM7eMc/DyNW6hJbVKef0d4STlwAN9s/JVKXKGiz0B4Zd6+tGWbNSsaHCxSJopvHyrzcsZhNgm52R96DsWwjdGo/6CNIlPTPFWjsgdzk9nP3QLn1XpxKhIWywYoXXQ3H4/z8YiS4bcVlsKPpFPmFtDmv2DbGtc0gknAfecT3kbsfdG7HMbmFLAEqkbtAGu6LfXV9cgZ7LkVEQu+tcj//fi2HaXlW5irJ++MB2/Lm2YPQ/qZ6e5C/2/9KlEX5E+eHgZx00JRNHTdnQRHOCbnR70W7uQAHcbGd8oEBZ/OtohmgJ5Rdsv/yMOC9jV3Ypa9IqkuWgqPSaCXgeY64QZQ5IPN3JoFjOE/o4OffYvign7+yvrA7KvuY4fmmeTbVjKATTFHvUP7kmlzZxrMJQO3rj582+BPfcH/wzerwXao0SuZGytXf4xEQfmmf81ueGtNroFE71I8GF8mz9d7ve1Gi7P+1+P6Bc7gd7cDMFIw/I12ZzwEbuh3JIpZMNEqvqErB82NLrATfJOFwuWWj8ezOL6A/mYCAp9Q1C0Q== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 62tibihHLQT5ZclLPWRg7YwKdKuj40YMqDX8Xz2/VhRJDuT4+w0YsnTYqTAT4DDwLKVVlage+bwioxgpCjxgN3X24r5t0aix8lkH0s4dLBJ361g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cJoOj6WEdCB+OLr8X5eqFJ6FJX0ZbK6WLaYAV5OGHmMGBS+Vr1GsWgDpJ+VmXtukWGkNW5MQL/dIDR1PDTj7DPPMSWRnKDK6uDndYRDF/+Pb00MPISdWSFPxGxS4dO3HQwYSC9G/W8948SYb3CMxnUhYWxhotW7hjIqBbyFiv1mpCd3GXXhPDiX/3yBkIKOsafzyjwbk0xYrfXTSx9tQCTNfflIdS+B7B0qZ8pAuqEMZ0CJA98/e/1vp/muuRQTRscSWaRuzxozTG32vg//EfckF3mnlL/6ZAgmK3jbVenB3z0l+ieVJ1ZPUk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 039a22d7-1c8a-4d10-d8cb-08db0252d9a4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:06.6496 (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: 5JQggDJLCDHfuhoDOwC4mrzOkgr5Yy0BZYUv8+OiOTHv1f01vWN9VC2wyaHUGiUvX/jJyyTwBP5nYp5wRx5+NmGTx0ejZFIKPDTA6V2tYGc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: fHntzYBRH5bH-hzhs6ivE0F3TImjsY6I X-Proofpoint-ORIG-GUID: fHntzYBRH5bH-hzhs6ivE0F3TImjsY6I Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org We don't need the t_state_lock lock in compare_and_write_post while checking the scsi_status because we have just set it before calling the callback and there is no chance for races with other accesses. This patch removes it so in the next patch we can hold the lock when calling the callbacks. Signed-off-by: Mike Christie --- drivers/target/target_core_sbc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 7536ca797606..c1cf37a1b4ce 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -352,14 +352,12 @@ static sense_reason_t compare_and_write_post(struct se_cmd *cmd, bool success, struct se_device *dev = cmd->se_dev; sense_reason_t ret = TCM_NO_SENSE; - spin_lock_irq(&cmd->t_state_lock); if (success) { *post_ret = 1; if (cmd->scsi_status == SAM_STAT_CHECK_CONDITION) ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; } - spin_unlock_irq(&cmd->t_state_lock); /* * Unlock ->caw_sem originally obtained during sbc_compare_and_write() From patchwork Sun Jan 29 23:44:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120294 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 581D2C05027 for ; Sun, 29 Jan 2023 23:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbjA2Xpe (ORCPT ); Sun, 29 Jan 2023 18:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235082AbjA2Xp0 (ORCPT ); Sun, 29 Jan 2023 18:45:26 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A511DB8B; Sun, 29 Jan 2023 15:45:23 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30TJY8ki016081; Sun, 29 Jan 2023 23:45:12 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=SqmEcC1sALcRl+cnDmc+wNT8AmjsywVRrvAe56BxxGk=; b=lGM70QgmDitn4/miLIL8Mm46YGQbvXcdpiJHz80u7e1bj1C5pqcwExWxUuAIaxMvoYBK GvI+Ez6mIu/hfdSNIBuyynUZgvYYko0judVIqtV8+H25biQz/HxFn1A0JploMKjpTwd7 zs7Rgnj8JxQXYqEtITOkr38F3LiCJ373fvAiKGNuKu81z9lHotVYpcDoCUe1fnH7KjyH 1se5/OgMHHDp/L6q/ONXRlSxvWydMR6h4Ccy9TUSE1FiC03mpdIY4J6qJngFWH4EoFiv XEUukv3x10lEnWHqXL6guCUql0XuZ8rUqobKBmoX99JuBoPipOuU1C+H+s8xqBtNCzK4 Dg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvq9hs4j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:11 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30TNOFmS018641; Sun, 29 Jan 2023 23:45:10 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5anwmr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=motduGZ1lAN56znYTm1x3iwVfTFbejH9LayH9t3lYSWggB6Der6iIQi+PaqUhFpoFSXygZvgVdqNPSWGBEdoq62MuNzem0H2F9PHtxDgvoIlnDnlXU5Gaeh3Cf2QyHOFVKoLosGbTtjMGT/2lprAZB0tI9olafHZmpahkwhLLe8hL9RS+F2h1DYdHFOKxnn0VTnSGRLhCPchA7uureVgOgO81X3VyW8ARHgMRdEFdevYjyVr1EQcT+Uq6NoVOgMuLIZyHe5PeGxfHoF9eDC+y6F3Akn/sWaF0khc8D9A6Jy5xf831t5gGJ/4gyFXmPJCjbc2UfU8lUJUzpnu7f/Hng== 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=SqmEcC1sALcRl+cnDmc+wNT8AmjsywVRrvAe56BxxGk=; b=XKgxLytZzPOtCu3uskflJZ5848X8FPRgCuEnxlH95HAKHxZU3F2AIep7dyl1N5DGWBJPv85L0Zbq8a0WXd+g1O5dhmxuZ5aOSg0C8Kmv4U/f0IxVlCicXDk10kQB3omYLS0bqoBCLb4d4mS9P0Dv6fwOty81UBKpKKqPM4uAjUGs6nBl0zAyxYa/pyr1iywEbc969dUaLmPGAn47AMt/2+94MkgpWwY74J2AlEQyc60ysVeiz4Qa1zFr7ez65GF/c9PDmv1Lctbld6EhNhHAS9d7NkML0S2jfhN04fpFPts4k9/2rmIUkPNXonzqowg4DiAHp+MW/lvZdYF0edp0PQ== 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=SqmEcC1sALcRl+cnDmc+wNT8AmjsywVRrvAe56BxxGk=; b=rnkdBmGrSfx4OuxT5RTg/kQ+DzydgWfttcb6m8CMwrqLvU8bPrVHlIT8SEr3Jf6PEg1rSS6Yi8o5iEQNUv9jOkpaHXvbIe+yUShrXEgWLAIZRvg/CLWeGMl+1cO18yqc7Zzj2J1A5lwhrzxyyIFotiyHRdp4KAillENYBsiaEtM= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:08 +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.6064.017; Sun, 29 Jan 2023 23:45:08 +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 v3 09/14] scsi: target: Treat CMD_T_FABRIC_STOP like CMD_T_STOP Date: Sun, 29 Jan 2023 17:44:36 -0600 Message-Id: <20230129234441.116310-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR14CA0064.namprd14.prod.outlook.com (2603:10b6:5:18f::41) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: d3fb00ea-05b6-45a7-c3df-08db0252dada X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DlnZljPdtfpS0lXapmNr+S3/zKe+5kUyjN7vvqLviWV2UemvfaaS1Sd+6tVelPEjaI4+gUSk1VCt8EC972rJJ3bcuJgsBflPGM0NNzc/W0o356DBf/Of7vqbGwP3ypFfY0Bg3glzKu9Gv8r1DgW68LUPpRVgAXQF3xC1OGzcVCdO+sLHO84jRJ2QuCs/9Z4H0JXus5KnC1xRsYg+GrIPHdC5uA5SnhrHgEsSPPRCE1yYDr4m1LOH2X8gmwnzjZ5EfjuJaKQgfWrA8rjMik0WFMw97xJwDWzps6SH9p5Isf6WkCuadoHLCIwsvb9keGOG6f5TzSQiM/wOYMUKietrGYIz8XBouP2VnbGTER6ejiN55xbCQK8vPWVDUaRFcwMDJ75aezGh9NLxi/3IVrf/laaIFFBDwkL485XyKQxstgAi8GbrTMp0ylQSMhT1zpjH++MFLj34PO6FcdJ7wzva+TNASHHFpG52qBifTM6EYK0wAM4IZOe87lO8LpHyEVbhGJzow+bnOLgdnL5icMjwOex2/POxDCSA/BCwB1+a0jZPYHF+bZhc0ZXFJQVHvsP2DkZ+kzM/nL3W1HpZ00Fg4qDfQRSFGN3YqlPC7xFyx+RdVj9mJ1OLYcgyTg/dfo3Wndc2u8huFe3agR1fAqYcbA== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7yHtly7O5oFFCeGJI+aIRLIyGn25lboldz1XjL8069EcCHyRVzVnzD3h7q4zkQ9+V0M8Jg3tnYvTH/vawnhJFyCXq7BXwmq0UzYi5cUYlj3bVg4RWFzqtXChACs/6hXcXdgdBoCVVe4e+rPpX8l+UyZrE3HpIFdWv1xwnWnEXLILODlnMfOpGzYcw/L/mqpUPjQ7mOhFP8oFBSwO9QJ2cPpjZEmHvZenxZpmZEfKmYTeznBVLlrda793b8w9fPXaHfR4tjTBD8GFfonje/bQFDfgNvJ1w+OO6M4wyX6dx8OU3jkoiiiNdrz6irRqRX4ROKoPNDNy09xw5oDVVvaKhOaXbWHVXFdIbReZR2HMh4InuudI7TCT7LXtrtC4KXDxFedOWeTscbSldJAsGqeQ2Z4LFxqoRMwpVRlxp4s380yY6MhUYnO27KG6UqedTl8t2Kyyv7RWdi7OXby5a89w0mw+PAJY2CURmsrsoOQveWHpAdbXCaVyYhF5GX8ofg95VOFDDP1kKTW/WURpuVAHtvXGNpbQF8zqDLnqgj1fFL9C7I7E3YeLqhYSaFi/wUvA/+NwWX7+JYFvgt6bEzTSoHzBLwKPANpiMxUr+YcUzd6F2qfww33GBI5nKmV8J3lhRFZCtjroJ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WrdYbXWrEiUA/Ic+iRcTrvNgLBKm2qifK2SZ4SKlRtc/2FKNellJKFv+iva61Su3CqEp23DOk55LsAGq9GTZoWfA8jWlFR6/Vuwt1MBqXeuXxDRrZv0+fRqqeSwF7jI/OO01sIUMneWlVzLFnJHrRwP9kIbTuUuEgdjhlW38BTwjsAHE3Y/Z8kC9GkCB2kSl9RZJvUDXs+vNJdB9CJa1TLBeXYGGbx23oHe8BRRErbsE12jl3xzVvmLr9Gi1q/ytndTs7Tnhaal5HeaxSDUX0UhpQtD+4P9XwmYnhRjqgwACJUTTS4jzD60Zj8wpI9nb7uxNH3HOlLHivmVGzt4FwMIRpR/qnrMwQUcbELxIiLYibBU4Beg28e/rd220Zx4VA5KJiyt1tBvTLfb284iGHGSNj3MMaoAk8X0KH9vy9oSe/IG/6k86lGJ85lcIgfpSgPr/bdm/lCWCs1bg1ZnedWg5gPeVHq5Y9aja6T6yNy9niD1Ue90f07Bmn+4Gg+GaGDMmjandxvqswGfSPH+HpVD7EqYSVlqlOF6FuM1+Zva77y3DqFcr5G6wKtVK3+fImT3rx4ErBb+mvE/FFder9Pn79azWtp7VxECClMdJeAxf7SpDBJEGuySa7eMD9RgjRniLqBsFqpD6Ah5ilGNvh3HDoBPGrPLEK4+d3xU/UzdVQ0gbnL0sk9u9Z/GpllvEWFEbLuYIeqa+XjtvTTBagdL1MxMw60oZqveN7IJ2JCL9LQKUWhbWYFWeSrVM3JcEHkprxD+ggRVt3fV8yTqTe6jtht9v4138vGkBc747arKuFgWyoBVQQzDeuIyWSli3Lh+G5MQu5kMWWskRmbVWto0ne+bjpgz4SUb X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3fb00ea-05b6-45a7-c3df-08db0252dada X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:08.6807 (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: BLr9u2bn1gXaafW1cOnwyQXM9jsffHio0grNN6Pqoa+PSZZ5OwVExwVcG3RHqR4trSVmPxanXFXAb+JI3h3HO1NP/M7f4DBNDmZjOcfW5/g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-ORIG-GUID: E97NjmIH0Je2PKe3qr3fl9HP7zzGYnEI X-Proofpoint-GUID: E97NjmIH0Je2PKe3qr3fl9HP7zzGYnEI Precedence: bulk List-ID: X-Mailing-List: target-devel@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 fabric modules can make sure cmds are never marked both CMD_T_COMPLETE and CMD_T_STOP|CMD_T_FABRIC_STOP. 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 c1cf37a1b4ce..ff1ae779543f 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -457,7 +457,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 86adff2a86ed..1c23079a5d7f 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 Sun Jan 29 23:44:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120295 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 CE8A8C54EED for ; Sun, 29 Jan 2023 23:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235056AbjA2Xpo (ORCPT ); Sun, 29 Jan 2023 18:45:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235183AbjA2Xpm (ORCPT ); Sun, 29 Jan 2023 18:45:42 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C001DBA9; Sun, 29 Jan 2023 15:45:35 -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 30TMfCvf012753; Sun, 29 Jan 2023 23:45:29 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=dN5rUiI2Jyg2D+WUbI2gb+szxiEqyKQf20sYbe9oGA0=; b=KxbO3SvIjdfuKNRGEvbq/5t1hXwVpwGJomJkOlUZmrzMh1UdT1nyzX0ed7/dt9Pbw1uq S2TznbSCc9+BEDko6M4vJ8Rt2KuP/1qLwsPwvkyYBMYabxhrjUE1YDgHdctzss6+jRHA rwbYYEQ9LewFJhVBpfhULKqVcJ9jTqC3dBKIAY88s1O7m1ZImN2cHf/1SfbnGtXeAgaG Du1YNiN3T2TSnEGrb5ToVTS/jmgABDxLcM56uG8NuwEtIEuFp04O0cu7jZPiWU/NqBWV bqp7842/Ez1TLcwz1YHT6w/vpLcK2jbqPAHXzl9BezboisiJ99J547SkAV2Fl+IikKFW lQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8hryb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:29 +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 30TJ5KKf037694; Sun, 29 Jan 2023 23:45:27 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 3nct5a5pb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RvRVA3JP8Y/rIx0b5X0JUv8+Hh8yj4iCoLBBf6LgOqSPKStEIqreTol8J6sLlvXKdHVEZ0KwUm5zzmvtJul2GJ9K5OMjlmmHhbFiv8vhs0YsrvkWIz6rIPfe7/N2Sbt0Vtn97QzG8pLfVHgMTsDd5x7omXIBICTKH/fteDPXAitXpV/ez+t5G9rPk1t7Wt5NZ0yEBnaW7D8g9790fKExh132jDoPp5LnS6qlVnJZZT62azqsNEfIa5ZqCPLNWOoWoddjHULWVSG5ZW8g12O+vFvGHN0DOf2VTUd8csPwHULQnsU4M9Z8AbsI6AQ5JVQpf+DdFGNjA4y/091GnM55TQ== 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=dN5rUiI2Jyg2D+WUbI2gb+szxiEqyKQf20sYbe9oGA0=; b=hBNYDfsktfVgN28mx5mMkDHCkCSTFaXnYCq8K47zwPEP6NttA71VBFkNS8EiKQXT3FXRQ4Hki56O/tNLHc3Jo0mpYLcRgd7jlRzSDpClZirIXuh6oalYiGf/gg3zO/UCuf/ykcW+7vegOqysythbe4JCumYN+LIG1DZd3nPoUi/kzW0ufkp+DGDkCrsPd7xUzv6F+egdN4FqtIJhWxVkQ7m2z3MxfKICsml5cac/81RUD40z+B19kPYLjWYWLB4VbnY+iF9Ar6onRcBE3P4is67sX7013WbcfjxRk4aj5hvDn+sOM+Pr+O00+fJP/NDLL4O3c6gpos9uAvAIZOlLiw== 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=dN5rUiI2Jyg2D+WUbI2gb+szxiEqyKQf20sYbe9oGA0=; b=H0C+rJMKR9k/O/6TxnMqBr3J64KvpkH3G0oEQJ7QDM3W7+CzVtk9YJkt6ygIr+TuPmGf0pnHW417ym0Q7p+aRGL115A8DwxUUV+MMh6cQhe1m7+1PlD+6fFzm2X16NYZzP6PUspyJAiuicSZi8fM106zgYlkENFTmKizGPeP+Tc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:26 +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.6064.017; Sun, 29 Jan 2023 23:45:26 +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 v3 10/14] scsi: target: iscsit: Add helper to check when cmd has failed Date: Sun, 29 Jan 2023 17:44:37 -0600 Message-Id: <20230129234441.116310-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0056.namprd07.prod.outlook.com (2603:10b6:4:ad::21) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 8399e17f-2674-4b66-fb8e-08db0252e54f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W+9yQED7zo1IZUyVp00lWGk2w/90NEoXIQw957awYntgRKRieIvSfHevkw+Tieku2b2m3iCLmjTQtljjXGegyiTG0BRo85B8FnYZeL7lJfSHkDNeKqP273XYTDIYFwQ7TSlk5INVJnbAxaVYHrQdDfiueILVgKUmQYcn9zQ953pEjoQhtDehhB+WoPnCsY6o+5psNmwJvSKfiXaqVBr0mV4rBJapFEv8EHWRPkdG6LvONj1QtRHvafNiRyQBCtIUymhHAN357lHpRUSu4e+dm3A6Dus5mOo1A3HdMRGghJXg8uzcO4N5hMdPwm55j4yJh61nMJUiZ0TPqAU2tEsa5O1Jm6uxBRSQLXEWSiDP7D6nIoG4Y9UIMAAKSLI8pDRzuYbFUvu1yTvI+wsNK9ocnZ/P82dP7ieWq5txanYEVlUTMPH6xLHroSONCifh+h48PjeHxqAP0dFSROqSn9b+RKOe88vhyqyDATdfqtwg+qnbxvUzDLdYz0YkR55tApYcRl9PgNngi7e+D0wtFMEacAmfyo98ffZ7RxuhClFkNAHM4ivRLT1t3nj9QdaLQ6YyC2au8s5RDhU9WPpWBBtPikvJ2UO6wFlw2wUIxhT/BtDAfa0eYrgH5DfVkn0AlqbC1lw9MkDeajT9q2/f4X2V6w== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YoPkS/Pd05afbdv0DMFfV8mbh7QCWLN/8NfwhiAKpcYzAV2XLlpzn8nPKBhMZh8is2I7tvHJ4s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zci+9HI/3A+NVnl+iV0+Hrj/8rIFaTiSGyqQuKloHCTcrLNbCNHowV6uMzXqCP5eupP4YEwiI4AQZiQQeZHlTPy2S/VUv4in/gEWo2ie7VvPUgX9aG5YW79UVeyCe2UlYt8gTTDF5LxCGIW+NgXdJo6nqoARHHSWDo2Q2rJUsxObPn9Xi5CN8t3q6W0iep82cVqjZKmzirC8j87U5yIveI1+D2jJEIOkWnfWMWel1Uk9taP81r/6cbI0K49eogbjYDm8nBUjwnG58Poa+xUGMWqyJVFOjEVMl3s/A+OmN0YheYC07xqXx1Lb4rozjLjCliojK6je36GSkxZNB1Ff+2tnHfOMXlzZpkItLb+SHL9nZ1wbRTAFR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8399e17f-2674-4b66-fb8e-08db0252e54f X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:26.1948 (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: nSINoc55aMHwOpPgV7orPNTUwpK/cmNlGdqaZSlcjCS3smALAVUr1U1M8YDfQkRpW2mTHgC4giEiCcwWZMjzUrfdU+Geivvd6Ic7HC9E3Is= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: E9EPn2ksmtFHyfTjNGLkZbQ4qnJtL4wG X-Proofpoint-ORIG-GUID: E9EPn2ksmtFHyfTjNGLkZbQ4qnJtL4wG Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Reviewed-by: Maurizio Lombardi --- 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 Sun Jan 29 23:44:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120296 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 685DAC05027 for ; Sun, 29 Jan 2023 23:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234978AbjA2Xpq (ORCPT ); Sun, 29 Jan 2023 18:45:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235199AbjA2Xpn (ORCPT ); Sun, 29 Jan 2023 18:45:43 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DB8F1DB8B; Sun, 29 Jan 2023 15:45:40 -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 30TMNxgn022092; Sun, 29 Jan 2023 23:45:30 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=YbFqQoDV+s/omj+4YVm2wMB0w+9V+JoX7/crHNmatd4=; b=pNtxeQoLu3egu7a1jtQ/mw47vTjBPGf+2yC36cxJncZe+NnnpRXl2g3GHgczcIEEd2UJ nD3tIjs5O61O57yC5iZ/EbDxM7FXZp7lXUdXhRSZwTwR4tVMRqxfvet5zaYj9vR0e3eL rjkqqfscPh/K6EHPio/sAwXLWq79Eg4YowirHjqbk67g7RWj0Yr1DAJDOwr6iq/g6Mgs 3exBE2ipTv/jVnOQNwEW5gQHruJS4sE3BUrJF/VcxNyF+RFUVJCuarshnfoproetIyNd 5Kx9DWA66vMBGRv+SVkaNjYpTfgySReW/CRDo/evpBA6c5sstqV7+c2eX/xGaiJEdLaA Gw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvn9srpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:29 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30TIT3gK018653; Sun, 29 Jan 2023 23:45:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5anww0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NdXWoSzV8H53EdRhlDx1YJIr172fAPXP8CGWQn5VFUUT7p0a2ZJ5reKqWP1/FCVbFe9ugUaJp0xCWnCsGU8TUioJqEpEQa+tJIOFZLpEh8uR0p3Ra8g5OXXqJj2XsOZLv3p7BN2SFL67QAcgacjKNkKUgW3b+wmahs8a7n7PAvK8lpFZIzxsnoDcKm5Dn+ELwQ6d02wLz5z8S95+3IdQjSj9V7ofGaMrKwxmVyMkWz86HA4Col3Q2exsncz5rqeThyr2vXr1/IRaN0Vt+XsZzBOswgFcBgQ1d4x54gzDalEVy75tgv/YX3H+fUcmiSePdYo2I/89jZEd2TXB/xUzsA== 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=YbFqQoDV+s/omj+4YVm2wMB0w+9V+JoX7/crHNmatd4=; b=Oi5xI+Gn8biJkf0ztMm7d463atRlQNRWTkTGioI4VqybwDN8dJLG66tHG+Z1t+n+HoWz1FuGRTw0j99S64QAqS6beMrw7tU5tT9vSIS8vAm794seGu4Po8dVPx8hh91QFRveUpxjiPBK5xXy2N1ehhR0mDDVe5OuO8g2WvzyvAvcqzkh74JUhv5rPFfEg/rv0xW6u7DHYNJAc6+hDv2BxFKi/hY2qQdvc14tuf31zOG+fE6zRcrWbnIURSiNTOBMM5A6gvdDD3z3+pa2QsXjnE4EIeCN4ryzbbwksN00xutqeLnRhCNcdtSAz27uIOai9ABJQxDxcXoFYmOEBi8t1A== 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=YbFqQoDV+s/omj+4YVm2wMB0w+9V+JoX7/crHNmatd4=; b=S2PNi9HBfW4jF7eDAXehs4Sdqo2NNaLdrq17Ioj8A70qbQPcT8j7jbmJjviFZdgqqNijoepbjAwypBfMgE3eO0r+1KXY6xMZencM/NArP3Of62rJDMfj80+FXGehY/LDSNHAKmp2czdu22odYGcmwhHms9IM/uO/t55tKLqmtOc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:27 +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.6064.017; Sun, 29 Jan 2023 23:45:27 +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 v3 11/14] scsi: target: iscsit: Cleanup isert commands at conn closure Date: Sun, 29 Jan 2023 17:44:38 -0600 Message-Id: <20230129234441.116310-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR04CA0033.namprd04.prod.outlook.com (2603:10b6:610:77::8) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dbb9118-fcd1-474e-13cb-08db0252e630 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uEo2oy1CfmLEvrQgqqkMuQmPolfIZypcEIvB1BFVL07NuLoCe+R4sEvqOPUvNiVmt6hu1hfY3DCelIsWTqr47RkAkVNtM94b1edBdXdwp6WnBtmb9GchjQ2a3PaIT+y3rLYtnjdXMrQt8DBSYaKI0NXsy1uaNJEFo9TjqoVO8J4/VSxHGtDcys5eRF61/YmeHwkotb9VBWcOQxHg27BLl6Qe8t5iSrovxJQp2f+BhUJMqZ3E49ZUqu/aiKxlskrkcsrkGn3oRjkhXoJdtOCvWlqGFrI5hDsy2+jVa3taIXqfyVGmfl09ZeJJ/VfEAu0mwYTrdNv5WwFg/pRm/x9KUYBzQBIa01SoU2i2khAOhCoMp6vMvuoAWX1Au7E7a26vQj5DTIw8HYLAzlB7ahnaPn6nXZMUlby8H1cF7qGS3oOzIH4KOyaX3D2yVODcqKRVs3rKj7tJbLTq9cnKnaSaghBDMngK88Ic0rUCqrYidg10JfuVeukpYoxuYidzDuJ1H2knyRZ0jwfr+tsYz3ydvtL3mpidnwnfd4HFRC+pw9t4lTJFQze1xw2HgCctxEJ3AO1XguQ5AlaDGN83DgY8O3P9uQJPPr51HNzNxfX0jepHx0P6glBRMFdlAhiscp9ySXquT16tbyfHFIJFZS+rmg== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ifvW4cfIW7hYCn0cRTe94j1zMc9CxQPcy0TcbQi9O200xXlDPeqOlO7yLH5QdtWSYe5H3DmuBmFk6ZtEfdWL2o3+QsmC/+sP+eSg3eVP3CaXbyBZyf2xrnukcPAKs1LH8pdtHvEVn7sCcPBZB74cAznmzlLnZDc2DJymDLeD1BvfKetwiK3HIa9ztdPdn+ThaIYxE/OvDlf01MGuAJfQFCFVsIgZj9AZ4w5TSLGkkKoryg4XLFe/+xZYrDzPQHYBKLJQDvHs+X7whaiEyjR9KV+PCYUKrj1YKCDlGiagqH00/npuwIpC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z3n/ed3GW90CMja41IbRulyaf3ZxW5vhusfslgckg16okCsz0pKn+o85vlVfCiha3w5HdZbAWNWwrc46f3ko83qzxo8eEyik2v/0nNZkwqbNRUbcOFht7vhHW3tnR2Ya/dpsXO8D X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dbb9118-fcd1-474e-13cb-08db0252e630 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:27.7260 (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: uSYFJbeLLLSAbHEzORH2Ec/pTh31JFJeauzGPB+MpUxoBZiV8FcBNj2MACEh2TIn5tJH/Un3IOWv7pozoIiTcE8mdm3EJM7vtp/oAFmU2m4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: mTQ1QSu_Ipil09A38nv8xg3PFBBBArw6 X-Proofpoint-ORIG-GUID: mTQ1QSu_Ipil09A38nv8xg3PFBBBArw6 Precedence: bulk List-ID: X-Mailing-List: target-devel@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 Sun Jan 29 23:44:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120297 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 86B34C54EED for ; Sun, 29 Jan 2023 23:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235148AbjA2Xp4 (ORCPT ); Sun, 29 Jan 2023 18:45:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235164AbjA2Xps (ORCPT ); Sun, 29 Jan 2023 18:45:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 915F31DB85; Sun, 29 Jan 2023 15:45:47 -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 30TKxIXU010697; Sun, 29 Jan 2023 23:45:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=lQ6wET7ea73HkdHDAZsyjQ9jVSUL7gC8ZFcL8LEEQR0=; b=AVQa1nWPC/97zctzx6XRpSIj8CtXhAwY/V0Cz1G/s8xOLBSq8r/velE/b0e03s5ks++i xeFt/MQbuVOkh7VQ1pW1CkFG0xVxKNBetXdaM77xnptQPN43MyEpsDpWeGpYJPze6bVL qFBrCbAMifZaHk5SouV+PyJkE4GHxiVl+lvAU70pgsF6mELdXn+ts+0eKnbIvjoDPsTd 4Rmv5/v38n/FigP5Om6AJ+TBB6/CyYNixPL9Hq/fYJ6GGJALVKKjimgmSFQ9tGkpiUyO kvRdJKgzz6fSQR8q8molZrlBgy6uFYRcGC0hJZSxYqo0t3P4pEeD9OP7l+Y2QqR/7RBJ Zw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvn9srpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:37 +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 30TJ5qYS000798; Sun, 29 Jan 2023 23:45:36 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53drf2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DJq5rOKQR6/OvcxLYqyVbG97Fxk8ccq5f9H6OC7y9c4QmWlPxwiaiMpAbo4MwEHpzqde4Q8Kv/NgDsy7xNgkPCZ6XfQrB/bjFUmyNCf6m/i6jNLHcI24pXk5mS39NWe4qNjv1eDrPrEO2nGP+MZUVk8HR2qrZAq3/9Th/rC3MbR2dnDKydW1Yax/xuvVrLY4NEbuAO1NHL17kcJriMnhN3zFfeUot4+m/nZpLhYgSL+39dJUnWlq5e2V3qQ4pRvxsonhuf3fJpL2gRKFHaQCV3kZ3vKO6SOlibk7iOyFBM1iNNxVZieuke4ekhtd8if7BP0W2K6D4j1Trdoq6Hdkqw== 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=lQ6wET7ea73HkdHDAZsyjQ9jVSUL7gC8ZFcL8LEEQR0=; b=BGILg4HlozD9qaMPIb+NrOm7qxEUX9jN6sUp0z33S+VGJkysPJ8KWFpCqm2IoX0J4TumWR1rLrKV5GeLPf1T5UxKRwd/lRSCjCGGaHSpelinwRCZ6bLKcFsBIk9DwFM0joNL1jCF3/JaqSERV1P2zwATRHD3J5qP2umexXzaV8/qbFOAD4OvJWhrPIPy+ariY7F4WmF17JVcrMNBzGsPeUyOss87Nvoc7M1UnHjKbCMQSJebAAS5o7zjc7By4Wi+xIct7ksSYq6XvY2pUApPpxVBkLHIb1lK9snRSvV9dT+CGREhgaNRtELL+z2AeWS91q4CpqSVxVXrNe01oYBQAQ== 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=lQ6wET7ea73HkdHDAZsyjQ9jVSUL7gC8ZFcL8LEEQR0=; b=QyuEde7xD4H1uWHs8YyuY2mpvhVJEBuF3SHqZAnt4g7IxG2lsELTXN0BtU326336T9Vv6/XfD0//WGqvHVBaG5tZxDunl9rQ374SJhK0exuV0YIYayw8C9ZTHvevI+lEDKE2miQ561fuaz390NHQHcf1tx+XO2T8dJqoGIliMz4= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:29 +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.6064.017; Sun, 29 Jan 2023 23:45:29 +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 v3 12/14] IB/isert: Fix hang in target_wait_for_cmds Date: Sun, 29 Jan 2023 17:44:39 -0600 Message-Id: <20230129234441.116310-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: CH0PR04CA0046.namprd04.prod.outlook.com (2603:10b6:610:77::21) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: c408bced-fcf1-4e8b-c7ab-08db0252e72c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lN5vBjuJ/azC52bBR2aPobMviFzIxEFQH7u4Bugbyf/bQUvn2MIN1IapkQ3PXqd9ufoeqooMS8rNjgWqWw9X4bvGnYorXsamAHqmOA/ohDEEzOq9rRuwjij5Ck8GQ27pGcZMYfp200IbYZBKMlUwuHjDr+tuC4s5H8QTwFV7YvXxtUlJ9wUdEGWov1kQEvY5v2DkLJ1V9UlYqs4E5mkh5UeFsgyW0IiNVO48DAa2sy3d42qD1nqktB27wiJfy8zHe+XMAvga5DAqNj8B+0siVQQ9Ya9kC9cY8gyreMzt53bb2lBnrFeJ2Vjb5OZcOacsGJ6qnjF3sMXt0bstmCJbb31EwumaQiWRmD6mAEB+MyKBLHKWRTtTAoBMv3POjm2flnrdHWuwWJSLr4/cQscvPb4KHPvLeAzhPJc+4HnsyGNu8A0PTYBhsXJdnsRKK+79X+Pqa66yO+ddhxEsfzYdWzlhNgyOnDoA/5rBTNq7LrPjT/lt+KkhXNP/uEUk3G3fNSi9BaO9KFrWTAnTypm3tS8Ax8CA8C2g7OIUdhsP+MSDOhRYMReXHDdOIsgWnGaPfajoFH3LMzuPamdMoA+A/XDSuVXgtK+IAG3lHcmGdBQ+pHtU8BU/xL60sSVab/1+1mRu8/JAi51D5mxYXmeY4Q== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lAR5dro2idcN6z1cXj7Mz6xfzr44rrEASfDHhKJbY/HuT9ZajzWUKkUGAOmomKaoXW7M+PHmjV6pORwBbetyl84IB3aUA+6kLj4pUFRw6Ts31KRkgOo0YAJqEW9zJ6+NPZurlAC9NnmztTUKr167JNX1Ap0/Pz2nWti7rbdscemLFqb4kJHkIIUtCWi6oqxBjnV1jcyxoAnvtBvRBT23wGq+Pi7+gR+w1B7lJTdYAbkgvWLYEId3OGW3umS/8lyYrysLxbV0tP4UbNwES1ZnqrshCZYa8yCVA2IHY3Df3YH9HVQhZHMVgaQLiBpPLah7AGu/sa8+wESdpwLxvWcSV1OcRqcenR6smt1P86MuRCOrKKvb1EsgPICE9LghNPB83Ke8Tgv8hDT8nB5xh/Iq7hGRHMV+tqRoS50HFwIraljGeSI/DxNlN8hcvbrIo3d0+EvqqhiEz1aPaU3/31gkB821lWBwUz0H/CVRpPAceR4G/2M76ccOCY1myifCct2fKHh41PtPUwZW7z9/juTaIWr4YtQ3oIje92f/F/wEekMdS4rZfvpmTBL2ONskIytlZQjTOtEbEtivP8I+Hko+xqX14vO4Zmo1CcwkJzf+mmIh0nar0f3hfUHl2tl4Gg/qLb8P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LKIDSuQyQ3op0j1EMHCEG9La0EA9I9yFSWWayI+cYzo6ZQGhkBGlT72gjeabN6EjgeV2RHS/iluQZKAtAMOCRbsZeFEQmnFcseUHPU+O0/T5rNqVomZfTuyOjQe8NogMvZecLn4CPp/UuQnQ0qQuoE7W9OihbWLmfwLFqBT2ezp5wOT8Rvmnne82aQDwkL+2S3atDEiMaos6HLDFAt9nC/Z9YAbvmMWSlXBhxia1mgAX0Ivum8WhzF0UG0K+i2c7p4IiHNmlM4gIdUtphagggiO2IiFYgPT5cOHnxOJUC8eyZV0l+6uBmSBs8WA5yvaPYUleE0Mj4awzez03mX2Hs5aDyLlKeEqIPqHS7Xu4H+tuYCfyZOZPWw5aI+rc0S7EuhHVvNU4OKzKvudQa7/HXdahFSBdKzVKkKkkzcf9ioDSLKMvfMR5OTv11vBee/vYhGAmd6RBjoR3OCnQzrIihGevk1b6JiiiARPfzdXIPWgzqe+F4405vd6l7IYZdGWHjNBp9bUTCi3t6iHl5iLlHuiAK6Q85i3dNmBA0KzmnXAARjJy9fbij9cIHremhRmRcEQzlI/ibfxP9vL7SnLWoBTegQ58ZXdOu/JF0q3DZPPPcFVY0Q7zfJ9Ys9Ut4KOIAsv/OAlMNFdeazPTLZIRahzzMKrSRrak0iVQSIGE9PN2JMvjGZUVyR2KPwWnDdk7oNCMoOubNGCB0xreJ51BDVemBCJOdKYdE5avsKvUU0HzwEpWRvB1rjQZ1qmqC4zMWqrJN2JJPA43Tl0LgOJltpbONXJ6JGhO+VRfj1O++fqnMccATgHufdDtvWUCd37bBli55i5ZI7M/x6ouP9ykB1qrPpZrsOT+RAceX8l8YbFjTUcNpIU+Z X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c408bced-fcf1-4e8b-c7ab-08db0252e72c X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:29.3508 (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: jARrBaAepPwTe07ARu1MRCPivC/V0gN9hb72JW/CxSPNoVnT8y7HZ0qYXH10VsAX12t5PloT7jLC+VmkoTsoeYRo0GUEws+FlsicJNHHFKQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: 4HDtzs-no2rS3Av_vVnaKf2YO5AKxjJn X-Proofpoint-ORIG-GUID: 4HDtzs-no2rS3Av_vVnaKf2YO5AKxjJn Precedence: bulk List-ID: X-Mailing-List: target-devel@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); From patchwork Sun Jan 29 23:44:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120298 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 2F6F3C61DA4 for ; Sun, 29 Jan 2023 23:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235164AbjA2Xp5 (ORCPT ); Sun, 29 Jan 2023 18:45:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbjA2Xpu (ORCPT ); Sun, 29 Jan 2023 18:45:50 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C72B71DB9F; Sun, 29 Jan 2023 15:45:49 -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 30TKG6t8032425; Sun, 29 Jan 2023 23:45:38 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=bpEwJYsNGPoWtcS6lq+xXJpSO/2cK2sbeVTQ0opfdWk=; b=yYafb6om2X1VH1h3FZEuSeJ1K6IFscfU6wY0KqKlkGxuqsOoPlS14Z2ofsNLlNBZrRrG v0pOgrzLbL+V2xl/oc5rLbrWGtGjrJxU7y3rV8Odlq1uGWa18SmuXlag/dEKV6UQjWWb /S2vaBuapgllL3nU8GjeQ5e0S4Dfr7TRNvIYZhgazTkGiGL6pwh7E24oPKawPeD87Eb6 GZB7u3Jkt1ZFvYAUBvNCcpygiDpkGgZfmZ3A/sxnVcc3CGDop9gBT/Vdi9xXz6vCvvLM Jhrb6wUlGXQs/bMjkANx8L8abESIacnjY63an+UpwSA1wO5RXp5yUI4qE2NH6PeHlf8v yQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvp11s9m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:37 +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 30TJ5qYT000798; Sun, 29 Jan 2023 23:45:37 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53drf2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h095xfsNlRtmXkypi+MISMVtWsFnmqAzK8HzPDKihP2iuV1UmxZy/7dkRGH54b41A5RUKb4t9TA6NiQVJjWLpFwyxSB5ZeIIcHs0Axkl4zDE7vkM2lOb8cih2vi4fmZU/3nGMe0XbsCJX0za/oXMedR8Jkpp5HxUnac5Bp/U7GRccK5oOp/ZNAlTMabTwk0yhFAUYPQ9cT3MnNs1lHCfMNFd6cLhzkXtFWmm007G2BMLMc9Kk2jr3QZyGf+zn0eFy9NEH8i2IDxvG9pb53GmRjxkJ2yQyfZlsGTvU0s+lg4VAH65Hz2SKSXC7tkAEivMoKkz2iECTH1ak0a60qkq0Q== 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=bpEwJYsNGPoWtcS6lq+xXJpSO/2cK2sbeVTQ0opfdWk=; b=AcV3nIlsFFY4qDEuwxHTeHxRT72kwnaCb4XTeu7MzPEFC0ICkshUQyqi5b8Xe6dwypSOcM555s1jNhTPYi30MF1MBgi0UUSwKfSmbQzCpwqd0mV0kAQ31i082sKz+YZBV1Jx80+arb7NvPT9Tjiz3HoUZEnioff+TESLeDDzgIEH4BH7K1KNk3TkfwucLRy/VWwXdHe1U/ausQUPc4Y3LkpT3QoQ1ezSqErQt3yVnAL8CkIdkLmJnC5VslRgt9Ewp8qgnxX8gL3+ANKURXQT+ygxMqfGNcy3IkSSbBKvUg/VQsHPCuGVWN5m1e4b//wwlr5RqXeUb4PSC8x+l289kg== 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=bpEwJYsNGPoWtcS6lq+xXJpSO/2cK2sbeVTQ0opfdWk=; b=pzPlkDr6B0hKpIi6NfsRoOkV5YHpD6XSbJc38keqFpAo5yfPYNjL8CcFnVwOYntsGUiTcxEmZ2bUmrp/clooJDP65fGAc8vOgBWt6/982NtivWXs9aNO1POpdMpy9xGwf/Hq9XsPpsGByv8wh1Im7RNokXwh2aDt6pHlqvP9sN0= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:31 +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.6064.017; Sun, 29 Jan 2023 23:45:30 +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 v3 13/14] IB/isert: Fix use after free during conn cleanup Date: Sun, 29 Jan 2023 17:44:40 -0600 Message-Id: <20230129234441.116310-14-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR05CA0044.namprd05.prod.outlook.com (2603:10b6:5:335::13) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 137af503-31df-44c7-06db-08db0252e814 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lQKbkAr2cuBh2C3MJPKDtF0TxUQjmu1IXGxmozy+iQFPIqPSPsHTRsPzauXVOOkKvlsPk3G4qNFEKIl8yBU+CvpC1g0aMTyz22RDYalfcYL/kOAi4aaQln4XZUEByXyrI3zEVvuZjkrJiHZiyzvjjJLQlLI8YN+PACOkH5uBhVuABxnxhd6UdlLNIlWtER1/pljtpeEfevcl6gYRpE1yWSexe8zhIzsGnTRHnq2L2ITTwjnET2O9FaFPEOs8FEs76HEseXr1T5lyithXMEHTyfLDMcNbmkBi4MZIjHuPtDjLqg5JPZWQFR+CBy7mQkPrVI7hBtTz6R2cTEy3Xj/ChF6nr5AzEH71J8rZinUwF9yajrBkAv6wJWMQjfWfcMiFOnsqNhbwqJT/QXjyEl2PTaKTQdmzV09GhO8CTjZYuD/apn6CGxa7A4pVFhvUWZLvtt+Zhhf/VWiGL/30hEhoGjpO+YK5eur0JG0FX+0RvCul+lAwsMkjPCDeE6T2Fva95GSU4chRA7dMxynVY0SphaH+TBlCHG4Id2FKZtVkq8J+rqEbcn0JiqsGf/m5X4Az80RbJ8xEyqDRoNIWsN8IkVf+B2uHx0FdmtxlZMz6pDejlE5aRJIAzpXoqdy8nHcNBoqCmMhPd4Rdqfh5xk3MaA== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UsN68/p0Q8gRjOYNcLGGqmUI+mhfRZIoRGcCD7sNlm8eagzIPSrQ4ME/kM9+0gGWlHjwBYst96ThvxGZcYmipLtOLU0tBgO/Ior/yiZ14SzJ1a1fiuczxPaaN3DX/dTV7Dtve7fILX9paA5GnbDNvpc0rF5TGfSbaNwXcdYiDK5EGsknf0V1ZntK8RDZHVQW4rZjRWyhC7voiqih1llSm4c/Wl74JxHOtREesl9MD7vGdwCZjif1ant5RdOclHIMrsOgArK6uCIQ7Wd9cNqJy1BlACRbIrNiPklGIpM3eWuZpSD6b5hM8wf4iR90Bnw1n/kmDEfSG5WkO85Xnzf3J+kdKk7uc84pfXb8ClreDBEBo/uVU4t9CL/ktQYWs5jnGDlzewxPqoZN9W+tQj4e9mk8+bHMMflGSZKOTCMEsuLg/lesC+zIgHIrTuuZUcvBxEAKfbQv4bW3tePWRj4hIIw97CkoJgzReRoP2HHCvDpYRcyzszhBqYnnMtiJ97Y5ro+D7C8/KA5maovUh827bLUonRmEeXdO4prTBeg2WQ5IxYGR5rKPj5ROzsFrtRkfKMF1upcskdwXzeH+qrITY0MnleUv4ojsNsaiGLVETKzJof9iUn9TYAMa6dLgemGPxCouK+zVcNJ7OUwRKo6HPX0Ge204U0GviCGxBJr18dR2/3pMN+VY8ckBOxBk8XAVwaZSRsfnyk0WdFkQuze/jeLLb9GYEbT07oSVtIsVLz8AcJWUz3rygBFVEsmtHWX4zdj55/KZF8x4+keOKuiEgdxE7NB370XPyhslocqOzUfOIeBw1uzcwEDgslL9CbsAikErzpDPNysDN2aeDRIvqHMM+ZG51Ht01z+b55guOcMIeJM8vaXOxf5mSVI3aYFeM3+YpZX9rBsz9J+NndFbM7BhkFS1tj0clquyBK4hWYI6JZ2FAQSmdYQ5vw+spy8iTeaHdTo9alSI61nwOZdGv9SxNQgVukCTiuGwz4tGDkFaibX4nUlat6c5rkZQC3LMKv7wCEfL/L3HIzUjBdmBydQx0hosH2gtMQGKTCh6K5mFetTIOdd+ehVvE3Wh7Nnv/aM6OSlioYApiqstpf1AQd4I0Gtt+UKKwaeSRHEt9DdHcfP/zsjbUZl2/cCnYUs4rXZk3JtQZVWysCDT6lvbBXdJ2YwzlxC9qaa7i4/iJBfJxfv5mGYK8GuaovZtQ9qk51eLqqjfn8e7pzIemeMffweZTDM2wtNztF80GjVIph+OHxNMos6x22u/3DmH460YsGBfulQypTnGCKJlF8+saI/1XdrJgC7HMSYRz0pKRIxZPZbKerSSxye5q2kEkQ9T0cluq75eeWjr9dka0Eaxwbh09OJUncQ1FJazR2pPbgsq77p8QnENXpxozobLkPhG7sD07A0zSzSvnDWrcEBChRY2K5/52VjRdUnu9yfy8/hddEMSb9KS54z3zJAem0ROxsrwAbcf7cAq82Vz/LlJN1xTj+WKJBdruJq7JwNrfkzb+D7fc5yIkzgP38HMKJTehMUQTpt7GPgVWvRg/VF1xaoyA/x3npWRjCTqrOA581Mnsk7z15JA/c696jNd1pd67hV6lrYxSmuqIoHAxAZkEg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 79Ig6IN6BJzqBJwijiDzv17VaFgBJDHzV1c/cgyQxPHf08xRk8VnvjGhgMnqNXiIfHCxUDk6+1Tm+1AqsRO5NMCT3zQL8grrVXdE7m6EHqTpgbWcnPi3KiyttojrgPeHay0QWuODOJaACNdgB8Nd5cRQO+9QYuAtqhxxXNY2HOCKPVq997UcTZMawrFvq683zSJfk5ulJBKNHDC/PPSfIUIqes+vA8klWOeBO3k0IKVe28Zd/P5peA+rMH84yMQYGiOvBfy0ppKFnT+pxaSmDmqrSTQB+RMLsk30v22h3Ze0qaxYKNEnu4KzXG1DA/KAQmjzdEmRduyxqEfNuQBx+Bq1IOT7jRO/L0x48Xbt6a7eeRGaoRq6I4qpRdawt2Xidpu83fhNIuq1REAjTp86xa3E9uf1z53C3dSpCUyQa4dIVe53BuhN2bf3PC0ZAsHqmYshltIwm2Kbhw5phq2tH5QybcWozwLgDKc0ldD5hTNg6QPaJrkHbqXkQM2LssK5ykDdtB2yR433xF9xc4jnM6uBsDoz/pIjvI4uH/Dn/GgQtKnKrJV/C8VOH/ajF8XdffbjrxwcEovvc/u+4A6rQQIsmq53baWg2L3yTD1GkbY/lHPXrMesP9ftzpqK0ndLodCYi2+jjBcGiCYjDAIHSumL0dyuuuj0qiox8ErI1kyXbNFRFBCL38NvXQXeXY7bN8wAA7x0gbzPahQYc1WdnG91SEtbyKHSKGv0LeN9e5UGuWmdNKmkyEdovXL/mvMWtEeB+HhNiPuK1iSouW7Np0UlA/J390wiV6y/4hlBunRKMaO7sXgjQ0Xmv3F4k4tiNNtwh/WRt0BLSJC+Zpt7E7FQh9c9XCqjBkuOA/NVBXkeHjxwK4fQBKG++RjdRGkE X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 137af503-31df-44c7-06db-08db0252e814 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:30.8507 (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: mnGYATELxn31lpVuz5ZiitW1Wc0nt2icjHR2Y7sRKME3kY7l+Ra7TqOfFmjmnq7ihqz2uxQZVLaTJzx9rhY88hnilotVW6jv+AjbE47ZJ60= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: GO1Jar5VFm_cRYIAgb2-_MidY3lPKIwD X-Proofpoint-ORIG-GUID: GO1Jar5VFm_cRYIAgb2-_MidY3lPKIwD Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org We can end up freeing a command too early during conn cleanup by doing: 1. Send iserts N 1MB writes. 2. Pull cable or down the port isert is using. 3. isert_wait_conn's call to isert_put_unsol_pending_cmds races with a running isert_send_done -> isert_completion_put -> isert_put_cmd where isert_put_unsol_pending_cmds sees the cmd on the conn_cmd_list and it does a isert_put_cmd which will free the cmd. Then isert_send_done is run and will access the freed command while doing it's normal command completion: isert_completion_put -> isert_put_cmd -> transport_generic_free_cmd This patch has us increment write_data_done, so isert_put_unsol_pending_cmds can correctly detect commands which will we will not be calling isert_send_done for. Fixes: 38a2d0d429f1 ("IB/isert: convert to the generic RDMA READ/WRITE API") [code written and suggested by] Suggested-by: Sagi Grimberg Signed-off-by: Mike Christie Reviewed-by: Maurizio Lombardi --- drivers/infiniband/ulp/isert/ib_isert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 516fa37494e1..a44da60352f6 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -1636,7 +1636,7 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) if (isert_prot_cmd(isert_conn, se_cmd)) ret = isert_check_pi_status(se_cmd, isert_cmd->rw.reg->mr); isert_rdma_rw_ctx_destroy(isert_cmd, isert_conn); - cmd->write_data_done = 0; + cmd->write_data_done = se_cmd->data_length; /* done fetching data */ isert_dbg("Cmd: %p RDMA_READ comp calling execute_cmd\n", isert_cmd); spin_lock_bh(&cmd->istate_lock); From patchwork Sun Jan 29 23:44:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13120299 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 1F53FC54EED for ; Sun, 29 Jan 2023 23:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234868AbjA2Xp6 (ORCPT ); Sun, 29 Jan 2023 18:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235183AbjA2Xpy (ORCPT ); Sun, 29 Jan 2023 18:45:54 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6374D1D93C; Sun, 29 Jan 2023 15:45:51 -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 30TMoE0x012099; Sun, 29 Jan 2023 23:45:38 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=5T0Ai1XuJ0bbkbsZ4/ZjntFAn6cy3kS/uJ9L4YN1Bwo=; b=jWp+8M9QlS1y+b1mUyFttXtizVNMHwdTFRCiyJIhmEfrj3F8VATLCYSjleyoFRpZBcI/ aGEqVTuum2J/KLsPpziwzPu+VoXT3eKPmz9jRz5N75/pPaY+Pby5UJ8TjOlHJIakHq0T QQgvn2Gr1F0e5Kt83wxiCA9RAdds/GOTdsJUmQ/v9ta8aYwk1qmQuCyiaf/s8X6Ow33E ZfmXz/7N6B06aktiiLiNiC78W/nKuiv0gbm0Y6gnG40VouhXmS5JrUjl1E4AWgVL0Wrt YXY7rTVmzLIcJ0lC5LnkcnE/3Z9oN3XE3ZzdjJ0ISWg5uh5ZsAms5Z/o3ybkHC/nS+Fo 9w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvm11sc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:38 +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 30TJ5qYU000798; Sun, 29 Jan 2023 23:45:37 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3nct53drf2-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 29 Jan 2023 23:45:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MtivldMTddcgUCbJXmK231QH2oJ/+Z6QcU7dkYSATbGa0TuwXcPkXcDI0vvoyIjYkonmPCIuyrIjpRyOAW3B25DWcnkxHUjKMIo7gv85VXE5RDYh5MublmZszWaUEwjPsMi7ujC4np27NF6rMyOOLe9RHY7BeEJkKDLpul3xy+zsZ9EZxBfNwgDy0XgIPf7jyxdbY10IYDaCKICuFow5kubly931S0RJF6z0sdfk6ABjDywJWaiYvmlB7bA/BYXqOIuSK+7YDRiyBvXLvmLzxHLImt2tyX0pUtgOYNP+rG0wqkIFmcxAaz41Nk7DhbIQeXhMwJ1yaKzZ55qeu+ymgQ== 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=5T0Ai1XuJ0bbkbsZ4/ZjntFAn6cy3kS/uJ9L4YN1Bwo=; b=TsNGNILQXa0bPel4yWkWNiY1JPSSa+wSQm7gtsL6L0rcnCAMinA0CiILEBf6uRXCAJ89bVD1HXV9G1Xyms8z8M7PDGXQdd9bJdyjVhNQpnSUoDJBF0js0yveye/dmg7FQd8gHv9dYRovAjzk+DJguStOBxOjwj6O+MJMIFG5nXZjM2uG/r7vMKm47BhNzYoOV8ddv3SZQ+Kyn7P8eVnTetLfTy6FrwPXcd/VLhLJ4aY5xMZdX7PHqawRKeUpXCjViu6Duhxeg7LTAV9Dzk+UQ+TAjywfcyJXn39itSO9q1UnrgGkdxB1E4nnBkCj6QJ+aPyJbsBZB+7gWra8V32Siw== 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=5T0Ai1XuJ0bbkbsZ4/ZjntFAn6cy3kS/uJ9L4YN1Bwo=; b=j0jFGqTbdfIz5CigqsjCZd9jQ5WOKfVOd8jF4vc4BPT0kraliPY+Zo1MfXETS6XnAAuYQNDlsnroZncz6XAyUGXXiTKuIxooplTi1uZo9lLqWrpBTdUcVVZKMav12YTfTwHwUMMYFh+FZy3jdb3CKRifAcRCVaoEiZRSonjq79E= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by SA2PR10MB4649.namprd10.prod.outlook.com (2603:10b6:806:119::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.17; Sun, 29 Jan 2023 23:45:32 +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.6064.017; Sun, 29 Jan 2023 23:45:32 +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: Forza , Mike Christie Subject: [PATCH v3 14/14] scsi: target: iscsit: free cmds before session free Date: Sun, 29 Jan 2023 17:44:41 -0600 Message-Id: <20230129234441.116310-15-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230129234441.116310-1-michael.christie@oracle.com> References: <20230129234441.116310-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0102.namprd07.prod.outlook.com (2603:10b6:4:ae::31) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|SA2PR10MB4649:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b34456b-0ba6-46d9-1d02-08db0252e913 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cTYMckJMED4M3+T1+QhZC73mU0Qlv52iiamnSYLt7N6ETD0ZWVbBXLA0f7YSaAso6kYjBNpu8aijOMIb/pYvq0d8dl93jldGzo1SGO3prSw/fCWGL7OLBDDmwWeyn93HxUS5F8mhI1wIZ/fYuBoWX7J20RnBFpbzMzOprp6aN6DU3Aj2A3ejqCBUnlGqK9IZRJSuLDgw1VfZKAeFrCmQ6xDosW7wuAqunoD55FvPQMDLfF7SNJLJB3FmxmMLTVaa/Sc0mg804q6WNFx2XdEYHE4qARB5XZvPR8v0TN1nNE0odTqaHY6CXoOOeCLBvdnu03mNsv2/rLHy+2PMi33UIXByHhPGo5ZoVkYVig66B4Q0r5WOoGFtJjCvrNosr93MqBFXiKCjexMh5pvOhJH0L9VyJJ2EFxq1xO1OGxICyg4sHJTmnuCQ+gHMCDspu03CvayexCXpnyXaF1qJDRXC/ZDXYz6ZdZISLMKuzi7BgpCSLNfHOshLiRrHErq5prbflsaXccy+Fy9+LsOrYHc6qfaPu/ECgkWvYOvVUHZub6AEI9tFLnk4iTgAhBwp1ouNgJNx6AjQ7EKm7tF4MA5xgxBD3HuMEB4joYdQqfkWwnn5cO/wsM8lJuPEWEW2AjxLWbxBrovpT/HlyI/fBWj7kg== 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:(13230025)(136003)(39860400002)(396003)(366004)(346002)(376002)(451199018)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(66946007)(66556008)(4326008)(54906003)(2906002)(6486002)(478600001)(26005)(186003)(1076003)(6666004)(6506007)(107886003)(6512007)(2616005)(36756003)(83380400001)(38100700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bGdu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UI1IzaA9mk6PvQcUOCGdBpexiJa6NaC/abk8cm43xyI38pA7p+YN5BVp4uM1mPFuN303Ics+b0x6yD1nipAkoVxt78gdDcZ5HTI9gv+yOb8iv3lNaxgA9Pxo9bGQVTV+gFxWebtytujWK1FzOkdi2pl2SHzus/Th42oL3Z8j7hRIpcR1rPp0PpgzQ89LG7JKcLJUzsvLkrB4ucyC+ZwQTQQpqZ87kh0wSrILbUcmB/atn65jjckhosc/DS4SiTBCnGvRgKmXhOzwnuubo3FqGHgRVw4DpCPfOSesh8LfEiqFtub/HR7IAWTfeb3qkeQG+fTdMbe2HO1DOM8YE4qT9uneUgXf+Wr+JbCHFPsd5dCsx77wkYrbluMfspgvIPlYq/vDm7Ajhw9WphrEqToqdghucllqX8AEAvR3+QJ4uSdVIbVwQYDYbjmOdilbvrNVqHoiDYd2OVDEn4+ZVJCFJ0nvXJ6WSwQBxuIA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b34456b-0ba6-46d9-1d02-08db0252e913 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2023 23:45:32.5224 (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: QBrXsb72AtZCWEnJE1ZYk0ZaFY+PASvjNo5gPerjJ/nhA4Yk3queB1p38nVULLmv6VN5gXnKgpLTYsFySRHaEYRWWYzgIo0ZC5tluIN3PTc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4649 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-29_13,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301290235 X-Proofpoint-GUID: c91duPt4GBhKH1nd3z3GLlgHVkA6BhD5 X-Proofpoint-ORIG-GUID: c91duPt4GBhKH1nd3z3GLlgHVkA6BhD5 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org From: Dmitry Bogdanov Commands from recovery entries are freed after its session has been closed. That leads to use-after-free at command free or NPE with such call trace: Time2Retain timer expired for SID: 1, cleaning up iSCSI session. BUG: kernel NULL pointer dereference, address: 0000000000000140 RIP: 0010:sbitmap_queue_clear+0x3a/0xa0 Call Trace: target_release_cmd_kref+0xd1/0x1f0 [target_core_mod] transport_generic_free_cmd+0xd1/0x180 [target_core_mod] iscsit_free_cmd+0x53/0xd0 [iscsi_target_mod] iscsit_free_connection_recovery_entries+0x29d/0x320 [iscsi_target_mod] iscsit_close_session+0x13a/0x140 [iscsi_target_mod] iscsit_check_post_dataout+0x440/0x440 [iscsi_target_mod] call_timer_fn+0x24/0x140 Move cleanup of recovery enrties to before session freeing. Reported-by: Forza Signed-off-by: Dmitry Bogdanov Signed-off-by: Mike Christie Reviewed-by: Maurizio Lombardi --- drivers/target/iscsi/iscsi_target.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index a57527beb340..eac5af87ccd8 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4547,6 +4547,9 @@ int iscsit_close_session(struct iscsit_session *sess, bool can_sleep) iscsit_stop_time2retain_timer(sess); spin_unlock_bh(&se_tpg->session_lock); + if (sess->sess_ops->ErrorRecoveryLevel == 2) + iscsit_free_connection_recovery_entries(sess); + /* * transport_deregister_session_configfs() will clear the * struct se_node_acl->nacl_sess pointer now as a iscsi_np process context @@ -4570,9 +4573,6 @@ int iscsit_close_session(struct iscsit_session *sess, bool can_sleep) transport_deregister_session(sess->se_sess); - if (sess->sess_ops->ErrorRecoveryLevel == 2) - iscsit_free_connection_recovery_entries(sess); - iscsit_free_all_ooo_cmdsns(sess); spin_lock_bh(&se_tpg->session_lock);