From patchwork Thu Mar 9 22:32:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168432 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 01649C6FD1C for ; Thu, 9 Mar 2023 22:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbjCIWeJ (ORCPT ); Thu, 9 Mar 2023 17:34:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbjCIWdt (ORCPT ); Thu, 9 Mar 2023 17:33:49 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD4E4F2203; Thu, 9 Mar 2023 14:33:46 -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 329Lwt4S021591; Thu, 9 Mar 2023 22:33:26 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=WRPF7bvaG5AJfX6yoPP8u5zd5rpHMkxjLLFA+gcFJIc=; b=GsY7i4PXmSQjiulSORy3o/9WF0ND+wi+4aBYMOghxW7ShbzLWU7sNGm7bzWF0/agkgU0 qD4hMW7dgyLpEiNxEp1e8sSW43yndDGxwVfBY93ClonI1QPMudKOzaI8gbYuko52+6/x vjJV95tdQ/DGx/PGV1RSaGuV7qp0eXm6uZeUZW7n2Y2Mlcz2r4ltACrvQibJ8M9bpvDq 5BJrUELzUGEBBR3sJzCOup/WWH3aBwRyPFa5YqlsK6H7anNil7bDgj5TsutBzQ7uvohr 1iBR/RpD8RJPVzhFd21JgANJ52MxrdB+wSXZlLpLO/96qWsJ1D0MFZfcA0lLpFXeOBWD eg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41813uxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:26 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86A007359; Thu, 9 Mar 2023 22:33:25 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PyVHbv+fzNOqI+Rz6/kk+PrnADnEkbYvBDWNkcLLCrT4t7Ugc3kLtD3RXBeLcZbISUhaB6/reS+fjJeg2W9Bpp24ZpL/kk9zzqLJUTAVVoBRTkG9PrPQHhPdJVhbut/VOht1M2tBwKixxC35/fhORyEvkLLOKsXttxdi0n1yJjgjQj6T5kL5n6aKCVIPc5Qdzg7E1DRt49LcM1AgLMyYvTVQN5MvPrlqIncYU7KKpA5Tl1kpnU35p4kaaB1JB/3U9KkiOXfZ7wB7ZTMQW1mPwsFwXf3QI5wHWkjoFFzmTOqYPRdTmyVXgBFS6IriX3Fp108i+z1tmQ1vjxkdrT3+bw== 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=WRPF7bvaG5AJfX6yoPP8u5zd5rpHMkxjLLFA+gcFJIc=; b=cpGGh31VKMq/uvS9DkbuzswVyJ2VWiklXObhFY4TNWkjSZBvyUzOU8zaZOhhTgvA2Zvz5DfT4Erm59CrExhIcc4I/1ItrWYUHQD3xOSe1aVAW7Jj5/Qx2S3tW9Q/lOhBi7JRQF/8Lrpn25UP/MVfV3AvhS95mVIS7T5JZZcKi8oEyXhq11nYHZhZLlbrO03ntxdZns1CPHz4ZJz/Ut7pJx0z3EQEC7/4d6SmAsfZiuVjNbHzH/7OAjrB1Oru4mPp6PXu3hoI8I38PNq4eBRftzCa8N3DsyDKcvIArC3xOhINH8YTNENb6nU5FQ62U9/alEto5oqbqtS+txg2GOL0+w== 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=WRPF7bvaG5AJfX6yoPP8u5zd5rpHMkxjLLFA+gcFJIc=; b=ym8bDml+5za2McN2l5I6Zp3DCOXlo0D4khBb9bDVKk9FKu7oAlqbNcZxux1m9G40w9drdI5QENQaHJr05HI1YQ+o2YsZyfdMyqVZQeZeVBVnoOJegKLrL2Qo+mM/k7BatYKsji89voT4ZAcR/y75nKa6N5WBuGgo/8mG3HxIwQQ= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:16 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:16 +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 01/18] scsi: target: Move sess cmd counter to new struct Date: Thu, 9 Mar 2023 16:32:55 -0600 Message-Id: <20230309223312.94595-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0237.namprd03.prod.outlook.com (2603:10b6:5:3ba::32) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 63c1fdd3-5108-43cd-392d-08db20ee46a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9lBslgSA0rCQHeRvge13/5LmaW1ATlL+vSNjNyBo4nyJDAKMK0cJlpRokzvYu5Ff3JrTkZlw5bqyjTMTDNDbDRg2mB4oAcfi59DCY3vHfkO84Fyhk7G0ML2PZfcvFOnHvNQEBQ1GzLvW23grmnc4DSwbrAojr4+g5KWNiNsb75Wo+KsYXlAB2CoLbE60PhoM8Ng8rDeDkFTYt+nty3AGFoRTCyoIz14g8KC4B9Ew5BKw1BivyFXTE0MGJMHLmRj1MhydaMmpNrS182rUtG0pAOe1qTLqtpR4yZ05c7JHEUfb1MDIXNPTR49e/qgUGrl+Jtczn3i1XFNfowYCNpxKmGCro0bFV0ypvUfw3WlCN6kImiUH/cOhddQ+QJzcTOfWFSge89yoZ3HMmHg5BSc/C9PdDfUWsDuMuBtx3mrgnRg77MilBuAYRXQsUoQTu1CK2o/alT5hU5rcwQX2RqujwlIoDCi5RjIw9fzPtSp0VT2RF1C0N+6iCE8/ETJzGd+8vDHAskWYQuC4L6NwaIn9vALw7hlPKcQyQUMnB3rGyI4G4nW8uGJ7QKopP1EyuaAav38z73L5QA+b46j6O23bA7KRcQU25IshmqT7zMbnQvO1S6ChWukSDWnqFIplTvDoe1+Jgsm5UBl/xcJxZOjsaQ== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dI7SNSsYXVRN0fT77zoNqu6mhHKMlzRfF7bGlHouh4L88+YJhH9gEkdZkhdbIm/X6xeFfRLaKkfeWd3Aps4lczDiclN7zjuHLbwGLY3qyxFtjomSZ95/XRgEGxpOx87D1sk7OSfSZuVH3faOADeAZzeIam4A2ucWDtzrMLpacQb+3+ExRbVNK4ADRZ8riGfZ/xNePyK+ZoB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vgylVLXKVoHCorOAHKL0ksORbUAisFBzBSaMawdSU8NYRA8ulcI2ZxUUeDqU5kJtC+fYfo/pJmn/13wYv1dUftYrvHoMv99btxeHPxc94D4qcq3oD6XrBIg+Vl2A9ASQvcbB4ThMc1PitKtsYp99lHgfmmnKQBeuSKBbWWlIkWbcwOvQfllQBazaTtKCBuHjGbfMhhcXzosh2sjcJ+VfDm/PwEnmg/rsR6Tv8/Sr X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63c1fdd3-5108-43cd-392d-08db20ee46a4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:16.3936 (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: 1/BKu5OMUK2msPG4bikbG5XW8ejApD9SGlYseJW1L175vpcC1uLiotdJhA00aoDe0PjKGpzG2nk8dDwhsir8O4jVhSzZf2AeJsE4MwYaICE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-ORIG-GUID: DakQs9P1B_b0ncvY3KTktnuYLCA_tEkR X-Proofpoint-GUID: DakQs9P1B_b0ncvY3KTktnuYLCA_tEkR 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 Thu Mar 9 22:32:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168435 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 BA3FBC6FD1C for ; Thu, 9 Mar 2023 22:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbjCIWeO (ORCPT ); Thu, 9 Mar 2023 17:34:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbjCIWd6 (ORCPT ); Thu, 9 Mar 2023 17:33:58 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E83DFE9CCE; Thu, 9 Mar 2023 14:33:47 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 329Lwt6i018084; Thu, 9 Mar 2023 22:33:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=IgzHmvphR39o3PjSXKQRjVIpDY4S0MEkoRf/Ej+4fuY=; b=rPFF2B+mZfi65AqF18HH+dS7+oGcWdvS8ZJiMWy1ZLQaw3DdPiFN9rX0iYDsppcDRfjQ 2xWKSnEJJkARNj18mgBGP1Ks1/ZZX1KrG49BhFOuZclwETQoToBU/fLeTlLt7EFO9HTv 9hDrKYQ5DbyOOvyBa8SKavxZQV021tgTDy2zwA513ftwX3YE8tNxl7FU615H8hfOk6o4 wa/9ECmlXZURmnulllscSi8GaDjKidWL6AWdhNxUfcbloJBT0Lt0wJtVU8g45abrgY8i SF/7HfOSPOwgAUre+3xnw2twQ3O4dkn770vL/Vj6U2K43JSXqeKyMPs0RJ0e1t3BRMk3 yg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4168v15b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:26 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86B007359; Thu, 9 Mar 2023 22:33:26 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MPAygN2M7QVW1tUPUwJq8MbgMgYC8OCayVrrbsg02flWRXrLyFPtyW9+z/8w3pB7EYFpsfFp/WBu1kzBIt/FmU0xhtiNjrm3/Mbr4FnLDb92PovsjAi7hps9UgAnEjSfxLajSpFEP6BEOWR4ybb7H94nCvzQ7W+0/sukLzHMWm1zmiFZGohGDE789AF8t80k7+rvYO+VCF/s+Yl6wXl0uYaF8ODwpHQl3tKIgT5TtjzbQW3cynTLI/tkqHRGJ1/vCX7LANboI9aHJc22Oqvv2QoJ0ZoTW50wTgqqon4TGMpGxOgw74aakBrZipsK8T6RSeUIOfgQpFDoPR3vNtu7wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IgzHmvphR39o3PjSXKQRjVIpDY4S0MEkoRf/Ej+4fuY=; b=j86C00Bf+Rm+5Z42Rct5PqPQD4ccmTb+VC6W3aFDtzpRpRKjyXkQl+irL6s/znBggKK9qtFSh06yTJqsuRQL45s5Pv2BMHOdDiP86Vu+B/Mcs2Fjqc8X779SddSLshVj2Vb+WEVT+ze/80Qjh4NMjFuhvmAZa4y0DTIjB9Hc/rU49R3v0TyuKQyS3hIy9TTZkkARrDDz9OqXNJ6a71hadafRL0KGKETsNcxqdue+BOnYDh+AqweRw4e+pTj3iBzdhpFMqRHyFQ7sf01oX/0iViiQr++rPPk9a1t6K1OSn7IWJvXhhbP2MmUQPoyAcaP40GbnlxtPuOSoUDmXBJ02eA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IgzHmvphR39o3PjSXKQRjVIpDY4S0MEkoRf/Ej+4fuY=; b=tlpadhiUIaqsl5es672fYMfXR8jfaMV5fADeHLiMnMHPG9XzywrKAPyAafu9/hjfx9QPP0ug5HOwGZR/YcQm50HXjHL2pQ349OEjHcwIwoUADQybMDqbsGyOOBqsbIF5Yq2f15Eq5s7zyKwJOjXkwdJvE2nV6DHOkPnLGCXAdbc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:18 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:17 +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 02/18] scsi: target: Move cmd counter allocation Date: Thu, 9 Mar 2023 16:32:56 -0600 Message-Id: <20230309223312.94595-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0223.namprd03.prod.outlook.com (2603:10b6:5:3ba::18) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 3700151c-4bbb-4be0-3d25-08db20ee4790 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uTlsU7VkweeR1l0rHAwDdoUreok+ZhqphcjaroeL1fIo+gOEL2PVtfCWSImgqQTJDQPo+BphIw0E3s1JqLw9UpxB5IIybMEX1NQFPNq8Lu113g8kSRh3tE7FoZrTMzC4opiDmZL8ckreom2oSlHHLDn629FEqZayquQlibyhipDdJUhXxWi0Khc0i8/T/coozay8g/0F9QnKABK0GEnh3wtrr11FEgOuRT7kNUYdwGEON6te8mdquA/7GdpYlrHQd4ZPYvXIMQBKVPMVC9+8I2DLnXz17uUR/OLTp9zjHez8ncRcAUHcl6DOQi80oUEVLQeYjp7T6otR7R7uUAfkRtDBg8iJPXDZZOKZe4v1hRacVAnJoYCfLQ6Wl21TOuzZaAny/pjdZKJvIyfBlzn7kso/BDt+9yK7qoIz5ZxJ9bPUaZCF4yEo8uXeApj7lQizzPDQwPveCqokctzingv6UwU0/BQRvUwiMXqeos2nv37UuhmfZ8OgQ2b0O9+/IbYdDX/+M74i+bTIXA28knbrUp9r4EVV47y4sUpi1XCg4er8h1RGmJ3Qruevy5oTMPdbW4ppQx08mWImrkYoPtfNu27OqmAkCGVdL+HqtblwOoDERZGkzV2Lr8vMH8pbk0PXiNNiqZJLY7FKYdBkjhfT+Q== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d1HQnPaoztZ6tuXpSKDC4av0lGez+DBica/UZGarxvlRY93jbGRedSZLFmE0UEl7GmRfMfEZ3l0iBFK5ubHIPdy0mbwAMGkhcnIJ2xiarurSJQtoHBlvVfRLNiufP4HITWzH2jC4IKY9C0c1qDoP7kCmsP3eK3tMKRj3cH7SkYTGO/NgSzRC24FvQiMbyCN7aMiAnP4R8xpdh7zzZ1YAe1aJleaZ4R3Cf7hIWslyoAuXhhvgYIARMaA4e+iCCkULgKHbYu4tbBbeZG8tQRL/CZ4hufrNJrGhVPhvbmBMSTDNJ+bQspLSqknnEXfikZgko54gWEcYDcDMnESHzWuqs6/tnXpDyLzWLPZ+lcWm6xbue6kSkYOZVeCVmLo4B1LJvX+qyb7R82leOvRKN32lZR7Hz1hJptESFjEO2HMK2b1Z9mLY/AWwVzzLOrfwndTMfczUNrvbb4cmXkjMVBV2TruFKjJhuRRPYtZ9J+oA+2ryCUVAsMVj+YKWm0HnCSF6R/wRkrdGnEXinwIxH/tL9dFijAhcGIgZ/aLEBKO47jmXc/QqGoqWamFVePCvnKGnULUq2ZvzsBAxKIkeqplZMUq9SqoNs3qCF35fcqpxCK8REfwcOOHG6qugny1JHBxVup3IZp/cfxr9OdbZItm7zGCz2rG5gr9OxrKLC05c/NwoOMN4ytZzZ6yoPgZZOovyOUd/f9b4udvtY6zPrtmV4YX6Te+RynXC44TBAjIZ9k5eWMEoDInezD6yfJ0WfvFMLgCvNE4TfTuG/nzBzYItRjVTydlETTIIGgqU8xPS8U4hmnWFWtkT9/GStHDAO1c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slfz7+M2zEJQDrWLHclsBrt9g9902NVNonSEx32VuqlYz4ZjdGm5B7bfXmgBHeqADMsc4bYsZsM+uDGy0/D1QufJO9cuoH0fvoBZequbTYWB0iEGJaJDDNdAbBaI33U8sT9Bj5Hruia8OhxGCbYbvoO+WBexqf3WkcbJogge1G4gkZ+8YUymcNmBam5wBptKR47BIdRHfYyoKRyQkygBF69vAt0bpy+TR9Rd5h/BxfmbopNmpnV7pbPiwyESAGpFxGceb6tN7TU2joGAUrCbySgS9ITStzAtW32TwPbqAt/nueFBdv2CPFumFr3DepFVQFwlkm4qfmcN6zE8LW5BIDob46FbGO6F8U3Z1a07oPxp8zHrG+tNcNMQvolVscVzHidpOuU6oLwuWrstmMkXrYDeiS5w3tDIAmEaQ88Ev/BlSV3/KRTvQnChBPLmZNBamUs7FoQKL9HmN7uEF3FE/OAnQ3C+HJC0n6WrmEkiKfVR3fks3n8GVtrMYgf1IzHGxRKLb4k6UnUF56dmNL0w6NYcbzTCJHSRlg8r3DcL3UZShKiIwNfh4vLWzQx1gyyAIJzguSaICx62NlDFTsU472TxQtUy5Uv64/LYjmJJk694ZJlPNjHyzrhp8sC99crEPz5Djp/JeGXueBgcDQBaxZkAY1tmgy86NtLLZHQf1I2AjilzvKmcpdPM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3700151c-4bbb-4be0-3d25-08db20ee4790 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:17.9247 (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: 2Y/hGXOr1QC3vWwoWFxbNj8EkDOggK9hvecpKL8BYhFLlb+LyiFVZFURpeD6GPZfTPuzoyvgFeBWtVTVM9pe4jpBvKwqBpvVWcwPlcs7YaQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: x4A0kszUS1FQWsUhwZSLiB38h84Bm_T4 X-Proofpoint-ORIG-GUID: x4A0kszUS1FQWsUhwZSLiB38h84Bm_T4 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 Thu Mar 9 22:32:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168425 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 66007C61DA4 for ; Thu, 9 Mar 2023 22:33:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbjCIWdj (ORCPT ); Thu, 9 Mar 2023 17:33:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbjCIWdh (ORCPT ); Thu, 9 Mar 2023 17:33:37 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF256B7D9F; Thu, 9 Mar 2023 14:33:35 -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 329LxK7o004827; Thu, 9 Mar 2023 22:33:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=Z9IJ1MpNV7Ww8oAFrYQBPbt42LUUWffkJ0U4jB/bzuQ=; b=mJBOWLvr2hBhZBhwDsdJ4U1aHeHuHZPgSVC85DiGpXlp1GO+uXnXdF1DJRSgCtGX0FjD S7PkdHPUHyrmJYXE7cddyOHFbEP6DDRTYN0wU5LDTK1h08QM5tq9f0ajieMCq37+tbHf J0pxblTlH9Z7iN45u7MVBKavCf6xwQEMmVq8Y9Y1qff9A211tAzFueVg5iYRPi7sdltd l2Fjr5udG/y1MTlRmJXZxa7AWNSn9QxNNS70bAYg8xHeCsvm83h/sQ6fr4Q7j/LV/Xf3 mg9MmZn9a+ikomgBfYnBiIOjbWawlfCN0Is7wQkGIYPII+PGe5Hxr/TuaOO4tqy/8A0i Jg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wv202-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:27 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86C007359; Thu, 9 Mar 2023 22:33:26 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CnDs4deYyWkOTrctkOhaVrbSy7z1RDXOysYGonMd8QPnsfVkKZyMlt3tS+nqDJ3X2J9q6URHxxQOxKbVFL6lOnHLAw448qlY0wR9nQGemEEjtf0ZjxgKjD2zqmbhAmpFcO8Vz3/XdSPZ3WlWs2zPYaTPS74hZiiSSz4hri4NYdYPVT3ljai6Qxc8fDPS8goEdn9W0A1OAGs7k/e/txgiTKPfYrWkQ2qULXDAeDs6mS3ZuEBF1bG5Dyd9nnSSaxcNPeRQDpWNfBuH8qbgEkXgoMqP8gNBTfiIIRrzUyCO/pLmJKZ/rOeBH+H87vh0yLg5+gXx3oahd75LMjIV10OA6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z9IJ1MpNV7Ww8oAFrYQBPbt42LUUWffkJ0U4jB/bzuQ=; b=YDcdv6ELYZojYTczUrxe5rUyRJA5MB5DlmuFwVh35s+et9yXl2gQtQnaTgUANimVVgpC1sA6329iwb1wh8DzS/ZRBIE5/eT6er2GkX/nCd4++9tZqnfe5ki7Gf8VFiKVBILDR5JnJKdpZvVP2we6ZSd3Z3bBt/A/gNAdnxjcB3J1GsjDraeNVinsWkz4arvF8Sl0RSTnPLmPbYGlk+A2GR9PNcnoYIWEIgoDRZNNyQhWVs7RzXGfKV2f6iC0UHqNW3PpK3l8XItc9XwLJ97QtGRr8Cz/7mWczgFEH+T4EOStGSPEe35KEy04QHLMdjnfBTIxHPTwksAYhMCeBIUPjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z9IJ1MpNV7Ww8oAFrYQBPbt42LUUWffkJ0U4jB/bzuQ=; b=MWeEXrXZz81Mc6TTO+IR16rCQ5tu2w0ctzP8AkieJTojedqbPQ4+znRHnXSfq4A3GSu7O7JRvrBbwsV4LehN+5gn7Uzdqsz1Ooh6lNiEIwcokrpTBHWTHNS+/kCJWqO4u7+5BVMomt5O5nABQfZda1a8ZTsHdsviSnljV7o2sMc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:19 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:19 +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 03/18] scsi: target: Pass in cmd counter to use during cmd setup Date: Thu, 9 Mar 2023 16:32:57 -0600 Message-Id: <20230309223312.94595-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0239.namprd03.prod.outlook.com (2603:10b6:5:3ba::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: c41751fa-115b-4f0b-b7d7-08db20ee4872 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d411kaRavqG4+YSRvqFbV6wEDV1pMEBO/rY32zELDuc884wPI80tDHydCuVdujlWVd7UIUxFfLY76IAeyM7QQzOOpYZ4JTK0UodGSOcmj1pAE0ojbxECpqaK7diQQkYX/d7ZU1WeZJKgBzh+UAEcphvfrWLcKP7stw3QfvGHv6oA8ggXcYcnScc+RZeYED7gfB+zHmhoENEpYM5ACMxgOBdN9MjwJ1gBOxPohgNz8paLnMXOsX/5NAcHjcEekVnxoZncAI8KSrMXOVLHUYIm/LVOkQpGcE0fcD1tKFw5jwS2YErnkgc3Jtm0/slDuE9b6BeQG3v4ccz+fiufKE/h2S5GGuHgqXlHiQmyTtrsCnpsGuUFDu0pYhv7zLyampf492EunRh7W9VDcrHkbjA9vlczPVMJTgGOJKVVZi47IKoBZORSUUiBQc9dtbHBn+wVkYS4iM3TS2K2olZH81tRfcTLDx19cbY6v2UD+wlrSdGkHZfUF7xrD9XZafXDPeTy3URS6drqBE5R7VBwKClWgDvTnR9iSKrNlGKPGRJU0X0MmUbiTJMRdsr7Sqei+luxmtMfzteBaHuGFet2viV5q+wy0uNtZDSPYN/l5LhUL8w1f4tkmauLOIGivY03Unj7XrV+ftNn+JOxf8EWIJXwng== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XC42kgCFHTovNOKaE/0412TUgNoYh1CHHzaEoAZHi6chWc31q5DejQguinViR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Oeu+JqpidOrE7QXlJmO30U9vESEYFnpuDA4uHLK6jID01MwM5FLq6BDTnfFPm/G+Sl+2eVUSJBjaQRc+wmy+f8JFMuD5qwo8jYGxMwBOkxrUyobv8wxGVFR97a5+ggLNbMiaiypnb7TwDQHN8c+C5magd+ITyQ42qYmyc2e6JSIGxvB7m3D/QDAbyk1V+u+SirbUeC7h9LzWr7BHKc2/JPV2kv5MoaJ8CnOwHFRC8/gaxtrabkikBkF+5g5p9ulhvgN7Y5yGTqHZUhUYwMV+k2I/EIctXxYLtJ8K3SPkPPRm3ytJnEbAOg7Z15VQniyIRUwPOOepm6c4a8foeqdB1OW/CdTv4wx6OGFhM17wlkK3o9a7hPJD+ieE4Ni7NhjbBI2d+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c41751fa-115b-4f0b-b7d7-08db20ee4872 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:19.4246 (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: luLaxsTlux7MYV+4MMY+12GrfI7JhkKXdmTqAJ5KKonVD1Ph9DqFiwAqGFwuGw+hmgYjZbcus+NKxclGuL/qmiU7fytARfgzhNu+Wwp5cLk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: 7NasSqLTYhkcQjRUKld1efmbJygmlOln X-Proofpoint-ORIG-GUID: 7NasSqLTYhkcQjRUKld1efmbJygmlOln 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 Thu Mar 9 22:32:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168423 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 9DFA4C64EC4 for ; Thu, 9 Mar 2023 22:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbjCIWdi (ORCPT ); Thu, 9 Mar 2023 17:33:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjCIWdh (ORCPT ); Thu, 9 Mar 2023 17:33:37 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80642B53DE; Thu, 9 Mar 2023 14:33:34 -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 329Lx5ZT004320; Thu, 9 Mar 2023 22:33:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=ayYhov2S2FhgBf6h2aTAseRP/uqX8wu3P57Ct2s1z0s=; b=jRXDMizH9GorGxs5urTZRMz0cM9aJjMkcX1z7Nd5SvIKErIL2RRtc2rZWj03YTi3bXEJ Tc3koazNttLzA4ySPmwIK/Mlz0GyvDKrwXHKisc7vFU1FXw0lmrt7Ggw82CRkBcvEgtn uigBfCAvIPfWB+K6P+y1NTdzNJcfJ7jXarh12TdBUHKXTf54Sga4r3FO3Llaob/VauBa dMdSEs8MNCh4PWT6odLsNYigHKTCxgZohNG7aKeVi2QuK3VS7YpV/R6jkaGN33z3eSOA QbnwT7mvL9dVceAo6415KD7gzv5Vwmmc+PqXcJGKUt5Eb6zCyjcj0i7lpz5s2jClYRJA tQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn98bp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:28 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86D007359; Thu, 9 Mar 2023 22:33:27 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=km0X3UJwdo+PO1U7K67dUUQzTIouNNbZQZlI1TcYuFLY6OixTWP2tFV+4kwWb072Ap8SiBOGKaolCH771GjA2vvGgvAUi9sf+oKE3o1fy87ImR9gw2qRcZeVr9rFwTgGe54AfpaISNT8ROEPBVSAWCSZqoP79ursJlsReNI2AAUjK46heNVjDcS9dHedx387qCsdKLeCd8WjiljbrGlDF2dSk58z3y6v/RqwfRO4f85wFr9x8xKYAQxk0J5jE36+qB4ZDhWTLGJ8Dco066Skw/aJLpnyVyGlJG/CBXGgaqykwIwlTua6kK4XDqvCmtl9fzIqaophL8fQcW6eeAbcaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ayYhov2S2FhgBf6h2aTAseRP/uqX8wu3P57Ct2s1z0s=; b=By8KhxGlv5XYLJKtoaGTHvnA3Re0uBLFt2Egf2kOaeJEFxDk9mgq+if7lYwpPCfteMkL9YEWG5ElKwE0xF8vWvaHU5QjifmSTY3aVly5HwQXmG0KtMDCe9BBFnNfzuCQ91p9SeWEDagG5s3GMe/BpYUwLVTz4pnqdL+vTPY4jJkgCrQILv7bxGaruS2QPxgOnigviuxBGB6x5gVrzG62LFNJGe1p7UjJxMorqrWq1uBGtw687oc1yEtsIrZIibx6AQsg9eduz3yulBuKrzv2JnNYNZoR9ymtdeNz9n5RDqjvrkAQ0W3WQ0EVQHlCV5YUck7IjgW+SN9cdtuqYPKOfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ayYhov2S2FhgBf6h2aTAseRP/uqX8wu3P57Ct2s1z0s=; b=WlrL56cr3tEDe3HbQudNI2EMIeK5MawfzVkaHCT7JjxWasUwO1SGgdJ+4G/xXAPfqpMbNdnS7uD19xXapvd2M7b/9seNDdXWsdhXJV86J/JUVyKdCja6/yPgo9SXBtyRilGZe9EvIZsEZmdASxdB+4qIVdKAjjczKBLfKCgiofY= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:20 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:20 +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 04/18] scsi: target: iscsit/isert: Alloc per conn cmd counter Date: Thu, 9 Mar 2023 16:32:58 -0600 Message-Id: <20230309223312.94595-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0232.namprd03.prod.outlook.com (2603:10b6:5:3ba::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_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 38d15fc9-cc12-4000-d267-08db20ee4933 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vFtTHe1y/dLGmAjVwDOI9jx0JU0Or//TtcR7CtG03A1MwkrE2ZBTeBj+v4O3waqbnmTR/mrBARPLVowXlpgj8tYVLL70BoM40yEHZopgy/WiKg23IvDrz03P1VE9ziUEuN1cKuArK67XvKwBhA6rAjAKA/uxc49QFdY/pcKuk+carKD2+4B6CY1UaUcncCKtT0FMZvmPiJFjxxbbob2p3qfjAndwLo265ocDn247brHneNH02E1ZT335guMB0kqFI/Z+Ej9wI+BiVlULyYz9IkBe3MYGRdTJ+giyWNTQD/nk29iIQR9NpDbljDXhNpQkHlQTXm1Qh2AtwPS/38Gj2ad8KrhwkKJD5VdKigqumdzyKRYIzQVVKfSxu02Xuy9GOJOhNn2sf/nJ+Wy2FzCFvmbEH/ZvJrxc7sJdNBEoe8I87a/veMnwnJsp7P/HOmv4uUu2FG0rUMaFVSWtCPmTBDikkGWXurh/79MzkRMsS7AcNb3nDVCqdtWx0iUMO9TsBaB+5Lqe7F/KSz3LodeLGkC0ktkwffX+vS2i036VfJvE2+cvq3XV/ifMQVmV31s0ADIDlZbfflQ3sYaEPcBOEzErVX1O5otw1v79Eh9gL+PPiQUu4WtTOsLPz0g+LoLnWqCKt+34XmsS/VNxPugGXg== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YfECem1VYWaqnVEUxF9FOsOx0JIqrbkYwpmLecrzJFxTX+8e4vdbewmz+KjTASWn71ZpEsys0V2Ht9AsbeHNmTZ1pvZ6QtMtWHpHUz3YL4RkRmn8ImwalU+3qiyDfdvN0v8FYsdNljaay4C9/cF8myaEQ6/ohWj8gQkEvuDskvKHL6GTZ876vlhh9rupnO5dH31vUFjNuFYJ9aDHC43zjAlsSTuV4CkYgzW0y1Abl/m7CZ5UQC7NoP0XbwzxpfH/idUDe/d24uygjOOxEDWhNrRMssBUiqh2TXroU9YvwdmfHD33O4dfwDJjyI3VtpcgpIYf3mgfd3AjyUnPKoIS7FbWjqq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SuRxuIRPsrPu1PnAwHPHcpEGLgu+xLc+CkIl1NaPipe1+TSpIpFL/HbENBkDZu9N0J5aeWxBgZc+SS3RDwxitM4sjJCm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38d15fc9-cc12-4000-d267-08db20ee4933 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:20.6745 (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: 150n2tunD5XOyJi9RIlfqYYGcl6D5JA68mzwhDkqqG3S13vBplaJo6LWKWEVbCJVzjTbG18VWD266kjEuP0UfEVNyWcJr8+lgQatvMpZY/s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: -aWt9eIy2J3kKCk5hUrxj3W9KlzM7K_K X-Proofpoint-ORIG-GUID: -aWt9eIy2J3kKCk5hUrxj3W9KlzM7K_K 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 Thu Mar 9 22:32:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168427 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 18B9CC74A5B for ; Thu, 9 Mar 2023 22:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231338AbjCIWdn (ORCPT ); Thu, 9 Mar 2023 17:33:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbjCIWdj (ORCPT ); Thu, 9 Mar 2023 17:33:39 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BDF9B7D9F; Thu, 9 Mar 2023 14:33:38 -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 329LxOND007024; Thu, 9 Mar 2023 22:33: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=1LK8xLuUsUctIph6VpQLPS4P3rEq5fOSKGhU+2oH3c8=; b=g10YNZbrT1+NvxZ/CchzgM05yIkA8truaey4fHXow+1ub5DlBLOmbAQvACLatVvrauJH H9EJy2RAfMu23bsWWw9D5jhb30La3lM14y+DeTTD85fmWXoyR2w72z5w10AjABi+Oyld Frcqet3vFaqUUEVRVAb4uNPBQyyE1lw6Qcr7HM0/Hix13JlkDqUh/wH889jp8cgtJAS8 AuI5i2pjsulF8w3FK/bcbzqnADyKd3X3x+1sZtvtzz+W7SiilV73opi/P8cYhxPk84Ek xChhZWiYCodPPW1GPYMy+H/SsaCIHCn5XqJsQ2T1nedQAssu+MwEGr56CbKJLgUZWFOI 2A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41623wtr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:29 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86G007359; Thu, 9 Mar 2023 22:33:28 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VWTN+VmpE2MJFAjDP+55BU8MQPZk5XvKkkO/yzdWM1DGrsn8u94O+DodWYyXSvzJeR3jGAu4SvIpFRUWf1dquPd4OPPmAPK3o6fkN718t1FPYyO4bAiKISF58pQ9EmZpQg9SxCm6lfujPLU89DddqkVaVPC4BsYn+zwPCbRthehuYh8rzbt7eG4uFMeaQzpjIKZMRXvwrSFQSxD4lw4jazhAQU8v+GHtywunFPyOhqTxjXxxAd3sZ/tPaEQcvjQ/UoSEyFQgCsVH49tyP21WjXVmABll/1TkoFBPfE1OCmsZO9PX8me8NhErsjLtuEndsfwMGEqJ/Uehup7uBbpW0A== 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=1LK8xLuUsUctIph6VpQLPS4P3rEq5fOSKGhU+2oH3c8=; b=WKrMex6AYHlBoJmpqNomrypiUgI6Cd7XS0WgwLV76fefyZwezWsSjoMwU8kKoCW0cMM9/WJvkC4mmhhG1dGrQLXKNkyHAgVazuLPVU+TPegEDMOk7djk9FETrJoJnBMFQ+nKhL0XbfRtMt1LLqXu54sUzsW8/jEcMRj39fMON6L2slesBYKsHYbyGuxTTXpJcyVxX8qH5oypfEpzNE1LcMO7Hzn6MXGLADZCPRpsab6yPfGAY3sJ2NybPKdUZSNC9QrOs3+z04ugREcm3QsnZRaHJXFjXSZi832ZAS+bP6Quu6mJ+K57ETRqupfndJJPW1ISMHaVTt1xO5UFDuJbTw== 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=1LK8xLuUsUctIph6VpQLPS4P3rEq5fOSKGhU+2oH3c8=; b=MaynjHCH3wJz054uD05lbMtliObAhheVOt1YgBOv7J0TE/n/+nAaikt0IeWfIIeJbeDclXoTur+lzMu+XSbppOd+k9QvDD5ur7mwWRCvjAPHnBksz2cLwg/UBi/t+uh4IR2yT0MeQTH6nCE6kvvJbSpczivL9LRdyFn5YGvPPkM= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:22 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:22 +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 05/18] scsi: target: iscsit: stop/wait on cmds during conn close Date: Thu, 9 Mar 2023 16:32:59 -0600 Message-Id: <20230309223312.94595-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0237.namprd03.prod.outlook.com (2603:10b6:5:3ba::32) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 171d8a04-47ec-4dd8-d434-08db20ee4a3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B3vZDAonJf+bSUBpsN5a1UIxsURrMmqhwL7Ai0yUqLsVTcca21kXmVCFjSghzvzmRAkzzW+wePYKSxpl4gC25Lou2SpDPNotkBzJRRbQ3scLwcHmd8viK/tC5n/VenbyhfBbt7VPDVrqpGpV+6u7chB8Sn8nI2TJh/mhbwf0ed2Tucb4OzmnFz1sYDT2GKQ9tFZggIA/PQFgSXaRtZDSMwRraN44RN+RRLPihjkg7ko8gQfyw7U5PxXn2EiOYrI6Eb0fSvkswfS9QglUIjGCi0GhC4RQ9komWI3xSMBXvGgJHeHtXOEfKqJv1WmXLgjNABPV2/kl8E9k5ESZq2u7nz+EdjRHrP2CTGyps6As/NMb3cJXKTwQFQnTNAn4SuJMCPG2FJh+8xUnF/DfSmlgyhcffyzBR4ha+iWwXHehTfZRlFqsZ0Wqe7h9apONc9o3kUCLQ/ShQJYbmHyDRklhw5rIfZ/A049C0cFgCBDQJyMK2Y26N7ZeADKhbebMex629Rk2Tx/w7zcTCGaPiapEbIcuEzIQAlklLwQWkuTF0FMne1vJ/N2PZgwoIus2CVXdgZfbcy2zWuxLnnBGGU7ekw5xpcsMG6l2YLXy11NDv72rw/bMVy4Suh1IaPOC4ZuM++mWL6HDkT+g2eMUvQOC3Q== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4kAooDQPocAJbHk6M7OFvraw+5PGAqDCRcIN0zRnUJWHUsRYb1wk8yVA4HvsVT20iVnPUJMtCO95MDdAwhn1e2i0EfqpnSHkbUrnSpcPpJKc+vCSap733+YDLZkAVYIMV40y1hMhH1axMY4vLLu2LBnzCdKOd9B0Xi+Udqmf/w8MuiQg52sFPrpOL8UvCBmDOVt5W9+NML0Jpt18vsUJRwK9C7ReG2AuozjstOwxpMwDOmwEbweT4WzaUFnCb5C+jP3qfJovsukUI3EOtrAhwEzxZYzxX3oIBwQSf4WL393fyDZyHJSZzpMR2KMxEJdxI4ffPbgTCCsL7hMLVDDF4T+8KUP3RUX3R5lEF+IKK/762LXqYnhHoi5zuY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BaovKOIjgo7GTFGYMYwemfcfU7F69c68gVANTjJOaLyDPspFiMzCoXr4yOkgd6t065YWPuHatvD8i4EsRsHtJLOwSXF4u/pV7jLVBKVIMp4/wqIAgq4kTaexTlSOfm77hVDsVkmXS3rTHQocYRZDKFcLnFnLgmHkpbX1RR5K0IEg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9qhU1LoI+tbvhkZ3L3N5cbEu+dfboF3GUugNaVP7iuFjJAgMHrmfG9gXvQVPvoye+TtH+687GtM3vGw8NVJGpr77eeUJn45dFIB7fgSk4sJV3dQIcJ7esczx0iDuJlgvXRBMYc18CIsLrT3DtVCQsEf5c+i/DMn5UX/i4hLDhkl7X09SsERuBPuHotnxrXxdgpdkCp+ZNIQrpMFzoeIe6xFqVda4F+iqy+CQfA8qfsi4PWTe1GTwcE9KQERRBbtJ9FUKOSWjNC3iC9DmyLjez5xKwraMLc3djTCQ/zwltXfSRIR7Bv0gj3BrehJHm35UcQ7N8eyyiJaimsXop2Iksgiy1c08T9JNfkCYSqG5ceQOZly011BPEkmQpoW3PwwMQXu7aYqJRt6yV8DraMYbFUxgfSub1DBBixO2FL5NwERptiVY+ml2uELMWZzRhgTraaZJYkylFxqglX+ci9zXvK0g7kmSzcD+pZB78LPPipX/Eoxyn3/yp7ldXJEkhqajvSE2mD6BaPYX6hMsrDINZEsRT03V7VmltpE4A9lOOUTn21rabGUa1pk0fBUb/c08acPrOa6HJOLDHX8sF4co/j0AB9qyXrq7NM+CK+I/LzeCi8Scj0/Ptc7YNRdA7OY2rzXjCN3Bpi69Yao3LNYfKB+dydL+d9JGGLmG4a+CozcNCHmKojzNSc5CHgUmpcF8YdZeAUWcsLvfiN6oidhU7cd6BHx4h+iZlciEViUQMjyG2gZ0UqbtfFf0hS9ERGo15t/myu3jRIod9DIzncgQjXrTgzXY+YNfX09EgD1l3g2diZNwbfCIGstuB0tVesH3Kfqee9A+UOY0YoHsq6Qm7z7VCb+1jdB1XAR5b6QJLnKOPuKXmJ2hTRMAkvk5oQdu X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 171d8a04-47ec-4dd8-d434-08db20ee4a3e X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:22.4556 (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: WOnYli1NIk20n59JCBmTuyZrVn/4Njk86aUVSD3T3+SaABVrd8ztVzsP28LnnPReGD3kDGg68eW+gNqhHWSVAKOvFpRGANHnngwn1m+V18k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: HGixoQrZ7lsY8ZEhQkBsmvmY8e1pLfpp X-Proofpoint-ORIG-GUID: HGixoQrZ7lsY8ZEhQkBsmvmY8e1pLfpp 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 Thu Mar 9 22:33:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168426 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 BF1F4C6FD1F for ; Thu, 9 Mar 2023 22:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjCIWdl (ORCPT ); Thu, 9 Mar 2023 17:33:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230383AbjCIWdj (ORCPT ); Thu, 9 Mar 2023 17:33:39 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EAC9D1AC8; Thu, 9 Mar 2023 14:33:38 -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 329Lx1Dp003653; Thu, 9 Mar 2023 22:33: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=YuHy7KwdY7sUY8P65m7iELRED/67+tmk9KbqQ/9mSk4=; b=PEeyHHtMg4AKM53nXoQIrNKaCPOwd+eeHXUoKXFwY3vRH5XvfToxuklbXxraiRR63wvp VaTaCgxgTC/nOZW375ApzZHxDQCglTWJU+kwJQLXfSDEKNJ9IedqAgsViLXq+bVd8mF2 KQ4kiSvpVMTcsITPmgqbZhk6uh2+p7PxVy3yCM5UxfHPzpDaxgeBa1IbnjYMdrk1do3P jUcTVFvoZK5sxO4wN/tR/vXqEfFGOe6Yagar5mW3zLcvx2mzxcHliqKizdZNJzYNkLJm A0UNMeWuuIvLUMvXsofHuy26hw7EZ14RNVU89MwxR8B0pLMWsPT5YDX3IS/t1pzuBzsg tw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wv203-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:29 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86H007359; Thu, 9 Mar 2023 22:33:28 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A6OVuBNYDYn9SGodCxSW8m+PbAnLc01pqpmi5Q1OQZFnjUVkEFS49HXj4SjGyrNK2IANWtxDRuuPUs8eHI1oF9UmeMPa7da42mx0BqSv6Q189ndQdJnWU2T1IGmKX59BRrLc8aetkeoqU9MuY4Zp+Blh0m6T9TBvFlsIS99dMeU75HuSsXBd4ivt0Ac2IcRoOFlrj9pkN9cBsqvmVHKGo+QBbpAjP9+Rx0+w5x7ZM6jBDb8jkbwomMZXUV1O6HtXhj1uEKCBDULz3+2FWiJu1FQF5QIzYpzyyElN82I85HyLn+bxDJFP0YZlJCZF0A3Yfzn+gEj0hJtQQPhpfS95FA== 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=YuHy7KwdY7sUY8P65m7iELRED/67+tmk9KbqQ/9mSk4=; b=ZtLG38sy3WWNk+xDQS72hcLTa3aJeHyeVyppH0ylTUaUMSTg/ILFBp377VmMruELk7ZnQ9yaHZKj0O4zLxkXKIWoW6JaNKGcFYWFAp5uSCQGwm7pCNYmYFiRqPnenpKz9awRTFvlM4BVxU5YJUXXTnO2eQm4fLDpMXH102ixz/3f9g8O9zHK+rZFaaGJ5i93HzJfCI26VjsoZU4mQas+/Zt09gQT+KYmsVxAxY4tA9ldij5OpD0iByyPGI4FUZfNoXuNZb35U5lbWNGsIrldWV7+clGUexgpiLfyIN28Ot/ImuHyKJFyScbtmY6su2vU6n109BHfXLxT3eJ1Zlg+6Q== 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=YuHy7KwdY7sUY8P65m7iELRED/67+tmk9KbqQ/9mSk4=; b=IRXy5U/4zbnhCXdadgPqA3bVIjsG4hzV4FiVonmXnDE9xeIljG/QWQXuXIvVny1TEnFMB6F58UhlkVekUueGfQfgMqeUddeZHFvxsilZjy9MFtHODVgpW4FMpP2Ro0p2ymyNTLVVfEI3dx3W47JFE2jf23PiI8D5CS3FofujGnc= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:23 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:23 +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 06/18] scsi: target: Drop t_state_lock use in compare_and_write_post Date: Thu, 9 Mar 2023 16:33:00 -0600 Message-Id: <20230309223312.94595-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR21CA0005.namprd21.prod.outlook.com (2603:10b6:5:174::15) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 77869d30-ae08-4214-3e95-08db20ee4aef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aOpKWlAot3WgvYpvN65FnqZaeI2NZ4m5TFm4fWzqiqjdVzxYznouMNRVfo3a7TZc0gDKErewOFPzIQtF+HGvO0+D8b3TZg4IwQnvUP11bYuafs/mDwX0gNka9XKn2zWtQvSM2ZqOjG+k7fTV2FuYHEgd1HMRG/u9+ymG33T88qUQ2hFpeNYuzbzqMjbn9iOANRerq0H5fdICbTfWki0zr7veIPYMz1YEkmfgSeE1WtVegOiFdUPxhvswL01FsJ/O4MdDmn46+M2DnXPsgcS1wBGi9l2zPGZmok87nbYm4X8t5f0I0ovCP7hNJ2Tk8D/QIeb8JJ+8e47DFSPAAFUY2J96RqYSoUiZ2Lf5QXir6/7FxoanuzmwzwDdLeAaGyD8B6Wxj7VqX+uQOU1dRYs1QOD7n+2Gka2cc58Hzg1lNzySY+qqPAeJEhsyi9lFs2Y1+L5dF8EZRlJ3YEGAmNKOEduBM/kiEb9E1iuUk0noUv0fyAea+gLM74opNnn/qV2pmvsV7ypURPCYUhBxOM6S2wZJPT12f0IYX29UjonZ7JpVfXaajfVapasPUCWoP9DZAaBrEPHkrb44I2+Ag1QQzdOyqlhMBPBBX4mLJ0SzNpj0tUn3BK3CabHmilkG1XoeIiwKZjYSt7DeREBtK3JOhQ== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qXJiLM0UTB1PbBnx/5ZGvRI6Fi/WSwaEPT5tJkORVtrKQh5X4Psc6QdbFg+2OTbeYUqOejvBCJpECiwaL9X+j0B3vXZ3uYJnQBxGkdCRLpsagGc+3zUxXQuVsdI7NEYADEKiVX6DLgyEKhPFCbh9+XMjL0Zyzg+SoUzLLzsfYCZNy2BSiFtPxdreEBU/FZU3hnTTx7qlGtnnzfFSbqp3AfbU926+dDTxA5b0+A8zaQfP4EuSWL3l4ShloD/9MEh2qMzSTYz/R5T7t31kVRKfhZtfaiYRIT2sEMDI3w2gTbop5WQ/Q1wkQVikG3YVatg0yCizVlqvY5PoewfNRy80VoT/Gz4d75mJ0eUy524U0Mcvz991llt1jVwKfzvWVROuOhdlr1qBx5bMYKpT9WPyCh45whar6fyStbPfHGgvxNW8DCWV9llkDbaskx2LaFDUXFZKSgGNjtfzJA5IC5hVwFqnA9Kzm4YCX0vXn9HxIy3fB02J6OOwFXOLURUNpu2tCYjdIDe86v81renYtIBbzmTWS1k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== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rS3u7MUNVV5qDt6UP8WBcxlqwcSClKeat5OGUT+gEOxNEU3UlcKDrAbiyY/fYnls6018t7zfGMUSrPL17OP48tHro3ZhyCtVuyAJ+nYArsaSqF2zEsp9z7IRMbJIdcEhiFU5ldUJSzOHPBBWMyf+wCR3ApLz9pUmoGrsJOHfKPhJN54JKXaRaP/5VcgsCcAYJ+1OkK1W4up2MsmQ4XmfkWZHSETWbo5DRALcE5XuSyW/4cM/g5zIPykNgPxMhgzz2TyA7rmC/LEI2XCy9dEDdFRyAwnoMGkVDIh+Y01xcRT/lGgdhVfwcdhKGJPMu28LCaEiaA427oesOUnCdiC1NpyP1FsDQlptS8I3dKULLyLIIzXiy00/wFpmXt/cClAlMbz0b7CTYQeZRi6orlwTyXsjm7c7TdDL/fLrxfPX9qgbLrYnyByxzemzIuJRHdRyw1Kgkv7cLOgjCS5qw8n7Bbu8b0FvGdoIpbw8HKdyQ3mOR2n+B8ab6wi6CA1nrKnoBkx6dj9J1V/3y/mYUbtyeBDD+bdV1O31MzPz/AAtvrRXf0pbXzoajNyu31vtdfJ+huHhPYvHxxQnKRweXNLIYJrXfVpTVPZOxe8QteX3LT6xck9ibwkcHn9kZSvEl2PnwOeVROFqY0Z6hegKs/XU6EMQOveYAWfDC48n39ho+eBCbJ1C3jLkxEDAafNrGaxaCbukeUMOTCVhR8bS0l49oyhbOj5v+DWBNlUeNQpR0rZwQXg7mX8qwAMPV9s9jmWMqFMtgT+32fCrNztbcxLMRou167WZgTfTWbBkWD5gxpCY8XGxfVWvGfuwerhJvCP1fqkFRqVffvyfQWJe1rcUlK3xDaP+ZZoU72i0ptOVcw/pdKc3TThpI4Ru0GctCG6q X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77869d30-ae08-4214-3e95-08db20ee4aef X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:23.5805 (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: AzQntKeP1nSNYL0wuTUD1vtJy33Ho5AMWImyjHt5Gjgu2Qi8BXsvLXCgnRzkJOcylmMnu/yY9Ytplu9KDxXdNuTBdc+BREx8an3sRyOJtLw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: Jn1fx70ntKaSa-0FYWA6s2TlKrAbMDjT X-Proofpoint-ORIG-GUID: Jn1fx70ntKaSa-0FYWA6s2TlKrAbMDjT 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 Thu Mar 9 22:33:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168437 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 628DAC61DA4 for ; Thu, 9 Mar 2023 22:34:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231432AbjCIWeR (ORCPT ); Thu, 9 Mar 2023 17:34:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbjCIWeF (ORCPT ); Thu, 9 Mar 2023 17:34:05 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51BB5E2503; Thu, 9 Mar 2023 14:33:51 -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 329LwpQb026384; Thu, 9 Mar 2023 22:33: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=hfMoiu+lZ0BV8kkTEIEtnhK4hdFmkp5P2iTT08J2NxY=; b=mlLgGw6XDkjZDdS4vker+SWIzo6sIaS7j1G/j9gbMz58WNqOerEwu0LDQWM02EUWmqu3 rrCdOwEitUFDzziEciKSHoisxadB7q6JMlw6Tlw7Zsg5jhD4p/dR5sVWAnbhmEBMgCcv e4egJKil4rE54xRro5stvWL3Q/m8Mga6bQ9gjPMwRDO1MGj3/Fjog202SzdqhO2RU+FA DdYbWzDiMYJ2RgLHnD3t08KE2/dA9Kvdg1ijbwUbPGvv8dPzoiFsx72VFDS33vMWy1X6 oQQz17cACPupQTgVW3wRIESaIBQG8LRdvFDBC3ZZ73puiubxlEONtbB1cq74V6rkfDUg oA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p415j43ef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:29 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86I007359; Thu, 9 Mar 2023 22:33:29 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKg2j4ES6x+xzf42xCi3qKUKMyL2GIDeWzk2Y36Rvyn3e6VNt9jZYFuhw/k/OHZOSHWGubLEW82ODJRM1Ly6DOG7dbRzpPg49FnemQEXMxhC+trwjLs48vNbPFgztelngYe/WslOqac6CMBmGeIPtuNvcSDsuF7sOWMKNQrWqggntTvgbaetjZqjtZ5/dcNlThK97IPKIArk0yuCMZULJNS1j3pBilOjmf1krXsc42JvmMiO1YDyZif/5yuAHv75Xd/GcAXcwMB7G7+IVejnfT4wfPvzlnvr/Oq8bsa446mcb9E6rV80+ZcEWWM1OtpgDXrIBwm0KRwniCQvT8pDUA== 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=hfMoiu+lZ0BV8kkTEIEtnhK4hdFmkp5P2iTT08J2NxY=; b=HeD4M2EC2dt7ZEbYgJXRH4Yq03OC/ior5PmMrZM7S7nm65j0LeIG3jeAxEjpmjJSusPqSbAKH7iDTsrsph9Pko2LaJ3pluM+e6LJRFD1bHctzkoWYdqk6MMW1p6B6MEyk2Md4qy9NPQ/KVBO6HyRt4dm3UDhiJ0hZS9tQ5wfllvavQX/VKXKnD9Dl4ZWfQPtsdhjImd0+O6Immjz0qNeHpbL04tLrJojroze6lVeVvtJt1o+05pi2gxvbGqdh7lHI9uJKhEYWGtiHYDnnEQDV6Dv4w37+OcivIUlGG+fLH7h1L4q3ObyMp5iA32z4E0d3VBIyGS5P7rINPnFzmmH/A== 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=hfMoiu+lZ0BV8kkTEIEtnhK4hdFmkp5P2iTT08J2NxY=; b=Hs6by4XCXTVP5RBJ+csECpX/GJoAePsBZF+OIW4aa3kYgqI8hBxqqfM/XuvVF4f8892ozcgvvTAwLRr2EyZ8Xbk+R9fX6YbaF5NCnOfgJJQYyx4nNADc9a+4hmX2PK41ZPWX6yrEsOOSQTLxW08fLVyBpdVwmmo7Renlk+DPrEw= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:24 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:24 +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 07/18] scsi: target: Treat CMD_T_FABRIC_STOP like CMD_T_STOP Date: Thu, 9 Mar 2023 16:33:01 -0600 Message-Id: <20230309223312.94595-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0037.namprd03.prod.outlook.com (2603:10b6:5:100::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_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 4540be1c-4cea-4421-46a4-08db20ee4b9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NEF/1AcV8kxBnP7mBYEMrzSDezVGHjhTc7KThaRoB88LlT1TVofKbDwzeIELnhe9ByYiMTbt1m2BcmPQoTssBZre2k7MXvpZrix2e1E5NYb3tBzVTUisKPBEMUGb7mDj4erfotSN/PfHNNXqbLsksroJm9Uy0iOYRRcwyJ4st9CEJOwUfEWQT8eISIi8bXajNtCKJ06fJM8zez5y8WuhzJZFQMCQknemTWL1S0sEGU8i0Aa0/mkie3+4Ob++S20XXaOyNlD6opxNWsqlB55NU+1e0zjM+l3nuPR1ty65M/218MPTJxWwLZDdlAkezhtMj5jL7+kPNSnoQdQLMJ4XY3iZmHiDSLToi8zFghc3BMVTwYeQqxLHJDZqeG9XkfB+iD4N1sJnAvwmZ7m5A1S6TXb/Kwt/O46d0gfGFwo/8v3RFGNrhiBUgddjn/eX1LasKGGmU7yIyUXR83tG3oTVD+0dbazS9d/Loz2oiqU+ze6pKPvCu8m0HGjipcTTe14UD+wLCz2nSiT0BxyJxz7wVgS0NF/dtqmH2yQc3HqqdW6ezkGZQNb7zaQPtlx8nAP+sDzv1lYdF952nEfg1XqiwzYs3D4ov7BAgZWmQjG3i6kDo6lyGaFYCDLf1dheI5dEX4xXzFySR2Adf/APdYNz3Q== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-M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fJvBhbjZNY6+9qgBOPejD+Iq+qIN95b9JDDQvjfZP0N1LXXO6zcbYVJiza57Bt8XTUSxiNs1+PTI82sUpwWmgUHup/VJRfklQhIrs+Er1qwTlRjmkLMphfD3liAN9i4gNMDE78mtfQC5ARXhGthmgv1IHY97r50/acbXvMhjRw7dz4Vd3mdtjGUgGjkpofYJBYfky2OHT4pU4RIiF/oRAPkPNL0ANEPwnjIFGEOUOQMlaiUL87ujX+u/otU1biK25RPCFHYYPZj9MiEvs9GDwZYpLRjmJWEK0f6pGAgVpSsfQEw9QZv7vSIzPZKCvl5+/4gNv9Bha7Eap5ngMVCmZeAfSYGu5mgy5XEsF8hPQyGpWZAUuVPYhSU/dQy5bMaZPvbvjo5KTcDUsyJQ/fnvpg46w X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4540be1c-4cea-4421-46a4-08db20ee4b9d X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:24.7367 (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: svFhL/qkI2GLZ1HYowGyrX/QtdoYfxhj0gF/UVEEDW75y/odH1vahZALZRfUYVqOqyAXiHchTT5SXPqhiJ5ORpUE5OCLzgUzP99AmxzQr+4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: 6PVY67tFoYlZF9eoDUcZz-GSQ1iSr1Og X-Proofpoint-ORIG-GUID: 6PVY67tFoYlZF9eoDUcZz-GSQ1iSr1Og 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 Thu Mar 9 22:33:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168424 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 E9E6FC74A44 for ; Thu, 9 Mar 2023 22:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbjCIWdk (ORCPT ); Thu, 9 Mar 2023 17:33:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbjCIWdi (ORCPT ); Thu, 9 Mar 2023 17:33:38 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5481BD7BA; Thu, 9 Mar 2023 14:33:37 -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 329Lx1Zs003614; Thu, 9 Mar 2023 22:33:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=8xcfLDWPaMgVcdlQrYif1pqD/aCtCDC6qLNcL5HiL/c=; b=StPUlqwRzjZJEQix/eG9vo2fNYHiAjpl+CoVo5WY7Yx1aGhFbW7PJc1Owazzd+ENiR1D JxlJNphoW7/F1M1agMCbiyrqgl5GSy1U/6/grrSWv3d2Dq2bHULSLK0MyE1wxrOB7dAD SoksEqqk0wNq9jDAShI4YWAJX5KgSXdL+dWrTeuwHcLX3uh2JF1nGKMmmhBOvkZkzdiH vXTPGNHz4g7s5O5pThwAGJP1SlcRmOhdiaDNjnJbv1MXYAakmgXeJ634/oWK7YIiKvGe +kQm13sDSsC4bVzzT/FLqUrW7PQ9WpnmKLBxK7H4ni3vkOaek5t8JkTCUGG+qpkVGbsX qA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wv205-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:30 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86J007359; Thu, 9 Mar 2023 22:33:29 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHpUCEH7gYqY6OO1ZvmNmNI93hi5RYX3R3yBb7I3mWk2+mcuwJV7P1qqbqlb8WMcDf+5wi5qaquvBOSI5sskoGmRjvK00Wvp2B0sCBK5/IvExyBoFR/y9ELdm6+STHsBdK4zM6JBLWtBJKZL9kLDoq6bC3SCEHvEy/OP/vumY+rxKjFswek6j3d5TrlJjzNukADVPzBk7tmhZ2wrbag4hmDEc9XL3JOedwHrTtONLwWymZ8FdL9C/GqvHhhC6SCNx3TXxs9/dsk2QaoxhjiqtfSGnBLiqaGbrZXSIx+FvNl7rAD2SG3HAIKqP+kIaEujY8GJiKdzi4MG/JVZgLrrLw== 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=8xcfLDWPaMgVcdlQrYif1pqD/aCtCDC6qLNcL5HiL/c=; b=mpFhvw5IzewoB6+m+zUrApAHmRCXET7F6Cpm/eU6+a3ayqhv0rDQItcijjv4g4kT0gprRo+A8qV4U8vdhDWgqigzF/0t2PMJinY3qecCPX/yFcBu2jY039odpH41LyC7eDhfc/S+ZrlLOwBy80nff6hQuhRzxlZgZPLDyA/RLAvU8gUb3AZ7GCrVTXcUWVaUYGCGqb2qlKuuhn5sDeefbjajnCt3HHzCHdUNfxDHz+QEq20MArWfDK4qBJLwFStlZ+ckWoEX6zgVlm3WIPPX38TLJL/wHodxjyaBxM23HyjxmGSbR8mxOsLp2ugNETjNYMAtq7Ne8li8q04k1Vwpeg== 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=8xcfLDWPaMgVcdlQrYif1pqD/aCtCDC6qLNcL5HiL/c=; b=LVqOpC3bG2ci0uUQzr85ycXl8Gx29kgZ8KQ275dRqndOrHJQRTbGGQnVIqxdSbs+u5utRzoGBPxJOfuTWfQ2QqjZsNWzOK6JgNRM0+gdbi6kc3Kgo3TJsoBLZRMORyjRsvrNO7NERezzyZkuMFuZJpVNOlYxzDlEUY2sKVqjBfE= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:26 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:25 +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 08/18] scsi: target: iscsit: Add helper to check when cmd has failed Date: Thu, 9 Mar 2023 16:33:02 -0600 Message-Id: <20230309223312.94595-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0056.namprd03.prod.outlook.com (2603:10b6:5:100::33) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 12d69d48-87c8-45bf-4ebc-08db20ee4c4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kmi6HS5DNQ0PPLFzt0V9rq/IhoCuah40V2dv2aHJJFvFnjXKLEyRvpZkWd6G2cPDOPMjUAT4bOeFdw6/mHt3TvZQ7JT+z681OM/wzWfqnxeWYlCZx+sWUTV/4f7oOsjaTf9RnKt4mN9A3VK73pEtjhAIbfUG2QSp3HBS0T9YmpdUsMT+aAmSlbdi90E6HY8o2mv7x29+NL0EmfbcEQJAoEjQIhrL/1tgQCemRfugN0Q/XSNdfFXFNeqpyykMd2SVrtu75nJy1pTghmTUm11cwFwYoCOCbuNNldm6iOUPi4C7FeKBKHBsAyh3TO5Ssu0VpU2gO847qvpXyCSWbLdv9twsLuCXLGF2+HogMl/+iYNUhQmyArrSv7DYP5+iG0WEzNp/6yo6XkQP6OljlsfQnFPiikA04H2xsuIAQ6w3ug7ixh8FkMMRezG4osJV4/U99t9uP2bXhlIxh0lMzCnXf9KGQDePR6bQdRHekQ9UiLqPgCl6gNSYmd8vpdy0ililQu46VlLF4ZQ54gXquwMKCX70jG4PjVbq5cLwaK9X72g/MmTmeFwyb3EMpZNxelzRm58K2dihEu+W5uJH0kivzUJNpXZ2c4uhObKfLjgL0+Z/WYKFhKThSwkP73nuaDyD1ZmKta3J4hgVoaQLsKRTjw== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KIf05ZEt1A8KVdKpmXg0MEzV7WVvA6EUFFl+nO1HJxS+gVL2pM5WebtnbBaOsY2Q16jnxmbJWwNCQ0HosYb3Y6En8x4PDOZAJlkADwKuN/2E4D5sOkZNcSJluyotX7iq/uzP2DXUjshC6ntQtDPq0Bnb3guoX1DSKELTO1bTaYmLNt/8TvnhnjghZSwi8iqUG8Sr2k5vzG4EcP+V5XD/WOw6MzCoShQFlGejBtbScHVlObDhAbg9YtCIExP8J58AO1gwdraTPe+bS1fFbG83Xflx0MUMsvQOD8GHSxKhvfqcAFI2wRsPFHkWJhbT5vm1xFMz+aIHvYSh1y7EpGLlJ5m2JUUEbV9qTNjQKtlQMk1poUkrMUPHDGuejvR1TS1llXg1oxKtDO9z5EvxQ9CFIHMt7uWQ7gB0Oiz9kNx4+0uLk98QOceInStydfd9O+2bs0JKJmoXpj6WJR7jzyN+QaohDB9oBwcAlnWo0npsCCArk4CGt9bGnBAAvCY86kcSNi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TM/LfeGtkPHrvTmEBskxT7JqcHMxwc402clcw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: RZq7iVtmMIrAiE3pBZqP6s7pHd/d2mW3+8psZdMMZEBOla9KmoG/7kDKZ5T+gfsn3BuCli4uf3R0WWRDC3vZj0Q+xWAy2XUiM4argEtGaj/ZnnkRgC9YCqVLb4ykf/KzkC5U8wM/gldPKdx0YfsdVB+jy5KPxjYNM1HhdZvitGkn6ZlQuSgMN4LcP10BaDqQQkQ8ldcv0WVMK17byBIbZgUvw/FZ9cuVhfpBtIPT9SNPplIVsyDgbZArKkJu6bHLlNVTrEEpVDGNPZInXeUUpKEB2xKZmvD35qOlfc9ji+5Me9TVDX1hKS3m30vLgtTIHlJ0ZQgbnDnCqGOyebOyULvOwxY7SzDWR9h4SjbqcVUxyCdPImmSZ1NGg4x2+Wvkb4hOFuMT6QW1J0qGJx1+ikabH3UEVYZMjQSc3QBdv+BExCaM+0t2ZztQzTgaf8odEeosETBjS8RlRo0nnUSPYwQxIBfnW68HUvOpUjU6+d6QjP2jbc0SMPyihG7PWAiMXbYylqa96QI6/38CXZEawUT2Qndx/JSp3kbqdRceJaaGn9RAfBCcucikLhizOnmxllk0YoF/Bzi1bEsYdp4RyLk+2AKZKPc4sC8QFbSi+wEdD9iVeuVTE0K8qpm1yd7Q2BQ48ViW4qnc5L37SIpEBOs7ycvoNddakZCTdX96510fcl8ijRVsm0lfbxqvDzQIcOjGXuBmj1MreG0GL+P7Fb94AEV6OAU8+c1m9pz57w+cgcJc2Ye2/X5aUoqTdojAaAHaxYXhQX6tG3bikEBoRklqp0HyYplh2w2aRJBbeTcd684L0mYKMNBGBYfr1qOc9e5uHGkGUaUfpCiMEHklE1BoCrgC+ZoZWXaAmSJUsb1VeUdt1Ykp7/zYr7wsgOcy X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12d69d48-87c8-45bf-4ebc-08db20ee4c4b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:25.8772 (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: WtZfMBgG/+fxgs8MEYy28oxMuCWBZzSyVtQYS1jLSkPa5lKrvvMZJR5eZ4PfwQswA3GFJXrFwxwSuUqPNpCcP+EiobkvrpvJnlFtyYiKsJY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: -gv4vnasYUF-2bLjfXUb2t-Rv1swdyjn X-Proofpoint-ORIG-GUID: -gv4vnasYUF-2bLjfXUb2t-Rv1swdyjn 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 Thu Mar 9 22:33:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168431 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 9402CC64EC4 for ; Thu, 9 Mar 2023 22:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231411AbjCIWeH (ORCPT ); Thu, 9 Mar 2023 17:34:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230395AbjCIWds (ORCPT ); Thu, 9 Mar 2023 17:33:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDFB3F31F7; Thu, 9 Mar 2023 14:33:46 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 329LwtCn018103; Thu, 9 Mar 2023 22:33: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=TFJzELSchRUQEtTBbwjLGxNY4rLxL7TqMFkQgj20msc=; b=lZtyqaC1y0GVB6ofHxphazjOw4hIsYRyLzxvDOqrpJ72sQ0byDLvdRDV1pwqfkYrvL31 V6cNqPi4ZiW6aHwku9eL/m5Od0OOw6HY94aTKx3l6WYp+b8eay1qisoGvht1NFIaIEz1 /zNKas3JdeAvwmBKlSBOD5Kw0OJkcKb+caEMmRCrOEECXHArv57F/9qmu8rM3IWdqMPj VcEj/580YNsk3wEc0vqloHK7C53Bl1uRAhIDV37tOQAu0W+8UMXwKV6mlg9ncNRNu/y2 +tLVfeDz0uaj6Apt4va8zuHzfvNGygFAupowYLU5uJ6q1E5AWXV+wnI9Skyv7S2RJPKy 2g== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4168v15k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:30 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Kf86L007359; Thu, 9 Mar 2023 22:33:30 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g4hw9r6-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JTgpQeu6Xcv4xUBN3xg0/7CynJxz9nWuMgNtANNzd0yb2j8SZwEkWBzCd07uE1bCC2D1YPYss00nfQgAjgoLXhcrR/PK9c6sHrVcm1BqaVS3KjkEYKZOKV1KM/CtwBDJlM5ZVgB46jB/SbQoSJ8Ed66WG+3tn5c0kQhv08h/FMO07oxb6Q/QJA3XY5K19EH7sRs9K/br0jX6xZ/e2deNak16kI+jcPeGXr+yfsiYLSkSmhfWnw5JRz+h9uiaO2zGaf8WT+ns0zBjkmly4qPkClNElFd7FQDBomVUvrBd3IazBYz7Vyh4fKU+SSyB+29f3+3BgDM8VmxDoEbNjFgysg== 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=TFJzELSchRUQEtTBbwjLGxNY4rLxL7TqMFkQgj20msc=; b=RVS6o7XwU7F+Wf3+visRMb+/ALdSTcTRZROKVQywumB8SpL775P+LtcOXLrTnVZajR6eal67C/T4BoS2ld0ej6LV1p9pgB9O/WyNS10AGM+OfEb2FbksAewswOD9x+mVGcpwXz3L8lzfifhOdvlyV2Nk8pzN+UkEDs7609q+kG66SIwxqiE/KyTYWEJwdIvKzDgXVocChXmARkJzr81p7+GokaYIhQ6+UkkKtAbyjuuns+sA/P7+KEts95PtE1wsOe4/uPoJN/A0Sbx7wLrQ/3FlJ4axaym2tU2OwgE4GbJCmhDP3jzDw/2zmlpRZ3NthJsHo3o6PvGivpA4JS86hA== 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=TFJzELSchRUQEtTBbwjLGxNY4rLxL7TqMFkQgj20msc=; b=IkgS7EdmLP/uemYluJgPfGWE8rjrFdr3cFCbYWp/7hLyrfKi+wrem9kcczvFcgeRmZYxRDR0LeeTV316x0233daqmXClQoafRfZ3jGS8FcL9OAaiQ6Q7vtZPME4+3+OfxMd8XJf/YqoiJk3Y4XYMlQ0evf3EUmyKa7LIO4Tp4UI= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:27 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33: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 09/18] scsi: target: iscsit: Cleanup isert commands at conn closure Date: Thu, 9 Mar 2023 16:33:03 -0600 Message-Id: <20230309223312.94595-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0040.namprd03.prod.outlook.com (2603:10b6:5:100::17) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 1aa19ba4-96f9-46fc-c75d-08db20ee4d4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VE5SQzL+WKtXuiHCHWtLaCcwuFr5pXU6qp3TABPstbGKzj1daF3LwxpA8N/VYq5OHbKHw28WaqkK3fE2UdQ97uaXpZWLF1Dv6XY4WP9RNupwJ8u2r+ucFs83+Av4Kh/FhJ+qrYZ6MxHzszLYlosERvI8SoPo0aSBALItUC4eel7DnYm8j4puAPoc35FpJ2I7UfuKjs5mMwtqH+5ww5nJk1smULj+IUi1z3yOZi3W7Mx+A9B+BvDl0zIuvuIMaSEi9yeYYoHBXWoSIHUS825tduNJ+7r/zdxpn6fXt6js9AIPaWJYknuMgpGGdq9xSVvzpDd4YA4C/+0aKkWz6x+v92RrBW0CKCXaqJdkt8mtXlVpkoALJUEBav1Ggs5wlmIfGYjHGTZah+os+GkHWbQAxaXScgr10/8nH99f4tjp81ZpconldkL68LUHfneif6HfAjvkV22orSeib+FRghwOJ89pP47Lpcq6OUbdhUTSoq+V0Tye3L/lva27f69E7X0Erm1AsSPkE/QmhE2QNiFJ9snfUC0vLSHEPKqZmwZp+c0gwJwrIJHE4nh3vYIC/V6jlASN44eY5cWHxBqV1IAowhAxXOfDDFvjpNfrDQirkGjyWolGTMAJ/DuQI7/dLdLoFyhE3CtPRBAI+TBWuR4vwQ== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wQPlj+UYc9t/CilarTsOpQBT//u4UEtcjbI/AlAAx4cL/pe/MxfSjvI2uCkLgXyMObIGc8yGNEJdJW9aS6V1X70ZI+y6Ha1hkKwQcf+yvN7HRoIO0tdsALZRe01pGO3wLeIhyFL6y9JVpumW1OK37fa8PYg514mx9/NqjxF//jgC/vtGfLqIqF2wryciXA7zbBcu0g0YWByE9v0oFYUYg2bOruT/s01QRYIh/FToVjiZQUgok3F/81ySbPsv1gSrFZ8u1cYavQ7jPTZ3tKThQsI//ast9dElCePVXPoylZFfqIYBt1vmyEIypZ9gsuX772UytGnRE7ZFAjm3NwoclCi1WfnFbF4eWoF/vAjUlP+ORrLQd6PYx1xtzYSLfuHLFltZ2qfs0dfeJdWp8l6QLK8Dil7lP0lXL7jqX/9oLYetM/8y+lQu0BN+KZwqAcR+CAfjy5UFk0IHD05xWHrwhH6sdV8zH4BOXFBV3ivF8QxmyyIZR8QtnpQEoT+rT/kP/qXjCwNURLucgsQmjpzj/iSOsJ+VavDQIy8EYcPsqMYG6uyo25+/LF9fbfq4TQOnkRQagq3Wa7EldkY3IgD0hvXpOddBhYhPIyhtGy7maUdgL+kt4TkrMFJvOR0HNRQkY0gXA5KqgvS88eBoslj0MqtCabghWnCQBQRYIVNLWwDJ8lQg7VKfHg2y7Fz84aGPPU6JVmpHRoy0s7h43M5BTNfyk7ziH/AVx70bBLtSDA8p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8ZQwcF2YI581Gf0v+Fz3PtKCMora0Si6VBQ2bB/V8u1M9vgf01/3cbT0piG6gObVH5tv1ERPDVDp3CXS8C8v7RqeHNpxz70D00SowBWzQvADrWTl+ukj2iiKoGOVUNL7G2oyX/Npkg4YGIM8xot8tcbIUJGWZ9xaop8G0zcLqEgTYRKmNc9yG0+RclNrTmaAgHjTx3SgRsMhS+Kkv/SMCtxBf63kMvyjlHnRnh+CLI/Kgf3Xo4z1jLI6UfVw7E3i3SJbxeBVtzj22Pb8JQdnF/6/nW+3Gg8kraF0v2IPzWixYayvMYewwnxXIKswPh037HGGGPKOsG9MzF2q6+pS88SrgYVi5qzJc03Xa/fvl6nL/C2USL7tMSCF0o+xlC/17iViXJsTB/SapynNXoONCBkD/Yu80P9fl7AcH5aEey5InQlB0+Efc/dZzjVMBDqYL89TJ4QOWWWN+tgaiIOBoRaFJCfqsJ6OXBBEf5d2HghhoIo/YMYO2fci3NpBvDaLJcciANVsscs1oYUlHx6rv6D40VUDexg1ipMu5Trg9pxZs84IS3HOpe+D1UPikBAj/j8ngTWmUapn4k940hy15/78zt8SwkahoyT8tZi0hlFXrv3AK1vODIHBGjkKAUKCDOMNK73N3MIS6fukSlfC2KYex78Wwh+c3z/DgoDw1MjPMEDmZmyZawepbv/R634SB8ekSWlaFds3Ej2JXDfNn+nRzbp2EzYaPIneDrGt70SC20BrT3sAoL/X X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa19ba4-96f9-46fc-c75d-08db20ee4d4c X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:27.5489 (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: fZ9z3dNU7DXYTiPt8CbXIJsFyQ1t/fo0e6VIlDUTBOYA/RpheYxfdXBCM2VLN42NLYFgu4rjgwY8YsRRyHtH7t2vnpTa8hUIVPLoNEg4tdA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: hz9FeliLDVP1DDRxliR-16srGA8SJ7DV X-Proofpoint-ORIG-GUID: hz9FeliLDVP1DDRxliR-16srGA8SJ7DV 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 83b007141229..2e9c0d7b36a9 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4230,6 +4230,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; } @@ -4242,19 +4251,27 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) list_del_init(&cmd->i_conn_node); iscsit_increment_maxcmdsn(cmd, sess); + /* + * Free cmds that: + * 1. we have not got acks for. + * 2. are (or will be when the backend completes them) stuck + * on the response/immediate queue (failed cmds, TMRs, iscsi + * reqs). + * 3. completed ok on the backend, but hit the CMD_T_FABRIC_STOP + * or CMD_T_STOP checks. + */ iscsit_free_cmd(cmd, true); - } /* - * Wait on commands that were cleaned up via the aborted_task path. - * LLDs that implement iscsit_wait_conn will already have waited for - * commands. + * We need to wait: + * 1. for commands that are being cleaned up via the aborted_task path. + * 2. for isert we need to wait for iscsit_queue_status calls + * that posted a response after the ib_drain_qp call returned but + * have not yet called isert_send_done. */ - if (!conn->conn_transport->iscsit_wait_conn) { - target_stop_cmd_counter(conn->cmd_cnt); - target_wait_for_cmds(conn->cmd_cnt); - } + target_stop_cmd_counter(conn->cmd_cnt); + target_wait_for_cmds(conn->cmd_cnt); } static void iscsit_stop_timers_for_cmds( diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 26dc8ed3045b..b0d7d6c73a1c 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -753,7 +753,13 @@ void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown) if (se_cmd) { rc = transport_generic_free_cmd(se_cmd, shutdown); if (!rc && shutdown && se_cmd->se_sess) { - __iscsit_free_cmd(cmd, shutdown); + struct iscsit_conn *conn = cmd->conn; + /* + * The command wasn't aborted via ABORT_TASK but didn't + * reach the driver so allow it to cleanup resources + * now. + */ + conn->conn_transport->iscsit_aborted_task(conn, cmd); target_put_sess_cmd(se_cmd); } } else { From patchwork Thu Mar 9 22:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168428 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 2D2E3C64EC4 for ; Thu, 9 Mar 2023 22:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231374AbjCIWdo (ORCPT ); Thu, 9 Mar 2023 17:33:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbjCIWdn (ORCPT ); Thu, 9 Mar 2023 17:33:43 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BB2DF726; Thu, 9 Mar 2023 14:33:42 -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 329LwxSw005714; Thu, 9 Mar 2023 22:33:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=aFXKQNdrId13GoG7UREjkr3Tj6ozNjhBWIoR+bux/NE=; b=MWUB2t7x6U39tP1mCxO3LnDVkqCPLuvh8CfzPOOWuy0Lh673yzUvstC5z2d2b1rYICfB MWuF1izhbJx+F3tkC3jH4vy099GHXBxyA8/VBTS92UkZkYMKvsqiRHN2AtCen5oJ8sgw yE+NS67hPrN/tqlIiPhvv2qF4YTbO/Juz/ehTXn7yfbY5jjY9QSA6V+7yBAtxvSQYtOg nDpOT7KJKBgWySXuKCuGhhWPiOE/HiFWrV2EcZjZw/JZRp0/q5ULDVVDJocUCZ8DY8+t VX2Xx9rmBDRBIRcSTm3e9+8H/mNOS73j6hlBWk2qzc9mB8W0B0N0fORIbFtj9jnaxl/+ fg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41623wu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:33 +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 329LmFdc036440; Thu, 9 Mar 2023 22:33:31 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g47nhaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0nG42FfOux+vDJB2bYZYNgbe8VH0griq8ehIAarAbh+oU5paRsX7kRlVtHgIeFgClQgKh54OHSxhapjWo5JTS7OxDS5DhQkMjqCNf5y/YYJMDFnr4gpE1HlJlArkM+sQmVQvczn83BWYpe1lStrLWU+mdljDPOBkLLULNkjoA6EOVFGgSdDf1J9bK5Z/CfigmV99hVwArHrLLNjv1gKCeZ4CeCxq2v6UhIp70SEjgdGl9jVwPoE03gUgNLDMi71YZ2y3NTCrA8kbGj1wwGnh/klEIBPSkiGtqAxHmtbG3xa/fBPgWDMIbJk0Jz8WuVu3PFNaLRVLpZfbXN+URGaig== 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=aFXKQNdrId13GoG7UREjkr3Tj6ozNjhBWIoR+bux/NE=; b=NK2+QXzok8BBA1b1Ze1/G545p+w/Wo/WuANpjSgz+pk0JxwjTFTqe2nWzeHDNhLOfcmLdzo+2WL1itAEYF1cvnLMuGazzGm9jv4Z5GW+rxPEIzLi/AFS+7t6qGXEeTe+mgIl41Nkaz56/S1TspNEbJhqMeljUgj7Jhbve2vOfytubZkr92Pa+dfBYCtYCFgeuvND9BRdonD3dw1AJJ/cq+sv73iDQexktZHOE9NXbHsbaTn2OtoszBcpAONF0KKjWDeIX82KIH74lrhWI75Ekz4GNWXviOiOL1G+0zj1mwWO6Ky4CfpTluHYMkXKfq8m7R8Z9KwoPqCwew2OPRkiwA== 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=aFXKQNdrId13GoG7UREjkr3Tj6ozNjhBWIoR+bux/NE=; b=scBm1uYfa3cjwaYv2zOOaaOpvU9S1nWoDJ2g/jk7+aoH8ffrg41NMdbjmguUoLTMJiFQfDu3MKM0mD+KYL5iykXeR+ZdwWKAmFF9GsqLuHkidmvzwVG5BK/9Jc9VurpGasiR09H9qER7lnQWuPfaIGEL5XUgKagrdKUjbLij9Jw= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:29 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33: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 10/18] IB/isert: Fix hang in target_wait_for_cmds Date: Thu, 9 Mar 2023 16:33:04 -0600 Message-Id: <20230309223312.94595-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0045.namprd03.prod.outlook.com (2603:10b6:5:100::22) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 700b11b0-ac75-455a-1712-08db20ee4e66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1Flpr89ftPjsfEWC7HeyULcWlnm9T1EJjHgUp0T90qBcaFTMw7GcY5+/AltNtNQyydhQIJbM/Tu9iwjrmtBwzRcCzx9ozzyRSBBdJ6Cuw1luuEuLIABARKEwn36uUkC2Syj547ypDfyyabMq8ok06RQvYCu6zRcv2InNzpXQWkiD8q1NjoY120c3uV8GY0ogo9/sy9P/5DKM32EywIZMNVkngGeTmaPcEfd96bamqM1ljimqzvKap5C99xbCsC6ggAx17GgcTKYlBh9GsCuOjLnT7NlalA67SCbIw1Gj57YcBx6HDM1b9OHQ8DOyk/3Mnu1ci1qV7ho11khxixeuljkzzq8ppwHu3R06KFumrB385ekfhSKpWcOSjpkO4zSI0RJ9vC2iQM9VVnqTCBRLaiH21oip2AFcFxMunTFS953yOjPgurJY9nwK5RwCPEC5MeXrorpCQYZy+Ty5zv7CVx3LhUANgAyBVVp4dLl03oVdr2RTvZrSxRi8Bmpq0AfFgm51JPiX2GYYIp5W2RTV7kOVTmDVreLts3Dyp9J9nuhKVTxded63MLFDbIaJaiMLxyRUO3o8L6mEvb9zTIBf6pySGQ0jMv0TRZV2RECwhqLN3iJGtUj4rb4VWKRiwFZy94opLXSDsD1zNljPFERf6w== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U45La/9jbnRH+cAJTqHhbJeumXUDcGe89G6X0SA56/Ufc3XWoiact+OYX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A6fk8ni8i+fm8OWngFCLkrBd6zQQOJkZfFF1T/y7HVl9CUGhXLv8S3HWN/GXT6Yg1pdsODYQmElMilCAsEWhPtcUmeBtTr9goCJ1kL7uYGPBI6PfYhh1uPm1IY0uTtAPdyehGlEoelOReqfiFRy4ayWTXuqWy3iJ2XNiiKM/61+7J4ZPUYdqIRX6v+S4r/IG7mo8ofPJHxAl1y6+zK6tuByKq7+oNu/FlhjzotokLBfRAhY57dgeAX8BWpbE+x8zzCNCMVZdLN0+V7JWq+AihS2iZXjOkyaX8J68nJd0ATzoFFAZGyN7ixonQ0SD4GdUc7lm4WUutGAnOITYKeP/8lY7aaEF9d8D82UqXVvX+C/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 700b11b0-ac75-455a-1712-08db20ee4e66 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:29.4394 (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: sws4/dm1mNstEAH7OskWR3RhvaDv49W9QjMbUs0bn0yzqP2kFy/GwcHxECQyHAV1GMa20b5fQAgoYGYGbxWB7EB4+obgeYutNgBnhZNQJ3M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: _NFUM-tS8PJUsonuamFUJEze1Wa-tmh6 X-Proofpoint-ORIG-GUID: _NFUM-tS8PJUsonuamFUJEze1Wa-tmh6 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 Thu Mar 9 22:33:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168436 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 83923C64EC4 for ; Thu, 9 Mar 2023 22:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbjCIWeQ (ORCPT ); Thu, 9 Mar 2023 17:34:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjCIWeF (ORCPT ); Thu, 9 Mar 2023 17:34:05 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18FBF4010; Thu, 9 Mar 2023 14:33:49 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 329Lwt4U021591; Thu, 9 Mar 2023 22:33:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=bRemT9/AY9I+Ye4JFKI3Em6dmfbYBI59cUNld/i/EVE=; b=i+eSbak3FhVGGVD5HGwok71kuWYYyenys8zZ/y7hTaZzPWrw+nSiEU35B+ukR9hImb5K k6xLWfUtgj2uVzWqdiWj0k12X0zeM1vpqjjwQj5JX6+cH9yva/I3QKm4h1x3QYdsCEZz GZnojKuq+j1WRLr3iWP/0wyE9Pa9EyGZi7agBSZpmyGomTIKiNlF7T+Q5OG4jU78yKA/ crPYZ8yytfLlvXuin8exZpN4Wn+4AjzgHpSxYp0qzgpbx2hyOKgTrRI6RQjtx7v2l2G4 /r4dJBTbOze0pwhJ4YUtjLnDUbbB7ltRr/WT8mTgUcKfa49kaQEMjLIMn8kMTVCFeD5l gg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41813uxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:32 +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 329LmFde036440; Thu, 9 Mar 2023 22:33:32 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g47nhaj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ncCJYyPcECXwuHr15m5/zrHsRpBJZiN/JVmZyU9yFeWYwJCg5oP8+voLl9yn43dINDXKzNqU8V62iPC4nEXkMxc54hDiANPeOs194HZw6KU+MmxFbcZd8YWB2Mc6t9Ezwdb4Y7i+q5DfKN9i7mNIgzcB/NN2qxIIB6I1zzpjQhAzbzZk1EQCU6dqsiz3KbNWeJYgoPItVgR2lKmyFUATcafWiSQf491pcIdA97Q1vLgsyztFOOkMXTUPJ8NSZE0y6RcRTLWoyBIbCuQOPpqDcV0q1mu6uC9Zo7H9dAP3/C5mRL3lnEUSFPxcSS+ik8UBMSuQLePFf1dJuXljP3Dn3g== 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=bRemT9/AY9I+Ye4JFKI3Em6dmfbYBI59cUNld/i/EVE=; b=d+82sT0Up+ivyXMxEf2rg/ExYdJo2r/5Y036neBsnEkGMr+sPr5/WekmrJoRpjM05UrtgU1E51E7uTMQQTDSEY5yV+XOXONJpwUppnfe4G6QwaqUm/mhyyO9xhbcEm/DlPOGvK9BHLD1q4+xXC6Ye1US57ckI5sy1yXgRyyvVOo3j+AWzIO8FxXFvbbwAicts6VTQm3qLv3gED4JSBol+U1B1B5XF+aXlVAVuYofbz76Zmx3UCOabj8cGh73k6sAuPwca5ZfgDSqyMrLgSfGvA+7xVFtSQPxEjBrkfkHDKVs6YaZ09UI2ZqHO4etjrSxg/b6xkuoNlfu/FpxhlCG+A== 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=bRemT9/AY9I+Ye4JFKI3Em6dmfbYBI59cUNld/i/EVE=; b=EmQpnd4uaT1WOe7JYFgh3jqTe76GbdEg0AGx7G7GVbbQAUQTe53tU59D90odnpgP0uVmfsZofs7is2cxKmDr39GrwXwfhpVk2yWe8Qz6/EdPLCWmeFpQ7qYZ9Ht0dC4304yyGnhJTJWtDDgWBCoPwMMwMTDdw+arPzywAbFJ0Nw= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:30 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33: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 11/18] IB/isert: Fix use after free during conn cleanup Date: Thu, 9 Mar 2023 16:33:05 -0600 Message-Id: <20230309223312.94595-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0055.namprd03.prod.outlook.com (2603:10b6:5:100::32) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: e94df0cf-3c40-4b21-4612-08db20ee4f1b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DxTnQsngryZKUukEZFO/+0bYXhB6CALjy6n293b8dHf0mcORHwVVoLKAbInvZxzUw+ZahOCaATJEuGw5v9J7yUDUNyDR++kM+LVW50uQtMqzJkDBrAhplsSuCn1Vw5Qqj8+FCq18csITYoEbV8fKtskpiZ7czD3wJaai+ZhkXcMXqkswbaddlhxj3DUeff/ETMhtT2UHba5cxl06AZs1pgdsS8RhyfdggLrv4GSKj7kVBSP4knoyNynBLjkPYPMvbhlw0MVW4L1yJXOAlqkngZMvec+AXxqm+9o3G4POW4QmPIxucMELtpEVj+Yprkd+vyR47gGQDCObC2GKRKVRZC8jvETE4hNsx7PCm7d4duR1Hmzh96xPhpHIGbh6Xsr6EqEn5jPymqj38ZKvLSL8Xwc9BUThEtydCtUj10rReQMjEpadTDm4qGnrYSgymuxI6PDDhbKSpkC25KmHD0qiukHB3tXvgv4uaEuvhkGqlF2q9LD6E72qY/bJbc+Vqr4lTyHDKeOhj7IYP42iXsJgjvjjSa6YXWueMbud0zfQ2f+Z6i5O/M96tE7mjWbmhi4tZgwn1W9kH835KmSRnJt7ifJTQVMWGf8qLoDRu/KeDYbkZy2a3EbPwty0gvwWTFV8gQK3aHa/KTVcPRAgZWSxiA== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: srpHxT6w906atXhoyyUcl0VJa7H7Yh9lBuhmKFF/6MY4WahiylbkuBqMrFz2Gdr24f5JYuJn2+dNVYaRTFqjjq5Jt1kghYIRLL+dVa9Gx/q0AbAAq+W8cZpePIaKIVQI+pUfi8Ldm6sMUEGVD8sdtOQDJ+NpkT6m+40dqP4SbZIIr5ZJccF0tADjWoYceh/SVy4qaCjprGSVg9yGbbHd4AJCP6/rjbyLchZs+V2179ZcialWtE3v3+M57G+gudmyGVSxRMXgJLK/UJyNyJ5DbZ+hPR0/qNvMkPDecfPosn5g0DZmEadPm3CWpnp5sm7y3jiLKLRj863uGnHYD5syes66BTJ/IOKYVtifQXc2S8zqjzurNj73B+z77QMNBE4Tm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PnGd/A4ECy6R8WxvZ6aH0AxZl4y6Usy5lgZfR0ckdwoSE5bZVHRluDNMKO9gb1XqnIp X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e94df0cf-3c40-4b21-4612-08db20ee4f1b X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:30.5956 (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: RqkMEDz+hH1NnDx5yq2l1csDR80GxGal55pufdNO96np4QCtZaiO8mEJbZauk//kPq/4d4XORXP1HDUJ1e1WQRYtf+Zue8VXu//O+rIFxHk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-ORIG-GUID: F267OsLxrQv6kv_WYcsGDFAClA2NKu8j X-Proofpoint-GUID: F267OsLxrQv6kv_WYcsGDFAClA2NKu8j 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 Reviewed-by: Sagi Grimberg --- 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 Thu Mar 9 22:33:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168429 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 47531C61DA4 for ; Thu, 9 Mar 2023 22:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231375AbjCIWeF (ORCPT ); Thu, 9 Mar 2023 17:34:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbjCIWdr (ORCPT ); Thu, 9 Mar 2023 17:33:47 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F69AE190D; Thu, 9 Mar 2023 14:33:45 -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 329Lxdax014203; Thu, 9 Mar 2023 22:33:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=T0ZFWsIIIYlq1z3p2EKUZTbxUrsbjFhpoba9Q3GZwgw=; b=I0GuwcjcnkvpqifwJZA0ZLd6SplvKHpVsUtaitTneMIvpwjrDOGENpJjET3QH+WM7vls Xgx2K+Cf60eda+KWLzIDnpnbUGaWcZhSJe5C4XgTj3LCnE7vDU2HYoTf7LZC9qYLqha7 tQn7tqZr2PPwZNfywQMAxP+u+PgbC+zQHZKggV9TSC9VlAcxl254tAt4In8lOdcUAKyL APLEI62l4IRWHQcSV2+NesDAMMVXP6UJuy4f8EIZgtF0YnV5aFciNXOnvkkf1rVWg/sA fw54ipRDl2U+OkcI0cSJGVRM39zs76gMqz73kcS/djpPAkLsi1vyKrL0j6e/b1M4mIBX fg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p418y436m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:35 +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 329M78Pd020848; Thu, 9 Mar 2023 22:33:34 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fua4rge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ftioIQMI+WR/E1Nq7NiytqQSHpq5iOzK1P7xsKCowwjTnEolw/soFXKhQTBn7IeWCw/3AApWyCAUdtD1Hg1murAof7E5nA+o5Clqgfg+w9T06VwhUKeoVV+0kYjk3k3EdaUviURrtH6I0vpnv42Pb45Gz4LrDBrNpiQExEFPNCVHFUJxmOTAFEbNMWXypMjubCJI8R4mGg2UYsMZID06BwpH41oZdnx5INVW3R2nqgnnR83A8i3MKuPlzhl62Df0pVrN2CA35JPoQLjzZCaRU1mE9AqWSo0f4H3jwK8CflgC96T7eXkPue+2RYI98ca/Fi6r5MB6JDp/eqPClj/Inw== 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=T0ZFWsIIIYlq1z3p2EKUZTbxUrsbjFhpoba9Q3GZwgw=; b=ZZsUuE5A3Cid4wpy+UfMxKAEhCkO9qgfCtpXfe4b7LwgWn703rUP4xjAyFc5OIpiMbGpIAkE4ksMQglf9DJTr/xMHzgVhDxq9Q2se7yShVpy9d8WW3pVjAdRw1XHt7NT6cjyqPbbXMOcgMi/JNKZ6OiO/YxasiFbSo7gq7F32Tr09w6HUlvOqDLuoOMbfC5W83/PPpn9SxvSpcVRwuUSoFytTxu8XDcWI15UUU0WfrvtZqz/2p2gtbO7rL9EbNKLTxah70PbyZgUw7RxW0x33Nx7wMfzJvCghS44qGC5pRTRo0W7AKdk39KkP4YhieZBsOV9feO+wC729UqRlwAjqA== 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=T0ZFWsIIIYlq1z3p2EKUZTbxUrsbjFhpoba9Q3GZwgw=; b=gF2ZpHEE2SfnXV3/64S4lFpnhZkQ67AOMIUgZjU/zcgpnG96iY/VAcr7g395de4cEfY+UpwhoLazOpt0jdhc2OZdxRkUZyo1Dxb1TeuTJ/fI5G7s6yOorFoG+1SHfuqpGMP1ovaUW6fukevtCsdpTdCpYzFNsUpwhebNY62iC7A= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:32 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33: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 12/18] scsi: target: iscsit: free cmds before session free Date: Thu, 9 Mar 2023 16:33:06 -0600 Message-Id: <20230309223312.94595-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0054.namprd03.prod.outlook.com (2603:10b6:5:100::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_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: c0001b87-9347-405e-ae5c-08db20ee4fea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mu1I19GBNFplHhdVFRqazlMXerI+bReIafMU9kEwPEks97E5zqc7urKCX41afY/LVKNO3C4ZKFidX1+nZhLoq5R1cLzmdNy5KBhRQEVB+5Ccg27uwLYfo+c9lnOQvFVkPWFWleaG4eLcY9CdNetzxZ/Z3cFPbOBNHzvIRnxQZ3ifcdoyBLY9Bq1XAjbtgGiuhPDygotaY3z4hjbQpxK30S8fsJwXN3ufmYMOXjhkBMdVVLFyDmP0TACLWI0bXY4HUu6sygI0+3canIB4oNW0drK9Um7S79PcRHgxPvXrej3jH7oChmgoisXJQUvb4XKbHIDNY9tlPFYYI9Zm+3Q/mI4N9CAIi9/EqPCVxZ38pFNwaAWiAsW1x5O+NIqJG4JsEf1p+4OmNHWPbXFjfWSdmDwwNXUyg5Cypqzp3e8ljrVk5NwF08wT7O/PxqXzfFNvCjPz/nDcNZcTD7XrNrePvcIKhRUSV9jFf7YlWgzL9joLU8wjiGzvYcpWiNiQY0kZS6JPNw2X39mNwjTSP6mQA2Q74fUjeYr/f6uHo3zrwCCPQrPwrYMnc2ld/00YDN2wqO82ymaZAN2XHFIqCIGgoxoEKPJI2dY/qIvZpLyHutVKOYCPQ78ZG4Hz9E9wpqGpayjP9KUAUg8+VQbqgAHT3A== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(54906003)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FwQ1ToksX9XnqG9KWe4boW1gZE30mVu3Yf4nenMzG9W4c5W4I00dNsmateERKBr4yRjinBEygazM5lIv3TTDOuI1YCpwG+3OKJ9lpQSIieE5/ulP9ZR9LUXBYMmdGaT5ao9fX4xVuCaZe0bqTLY2OtvHhgTB0DTOvIcL+CqsJv0aIw0My8Zz/YmJs9THBkcJvZoKhWFOfbTJxBZMGS0GGyR9vgYr0xoJSbFzxnqD9p5AmqycyCudi10U5Oa3tHW1+1a32/nwbHmoNkQ5OhZh0lPmUD7dqZFahcmTNvLN3vB37Xze5wMvM3vlm2+4mg72gBVM/FncOJIQX805UHRJSsxdOlKPfqxApPFol4ctwBluXsrh0l9G4sST/TNLGHg/8rhQ6RkoIfagun0R/WJp8LViumLrcvgJXwbSvi3SbinfZ8N8ZQ+7shGReOav5C+uRy69jizXOV1sFzKu97MfutpuPYfCAkvum8J/PEEYRio6KgpWS2cvfrHSYhX2gPqI8Z+dBetyClW/S56+6AU4lLS7XgL3EDQX6UMjQyAkf5c/oUgX4dIad6VMqU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MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5izjX17QxmJn8NEyx//sPNSyLpXa/HZQvmdjXVLaGrgP6FTNa38epM4fIEyze8bFjkutgHXtkij2x+5OE8GssYTLS7ZSBZMcKftYpSl0yqsUzD+kwTlEE0B/ztu6YWEGob8qqQqOb1QGOXQsBHzqFjkeKDtxZ/gNA1OrenKvN2K0szsG+bBa2rfV3+/KzpKhLzT2dpVZ5YvyBXBbyVJ0hKBCcmaXCKwE5dbceweaZ2buaJcjxkvtJLmb7tJ36lBJr92bJIT9A5nz/6R4Mi+3ZPo4l038vJDF9K4hpZVBgbk60IRj4pnWn0R34floxRK11lebzc4y5FdBH9J/SExWU0ng1WbJ+B2Zu5BRXx71ZuwvwOroEAXf+gknni33xnVgah7N1JR7QWjjkri+r5PUxVJeLvy5R9HCdHOrPaxQG0pH5q9SYbjJxynmW3G452oPlr4r1znggHFxqSVhklWovnIY/EXX+oSaa28SkldUg0bl+ioYozfr9cUzZiTMXvtrh71avE1RkGzsBtSdbY5LzRw0Uj2P4p1P5qYS3ohx5lYVby7Iy5IEHsKuqR6wmmVevoCFNIXghIEi9rOr+PWxDGGmVed/dT7QmzrGD8YLjCJJbmc9bv9/q78ATq2mWxYYMVxOYHgqoQRw2fSiojhe+L4hbRNZqoQtIWzeK+L7HpDjNKxWUB/Nx16MDAdBe5kviwSPKx5ULW14vVaOtW3NuPoUXigOPlUMBtM3FaLkuZdmgxJREoYuhVDhtgGMl75OM6722EF5N2g9+wHQ+MBVbETBg4X/IDkY2+h8WBkI5gXecgoa9c6LN81IaWKbh7ZykXQAKU+Yi6AdVv6lqDCSZj9Dcem5iBYJYsaivcFUuU31Sb6IA/n+RjFzZpTt53TkVtLWGN/C7DVpmdywO5NyAPClueFE6p+dbJ1jOmAMwts= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0001b87-9347-405e-ae5c-08db20ee4fea X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:31.9548 (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: hQKGTVmhIojy+ABN7ERof/1gnVsP+dQwM6nJylpJv8KgnwC7I8UJAbWDc2P28sx4b5ZNHCxMqKo77/LbFEY1VwCqwlcBW8v+hRGss3Ds9+s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: QCzXNn0VEMhzi-da-aAXCemrG17SGaeS X-Proofpoint-ORIG-GUID: QCzXNn0VEMhzi-da-aAXCemrG17SGaeS 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 2e9c0d7b36a9..cd9ef668a054 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4546,6 +4546,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 @@ -4569,9 +4572,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); From patchwork Thu Mar 9 22:33:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168438 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 A986BC64EC4 for ; Thu, 9 Mar 2023 22:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbjCIWeT (ORCPT ); Thu, 9 Mar 2023 17:34:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231391AbjCIWeG (ORCPT ); Thu, 9 Mar 2023 17:34:06 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586F4F4D98; Thu, 9 Mar 2023 14:33:51 -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 329Lwu0k021600; Thu, 9 Mar 2023 22:33:36 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=FEuO2chkVB8QsG+h9DSCpAFchCsFrl9T4A9jOLSVaXs=; b=E0qE1AydX8+pxu62CzXLLiy1dt904+Onfp0rpQFaW/Bup3N4P6pMU54A/u7t7YCq1FSp WXkbwjrqzOtdLl/38OUltdOzztcV4V88TitCE3aPESELeyatSt9oC1q32OmNc7FVPWTH MZYcZoEQhqPyoXFo+9cTCJxmWTyFFQatPuuQRAkPcCNoqUnzMiSRisggyHF9oix63Rfr cRz/aJ0IjMuGB84Sig2QRehkJgdaQb09vaxvEt4CwZ734yOHtTc/3G2zPW7G9d38ZSnE SYeb4PLOkNo7h3NX7maZnKYe/SpmlaMJepajemHGiJhTUxx+WAdrjUA9NP8dFokdah8C wQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p41813uy1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:36 +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 329MEWBA036526; Thu, 9 Mar 2023 22:33:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g47nhdf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bh9PKPLm805ra27y2iiZqHUStnowd/KLs6uUTYfuAoaigVS+tuaWvZ6Y1DFnijzO0g5eNWMWuLqLmYFVGz+6DIWrSqal3Q+1hZTEG/2L8MOsujUJqXMWE4My3lGdGf5QU5PWu7drfuda4fzjocVuEfdExAJ5yvpbE5bUFsAyNKl8P9x7p8Nw0RbtgXmStIsNjg1rBu8KGaCuaOttfWsLVDgSxlTTRFfyIwDCtM7mYZh6cPpbXdIwmuC23vXkvaZMr7KuGvN6KaOh19tK5EqG8eIwbUNx9r7WXUAK6GBMcYor2P9ziyq6Ji4V3WNC/3rXQxOUQ97y4SRYmKDD2uVexg== 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=FEuO2chkVB8QsG+h9DSCpAFchCsFrl9T4A9jOLSVaXs=; b=Lzq7kXEb7tQ5V1mmgcAT/bjDpnqve9SgR2aVNZ0lW8dDlZqAo5ncbP0kIUy5a62H/ueMtJgKK17Murd1nZ7mgTkOSyD/uO1qu3ey1LkGGx7f2dqRzAtULA5QADrp0PMctfONzmggiC68MjqH4Hvslc3qzu3ful06tWV+59UHozoPAWS6pXyGbS86B1sPVdclxTyO614MhMk8+vPJfTPHY2ebXYogx2ok0Wf6e/hobPxQEPAXeMkR/D+zCuR8XUi3Xzg0llBLgfEu2F2nh9bgZ0B+lhiYjMlcu/EIWZHTwfXuzBLbLIh97TsMx3iRLl0QmM/ub58E1tBtJdj7m7ZXjQ== 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=FEuO2chkVB8QsG+h9DSCpAFchCsFrl9T4A9jOLSVaXs=; b=L7tA5CwOqjsiFfs7InYCrm2oSTO8Td729IAMymY+7Gx9P36UoB8cVeJexrVZ/KokPlqBN6pwwwaaYLwirOyTVbn4UAMyZlUyl6ObPy1mffZPFEEE64YEbTef6inabmQiJb2JkUM7P/TIaitXo1SxT08Djhl6z1CvPNsWziWXmQ0= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:33 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:33 +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 13/18] scsi: target: Fix multiple LUN_RESET handling Date: Thu, 9 Mar 2023 16:33:07 -0600 Message-Id: <20230309223312.94595-14-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR05CA0065.namprd05.prod.outlook.com (2603:10b6:5:335::34) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b97d753-5eb2-47b9-edb0-08db20ee50d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zwTPidWK8VzXz7yADJq7KN6tVoqHTXcORpvEqUTFBDV/SoO66npeUeKfPz6ZqfMyJp4ont2OU6YbKMXUhZGbM0U+/OM0z3BeIjitTH5Mz5JP2rGPg2wD2EYp0RGk394DDcknh07JSad+40WIi1ErDMPnWZy7W6mBsk+1VmhRYpQwaXBMaM4MDc+HkvoskWVPJlK1OHI95UKwvKaygc8GeZld1ilGJH6xLlkxM2Px/UIE6BAl2/lCDZWh3nObfwD3lqQZhdgwsIO9cNQlEbBtucQXWqqVmdZqT68laUQU+afXqF9nTwb/nJrUFHWjWOTgmMydD6bkU8p2PiL2QxYoZDIYu6jEeT8X2ddGX97Lyxl2q7ANm+orKipveOE/n2I2gIWQpcDyby36SgOh19RLBUWVYwaE0N1/HOOBLRrUJMu8nKqko5NnsH3GgrVbn3L5pU9vkTLPtCX+tiBvF034qaiULL5CEHTQKSajs/fieCDjKfOyiEEolN+tX68c7sFP/1rlrksVY6Zg4Q07BXJoOqf8RR5SL0AmHRpH22rDIc3xA5RtPlv0TPQwWKiVgRc5PCAfa13HCw8XZ1IGpfbVOFCS6sgTLH+dUIH4ilIPv3znVebbn7vG57wS4MRW95my5KuPNeYrIVBc64rdG8HOzQ== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IJTNDbwNP/RsR+fWl/qj5l1UBOpFudu0wG1NYdPxu0ZopIiq3LPu7n8WYbVEUUIREjw2689kdU29ZlNhQlRUI2cwBUjihNCedwEsNtZFvRhnV9rzbeq2zoF1A7Nc7s36NfdX0vVrWFxZ4NO89okjGZCyzuxiIcK1cCriZFqmlgVO+3CO2o1y6x6U+Njd34wsc0NkRyV4TDZzsLIrIURyZSzlS+QOhjXVMZgqnUiu/9cJbhzeipA6HIYCdvp/tvhK5gCy1G/8xOo6+wwMa7dMWAXexOb4cpoPc58hnM6M3+OTjRioCRHhKkuX+0naOZfULKhn5Lb5EcPze4fYpaiJjDWHoekgWuUlxFTF8JuX6m+jDsGZBYWFqNHix/2XjwBzedjMloWG6waXKgI2wzcXL8aRolW8hW21h7DfrhyvsnbG2evbqx4RF0FvJjJo6JecCMcj3OOzcjs6cFnXI4yyxsEeRuxEH4hynDKlBMQJ2MxqGALjPl8JjB67JzIyQ/Bl3HuQwsz9Gci486H1xU5YwfphNeg9EY/3be6O8VK3+lCQDk6qe6SzS2ZNd29TwD6I1SZEALKnCl1hHi6Bn9OIwCCbWjuqfkds4hK/MYBYaZI3u2Dkolh+esqkK/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4XmHVdy2nDDiUuDvmvdZz3o7USV1g95spZM1WtdaQqbJXoqOpeTfo48vBNl3/SQySXu29/wKzZ2JWUd2UKLqUMUrR9SPD2gLWklNnuGVrcDHRvZF4oN6eeeFfiC6UGFUKvKXq8PCuEDrl6bPQ2YUojcMKL1ueTiBNTqDmmFQEzZZ0eL47PDJ7h7sNRB9bGjk0rX0+8CETBjI0qRlhHnM+cjPcmzAcP4tYACUyIacm2dCh6XCfXL14iA+eKyEaqnPx/kLMwt2oqSb7qH4gu62zFAuNlFZjsw/H12BWDsMuyIveseWjrU4Rf2B/UpZ6jQd0mwFXkD1EM3h2x9ngKHbht6kdNDBEMDqI5e/lSMhYUxX2KoYibVstqFZOCr2rKDhJogmeeFbIuWbmkhBSCPUpezi4s9i35hkOGx6PTTZRoGh2/Yry1Ua1nO3qIMVyF94ZvqZ112g0qkYRjGGi7XCCBz+LA4mVD+2U0SKaBLRex/V6ID+IeCrg1EqJo69Fu4pDeNgWv/dcnZbhoEGp6XiUY3UAkIZSYrgPUCvtntIa9QNcgICDfAz7gPkS39YiJFjmSgYhZx7K4pJ889ZIAMW8WKF9dmpnOzXLaFOXxzCuIjkYDO7RzURLWjhAYGch3CfzoWR8viJgeq5i0YTd3g5n2h2NicB2rs+1zuO7BdVVPPbNNvcdO/mFDEJqyWsONfPNSLig/M41a2S2LCzaKBjM8lWqZ7PCCbywWqJ+S2yziYFXV0KVHY7qwAbKE82eWL3/lrGPjCt/lAmFIEDyGQDp9/WIaIoZfymMOLtFDVUDPCc9Iua16nOAZjufNa+MJ326IA0p8G+3dRPxGpqPQpARbjQqTbfjXMNIyBzexPy+5a7Et6m7to X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b97d753-5eb2-47b9-edb0-08db20ee50d1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:33.4703 (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: Vwyt+rFXovJIHZKHHGQMIbkQ3BRL8DTarJR/kf+NStpLq9VKjvhYtdBm0eAsVjXhGYZTyCU0QuE8stcBCrXA2jhzh8Yu3+6rnFMWQbBuJZ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-ORIG-GUID: rrP4gQGhgdCUSu8-UoQDDjaCHN261Zrm X-Proofpoint-GUID: rrP4gQGhgdCUSu8-UoQDDjaCHN261Zrm 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, and also serializes the execution of LUN_RESETs and Preempt and Aborts. The latter is necessary because it turns out the commit accidentally fixed a bug where if there are 2 LUN RESETs executing they can see each other on the dev_tmr_list, put the other one on their local drain list, then end up waiting on each other resulting in a deadlock. Fixes: 51ec502a3266 ("target: Delete tmr from list before processing") Signed-off-by: Mike Christie --- drivers/target/target_core_device.c | 15 ++++++-- drivers/target/target_core_tmr.c | 15 ++++---- drivers/target/target_core_transport.c | 50 ++++++++++++++++++++++++-- include/target/target_core_base.h | 5 ++- 4 files changed, 74 insertions(+), 11 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index f6e58410ec3f..c9f75ed1566b 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -179,7 +179,16 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd) se_tmr->tmr_dev = rcu_dereference_raw(se_lun->lun_se_dev); spin_lock_irqsave(&se_tmr->tmr_dev->se_tmr_lock, flags); - list_add_tail(&se_tmr->tmr_list, &se_tmr->tmr_dev->dev_tmr_list); + switch (se_tmr->function) { + case TMR_ABORT_TASK: + list_add_tail(&se_tmr->tmr_list, + &se_tmr->tmr_dev->generic_tmr_list); + break; + case TMR_LUN_RESET: + list_add_tail(&se_tmr->tmr_list, + &se_tmr->tmr_dev->lun_reset_tmr_list); + break; + } spin_unlock_irqrestore(&se_tmr->tmr_dev->se_tmr_lock, flags); return 0; @@ -761,7 +770,8 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) dev->hba_index = hba->hba_index; INIT_LIST_HEAD(&dev->dev_sep_list); - INIT_LIST_HEAD(&dev->dev_tmr_list); + INIT_LIST_HEAD(&dev->generic_tmr_list); + INIT_LIST_HEAD(&dev->lun_reset_tmr_list); INIT_LIST_HEAD(&dev->delayed_cmd_list); INIT_LIST_HEAD(&dev->qf_cmd_list); spin_lock_init(&dev->delayed_cmd_lock); @@ -782,6 +792,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) spin_lock_init(&dev->t10_alua.lba_map_lock); INIT_WORK(&dev->delayed_cmd_work, target_do_delayed_work); + mutex_init(&dev->lun_reset_mutex); dev->t10_wwn.t10_dev = dev; /* diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 2b95b4550a63..88d2a7839876 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -184,13 +184,11 @@ static void core_tmr_drain_tmr_list( unsigned long flags; bool rc; /* - * Release all pending and outgoing TMRs aside from the received - * LUN_RESET tmr.. + * Release all pending and outgoing TMRs except for LUN_RESETS. */ 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) { + list_for_each_entry_safe(tmr_p, tmr_pp, &dev->generic_tmr_list, + tmr_list) { cmd = tmr_p->task_cmd; if (!cmd) { pr_err("Unable to locate struct se_cmd for TMR\n"); @@ -379,14 +377,19 @@ int core_tmr_lun_reset( tmr_nacl->initiatorname); } } + + /* Serialize LUN RESET TMRs and preempt and aborts */ + mutex_lock(&dev->lun_reset_mutex); + pr_debug("LUN_RESET: %s starting for [%s], tas: %d\n", (preempt_and_abort_list) ? "Preempt" : "TMR", dev->transport->name, tas); - core_tmr_drain_tmr_list(dev, tmr, preempt_and_abort_list); core_tmr_drain_state_list(dev, prout_cmd, tmr_sess, tas, preempt_and_abort_list); + mutex_unlock(&dev->lun_reset_mutex); + /* * Clear any legacy SPC-2 reservation when called during * LOGICAL UNIT RESET diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 1c23079a5d7f..3c732b1b5389 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3574,6 +3574,7 @@ static void target_tmr_work(struct work_struct *work) struct se_cmd *cmd = container_of(work, struct se_cmd, work); struct se_device *dev = cmd->se_dev; struct se_tmr_req *tmr = cmd->se_tmr_req; + bool sched_reset = false; int ret; if (cmd->transport_state & CMD_T_ABORTED) @@ -3596,6 +3597,22 @@ static void target_tmr_work(struct work_struct *work) target_dev_ua_allocate(dev, 0x29, ASCQ_29H_BUS_DEVICE_RESET_FUNCTION_OCCURRED); } + + /* + * If this is the last reset the device can be freed after we + * run transport_cmd_check_stop_to_fabric. Figure out if there + * are other resets that need to be scheduled while we know we + * have a refcount on the device. + */ + spin_lock_irq(&dev->se_tmr_lock); + if (list_first_entry(&dev->lun_reset_tmr_list, + struct se_tmr_req, tmr_list) != + list_last_entry(&dev->lun_reset_tmr_list, + struct se_tmr_req, tmr_list)) + sched_reset = true; + else + dev->dev_flags &= ~DF_RESETTING_LUN; + spin_unlock_irq(&dev->se_tmr_lock); break; case TMR_TARGET_WARM_RESET: tmr->response = TMR_FUNCTION_REJECTED; @@ -3617,15 +3634,26 @@ static void target_tmr_work(struct work_struct *work) transport_lun_remove_cmd(cmd); transport_cmd_check_stop_to_fabric(cmd); + + if (!sched_reset) + return; + + spin_lock_irq(&dev->se_tmr_lock); + tmr = list_first_entry(&dev->lun_reset_tmr_list, struct se_tmr_req, + tmr_list); + spin_unlock_irq(&dev->se_tmr_lock); + + INIT_WORK(&tmr->task_cmd->work, target_tmr_work); + schedule_work(&tmr->task_cmd->work); return; aborted: target_handle_abort(cmd); } -int transport_generic_handle_tmr( - struct se_cmd *cmd) +int transport_generic_handle_tmr(struct se_cmd *cmd) { + struct se_device *dev = cmd->se_dev; unsigned long flags; bool aborted = false; @@ -3646,8 +3674,26 @@ int transport_generic_handle_tmr( return 0; } + spin_lock_irqsave(&dev->se_tmr_lock, flags); + if (cmd->se_tmr_req->function == TMR_LUN_RESET) { + /* + * We only allow one reset to execute at a time to prevent + * one reset waiting on another, and to make sure one reset + * does not claim all the cmds causing the other reset to + * return early. + */ + if (dev->dev_flags & DF_RESETTING_LUN) { + spin_unlock_irqrestore(&dev->se_tmr_lock, flags); + goto done; + } + + dev->dev_flags |= DF_RESETTING_LUN; + } + spin_unlock_irqrestore(&dev->se_tmr_lock, flags); + INIT_WORK(&cmd->work, target_tmr_work); schedule_work(&cmd->work); +done: return 0; } EXPORT_SYMBOL(transport_generic_handle_tmr); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index bd299790e99c..0a5b51f8e5e8 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -804,6 +804,7 @@ struct se_device { #define DF_USING_UDEV_PATH 0x00000008 #define DF_USING_ALIAS 0x00000010 #define DF_READ_ONLY 0x00000020 +#define DF_RESETTING_LUN 0x00000040 u8 transport_flags; /* Physical device queue depth */ u32 queue_depth; @@ -840,7 +841,8 @@ struct se_device { /* Used for SPC-3 Persistent Reservations */ struct t10_pr_registration *dev_pr_res_holder; struct list_head dev_sep_list; - struct list_head dev_tmr_list; + struct list_head generic_tmr_list; + struct list_head lun_reset_tmr_list; struct work_struct qf_work_queue; struct work_struct delayed_cmd_work; struct list_head delayed_cmd_list; @@ -872,6 +874,7 @@ struct se_device { struct rcu_head rcu_head; int queue_cnt; struct se_device_queue *queues; + struct mutex lun_reset_mutex; }; struct target_opcode_descriptor { From patchwork Thu Mar 9 22:33:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168430 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 1E6F7C74A44 for ; Thu, 9 Mar 2023 22:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbjCIWeI (ORCPT ); Thu, 9 Mar 2023 17:34:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbjCIWds (ORCPT ); Thu, 9 Mar 2023 17:33:48 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDE7AF2C0B; Thu, 9 Mar 2023 14:33:46 -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 329LwvhV008493; Thu, 9 Mar 2023 22:33: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=0DIVFmFQcz1zt0nKytRT6G1MXFF41tAj35//gDW2lbY=; b=bpZBMzNERrXNn64SXmZNyDWpZcyBrYC+K8RfQRABn6aJBp0NGTKN1SgCo5FJhRYFtbUk owm/TZPcONJb57EnMo05tsLXHA856lhfrrv/SNS5EB0cuNRDArY3xaT+2ZmRdE806Ziv yELaER8wLrcRbJUk7e+yAGcypFRkb2GmPTy+ulC5W0qHWe5wTIfc7lfYW/sJf4W0RMkC Zji4h6hMa31e5UkIVjk4Xb84TLiMMcmm+LadOmaaZIAWGF1O2mtTgDRJowBGz7wswjpe fs380fEObU4xA/3bwVwDzHK5eXpBDS1gB40ZxFqyNpOuZiTHrVJHjp7PqzXIisBOA+fG iw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417ckyqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:37 +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 329LG3c9021722; Thu, 9 Mar 2023 22:33:37 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fraxmf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XhYB5QdcCqdSeqJXypCujwke3rxIQLtNadbBaY9vupS1Lf1ALVj27N4HJBK1JtkyeeCeczWteKtOa5d7jK7rddVPNbmJ5cDL1K7LM+5fN2o+kmoB0s9hVbVUTkSwaVgE/odASx1znih5SDFndN9SHOwv86LJMaSRe65mUsv56TwpFaHxy6VHNNjh/O+f7dIu5i83HwdA6nK6v9qB2UK/pmM54fuS+Ki33b4jP2/4JjkFMgzC7xotZioSwa0rfP4PswqAdrCQvPfkYILIGAooJ8eeJs2TF/s7TB3PSKXX4YBdN5JDvJA6sVYKa+hV6aNdehmfr38L/DdkoCoGr5+71w== 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=0DIVFmFQcz1zt0nKytRT6G1MXFF41tAj35//gDW2lbY=; b=AzzuwhqEWKg5TrGjy7pCfDrF4kfRshl91DlMMCUKrfrWoJmNHzxFNIc7a6Kz2eMriYpVvAyXdK+6Zpbm0wkwjnGFZMspafD3ZD26eRHr+BH+h/vNlj6eIJow3UzyMHvHpigT9MAZvBbGdbHwPb2n8zIP2+Hh2giIO6he8i2e3KSfgqpWl5AMOllmoBVUNu+5suFUJiHWVWt61c1NVoSt7KNx2XfFuL8FYXN2C2/op5USbLVhJSgDjmQLMIbW1pU5zEUShx+o8bML10TfkYkoRWNShFUKS8nxzfje2wOVDVG2crER101ycVqbV1iW1V34quQZG3f3qc7yhnDmw5u6xw== 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=0DIVFmFQcz1zt0nKytRT6G1MXFF41tAj35//gDW2lbY=; b=JP3gJH4BnIBorT7qoZUWaK/7RpSZOwE8n6+QKiE758O3BI9Z4mNkFAU69TlZMS1E4O2G98PchsFJ0fJ3xWXtYAyebqMiXH9BxDaLxRWcV6RobzGG6S1w/uKFVIzgEfYnKPTY6v2IcQhPrjTA0g5ZiRjxBk0g9e4wRlbjux0CV+o= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by PH8PR10MB6479.namprd10.prod.outlook.com (2603:10b6:510:22d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Thu, 9 Mar 2023 22:33:35 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:35 +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 14/18] scsi: target: Don't set CMD_T_FABRIC_STOP for aborted tasks Date: Thu, 9 Mar 2023 16:33:08 -0600 Message-Id: <20230309223312.94595-15-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0002.namprd03.prod.outlook.com (2603:10b6:5:40::15) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|PH8PR10MB6479:EE_ X-MS-Office365-Filtering-Correlation-Id: 07583769-e02a-4274-b426-08db20ee51e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2mWey6G3i23wprwc7ryrP16ubRSlgkJYs4iBEM6drAmnxplgyqalUV7ZuO/kUtGjGLT0naiZ/vu4OpDGsEA8wc5q2kROuU0MMfwB+Zlg14oKfEXheUcKcVennregNA4mAJgOAqj2pL2qbz+a9iJpVgMs2+FKWdUFQ0xQvz4blfGeu7BaUbsJMW+QbeST57PaixCP+/0G4rQvXlfmaDIGx5DiMtjWdU9ueXwMWwOz/YU9tIs1SZ0XSvlIuEcwcqaWuYqNRJdMNGWybveJy0V/RXL7eqRXO+BnbK3QkamHVUnEaBG9anzNhtLplHfD6FAGnLY/kzo2h7EYT08SglHJ+Zaax2qIwm45Cs008rePw2noDTcxqIhxxwmmMnQuR+HApp6K/FjloaCiC5AuYqyDa559OhOum9No7yvHSBo0jp3PMFW10W3uQtqDYkwQ/ZtEgR1Rdg8tQ1xg6lCaHDKNMLzSCtpKsBkikgMjRuitrSl9/LRXeqtDPQvUuwG44VXgDhFLaJmYphQEZK3x8dEPnJXkq0dvHIBJY9LXBCce+/4TdQYSuZKVgs0xypRmPzkn+mP6c005iYEgkHfb2OWebuv9tEZ3N+CeRLJoepY+nYgGQ7KcLKL8LT15pyRi5xt5fITsngI7/3C8OReUkuJzdQ== 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)(346002)(366004)(396003)(376002)(451199018)(2906002)(5660300002)(36756003)(66476007)(26005)(8936002)(4326008)(66556008)(41300700001)(1076003)(8676002)(316002)(86362001)(478600001)(6486002)(66946007)(6666004)(6512007)(107886003)(6506007)(38100700002)(186003)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6ofxCaPHS8Dai3nQfgyOkt9HYqs+HXbywaWSr7zQ8gR7VC8nSCpXP3yHVnKLdpL8x1fuIy1Pfyf4n52jHZgkZgajtRHK1ABeGv/PtJkTSEflmE1mmaQ/vp+topCghPGF9rkzC7FJXvIdGxBvw95ryZ+dtewUUKI79ssnxXRiUNeAokf0q+M1qlS34zxQp3282pLgz5Cw6KPeLD+WYGRxphwZouvxLVioFy/N7okzmBffnehr1b2OApJ5VbulKJBMqOuIctxF/pz30ZPvv7e3p268tz/RsDHNDdWXtPqOdDoJeyzYz7DRQ8n8HousQPg4HVmj5u1q93yhcavZrOTAgrp/lmopHlz5jGDJlSmdjKwrb0uvpO/zUbtoITU8vithKNV9RlJRjw0yKypOThcJao834BhESWX6ZbOy/nqPqUPcNbQ+kpr4jtQJM8za79mfu+qZVWj0PZbUfry9yQa7uK2pQjURfnpQ+AwaPJmwSu35R8k8lfM7GwhjaClfVMeh9ni7VNMokDai+kCmY99Tgn1sfpaQf2l5dSQ92tSP5bqkmv7AsxQbBNbVz9fnW9itFTaHnh2tYeyTb5+PKnMSMBZCR2mDkZkzWiz5jnxnRrBcFIKCkiKnYJg6zBLKPTKdJOEnAz3HEeRdjUrhwy71LOwLp6uK270AqckJ2asuZl14rQHOTj2Vd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rJC8/E4CSdgTUNKLgAM2arkNxfUSzdBB0VZlcWhhg71T+CrRSulFkSqjh4ZTvU3ZaMMGz89GOnD8DKJ24YUTRcTYyiQhZfHCeRQ6QzAnOBJFEc21OCGWm2K3vpAW4Z9FUndzix/wNBOpRlU/mlW1jmeAR1sB/kQUjCDt/9XZ680sq2Pm0ezRhWbQ2WzbF/OTfrYDzG5lSoi9ggDx98oOUZT6nt4kf3Gl7bjSYnFo8VN7nn6x4MuQmvYblpyf4wDadmETF3cPXMc0sGVtU7tcwyReaO2xle0Rol59c/dBMQXM0Ur/gIP/H8znlCP1ZOoJQptNk3g1xg87OFuuc7mWnDQULD7uSZCSDTQp2cv2aptvYRXIemTKxg7ngaWAROTU0gZQT3fbbioV+YoxTowm6CScOZiYtnXHZJ+Z0Azi3Laj60hKsXM1ZaffMyOhwJTRDb0FDr+kJW1qgQQquvxmlPaMXo04LSW2W+HiGy9RRB5EEUJjJ65lanahfcJZRSfux5vZI0ik5P7mjeMWTtIFyAKjkhuxdZrsw026H7oBAv4TgdzybfFRdmVjsoV6PQ6c4XNhksl+odqHCGhXJiaZKWiRhnkYX5uFPierQUczs8E4VDGceKaeMW0FkQaV564nj0Ym8rJRR3/elwM3snFFMVl52Zz0nQ0gPh1EMdduXZOuQd4xGZGcoMZYMVWQRGSPIw4FXd0xbk7scpaV1rmefCVhVyIK5l53JiJt8lRbWfc6B5fmavXOFYuequIQ1VEpAbLo+UOKm84q82dGZ72DBgAtOnE/MScxwIuZf4ELgN0Cw9RsFPXxSXauJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07583769-e02a-4274-b426-08db20ee51e1 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:35.2358 (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: Zhu2UDVJssNCAq1WiyiTGdg9WYpNACgZgWs9YHu1tPkN36u3wY9T3OY2ifHmqDagZHuyQsOqMEIIDMzzqdf/4WlllUMBgDrKzgovasGNKc0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6479 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: CRc_7INRIhhZrE0LOURN9LOgT9ClPjt1 X-Proofpoint-ORIG-GUID: CRc_7INRIhhZrE0LOURN9LOgT9ClPjt1 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org We don't want to set CMD_T_FABRIC_STOP on commands with CMD_T_ABORTED set, because we can end up with hangs where: 1. __transport_wait_for_tasks sets CMD_T_FABRIC_STOP but because CMD_T_ABORTED is set we hit the: if (fabric_stop && *aborted) return false; and wait in transport_generic_free_cmd's aborted wait on the free_compl. 2. transport_cmd_check_stop_to_fabric sees CMD_T_FABRIC_STOP set and does the complete_all call on the t_transport_stop_comp and returns. 3. We are now hung because we are waiting on the free_compl which won't happen because transport_cmd_check_stop_to_fabric completed the transport completion and didn't do the check_stop_free call which normally drops the refcount which is needed for the free_compl to get waken up. This patch has us either set the CMD_T_FABRIC_STOP bit and wait on t_transport_stop_comp, or set the CMD_T_ABORTED and wait on free_compl completion. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 3c732b1b5389..1e42fd3ac8a8 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3245,11 +3245,14 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, { lockdep_assert_held(&cmd->t_state_lock); - if (fabric_stop) - cmd->transport_state |= CMD_T_FABRIC_STOP; - if (cmd->transport_state & CMD_T_ABORTED) *aborted = true; + /* + * We can be either CMD_T_FABRIC_STOP and wait below or CMD_T_ABORTED + * and return early below and wait in transport_generic_free_cmd. + */ + if (fabric_stop && !*aborted) + cmd->transport_state |= CMD_T_FABRIC_STOP; if (cmd->transport_state & CMD_T_TAS) *tas = true; From patchwork Thu Mar 9 22:33:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168433 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 38A77C64EC4 for ; Thu, 9 Mar 2023 22:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjCIWeK (ORCPT ); Thu, 9 Mar 2023 17:34:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbjCIWeE (ORCPT ); Thu, 9 Mar 2023 17:34:04 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C5EF6925; Thu, 9 Mar 2023 14:33:49 -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 329Lx525004314; Thu, 9 Mar 2023 22:33:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=BgfAWHdwN6LbnYK9qhMYYGPd1UoSr02+IYqU5zXxYWc=; b=DtyFmrzZv3rMBJ1GBHc2eMYRtEloK+fWzuTgDamW3n3/oBeNJub/8gLfneUjd80aAhTt e00COmoPejx9WIw+N0ovSg75Bj8LBI9oHN6WCQxE4Lyrmnoh5gj4z9PbBttnNLgCvjdJ l8HBc/9aBQLfErcNtBKd6Aj7V+zyXBErbGrgNbfLxYacVVRRgZrcvFfzEU6WVjlOMtWQ qSPazMtfV7/6bHEy3YnLdv+Y4+Ohq/Ut8iyw7z5aVdlfQWm+XZ0YTwBP+bewfHSMdckN ewVtuMFz1iyPxoz/GL3qIhOIQRwrT0sc9zhPlBmpWJXGCvtQQdsu3GMAkBEFAbLeHZPl Sg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn98bpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:40 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Lf5B8020892; Thu, 9 Mar 2023 22:33:39 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fua4rk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nG6WXauqIKtcRM5QsrxjASuzbEYPDMURSeK3PsJoz3teNlQctJ8avnGLVnGYY34PbIRF4WJolwVWciJsGUj6jAfRkvcfZy2Ylm7n7lBX6au5pgvb8hx5pbH4OzL3oY9sS/3mBZTvnEYsurkO+PdQU/WA/iUT7RRUWfEV1JOQqfpL/KGgCBgNSScQJqKCCciDCclGSbBGBt5T1P55f3F1maSJDpXfS8jy2nDYNwt6cBA9LB/uWesfNQ9Pu9atgRiGen4fUBenH9nPvRKkb+UigPTidkL0x32RbQHJ7HxBwaMGawIQ+jeSZDK58rHmD2RRLWd4tHOCc4SxB2tdq4WEyQ== 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=BgfAWHdwN6LbnYK9qhMYYGPd1UoSr02+IYqU5zXxYWc=; b=FXLQl8F0/ovwV8Khf7+IguD5La+1QyAXWNRKRDosiy1bGviuo9EQ7X+rv8n3qOg7ONwJrwn3ls1VZIc1gF8wT13HY9HC7me6wOub6MHaTk2J5HtMvzmGQuQm2r/3J404Nz/rKQ1lNCS/n6uOsyG3flM7G/+0Y8zzNS0IeIm0xb/FyG5RxGU2DuO2DH1xidE+Ag6ayb1vYZMMjUj8CG1q58u0jOR313R6pMz+q7S5MV3dgrl/C6si8ELag89hA58EbXY2suZd1hKkQL5/hAP1l3GytiapHC7iAW2vpo1DYpGqxwkWdmglKNLP5JrI7llPpvKeohtMXEvbdVYCCTjLKA== 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=BgfAWHdwN6LbnYK9qhMYYGPd1UoSr02+IYqU5zXxYWc=; b=xbnJG5jchoEiKy4bj8KFSbZnyBc/UDg+qzxcn7iZOiuoV372q1jqAKqMA3KGVw6uKl9ao4XMd6/P+nIBuYKmI84+TrlwhC4l3KriJ7Hu+pN82xTC57eglaj0mgRgCqujp5Dn/Fluw6uz59D1X9WaX+Zql5s9ZJHT5vGgSuXMboM= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by IA1PR10MB6782.namprd10.prod.outlook.com (2603:10b6:208:42a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 22:33:37 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:36 +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 15/18] scsi: target: iscsit: Fix TAS handling during conn cleanup Date: Thu, 9 Mar 2023 16:33:09 -0600 Message-Id: <20230309223312.94595-16-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0025.namprd03.prod.outlook.com (2603:10b6:5:40::38) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|IA1PR10MB6782:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b5fbe46-3df2-4d0e-a39a-08db20ee52d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0KzcsFdRvcD3GhlYwkrcb6ryUfUfBnXvkRZGHhAXPBMYMF2C++42fbBdCqxjy5r2Lm32SLbss1BxWNQj+Yi1/eWXL/36rPOKYU1CqBOn9+3Syf6k/K2w//mjxa/ZFc/QrOGizz/qavZXJOQTb2aaVdVPz2K0Q10WFpMtHDW2+E+m5ElMyFFL83tNo8wIBfjp8H4q7+83gWVkJCMT6RAurszWv4YcHufKM9WeS5QabIcfP2rUh00oO/hduZU1P2Zux2RpccaPFGo/nbP56jePU8mvSUsGcMUGLyCt3P6kZdUXO/IoDWDR+L498Ha9ZKZsgmjjsV3E2V9LRqL5HWE1j39tdmeXXd3XzstzkTO6ArNLXl9z5ClC0tg/gjja70fh2ZEYlC+H8dbwvDggoCGMcVLQy4jDMr9iry4ZRZGbt6+nRpgx1ak+EOoXqLjiQ1LqOot8T+7+ywPscgSfnq375tq+wWPGj5glDGMcnq0k0eMz7yodwx3ei4c4aGV6KIgC2VLQvARS+Wq9S6v28YHs12S5aD4+xVVW4QXgtOJaC928gbrCsCttp0rtn4YegIcrr6xvFHOSlv9Ecj9Rs7fLrXWbyc0YAKeswaBmkvoikeqlqH1hnJ04/vkJuj4srV7N3Whf/Sl6cAsbHyW5r/gf5Q== 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)(376002)(396003)(39860400002)(366004)(346002)(136003)(451199018)(83380400001)(36756003)(478600001)(316002)(38100700002)(6486002)(2616005)(107886003)(6506007)(1076003)(6666004)(6512007)(186003)(26005)(5660300002)(66556008)(66946007)(8676002)(2906002)(41300700001)(66476007)(8936002)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WEvh4iWw6jSc2wwHDYoXfyCCOiX93OyFOYBTheHnhMxZW4QnHrERA8WXOo3APnRIMUFxdRfPVDHb6LxrSw4spDWWIBDyHd99VMzj3RUlfv10zziuYuK6xr6+P0mfRo0JKuQQf031aqcGzwsAUFq6L1rYfffKsElM/se1XcnrCzeMMIHucMrEfHaTthQozdQN6dVZFXFeZuurD3F9c3T0ohJbN0i3DZC1U7lWh5Z8PvXol5y+7DtcSuh2iljWA6lWhnSEG9ybbCRQATjogjcNy97pMoT2fnfSJdVWo6SyXJmQ4zruPctjlV9Hnk7cDeVUwbfBA4udUL5XzF9u18yL2ihQjHAHXFjp8cA9DGL08rWSaYMJTOPFZpenpOB0tuneTGDBU4UosrGqouaKeZzTKwFquDqi/57HDR5LSfndmJhyFjw1neNNyc79TSIk7N8B0qAb+HuogFYqC53RoiPWOS5PhhTT4BHh/W+skj4oBtKzxxDt4HJv/x3u3aDoidjtLODudbQa655KaYb6p6/ULqHkPlitOp1RLfAVN7I6YJIIF0o1auaZeM5LbQPgfYwTPIdRRW9wE3mO/mHd2gh304ghMPU7eEz5Ue8v1rOspngGCFd3lvqQWPS8/d4z1+EcsTu5RFf/OczlI76dxawEEfE4FQG+A8f6nDltoHBe60JSgvcGSvJjaZ3RCEu8Z+MbrUrXcSBY+BCdsM8gM63keWpJTsC+IGYLtMWajUCwyo3w2ZU8mWEn5y+3zdCAyRzWEdq61SkyqjLrCH/WFkmbdS7DUyXoFXpzWwACcuLjC8yHK/a88Ola433Yw6oZatro/BUGiMUF+01OJ7EiYdtt0jeaHurcUsBm+WAWtbCW0WhR58YHWyvIBZEH9c0OXTDMGA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DLi8aC0RTs+Z9W61vWPuJQXwxKYLtgCA/UWbEYJ/5rfx2VXLzlb4Ma+hj+fdncSgGq+h0leoRJLVGXZYI6SjayCjLvfLegrLsvBs+oIMY9krPngIpLkbSTQv42NH6kvfT6PeKh+nxHYanRx2F1dhVqm3b0r3lojMXNfHJ3Qe+SDautI/A9FUwzkIAOrnBTZWzP8RgkiffIbOMXiNoZ4hbZo5F3s1br7XuPxGQRbvQjKtnwXF3jCl/E/xwW0/mEbW/G8e6fBrg6or6nyzldFzLAohsOkAUw4GYOu1q9eCQAHquDNziCVMKKh0v7Zj1/K2UHBDKAuiziN4pHuPFUNPa/fNe7qQ4smKep76L9YKRglI8jx49viNp1R5sO/3Hsl2t7LOegmIbh6NbDho/lJDEWJ0BwQ7NJZhKtibm5d3moNyytKW9ZlJfuMR7EyundYX4lqGbDbuD3kX0Oe7ejeXzWBHzB9gfN3ldyuoTRieMsEG+MVD5oQ6Q1B0iUQwMFKiYxlOAXvhUDIw/Tg+M+kSsTP0HBX4hKJZ/JsZ3/TMBlSAPVRlHBAIbzdmuxoLB4O7ds8pFFkli5bdpm0h6D9gaKLo1feV42YUT4Fko1JCe4eCww5TOUA2ytyHd+a X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b5fbe46-3df2-4d0e-a39a-08db20ee52d9 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:36.8919 (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: OwgJXSFrp/iVo4cG1uyLZQ7oss5OCC3ff85y4Y8w+cIoYx+fL1rjR931OQKoz2ClpUsaMzXOaIZABYrj/nfjwYGURQd6sewoHc8/xmLJPyI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6782 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: JuYcn5gZ5aB_4dKbir7hMgF8uS1DUGLx X-Proofpoint-ORIG-GUID: JuYcn5gZ5aB_4dKbir7hMgF8uS1DUGLx 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 and run iscsit_free_cmd. Fixes: f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target.c | 52 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index cd9ef668a054..a64b984b9dca 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -4220,30 +4220,36 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) list_for_each_entry_safe(cmd, cmd_tmp, &tmp_list, i_conn_node) { struct se_cmd *se_cmd = &cmd->se_cmd; - if (se_cmd->se_tfo != NULL) { - spin_lock_irq(&se_cmd->t_state_lock); - if (se_cmd->transport_state & CMD_T_ABORTED) { - /* - * LIO's abort path owns the cleanup for this, - * so put it back on the list and let - * aborted_task handle it. - */ - 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. - */ + if (!se_cmd->se_tfo) + continue; + + spin_lock_irq(&se_cmd->t_state_lock); + if (se_cmd->transport_state & CMD_T_ABORTED) { + /* + * If TAS is set, we complete it similar to a normal + * cmd and will wait on and free it below. We don't + * set any of the STOP bits, so we work like other + * drivers and wait on the cmd's free_compl. + * + * If TAS is not set, then LIO's abort patch owns the + * cleanup, so we put it back on the list and let + * the aborted_task path handle it. + */ + if (!(se_cmd->transport_state & CMD_T_TAS)) list_move_tail(&cmd->i_conn_node, &conn->conn_cmd_list); - } else { - se_cmd->transport_state |= CMD_T_FABRIC_STOP; - } - spin_unlock_irq(&se_cmd->t_state_lock); + } 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; } + spin_unlock_irq(&se_cmd->t_state_lock); } spin_unlock_bh(&conn->cmd_lock); @@ -4256,7 +4262,7 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) * 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). + * reqs, aborted cmds with TAS). * 3. completed ok on the backend, but hit the CMD_T_FABRIC_STOP * or CMD_T_STOP checks. */ @@ -4265,7 +4271,7 @@ static void iscsit_release_commands_from_conn(struct iscsit_conn *conn) /* * We need to wait: - * 1. for commands that are being cleaned up via the aborted_task path. + * 1. for commands that are being aborted with no TAS. * 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. From patchwork Thu Mar 9 22:33:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168441 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 99468C64EC4 for ; Thu, 9 Mar 2023 22:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231400AbjCIWeo (ORCPT ); Thu, 9 Mar 2023 17:34:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231408AbjCIWeH (ORCPT ); Thu, 9 Mar 2023 17:34:07 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE52EF9ECD; Thu, 9 Mar 2023 14:33:52 -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 329LxEk1006464; Thu, 9 Mar 2023 22:33:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=chMr/Oq5Jbs0LvFD/FAENLg6xQxMrwm0Fp9h0/zAc2Y=; b=y3jLqvDgo0Vn3U0/hXjbEGX8f+HI+oWdBkDBn0EQaX98t3s/Sx/y7F/mbob0ThE37Uhh 8H3QEZRMpmYvl/NZeewZ623NbK3lOImwcwoU+BNKzd35Dx0yVFuML3f78k0bNyEI9lqK YDmKc3I8fiYTdaJtehDlHWYvD+OpG6ix1wsy86egB2/GWJ5xOClcn2UYSnlF3J2N6msP rB6uM0qbaaFtd4/djXo7HePaaaOAlTqgCyW9z6amsEMK5SIpgCSd46pDB8AFIBemphnV bfQlv40VCsv4+goo53zHTkgU5nL1RmPx80uVJFCq2wrPQHhDwH3mWAAYJCYyHcfOwmQN Ww== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn98bpw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:41 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 329Lf5BA020892; Thu, 9 Mar 2023 22:33:40 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p6fua4rk2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H63T6Mlee8MTeSZVtA4b90C7YqoknkCq5g7TJGUk2ydjuqLilQr4vx1I41uRGUh4br3sactL/QlsSGmh8bvYhoEb9KsmJO28p14JzhnAl/zQiY49wMdRWkTF4Q1QxylMdxxT/do9p5BBAfJ34fqgikjKyqFcFxkCqx0H6k6N2t3eRsdm0VSJihQZlHgktrxmTYEAD79sxv6TwiaFQOKro6twX/+Yacya2uedyddHI5FjnIHKBnpnq7UabxSQPTh3cePmQur12eZBVpT49TtCi2mCAli+05UIs2IVVgmwaFhy5hx7acffBx+ml4U3q4V0Bnds3vkwLrhWUkWl1wjwyw== 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=chMr/Oq5Jbs0LvFD/FAENLg6xQxMrwm0Fp9h0/zAc2Y=; b=EFM/1t5tQ4ul1ss+8917oHoFS83I5X0C/drtaJU98/KqHRkOZgMyIjLuBqKs7mjv8BZiVUIQNtiweVqHj3dn7zQni8f90Si/Ik9Xyci4OEU7hvs9sSHva1MUdYvmZvP5DbYxZkGmYmGGMQKPbKNt1XJiaaga/RqRvz5bkY6kOd4IShxRA4uKjW7CV0nAS/lmAm+0MzQswK7OP7xydLH6B5h2ulAUVqrUKvejkEmgozhOXYCWrmBRpefIRaplpB2BqvXl5lJRKdd6vt1mfox6Y/pbe9Mc3bxnuvytssGicQAo48jv7aIagoSzIyJ8xdb2Pr8rflIQ0lyk3YL6ysvjWg== 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=chMr/Oq5Jbs0LvFD/FAENLg6xQxMrwm0Fp9h0/zAc2Y=; b=ZUwzZbOmw1WNg+jlIZnaaHu7tvRdwDV45RzzWRNE6jQL5gjJ0waf4NKBzt8TZxsyDn+VxojPmZJWuhoqDVkHfpIWOmb8O4qDPhvMdmETa3iSUmBeGz/dVEhNtfqEeC6KkCxH6Tz7M5UTlJ08EGmMQt0N4d/+dQ8bjcsnM2rqNj0= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by IA1PR10MB6782.namprd10.prod.outlook.com (2603:10b6:208:42a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 22:33:38 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:38 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH 16/18] scsi: target: drop tas arg from __transport_wait_for_tasks Date: Thu, 9 Mar 2023 16:33:10 -0600 Message-Id: <20230309223312.94595-17-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0023.namprd03.prod.outlook.com (2603:10b6:5:40::36) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|IA1PR10MB6782:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b7854f7-6e63-4b94-9101-08db20ee53f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 43XY8GeHEf1bMLv3AJUi+NUP+7Ac9lqkjYwl/MY67t5osg7jrq7GCAUBilvjoQu/CKeukd+IN6nxB6VXIfJaSBx2WtDaYpFKycFS554RU5JIVPbunFnd9hz+N6swkAAjOKh9nnd/HWxKXx+sz2FwSnv4P/AXvbtBH/Ucb+PWLLvrcuanuo9iljibsErVtn1fxSiXkltri60u5pRvjlmwLSX5aSsoiiPuN5FW0I0nKFzeCYxJG4NtNHDbJDQGIyKSwQiMGUh7qUyA5UyYBucsbAmp9Qs6DfeoreDc4vmdBshxMDMlTJHhA5DtXLcNKVusPTAcH7XVP+ubRDJWGMhA6m+O9fEbQfSYrWdf7LvXSIvzq+UpFCPM74qeiCRrb9FUS+qoDEy709mKYa1vB5kw4/JDBLTVWFfzxTFn6Ra0yzm8fPHY5ysmI9Dp3LhrK+NRJoaD9k79tGRb3bW1dH7CmHpWd+n8UtO8lmPCDJmwUfOp/Z1p/0IKK6dcs1O5LSKYPju1hxoHTq1Q4ZH9rpFsxIskwTPGKSYVqwtaXFjGaomGZbiTzrPmSaw2TDGRW8C+Nn0UhBe/1m3b7dfj5/qw9TyNKJa1HjGGYixOe/y+vIMOqtuBN6ONrR7fGqj21MHVLqcKJiw1bCTV64p34vCTUA== 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)(376002)(396003)(39860400002)(366004)(346002)(136003)(451199018)(83380400001)(36756003)(478600001)(316002)(38100700002)(6486002)(2616005)(107886003)(6506007)(1076003)(6666004)(6512007)(186003)(26005)(5660300002)(66556008)(66946007)(8676002)(2906002)(41300700001)(66476007)(8936002)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mnz7ck2nbqKeo2IdEXT0/Lf29RrVogUhaogHrVNMVFLZz5lYCAKE5j/p+03b1JKrUvZvDFK6pBxaxByFOfA50Bqh7bYRwLy0t6nePjx6dSPKjHzYxGM9VBEGvcrgbFjOJlRejsMkPHKyD4nz7YuURp26cQst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E4lkpb51r6BknO7csF5m2v8uYQY7WjU8AiHgbmsYrZQk0HzHca3Nx2s+oWlymkm/h1nUQ2vfYMtsLazFhchqCSkNwc91ZeJlwL7ebaYI906Vw2T2JcUuMWV3IEh36cfbfhel2V2rKVvT2BWMkQHJFIr7r+NuA/oZv3f079XzjXjymBy96qqeTdICssysLOTNLR16ALF4xYaPTrVqGDAQWmNFsmU9cNFpSFn9/vh/sXrzNXCNSYM8QaJqjVMfBwKA1ZBEx9szTwshXvlN1jdIzeyJPihpVdbs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b7854f7-6e63-4b94-9101-08db20ee53f0 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:38.6730 (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: 2nGU2iTWWL6Vm7YZd7UuhlyRyVf8TmdK0NF5Q1wEQmSaGXl44If42YvpSHF5X0lT5ndJrXui5gNnaEdnMPQMY+szp/fNksSM+fASDq2epwk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6782 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: Sip_h4Ra0cxPFd_4ylnd9Gg8GQepv-5Y X-Proofpoint-ORIG-GUID: Sip_h4Ra0cxPFd_4ylnd9Gg8GQepv-5Y Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org The tas arg is no longer used by callers of __transport_wait_for_tasks so drop it. Also, fix up comment about us skipping the put, when TAS is not set because that was not correct as we always did the put. Signed-off-by: Mike Christie Reviewed-by: Dmitry Bogdanov --- drivers/target/target_core_transport.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 1e42fd3ac8a8..692104325b38 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2904,15 +2904,14 @@ static void transport_write_pending_qf(struct se_cmd *cmd) } static bool -__transport_wait_for_tasks(struct se_cmd *, bool, bool *, bool *, - unsigned long *flags); +__transport_wait_for_tasks(struct se_cmd *, bool, bool *, unsigned long *flags); -static void target_wait_free_cmd(struct se_cmd *cmd, bool *aborted, bool *tas) +static void target_wait_free_cmd(struct se_cmd *cmd, bool *aborted) { unsigned long flags; spin_lock_irqsave(&cmd->t_state_lock, flags); - __transport_wait_for_tasks(cmd, true, aborted, tas, &flags); + __transport_wait_for_tasks(cmd, true, aborted, &flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags); } @@ -2946,8 +2945,6 @@ void target_put_cmd_and_wait(struct se_cmd *cmd) * CMD_T_COMPLETE has been set. * - CMD_T_ABORTED is set atomically after the CMD_T_COMPLETE check for * commands that will be aborted. - * - If the CMD_T_ABORTED flag is set but CMD_T_TAS has not been set - * transport_generic_free_cmd() skips its call to target_put_sess_cmd(). * - For aborted commands for which CMD_T_TAS has been set .queue_status() will * be called and will drop a reference. * - For aborted commands for which CMD_T_TAS has not been set .aborted_task() @@ -2957,10 +2954,10 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) { DECLARE_COMPLETION_ONSTACK(compl); int ret = 0; - bool aborted = false, tas = false; + bool aborted = false; if (wait_for_tasks) - target_wait_free_cmd(cmd, &aborted, &tas); + target_wait_free_cmd(cmd, &aborted); if (cmd->se_cmd_flags & SCF_SE_LUN_CMD) { /* @@ -3239,7 +3236,7 @@ void transport_clear_lun_ref(struct se_lun *lun) static bool __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, - bool *aborted, bool *tas, unsigned long *flags) + bool *aborted, unsigned long *flags) __releases(&cmd->t_state_lock) __acquires(&cmd->t_state_lock) { @@ -3254,9 +3251,6 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, if (fabric_stop && !*aborted) cmd->transport_state |= CMD_T_FABRIC_STOP; - if (cmd->transport_state & CMD_T_TAS) - *tas = true; - if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) && !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) return false; @@ -3297,10 +3291,10 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, bool transport_wait_for_tasks(struct se_cmd *cmd) { unsigned long flags; - bool ret, aborted = false, tas = false; + bool ret, aborted = false; spin_lock_irqsave(&cmd->t_state_lock, flags); - ret = __transport_wait_for_tasks(cmd, false, &aborted, &tas, &flags); + ret = __transport_wait_for_tasks(cmd, false, &aborted, &flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags); return ret; From patchwork Thu Mar 9 22:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168439 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 CABEBC61DA4 for ; Thu, 9 Mar 2023 22:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjCIWeU (ORCPT ); Thu, 9 Mar 2023 17:34:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231389AbjCIWeG (ORCPT ); Thu, 9 Mar 2023 17:34:06 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E57AF6396; Thu, 9 Mar 2023 14:33:51 -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 329Lx526004314; Thu, 9 Mar 2023 22:33:43 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=COOGaSJHS4hYOkODWDBoMb2KgN+Wg4WHbiKbSajnJZ8=; b=QSJkgWyoEac1oZB5frqgnooZDZz4ihZtLe3z3Im55/o0btj3NYKlAmnjk6qIC4Y2U+ZU R0mgDs+IawkvBKFQ7ZhEe+YH31lMHk1OMp0PP0UbUhcpZNL/D5DramaS9N2nSdvphMO/ DpimPtPGmQQnaeVkPWI6JM9QKrCjYvPzx70BqROpHJQt3x6veqwcEnwEhHTv3zTbA49+ Q65NCoWmzcTge1+qiILahoyKKinUXYUFGQ466D3JgTonG1D+CHDoX/pyRotav6KGeXYL LDyCbAXM04/4VB7Z43qGiray1TjXULxLozAtks/fL21r1X0dZRMhWllXY3VVa+YYG8sJ CA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p5nn98bq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:43 +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 329ME6Me015564; Thu, 9 Mar 2023 22:33:42 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 3p6fepe5yh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EBV6btduCs7uZpPwnPKaHMTn6+LzNr9qTztH9chsC5zpxPdFkwQyXME5wSQATVO1X7/X7QLdshVhlY1+Yj0n/75RVJa0Mwoclev1ZqC9ZqGjRvkKpnXmmHxnMPuEiCR1WcdmRGXAsg2wMDEw9wCwLOHPY+n/sEStYyikNrkLoWjeOKhRBsJfQ2TcIktkNxbAKL96hgZKYAPRaekzxmj7RxBDf2T0VCgxDfqpAqs7nOvniaTyk1OI2BQK200WklYVj3SiSPgVw+TeiJc9sUNjoG2Oj2UwV3XEdeeYTh8A+/PxUehTNB6Gh6QO3NvjOg1Boz4tXtUkSYgdO/eiOBNwPQ== 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=COOGaSJHS4hYOkODWDBoMb2KgN+Wg4WHbiKbSajnJZ8=; b=RUhAteSB/lwru9zkxnyb/7e/vjNFgIpwj0t0wwjdbdw52BAK2x0AUVTq5cXgYK5TqBCgxPnhYd1dJya7kkiaeScOR6KV0CYfMUZZawWXi15/tOCJXfMplDqHWlijA6ai5CjiEyIyF2rF+pnkRV9OPPR4vKnS+LSnIs2igwIRNYqRjd9bM0BEjzlAVzBRK4o/tTHYRYeb99/5N5+7hqBIw5ZRHEVf4BYOR6pWKQGcHUCZbhuYv8hp3JfNAWAdN7yn/AvZSBnLs2nU0jMD3knp0q0XZIRwSwVx8VYw47Cb1aVrNz1ewa5OXVQ7aUAB62Gu3Cl1Eaif6BKyHVc9vr1WyQ== 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=COOGaSJHS4hYOkODWDBoMb2KgN+Wg4WHbiKbSajnJZ8=; b=pTZ4bOk2yC6YqZa080XzS+VRpcgsZ8qyNIrA8irQ2h5yEM1Tx2jUZK31v010qcU9TB8s+PI6pF6CCuUs/qKIQcgaqGKveqHHoCLJ02A845KY//YDJoqz0Enu0dYb4oKcTVW4ZrP/DDgNGrH3b8DB8R3LVfdJvjtL+xVgMfK82LQ= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by IA1PR10MB6782.namprd10.prod.outlook.com (2603:10b6:208:42a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 22:33:40 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:40 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH 17/18] scsi: target: Remove sess_cmd_lock Date: Thu, 9 Mar 2023 16:33:11 -0600 Message-Id: <20230309223312.94595-18-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR03CA0004.namprd03.prod.outlook.com (2603:10b6:5:40::17) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|IA1PR10MB6782:EE_ X-MS-Office365-Filtering-Correlation-Id: 5570ba8d-4521-4d84-f94a-08db20ee54bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AZHHJtYh+1akpDCp5BfHnScI0MJqjtyjPELemMZL25pWdmr0nbyfiQ0llPB/ImAJCt4zoNkl6b0jjvTj1jBEs4R0m1KaNE7KTtLQ7AK7j0ft/BdxLOvmeQZ/Q5M+LSnGxB6eVrR7O3lYu9WXeI8FzCJp8v9XYTu3OMM0hLyZKtIUAezCltVpeAELZjjrAJLAXsryZbv3W8ARFuBgxgcDo24ISbJxEpiJENGFFg1rx8fqn6FKgsGj0vSOTFb976GxDSgTI9UeHoWhEWLyUagfL7ji4sEhSsDDlQKjCzlKnHDBTWY/1+YD3CzzNCdd2o5OC/1IbS0P8M00wQ1u+TkHtUkvokJvTFE3rwgNrt9mxKl/ZVzlUIMn0OZqrp7+7sojHumMAcVMkCe1+Bc7kTDEHunJdpX45PPhgYDbU0xNcj8p4AZLOiUbf3qhDKHF0thdjZCiX/PB73ZatiUz63VoZWboUrV7+CyByAiOKZzKMtdkB1XUItZYnVaoPG1NvybndewffrXndMsvJ0jig8IhBQoWRsO3Ud56AaHL0cJLhq/GmTs3MGAPl7Bsj4dh/BkHa3kVYxPOMuEo51apjrU071Aeb9dUKFHL1wo0Y6TeV/VWaJ3J8XOE4vciwX8s488PwKOkkECrKMKYggl2+lgmBA== 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)(376002)(396003)(39860400002)(366004)(346002)(136003)(451199018)(83380400001)(36756003)(478600001)(316002)(38100700002)(6486002)(2616005)(107886003)(6506007)(1076003)(6666004)(6512007)(186003)(26005)(5660300002)(66556008)(66946007)(8676002)(2906002)(41300700001)(66476007)(8936002)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9lYjqWdDYOMcl9l639X8V93hNr4VjMl66vFMeIx4bImEFk2ubbjfh6sU50nVkOH8f+yJqyNI4fZN4DbYQ5u9Ly55e/NHOyfIBwlAuLh2wBhRgCVVvLBIrvqJRdqzg0l4rzjCQn2+fQuqxOmWgBv4BbIQCp067BkvOJSHaye3YKR8qSwQomZ/bILE/pfCzYHJHh2gKD5n93Mj0H7d52Y2/K4ps4s5gZx7C1K9voTuk2pvg9JiieZCY1u+6Cz6oFfgyXCDfLDVrno/bYH0Oq7+X8uUsy1FVKXPnAqwL6yBrU4wsoqyPIP2KvWP0dWvVm/lcWvoo52F5BKsn9zZH63YGxZKjMWA71XLGTsXCH8/JiQTqnywPKId+FCdNWtPT8rKoumB35JxfNUnQYIyJVvGENBJnL8VX4/sMsBCIFIfKS+PvSy4x8b5TMPW04CFDd54Of4BVZt3VMADRONErjc6KLVbUf/VOoVbEKfrV9ckt631moijCvvqqZYeM0MTDfhMUzxEsoaYXYJ6oiCtYFrIn+ehZZe8bLlEbeUgvY20Omj8wvPf/RniAJku0saIZUEmBgoBtPYgnAXHFOYF1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Exchange-AntiSpam-ExternalHop-MessageData-0: QxBu/7Pq0+Kt3GJar9Y1wlz5Y3MG5NAKLXvDVksM4iUhtJZN0LyjAzyjIMdg7akYeVaaCDQWEqtzI0gHKhao6U7cWFjoiYMH5OKp6YCBPxaiQgRpVXOsjH6qML+Va2t39UQzZzRklOzrWuClB1RXGbKlV6vBI7jf13BwqnZJmfqA08zdBuGeivy6xjJxb9tWY0cyhzyTE+SeoDOOOS8rW3MKzncyN83IE/TaZDWlatDnWLpfDnzz+KvdOF4lstUYOXRBE7sTJb8aqQGWQQmiTRPLGaTqijly8vsjcjSQXF5pUj8aQbIztn6k4fBEwmUWfjycYGvMIsgDG/2Oni/qfn+VWKsqmlXxHAqXG4qhc21d5jC1uLCDLHsYnhgY18v87CdCE8vyrogFoNMetTGlsXpl2ganMXpZoC8YBNByKff0FMmCm27ubQ14ZEm4kHT+AvPy2qe+WJYeJ3RwgnEtpomTqmxzHIpqY9t8NOBa2kPad3YHjzHmOoEjom1ItQG3pH3OM1pPvvaSlhPzCGjPZadwA2DWUR7s2+Qjdd8dAtc3cjDVkf9xPQEbslKThYJ9PPEKfkjHkw228ihJ6SCukCh1TA9jgz2Ie7S0x72u/wK4Hj6TQyz/Nn4Uve5NgMSaNXwNM1zuR9yI72wdNvrjNQ7cmq99yrmFbCcIIqQM/81eQqdQzQDssxWmumaaPOH8YuUJBI/uGkc+aBPAKSo0xE8m0k6hSyilre6vbYV9URSwyyMq+t06EtdZFrYwZ/UrxaF49vLa9ZQuPKWy3wQn2+G7h0vDpHjffvJgwDFV3vLEkUcusNTZmZzBHmMc2GYPIwXQPL2DlnpaD8n0tWmYECR2WqGluipj6lxWdaX2AzzG2DZGgwFdU4DFs9uptUVn X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5570ba8d-4521-4d84-f94a-08db20ee54bf X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:40.0323 (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: hPIQsUB0eoZmiLvlohHWyYK2q2DZ/Bc7M7QmVNwN8H8ukqmOPw3c5OYoSsBBjQOcBp9RpSHv2X6Vc1stKMGBdCr7Yf+v/mkbn6bhEAOr0zw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6782 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: b0yH3IS-LLtPkJ3pvd1kS651WN_BxEVy X-Proofpoint-ORIG-GUID: b0yH3IS-LLtPkJ3pvd1kS651WN_BxEVy Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org We used to ue the sess_cmd_lock to grab a ref to the se_cmd and add it to the se_cmd_list if the session was not being stopped. And if the cmd was being completed while __target_check_io_state was being run then we held the lock while taking a ref because we were looping over the se_cmd_list and because we didn't remove the cmd from the list until after the last ref was released in target_release_cmd_kref. In: Commit 6f55b06f9b07 ("scsi: target: Drop sess_cmd_lock from I/O path") we switched from the sess list and lock use to the per cpu session cmd_count, so the lock was no longer needed, but it didn't get removed from __target_check_io_state. This patch removes the last target uses of sess_cmd_lock. Signed-off-by: Mike Christie --- drivers/target/target_core_tmr.c | 11 ----------- drivers/target/target_core_transport.c | 1 - include/target/target_core_base.h | 1 - 3 files changed, 13 deletions(-) diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 88d2a7839876..6fa037ffc119 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -71,10 +71,6 @@ static int target_check_cdb_and_preempt(struct list_head *list, static bool __target_check_io_state(struct se_cmd *se_cmd, struct se_session *tmr_sess, bool tas) { - struct se_session *sess = se_cmd->se_sess; - - lockdep_assert_held(&sess->sess_cmd_lock); - /* * If command already reached CMD_T_COMPLETE state within * target_complete_cmd() or CMD_T_FABRIC_STOP due to shutdown, @@ -137,9 +133,7 @@ void core_tmr_abort_task( pr_err("ABORT_TASK: Found referenced %s task_tag: %llu\n", se_cmd->se_tfo->fabric_name, ref_tag); - spin_lock(&se_sess->sess_cmd_lock); rc = __target_check_io_state(se_cmd, se_sess, 0); - spin_unlock(&se_sess->sess_cmd_lock); if (!rc) continue; @@ -206,10 +200,7 @@ static void core_tmr_drain_tmr_list( if (WARN_ON_ONCE(!sess)) continue; - spin_lock(&sess->sess_cmd_lock); rc = __target_check_io_state(cmd, sess, 0); - spin_unlock(&sess->sess_cmd_lock); - if (!rc) { printk("LUN_RESET TMR: non-zero kref_get_unless_zero\n"); continue; @@ -310,9 +301,7 @@ static void core_tmr_drain_state_list( if (WARN_ON_ONCE(!sess)) continue; - spin_lock(&sess->sess_cmd_lock); rc = __target_check_io_state(cmd, tmr_sess, tas); - spin_unlock(&sess->sess_cmd_lock); if (!rc) continue; diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 692104325b38..c260cb60f5cb 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -277,7 +277,6 @@ 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); } EXPORT_SYMBOL(transport_init_session); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 0a5b51f8e5e8..845db96f50dd 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -636,7 +636,6 @@ struct se_session { void *fabric_sess_ptr; struct list_head sess_list; struct list_head sess_acl_list; - spinlock_t sess_cmd_lock; void *sess_cmd_map; struct sbitmap_queue sess_tag_pool; struct target_cmd_counter *cmd_cnt; From patchwork Thu Mar 9 22:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13168440 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 8D9FEC61DA4 for ; Thu, 9 Mar 2023 22:34:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbjCIWe3 (ORCPT ); Thu, 9 Mar 2023 17:34:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbjCIWeG (ORCPT ); Thu, 9 Mar 2023 17:34:06 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF0EF7392; Thu, 9 Mar 2023 14:33:52 -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 329LwvgK008483; Thu, 9 Mar 2023 22:33:44 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=aw8CS9AivX/mRr5VbhE25CZGu2e2Hz2RIoWPM69Dm94=; b=Hnjase12Yrqrl888pL5pL5x9SxLA/MEwdTMb/wX4BMIKbEXLywRKZizqfMQSRjm5ZX+8 Bx2AjqTvzvaH9OtkLOXjBKdh8JUJ2QCq4oul0/2jzXb+4BndhGathrBbHT9DY5hV5k1M Bhzzrj6cYWSwZtduup9wBgeUKeJXqTRCygAwNYJJtReVAiLZWe6X4uigwNgd92Ulqh1u LYGAQtlo6oD0LbzKL+iQJW5sEwd3Ck23omJR9DFYnY1ZQq6vQXD4+5ZNvJIh0P+Xn8q6 OeJPTZinU4sZnhbRHVAopqdc/xchpkveibFzL8hhpSiGvVx05D2RaD018H3AiWA5a696 EA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417ckyr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:43 +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 329Kf1GZ036551; Thu, 9 Mar 2023 22:33:43 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p6g47nhjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Mar 2023 22:33:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WNB6IT5jiP7OoXBTe9qn03+Y2dqPhKygbB64KdkoIrOvLFN45HyniaK97QTnB3HtkGLTeJQl3iG/kFkvWrf9if/drmFM+g4dmurhsrHc0ol/DzACUVbieQa+zdsVn0pWvitmT+Zo89eJNO42AS0VVXOqMTxZaTc4r0BCHsYoasYDtOZz3zSG/0DtJOS6uWCGjdXGjFoTpIajQP9zFBMsSikaUMt834vX1ymcZKVcSERxSjHTCJLCVJuTxEssSywLz81T5fxwIz91imK7m6ghp1/2id9vUhjeSzZkcdDCPDnrsliqMpK8T62t5n+87amnobaGUWkSJ1zxAaNSN4liow== 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=aw8CS9AivX/mRr5VbhE25CZGu2e2Hz2RIoWPM69Dm94=; b=hiJ4QS8Ve72ciAQzawxFseLYddDXWdUamRX+63eZ+pPFXajts8jmONulT1/iLYVpnC7b/DmDk8TquH4IzHiQyKylOCm+dEnQJul2n/gpejF0xjN6/CGWi6JNVdc+wijArZiHOkhxZmC3q43/XavwzZVIh0d3MEowMoXcrzgN3jvHfFJqdZ5lZx80gLUaMpfyFuKh5D/tBPcFTgPi6+pYY4tfMc29cIoK4lRMtBoyUlnSjjKt/bNqRbQpbdgT7pTxcx4Z+U6QcopXdYs4cWzzMomrjbI/D+ncCdqrlHxk2US/ttU5CZZ/NYP7Oxgyj6m6gUexsA0bp3EDkEyHcwJtrg== 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=aw8CS9AivX/mRr5VbhE25CZGu2e2Hz2RIoWPM69Dm94=; b=RBKPpXrehc2zvgW/q/XnBJoWlBgWROvUOyjcLA0TpdGjM4Jmx57y0NrK1QaARkDFQd2QFiK7eV7XySIdL//DzZI2wXMYcqDzpaV2E0RFHJN6mhma+JHg0x/EVmCyvYCL+U+ItridafNpxdGUtN1ES+9zNbHKvZf26Uq5uThqjxo= Received: from DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) by IA1PR10MB6782.namprd10.prod.outlook.com (2603:10b6:208:42a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.19; Thu, 9 Mar 2023 22:33:41 +0000 Received: from DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64]) by DM5PR10MB1466.namprd10.prod.outlook.com ([fe80::7dd7:8d22:104:8d64%7]) with mapi id 15.20.6178.019; Thu, 9 Mar 2023 22:33:41 +0000 From: Mike Christie To: mlombard@redhat.com, martin.petersen@oracle.com, mgurtovoy@nvidia.com, sagi@grimberg.me, d.bogdanov@yadro.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH 18/18] scsi: target: Move tag pr_debug to before we do a put on the cmd Date: Thu, 9 Mar 2023 16:33:12 -0600 Message-Id: <20230309223312.94595-19-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230309223312.94595-1-michael.christie@oracle.com> References: <20230309223312.94595-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0078.namprd06.prod.outlook.com (2603:10b6:5:336::11) To DM5PR10MB1466.namprd10.prod.outlook.com (2603:10b6:3:b::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR10MB1466:EE_|IA1PR10MB6782:EE_ X-MS-Office365-Filtering-Correlation-Id: 012fec80-82a9-40e6-e8bc-08db20ee55b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ha5MaFQCsoaEwMxYy80e7DQ1l/w5EM6GGT23NXidzBD9GuuZ33nIhoews09psypaFA/qx/dzzWTyYsVkYUYTF+wL+KUjTfvaaTlj6cAYfY+ZHeutHdeO1xjP2Frx+bUDuNrft2RM/xZKrWVQWSsNSXIuEpg9o6cKhGHBdkgFv2PZZ9yBCaQfnG7WFlaylavwgOruxBZe9MezuxnfTjshDUfHQ4/enARiiNlAMAFoza6J7F5MZMoI5vnXji/f5Q1JCj6JuAPPg4/DuK1EzlZLM39YuKdBDCwNLBFZ+z4x2E+nDGgiytZT/W8SQMwC5f4htBtpIEUr6GL79VIzcB/4NrLvijWHItulLHcsyeDZBk2TEcacrHH9erEXuYKO5CDUDLDZxZGn7M3WnqsdrMG6q5xDuyFXflJlaLYBMuXrHppllRypgymFT4VtW0Uav8TlIcv252Nw+fxbcEe2xERKMvDOS2fEBXseTAnum6MZbTKki4iLHZCzVt1A/cRJ1N6eME9Hr0ZhI4DVvguUtyRNrgt6wqqx3UraFNBaI7F7klpFABMXzfn+uoZ+rQYXHh8jHvk/o0s0WYOhljIusZs81rLu8Mq5/7wH+F2HW/S375LAViv7CXxJHEWCRtOde50MoSqsAX/3B0ktVpIXTs/84Q== 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)(376002)(396003)(39860400002)(366004)(346002)(136003)(451199018)(83380400001)(36756003)(478600001)(316002)(38100700002)(6486002)(2616005)(107886003)(6506007)(1076003)(6666004)(6512007)(186003)(26005)(5660300002)(4744005)(66556008)(66946007)(8676002)(2906002)(41300700001)(66476007)(8936002)(4326008)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sQHck7fbAUaItfev91nwrMmrpRE5z/9iiQ+jv3Qv4m0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PH0fLdrQ7xokTiLwXTdJV7xec10Km1XM0N3F7UiBS56PROGQVWT2tpqAvpS1xHNVotTrzMhwrBqt9a8stN+RdjPjtKU0OCTDd00TNSOADL4c3Hoc5yyMspKBpqMy3ZBYI2ilfJNDgkbmPzlx8/12dlbx68x8s99y8g3ixcIK6A6iXbte3KyY6OgTD/F3+OuA+QKKroWRW10YTuLHsycKYiZBY/ImR87qBIpUNbnxlteMnBBn1r52fV6kSEqo20e+fSJgR62toFCZU1eA7U8M5WDPxpAcIQ3bXWPpazoICCuAWnJmnoVd10GBYLY0bDy8jrugdHhSFw6iIcQlC/5zuQdYFoHufsGO+NBeT6KR2zibOPb/0RvuEGxO8rR+9AvfhSU3N/Dm59H X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 012fec80-82a9-40e6-e8bc-08db20ee55b7 X-MS-Exchange-CrossTenant-AuthSource: DM5PR10MB1466.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2023 22:33:41.7040 (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: WZ5iXQEgiTibtzvONcG8s71oILM38a/LRdFqpPXLaP7yczpZhc1vp6nfV2lW57FZqrLPO7sP+GDO/Igzq8dKEl2T38DQS33Kmd0NXGGF1ko= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6782 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-09_12,2023-03-09_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303090180 X-Proofpoint-GUID: TH0dcJGqImK0Bz-OyBTKz0jZvvIzJ3rE X-Proofpoint-ORIG-GUID: TH0dcJGqImK0Bz-OyBTKz0jZvvIzJ3rE Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org We have to print the tag before we do the put, because the put could free the cmd. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c260cb60f5cb..a39ffb8133f2 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2970,11 +2970,12 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) if (cmd->se_lun) transport_lun_remove_cmd(cmd); } - if (aborted) + if (aborted) { + pr_debug("Detected CMD_T_ABORTED for ITT: %llu\n", cmd->tag); cmd->free_compl = &compl; + } ret = target_put_sess_cmd(cmd); if (aborted) { - pr_debug("Detected CMD_T_ABORTED for ITT: %llu\n", cmd->tag); wait_for_completion(&compl); ret = 1; }