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: 661465 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 08368C61DA4 for ; Thu, 9 Mar 2023 22:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbjCIWeN (ORCPT ); Thu, 9 Mar 2023 17:34:13 -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+ZoB4/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ylVLXKVoHCorOAHKL0ksORbUAisFBzBSaMawdSU8NYRA8ulcI2ZxUUeDqU5kJtC+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: linux-scsi@vger.kernel.org iSCSI needs to wait on outstanding commands like how srp and the FC/fcoe drivers do. It can't use target_stop_session because for MCS support we can't stop the entire session during recovery because if other connections are ok then we want to be able to continue to execute IO on them. This patch moves the per session cmd counters to a new struct, so iSCSI can allocate it per connection. The xcopy code can also just not allocate it in the future since it doesn't need to track commands. Signed-off-by: Mike Christie 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: 661464 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 8607FC6FD1F for ; Thu, 9 Mar 2023 22:34:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjCIWeS (ORCPT ); Thu, 9 Mar 2023 17:34:18 -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/GStHDAO1cqU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z7+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: linux-scsi@vger.kernel.org iSCSI needs to allocate its cmd counter per connection for MCS support where we need to stop and wait on commands running on a connection instead of per session. This moves the cmd counter allocation to target_setup_session which is used by drivers that need the stop+wait behavior per session. xcopy doesn't need stop+wait at all, so we will be ok moving the cmd counter allocation outside of transport_init_session. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target_login.c | 10 +++++ drivers/target/target_core_internal.h | 1 - drivers/target/target_core_transport.c | 55 +++++++++++------------ drivers/target/target_core_xcopy.c | 15 +------ include/target/target_core_fabric.h | 4 +- 5 files changed, 42 insertions(+), 43 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 27e448c2d066..8ab6c0107d89 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -324,8 +324,18 @@ static int iscsi_login_zero_tsih_s1( goto free_ops; } + /* + * This is temp for iser. It will be moved to per conn in later + * patches for iscsi. + */ + sess->se_sess->cmd_cnt = target_alloc_cmd_counter(); + if (!sess->se_sess->cmd_cnt) + goto free_se_sess; + return 0; +free_se_sess: + transport_free_session(sess->se_sess); free_ops: kfree(sess->sess_ops); free_id: diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 38a6d08f75b3..85e35cf582e5 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -138,7 +138,6 @@ int init_se_kmem_caches(void); void release_se_kmem_caches(void); u32 scsi_get_new_index(scsi_index_t); void transport_subsystem_check_init(void); -void transport_uninit_session(struct se_session *); unsigned char *transport_dump_cmd_direction(struct se_cmd *); void transport_dump_dev_state(struct se_device *, char *, int *); void transport_dump_dev_info(struct se_device *, struct se_lun *, diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 3d6034f00dcd..60647a49a1d3 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -228,7 +228,7 @@ static void target_release_cmd_refcnt(struct percpu_ref *ref) wake_up(&cmd_cnt->refcnt_wq); } -static struct target_cmd_counter *target_alloc_cmd_counter(void) +struct target_cmd_counter *target_alloc_cmd_counter(void) { struct target_cmd_counter *cmd_cnt; int rc; @@ -252,6 +252,7 @@ static struct target_cmd_counter *target_alloc_cmd_counter(void) kfree(cmd_cnt); return NULL; } +EXPORT_SYMBOL_GPL(target_alloc_cmd_counter); static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) { @@ -271,24 +272,14 @@ static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) * * The caller must have zero-initialized @se_sess before calling this function. */ -int transport_init_session(struct se_session *se_sess) +void transport_init_session(struct se_session *se_sess) { INIT_LIST_HEAD(&se_sess->sess_list); INIT_LIST_HEAD(&se_sess->sess_acl_list); spin_lock_init(&se_sess->sess_cmd_lock); - se_sess->cmd_cnt = target_alloc_cmd_counter(); - if (!se_sess->cmd_cnt) - return -ENOMEM; - - return 0; } EXPORT_SYMBOL(transport_init_session); -void transport_uninit_session(struct se_session *se_sess) -{ - target_free_cmd_counter(se_sess->cmd_cnt); -} - /** * transport_alloc_session - allocate a session object and initialize it * @sup_prot_ops: bitmask that defines which T10-PI modes are supported. @@ -296,7 +287,6 @@ void transport_uninit_session(struct se_session *se_sess) struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) { struct se_session *se_sess; - int ret; se_sess = kmem_cache_zalloc(se_sess_cache, GFP_KERNEL); if (!se_sess) { @@ -304,11 +294,7 @@ struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) " se_sess_cache\n"); return ERR_PTR(-ENOMEM); } - ret = transport_init_session(se_sess); - if (ret < 0) { - kmem_cache_free(se_sess_cache, se_sess); - return ERR_PTR(ret); - } + transport_init_session(se_sess); se_sess->sup_prot_ops = sup_prot_ops; return se_sess; @@ -474,8 +460,13 @@ target_setup_session(struct se_portal_group *tpg, int (*callback)(struct se_portal_group *, struct se_session *, void *)) { + struct target_cmd_counter *cmd_cnt; struct se_session *sess; + int rc; + cmd_cnt = target_alloc_cmd_counter(); + if (!cmd_cnt) + return ERR_PTR(-ENOMEM); /* * If the fabric driver is using percpu-ida based pre allocation * of I/O descriptor tags, go ahead and perform that setup now.. @@ -485,29 +476,36 @@ target_setup_session(struct se_portal_group *tpg, else sess = transport_alloc_session(prot_op); - if (IS_ERR(sess)) - return sess; + if (IS_ERR(sess)) { + rc = PTR_ERR(sess); + goto free_cnt; + } + sess->cmd_cnt = cmd_cnt; sess->se_node_acl = core_tpg_check_initiator_node_acl(tpg, (unsigned char *)initiatorname); if (!sess->se_node_acl) { - transport_free_session(sess); - return ERR_PTR(-EACCES); + rc = -EACCES; + goto free_sess; } /* * Go ahead and perform any remaining fabric setup that is * required before transport_register_session(). */ if (callback != NULL) { - int rc = callback(tpg, sess, private); - if (rc) { - transport_free_session(sess); - return ERR_PTR(rc); - } + rc = callback(tpg, sess, private); + if (rc) + goto free_sess; } transport_register_session(tpg, sess->se_node_acl, sess, private); return sess; + +free_sess: + transport_free_session(sess); +free_cnt: + target_free_cmd_counter(cmd_cnt); + return ERR_PTR(rc); } EXPORT_SYMBOL(target_setup_session); @@ -632,7 +630,8 @@ void transport_free_session(struct se_session *se_sess) sbitmap_queue_free(&se_sess->sess_tag_pool); kvfree(se_sess->sess_cmd_map); } - transport_uninit_session(se_sess); + if (se_sess->cmd_cnt) + target_free_cmd_counter(se_sess->cmd_cnt); kmem_cache_free(se_sess_cache, se_sess); } EXPORT_SYMBOL(transport_free_session); diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index 49eaee022ef1..49a83500c8b7 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -461,8 +461,6 @@ static const struct target_core_fabric_ops xcopy_pt_tfo = { int target_xcopy_setup_pt(void) { - int ret; - xcopy_wq = alloc_workqueue("xcopy_wq", WQ_MEM_RECLAIM, 0); if (!xcopy_wq) { pr_err("Unable to allocate xcopy_wq\n"); @@ -479,9 +477,7 @@ int target_xcopy_setup_pt(void) INIT_LIST_HEAD(&xcopy_pt_nacl.acl_list); INIT_LIST_HEAD(&xcopy_pt_nacl.acl_sess_list); memset(&xcopy_pt_sess, 0, sizeof(struct se_session)); - ret = transport_init_session(&xcopy_pt_sess); - if (ret < 0) - goto destroy_wq; + transport_init_session(&xcopy_pt_sess); xcopy_pt_nacl.se_tpg = &xcopy_pt_tpg; xcopy_pt_nacl.nacl_sess = &xcopy_pt_sess; @@ -490,19 +486,12 @@ int target_xcopy_setup_pt(void) xcopy_pt_sess.se_node_acl = &xcopy_pt_nacl; return 0; - -destroy_wq: - destroy_workqueue(xcopy_wq); - xcopy_wq = NULL; - return ret; } void target_xcopy_release_pt(void) { - if (xcopy_wq) { + if (xcopy_wq) destroy_workqueue(xcopy_wq); - transport_uninit_session(&xcopy_pt_sess); - } } /* diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 38f0662476d1..65527174b8bc 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -133,7 +133,9 @@ struct se_session *target_setup_session(struct se_portal_group *, struct se_session *, void *)); void target_remove_session(struct se_session *); -int transport_init_session(struct se_session *se_sess); +struct target_cmd_counter *target_alloc_cmd_counter(void); + +void transport_init_session(struct se_session *se_sess); struct se_session *transport_alloc_session(enum target_prot_op); int transport_alloc_session_tags(struct se_session *, unsigned int, unsigned int); From patchwork Thu 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: 661470 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 DEFE1C6FD1C for ; Thu, 9 Mar 2023 22:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231356AbjCIWdj (ORCPT ); Thu, 9 Mar 2023 17:33:39 -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+KjTASWn71ZpEsys0V2Ht9AsbeHNmTZ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xRvo4eJZbxAIo71wVKZNe4kOVXp3IF9Q7jx19Fn25nVq08FVKYWGYa2r8yp23UVhPTRhsu7nNEBYpMGBbiiqtGlWY0KbPvnFQxOgWHJpmzdl3iP+62NR3+GjCossDmv8XcFm3gpeVnfpuwMwHC6GYpW89eY99DxC4byKDOFNOt0xE1gsTD/J70XwYifGZbxlAGI12udUMPjnuxZxcobmE1AsmgEeLvXuSzdHm0B0Cbq1u06cXuGVNc6vwefm1X7dj6DxMqYxITgXtzokyBG5CQdcECpDrHTrfg7kahMXnLlEn8DmhUZZCEDfKFYW1LAaOXcLOM1ta9IeyPDSXPoCsl0c07MW7hSqX7aMpf19KuywOgJ2caRsef/aB47ELOEZYS2ktmK30Plwu0a2IeqvnqBb2vI50y2dAVe7kTO15uSnTIJgTLk+LIO58JuFKPqCSi64zWc9od+invlM5qvuGllg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: SFrmzF0n0g/Bq6GKM/j/zCfso+oB9nsXgqGnMBqXV5z1G95M1E6SXbhf8JVTW7t8IXHNPIpjx6Scn5XUhrisRLD2/7/TjaMI2d6esTQElxTaietLj/zHsr+8ODNZycuRqPr6aCM3JIjA5HJ/hQG4sBatKEYqgynFgibVUVpwQA1NXG58mT41jVXRfZSGKQdG8j2TKxaFf9gpZ3BAsZ+ylKwRNrD73EP03dREyYkCnWl5hEOz88SIMUXF4KLGFvUDLO6HkBEs46bIvIK4p5sM8Jsu7tWUwcwcbHl8pmGn6wJ0N7F0eeQHEVzS34FQB8lastzWwbbTjKJw2ObWKnTGPP4f6ADDbkyCkG1ZLirF+pOQ7KVAwAiIubke7SrcOEbMpyxGqhOr752elkObq4HrC0vzOb129steoh2AlxlDJ4qlh56TQjGFEjLUzws/C7qUzTsw55rKbwU/em72jyBzSObJmi5RDKYMq22AkzhqYvywUmvdXA+q6hbH1GDHMpVCZ6XmzY4DwIlbVHryJzEFXG3aa6FkNHXstctdIwFySBDX740lIInUVMFxgMaQm56QSzu7Z2d3ZzXmDZNFXVAKuq9MTzQpOS+4eIJ3GW7+WC6XTQmbST+WaSBZurv24Qau6sXP9ihn8GRP44GPyqvzRy6x2rbQ/sbkuRYynyTCjNFGpPkeBKmD0pJLeLCHhu4rYBW7i+52I0W76Akl4Dm/GpC7I96aHy8I9a/g0QXgPJZpfn3sEpX4ul0cHAiCS1gvqfNsT9ngD+IQ6CBwwgu6ni9voD2N8sFSzA7iSuRxuIRPsrPu1PnAwHPHcpEGLgu+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: linux-scsi@vger.kernel.org This has iscsit allocate a per conn cmd counter and converts iscsit/isert to use it instead of the per session one. Signed-off-by: Mike Christie --- drivers/infiniband/ulp/isert/ib_isert.c | 4 ++-- drivers/target/iscsi/iscsi_target.c | 4 ++-- drivers/target/iscsi/iscsi_target_login.c | 17 +++++++---------- drivers/target/target_core_transport.c | 9 ++++++--- include/target/target_core_fabric.h | 3 +++ 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 75404885cf98..f290cd49698e 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -2506,8 +2506,8 @@ isert_wait4cmds(struct iscsit_conn *conn) isert_info("iscsit_conn %p\n", conn); if (conn->sess) { - target_stop_session(conn->sess->se_sess); - target_wait_for_sess_cmds(conn->sess->se_sess); + target_stop_cmd_counter(conn->cmd_cnt); + target_wait_for_cmds(conn->cmd_cnt); } } diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 87927a36f90d..11115c207844 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1193,7 +1193,7 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, conn->sess->se_sess, be32_to_cpu(hdr->data_length), cmd->data_direction, sam_task_attr, cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun), - conn->sess->se_sess->cmd_cnt); + conn->cmd_cnt); pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, @@ -2057,7 +2057,7 @@ iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd, conn->sess->se_sess, 0, DMA_NONE, TCM_SIMPLE_TAG, cmd->sense_buffer + 2, scsilun_to_int(&hdr->lun), - conn->sess->se_sess->cmd_cnt); + conn->cmd_cnt); target_get_sess_cmd(&cmd->se_cmd, true); diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 8ab6c0107d89..274bdd7845ca 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -324,18 +324,8 @@ static int iscsi_login_zero_tsih_s1( goto free_ops; } - /* - * This is temp for iser. It will be moved to per conn in later - * patches for iscsi. - */ - sess->se_sess->cmd_cnt = target_alloc_cmd_counter(); - if (!sess->se_sess->cmd_cnt) - goto free_se_sess; - return 0; -free_se_sess: - transport_free_session(sess->se_sess); free_ops: kfree(sess->sess_ops); free_id: @@ -1157,8 +1147,14 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np) goto free_conn_cpumask; } + conn->cmd_cnt = target_alloc_cmd_counter(); + if (!conn->cmd_cnt) + goto free_conn_allowed_cpumask; + return conn; +free_conn_allowed_cpumask: + free_cpumask_var(conn->allowed_cpumask); free_conn_cpumask: free_cpumask_var(conn->conn_cpumask); free_conn_ops: @@ -1172,6 +1168,7 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np) void iscsit_free_conn(struct iscsit_conn *conn) { + target_free_cmd_counter(conn->cmd_cnt); free_cpumask_var(conn->allowed_cpumask); free_cpumask_var(conn->conn_cpumask); kfree(conn->conn_ops); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c395606ab1a9..86adff2a86ed 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -254,7 +254,7 @@ struct target_cmd_counter *target_alloc_cmd_counter(void) } EXPORT_SYMBOL_GPL(target_alloc_cmd_counter); -static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) +void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) { /* * Drivers like loop do not call target_stop_session during session @@ -265,6 +265,7 @@ static void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt) percpu_ref_exit(&cmd_cnt->refcnt); } +EXPORT_SYMBOL_GPL(target_free_cmd_counter); /** * transport_init_session - initialize a session object @@ -3170,13 +3171,14 @@ static void target_stop_cmd_counter_confirm(struct percpu_ref *ref) * target_stop_cmd_counter - Stop new IO from being added to the counter. * @cmd_cnt: counter to stop */ -static void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt) +void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt) { pr_debug("Stopping command counter.\n"); if (!atomic_cmpxchg(&cmd_cnt->stopped, 0, 1)) percpu_ref_kill_and_confirm(&cmd_cnt->refcnt, target_stop_cmd_counter_confirm); } +EXPORT_SYMBOL_GPL(target_stop_cmd_counter); /** * target_stop_session - Stop new IO from being queued on the session. @@ -3192,7 +3194,7 @@ EXPORT_SYMBOL(target_stop_session); * target_wait_for_cmds - Wait for outstanding cmds. * @cmd_cnt: counter to wait for active I/O for. */ -static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) +void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) { int ret; @@ -3208,6 +3210,7 @@ static void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt) wait_for_completion(&cmd_cnt->stop_done); pr_debug("Waiting for cmds done.\n"); } +EXPORT_SYMBOL_GPL(target_wait_for_cmds); /** * target_wait_for_sess_cmds - Wait for outstanding commands diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index d507e7885f17..b188b1e90e1e 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -133,7 +133,10 @@ struct se_session *target_setup_session(struct se_portal_group *, struct se_session *, void *)); void target_remove_session(struct se_session *); +void target_stop_cmd_counter(struct target_cmd_counter *cmd_cnt); +void target_wait_for_cmds(struct target_cmd_counter *cmd_cnt); struct target_cmd_counter *target_alloc_cmd_counter(void); +void target_free_cmd_counter(struct target_cmd_counter *cmd_cnt); void transport_init_session(struct se_session *se_sess); struct se_session *transport_alloc_session(enum target_prot_op); From patchwork Thu 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: 661468 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 AC398C64EC4 for ; Thu, 9 Mar 2023 22:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbjCIWdr (ORCPT ); Thu, 9 Mar 2023 17:33:47 -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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a6HJOLDHX8sF4co/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: linux-scsi@vger.kernel.org This fixes a bug added in: commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") If we have multiple sessions to the same se_device we can hit a race where a LUN_RESET on one session cleans up the se_cmds from under another session which is being closed. This results in the closing session freeing its conn/session structs while they are still in use. The bug is: 1. Session1 has IO se_cmd1. 2. Session2 can also have se_cmds for IO and optionally TMRs for ABORTS but then gets a LUN_RESET. 3. The LUN_RESET on session2 sees the se_cmds on session1 and during the drain stages marks them all with CMD_T_ABORTED. 4. session1 is now closed so iscsit_release_commands_from_conn only sees se_cmds with the CMD_T_ABORTED bit set and returns immediately even though we have outstanding commands. 5. session1's connection and session are freed. 6. The backend request for se_cmd1 completes and it accesses the freed connection/session. This hooks the iscsit layer into the cmd counter code, so we can wait for all outstanding se_cmds before freeing the connection. Fixes: f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race") Signed-off-by: Mike Christie 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: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: 661463 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 48D98C6FD1F for ; Thu, 9 Mar 2023 22:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbjCIWeW (ORCPT ); Thu, 9 Mar 2023 17:34:22 -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-MessageData-0: WQsEP6oWvdbrUMefJRVPTdnPPD/6LpCHiwy8/Ndls9L3geQKE+vIFKsWWhMLOr4E4baBS7MJt+XsOpS8YYEnINRPaRdbf8rbJssQ41J6JS2rovfXqc5Ah6IPszubUldm/w9nWOmv4MaBAr2R6qOoaRhb97KdCLJftswN4JTruqeguI8WOhm60QHQz3bs+4gDx5DYH2Htfntr60twPECgZYPloQkReALXG4Sj//uftH3LaB0KYgpOtUkK99GOzfl15XUnGM/gHwUJPVArcrR3agI01GDBJ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RjmJWEK0f6pGAgVpSsfQEw9QZv7vSIzPZKCvl5+/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: linux-scsi@vger.kernel.org iscsit will set CMD_T_FABRIC_STOP on running commands when its transport connection is down and it can't send/recv IO (tx/rx threads are killed or the cleanup thread is run from the one thats up). It will then loop over running commands and wait for LIO core to complete them or clean them up if they were on an internal queue waiting to be sent or ackd. Currently, CMD_T_FABRIC_STOP only stops TMRs from operating on the command but for isert we need to prevent LIO core from calling into iscsit callouts when the connection is being brought down. If LIO core queues commands to iscsit and it ends up adding to an internal queue instead of passing back to the driver then we can end up hanging waiting on command completion that never occurs because it's stuck on the internal list (the tx thread is stopped at this time, so it will never loop over the response list and call into isert). We also want to sync up on a point where we no longer call into isert so it can cleanup it's structs. This has LIO core treat CMD_T_FABRIC_STOP like CMD_T_STOP during command execution and also fixes the locking around the target_cmd_interrupted calls so 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: 661469 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 466BAC6FD1C for ; Thu, 9 Mar 2023 22:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231367AbjCIWdm (ORCPT ); Thu, 9 Mar 2023 17:33:42 -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+QaohDB9oBwcAlnWo0npsCCArk4CGt9bGnBAAvCY86kcSNiwBB4BS2+lCUl/M3VdwHp9FUGNb4akYaiLngMgJbn/xqQjxQkAMGFceXGKfEVqblrQB7CAahGZUmCJMcqWMzV3JvQZEFor1ZwPXATGDc2KmrW7mDdtu5sRmlr7QNv4EgdETwjXBw9mkQCgcUQ6kVwjhgKZwxq5hIWi/AAu0285S9CEkMSQkTpKMLur7h9Fym+PFHAzRuUgXsiXfcznpWii76PMiIVAdq+3FFH6p7Ph8t825nZKDpTFSDyXQanZmGVpi2274Q05+frF0mFBflUlz+B0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HhdZvitGkn6ZlQuSgMN4LcP10BaDqQQkQ8ldcv0WVMK17byBIbZgUvw/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: linux-scsi@vger.kernel.org This moves the check in lio_queue_status to new helper so other code can use it to check for commands that were failed by lio core or iscsit. Signed-off-by: Mike Christie 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: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: 661467 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 5DABEC6FD1C for ; Thu, 9 Mar 2023 22:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjCIWeG (ORCPT ); Thu, 9 Mar 2023 17:34:06 -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/oUgX4dIad6VMqUQgYIwq7s86AS19R034DGS05EMLiXDRMl65zWcQHE5ktkD9D7/fwefEtRA8arKOhJsrhawzQ324/rdNH2Kx3uRkNY8ldIsBYQnxUNjQwj4DPLKedApum8WVSNRknxrlMA75NSa/gj9Hvf2q17JKqZM0SspEMfp8KOV00Bui6ix7czP5kt0z977w2j2yqihTJlqFjT07GogQ6SUsIXrpkGiaNCt+eXuOUexX0FzNk3z0BoiHUTrf86CgIfl+yEsZlKz8CMjAJOxWTJL4JqIwfvuf2HK97IOhrS8cHiuJiDfwmCmX41ziLPIDMtVme3A+047PcbXaq3JYms28GXvTp21UqAjunYzTU6Tz7hpOrJ+XglCmDnPyZLWKnqcDOyupJqvLVuNijKYq1wOUdJZ8O0U9xP/NQJVxIoOgifOOcmbHZxdzFDaSX/01zFGxUxsUK3ztajzcmX6+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HOrPaxQG0pH5q9SYbjJxynmW3G452oPlr4r1znggHFxqSVhklWovnIY/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: linux-scsi@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: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: 661466 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 E2CD6C74A44 for ; Thu, 9 Mar 2023 22:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbjCIWeK (ORCPT ); Thu, 9 Mar 2023 17:34:10 -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: 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QT3fbbioV+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: linux-scsi@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: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: 661461 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 19C0BC61DA4 for ; Thu, 9 Mar 2023 22:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbjCIWeo (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+03b1JKrUvZvDFK6pBxaxByFOfA50Bqh7bYRwLy0t6nePjx6dSPKjHzYxGM9VBEGvcrgbFjOJlRejsMkPHKyD4nz7YuURp26cQstOYI87tqcb3IAn2MlA0Cu4/sv0+lSLL/+O6wezQ0K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k0HzHca3Nx2s+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: linux-scsi@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: 661462 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 06B71C61DA4 for ; Thu, 9 Mar 2023 22:34:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231365AbjCIWe0 (ORCPT ); Thu, 9 Mar 2023 17:34:26 -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/RniAJku0saIZUEmBgoBtPYgnAXHFOYF1mAd51MWHJzozxdNBW04XiBewWyCmvWpNP/gksOWMRdT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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: linux-scsi@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;