From patchwork Thu Feb 4 11:35:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCC60C433E0 for ; Thu, 4 Feb 2021 11:38:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 793C864F44 for ; Thu, 4 Feb 2021 11:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236089AbhBDLiK (ORCPT ); Thu, 4 Feb 2021 06:38:10 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:39886 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235734AbhBDLgM (ORCPT ); Thu, 4 Feb 2021 06:36:12 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ8e0072968; Thu, 4 Feb 2021 11:35: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-2020-01-29; bh=J7EsSQpFvTzHYGuBhsrKHKMLJzLhhWIXETntUpwDzDc=; b=PjApFA6elHkZX2JO5rxe0TY9CO7eltpPRk2/sxcD88MFUeW6e5OcU/r87FImg1KNhLB7 3cCSAF0iUW+4tA9/RIAnLA4PAvvE1BAFkh0Rc2hUQ3UOcQOxGTIa+g/MpGuStV7spJYY cd3nCMg7yjs3uIqJ/55cGXD63OJBFyFKG9qTkdxWH9j3LxGHOgi2OezzH7ngAnwWO6g+ Krmr42OTbpVkhaLQvr2iTUa37HvJCzeb27FQ+bd9FXksyox6Ai1UcoRgzDqikEtqOWGK 66Ul/24njm/JMPr85zxclXqMozMZjz/PDu2ocE8+a5t3kH+n3Rml0y5+617DpyE/mjmR uA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 36cxvr7h02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:26 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYfbP134905; Thu, 4 Feb 2021 11:35:26 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by userp3030.oracle.com with ESMTP id 36dhd187nn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOnMnWM0llpJGpLtavQFx40FOMpVBzjsGiPI80qDJyHBo5C+bKDhkATBFnrPv/1v77S/mQ+4u6TSDpZt2J69o8Q8nJrXD+OUAsEgiPvrPckK1gb/ygvRcGFkTU5XzYOZypA6Lg1D6auayuaCKFlO4Lxwgd34if12jgaFE9oat/GELqO4AIUvdOEws/YViJepslmjmOdbNwfbz+5mxf4zDSW1fVSiqhec+Y7kwrFZm50mGYBcEYspbm7BMBEEu3r5FwayEc19cEpqSaKoMJ3TNC5fbXNoz53yVJ62+gbuoCNnFqg6qL50BSVrchJrTcrzBjeifWBdSFZ1j6Y8S7lrwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J7EsSQpFvTzHYGuBhsrKHKMLJzLhhWIXETntUpwDzDc=; b=Z+Jvdn0PA/UG055GIjk0/CDmFd8n03FJ8QBBquxTaOnhikKtDakn/DvOeGGqbgUJN+i6h5dRM0uoin7blgz2BSwqp+4lqltU6kkKNTHu821Ow7+Ehwa/MjxXo+issDKBOvp6mGvIpW9MnyEcreD4O19Quzwzd/owGE+aZYfx/JD7ml1/FnefURYYuQx0zkUT41+vQZ4jBClfImbqGfM2r9ymL2ZT6TvE8GykP/3MI62o9P7dg22ZhPfTwHiyu6swpQ7aayNzRkLM6K6GiZPMed4qkcW2Nm9RlpKMLY4bxU2Ccka0YDWPqtfRJuwinYmbQ6yPMdypnwrg82G+8nW6BQ== 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=J7EsSQpFvTzHYGuBhsrKHKMLJzLhhWIXETntUpwDzDc=; b=lnapzayk5hhhIS3/od3of7FFHlrNfHxJtCb/tsVqZOg7aWGWnMD2h6JgrNFZDrZcDKrTUqZiuGY6ZduvGGZx89tl4iYqTcVZqEjc+0ipDWCqqzG6tTJ/my/aADZ9qhmSZWtlkHdSrrO0BL6WEZ7qcxQdG1la3uv9RTu8cYefS+E= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:24 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:24 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 01/11] target: pass in fabric ops to session creation Date: Thu, 4 Feb 2021 05:35:03 -0600 Message-Id: <20210204113513.93204-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4978084f-07b0-4ae2-d2d9-08d8c900f643 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s3HtciQc+k7nhcUjvQNnxWMVcFX7GaAUjkMGeWvzSI/cQ9N7NWNUA10JA+QH3BXVy2D0626fMnBfL7ggp/2BKHceAx4MjLYhsj8lkVuKzExvX0KZCogJUBwQyGEUO0CzypHflvhX6coq+/BNGCuEbNjRrcL45H7oRj9YxWzZ7gbTI6n/zmEFmGsP9m2ATGlhcjG7XaKk3VGq/HKctWnomJrxg29QnrzKtZtepnA6D9TXDw/fmH4sxj2iB44koYTZ3jZmP8edHihkPfEgxh9KXaCZD0xupugqu0mXHslVtul/bHr+JxDHMKCW3vrM1fXM0dZWcfXa9lg0YWdpxyr3ftELrlbrEgUzwpMAyvW1gOTeKHgjpdj8zaxgq5W8FTlMxXDw7aNhoojNjuTId3ijd6VsRLEk0FqN+E2SpSeZsQMD0yXPA4l8IIgE/X5Rr2W1CkVkg/pVpCVMn1eiqFY9YUaRmRmURbmAPQpCkNstkdsKVuihNzC9uZyJpop+e4G9GlXmROvWRoNbs6ucNSnnVwCUo4PDIFYgeAvFYJS+DJT6OgOLQcW+MpZcTqHzSA9a5ybd8/pr7foP5iBs618nFw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: r1IbtGSXMzYbMwpW01/yJpN6vHqQXv6uBcyroXMFATs4lGJ6TUPWfagbMbgnauLzbsFGuhwJuy1hKB8rhJzQ9ugmHxkOOSDYE85Eey5VCcFMbRhMoz3SqzaFm/U5nYJqvHm+7QdF7j5UGgp7dky8yQ2yFdltEew6tqz5jxxl2FqOvDQ1C1vaKU0CYT68FfFqSN0OYXwbHlU9WQTZvoN78mve2M10JR80XiEVdFqFXh7cXSpwyGEEceGcc30ufENOpCew5NQEzAozCB0XQKycH79AIvw05jaOAML6r1Zq9wKGO/Lp7jf+mEhaRTkPe8N+vTUtk9ghrIjNZgNYb9v5HcixGDq7yR6jVhasDe1isk5IbLwIqpj3zIzFGWPp7Bf3udba6yLQeZRit7FnbQR1PNKACPtygsr+Zua2gYOeyCOd1ihrtrpd7dKisWPpVQC+M7WgUBuFZzXeV/bp5MEguWfmOWqsF5V/teBNESIXE6gLhVrA8Up76YHZvdwkfvQPzJ3uWrA+g6N+WL885MbIxOHYWcQE1BUe/7R5L82s5L0yEr+rIthzalaa1eQajy+Yv/drt7FNigA09G21jXEntFJxYtNrcGDwNtdVmyiCaHSBKcbUDEm6TZZjfiGgdN1dCsHVHvtOMXmtI6ggwvQLU6l8b4FAwIygNMBUTgBG6g6tkv3RhulzNt1ZVvLPE7ygxbyqoFEAWIVpv+dFC5GTy8Mp5ynkK4mFd7CXTrdXIFE1InsQAZMFzsQUIhWApDeNCkgtTu5i22yD5CYgmfgZ8sSuPCDBp92VlcqhJ7j8WZn3Q4DJ+dL3YaoAZGKwNHHtcytdk/2Rne954L4seZVArRA7/Y4kDAodEhxFqmpY442Un+CvI4Nas1rS4uwzt9tAT56pbgdr6q3FpGNsRp/eOxjFejEY9Wg/k6VGBH2hYX0G9U9RrQbH8jmj/MiLpbZffIljHtFKPJ2EcUNtjdX3x1hj0Xbw1/ngRGkdR0DdPrN8VRdVhfQg+XnS6CGDSrAchkPmi+dqzQ6Hqsv6oyiiHTt/L5Kcr2gr4NU+G14DgIE1GvphbyY5yss/ANP8AWU+ZDnDx5UMT8LEnE2S+ThPG0TjLfSwA/H9Xul2dkPRB+Pf5pvJB3EU4R1EK9BhfaqSA10nP0oz5JghCdVbrCEEen/upphp7Zrh28Twy9ugJdq6nt3c6l9A8Yx41WEM6GYnroz0XRmrZkINpk0knJu1rLPIZoqqlOm8ceKs2OM7HhduZUjQ3Qcr4PbyBO4JMAK73QeEOfSZJarS6Mt+EQabzqhipyjt61d2O7LZ8NwvaQsblEDPePrgyDweHmEIh60V X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4978084f-07b0-4ae2-d2d9-08d8c900f643 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:24.4616 (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: Hi59y60ORK06jnkDOO8xcncjYPWOHjUQbVlSahgenbMu8mFcvGqmDWTSFnv9kl807GqxHJ8LUT7psnSXPStHjjLbG/0LKte9AOjKhzrKAP8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org The next patch will create a session level submission work queue if the drivers fabric ops implements a new callout. This patch just converts the target code to take the new fabric ops arg so we can check if the callout is implemented and then call it in other functions when we have only the se_session available to us. Signed-off-by: Mike Christie --- drivers/target/iscsi/iscsi_target_login.c | 2 +- drivers/target/target_core_transport.c | 24 ++++++++++++++++------- drivers/target/target_core_xcopy.c | 2 +- include/target/target_core_base.h | 1 + include/target/target_core_fabric.h | 6 ++++-- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 1a9c50401bdb..ddf0c3b13671 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -317,7 +317,7 @@ static int iscsi_login_zero_tsih_s1( goto free_id; } - sess->se_sess = transport_alloc_session(TARGET_PROT_NORMAL); + sess->se_sess = transport_alloc_session(&iscsi_ops, TARGET_PROT_NORMAL); if (IS_ERR(sess->se_sess)) { iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, ISCSI_LOGIN_STATUS_NO_RESOURCES); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 93ea17cbad79..7c5d37bac561 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -220,11 +220,13 @@ static void target_release_sess_cmd_refcnt(struct percpu_ref *ref) /** * transport_init_session - initialize a session object + * @tfo: target core fabric ops * @se_sess: Session object pointer. * * The caller must have zero-initialized @se_sess before calling this function. */ -int transport_init_session(struct se_session *se_sess) +int transport_init_session(const struct target_core_fabric_ops *tfo, + struct se_session *se_sess) { INIT_LIST_HEAD(&se_sess->sess_list); INIT_LIST_HEAD(&se_sess->sess_acl_list); @@ -232,6 +234,7 @@ int transport_init_session(struct se_session *se_sess) init_waitqueue_head(&se_sess->cmd_count_wq); init_completion(&se_sess->stop_done); atomic_set(&se_sess->stopped, 0); + se_sess->tfo = tfo; return percpu_ref_init(&se_sess->cmd_count, target_release_sess_cmd_refcnt, 0, GFP_KERNEL); } @@ -252,9 +255,12 @@ void transport_uninit_session(struct se_session *se_sess) /** * transport_alloc_session - allocate a session object and initialize it + * @tfo: target core fabric ops * @sup_prot_ops: bitmask that defines which T10-PI modes are supported. */ -struct se_session *transport_alloc_session(enum target_prot_op sup_prot_ops) +struct se_session * +transport_alloc_session(const struct target_core_fabric_ops *tfo, + enum target_prot_op sup_prot_ops) { struct se_session *se_sess; int ret; @@ -265,7 +271,8 @@ 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); + + ret = transport_init_session(tfo, se_sess); if (ret < 0) { kmem_cache_free(se_sess_cache, se_sess); return ERR_PTR(ret); @@ -311,13 +318,15 @@ EXPORT_SYMBOL(transport_alloc_session_tags); /** * transport_init_session_tags - allocate a session and target driver private data + * @tfo: target core fabric ops * @tag_num: Maximum number of in-flight commands between initiator and target. * @tag_size: Size in bytes of the private data a target driver associates with * each command. * @sup_prot_ops: bitmask that defines which T10-PI modes are supported. */ static struct se_session * -transport_init_session_tags(unsigned int tag_num, unsigned int tag_size, +transport_init_session_tags(const struct target_core_fabric_ops *tfo, + unsigned int tag_num, unsigned int tag_size, enum target_prot_op sup_prot_ops) { struct se_session *se_sess; @@ -334,7 +343,7 @@ transport_init_session_tags(unsigned int tag_num, unsigned int tag_size, return ERR_PTR(-EINVAL); } - se_sess = transport_alloc_session(sup_prot_ops); + se_sess = transport_alloc_session(tfo, sup_prot_ops); if (IS_ERR(se_sess)) return se_sess; @@ -442,9 +451,10 @@ target_setup_session(struct se_portal_group *tpg, * of I/O descriptor tags, go ahead and perform that setup now.. */ if (tag_num != 0) - sess = transport_init_session_tags(tag_num, tag_size, prot_op); + sess = transport_init_session_tags(tpg->se_tpg_tfo, tag_num, + tag_size, prot_op); else - sess = transport_alloc_session(prot_op); + sess = transport_alloc_session(tpg->se_tpg_tfo, prot_op); if (IS_ERR(sess)) return sess; diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index 44e15d7fb2f0..a7553712da25 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -472,7 +472,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); + ret = transport_init_session(&xcopy_pt_tfo, &xcopy_pt_sess); if (ret < 0) goto destroy_wq; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 54dcc0eb25fa..50103a22b0e2 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -628,6 +628,7 @@ struct se_session { struct completion stop_done; void *sess_cmd_map; struct sbitmap_queue sess_tag_pool; + const struct target_core_fabric_ops *tfo; }; struct se_device; diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index d60a3eb7517a..cdf610838ba5 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -132,8 +132,10 @@ 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 se_session *transport_alloc_session(enum target_prot_op); +int transport_init_session(const struct target_core_fabric_ops *tfo, + struct se_session *se_sess); +struct se_session *transport_alloc_session(const struct target_core_fabric_ops *tfo, + enum target_prot_op); int transport_alloc_session_tags(struct se_session *, unsigned int, unsigned int); void __transport_register_session(struct se_portal_group *, From patchwork Thu Feb 4 11:35:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 606D4C432C3 for ; Thu, 4 Feb 2021 11:37:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3446864F44 for ; Thu, 4 Feb 2021 11:37:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236087AbhBDLhv (ORCPT ); Thu, 4 Feb 2021 06:37:51 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:38536 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235877AbhBDLgM (ORCPT ); Thu, 4 Feb 2021 06:36:12 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ0Tf122033; Thu, 4 Feb 2021 11:35: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-2020-01-29; bh=H/0FEOl+dZ3K/w0U7uGdBe6WHG5+aAYUJnMUHipTrTo=; b=W9UeeTgvUMolvn0ouJyZR9aNu2UKy05oRfC85fv1ZSWAAU8/sp+p4cDtUw57KzlFd2MF Wfd0pXARrGganaq+hmmEKNEGioejIVI8hmR+lfc4yepgaAm3lXREptHzBFABOTm+VFpY 3deu5unbKnWneg9DbtFCobLwnhtrB0WF1ilYc88YDAHXiP3ljsHxmz21GUnJ2ur2uhGR rrMtWwt2wBBZAj+E4jeNYLfl9yb8+nvKKG65WHMOhTI529Hjl/Sp8JVfwAV40qcX4CJo o2XYa2CDg8e6+anm8tJCkpRbQNJiIi7gNlj5sD+dRxdUQVOb3FR1fSI5s51LZTJs1rZi 0A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36cydm4r6x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:28 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYfUK134930; Thu, 4 Feb 2021 11:35:27 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 36dhd187r2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e9eY9eJGdnMS/aoc8Ub8Ul/gB01RioKRKhKjkLQGH6FYIo2Ms1H1zLFQ0RSJnxVK7BGmIF5JK3mNNgTWKIpJcmo7hCJhqbq4G3R2dhFc2AXXaMQc+v5z2jeV2zxPUQrvMs6pyZkiB7Wt6YHriM2ESk6htjH3ZYHqYhK8v+UD2TwyvfFLaVNLcsrAz+76zz/bha8lVa9QgFYxbnksT573l8J0j/LMXE+uaeH0GaeJM+zyshu2NJAVTXQy7200AcijXDXnT8W4i1WTvz/oIyknIb4ZDg9likohvXxluB9fXuu9FFrb9CbzbvVNdkKiAXbW9+MGg/EF74SBncmsxwKdIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H/0FEOl+dZ3K/w0U7uGdBe6WHG5+aAYUJnMUHipTrTo=; b=NNeNn5To1mteopXlnRRDS6FHpC2cM6HkXajlT8QAcGE4QvcVah1s3+0LJxTWDaQyRFpjLtds7QCpoeWuStUy1WI+hJ3XT1ZOd5chYdOozzws4IclDfOoIRsGviNAKOJi7XnNVQcxae7V+yuMjEeVqSbWwKBfCL7gnlgl4dUPBb0Y+fk9aI76Mp5kNqUELm3O831OhQ73YYmEZZt6FmvJ7fpeVcHKDVtQqKDlByQy6aI+WNxk//56n8B3yZZqA23wR2rOUf6r76eg3GhrwbVpnAFfwBtBT1dxWUyE1Qvo7IbgC6sYW8C0SoTRDXX/NxKVQ5+SxzsmaB2z3hhEi1bfmA== 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=H/0FEOl+dZ3K/w0U7uGdBe6WHG5+aAYUJnMUHipTrTo=; b=ujBgtcxo5TlzokD+NnLcZvp+lwseAulHrDOnPLZL4JYQIUt4pskeRHy1DCLFD+EXGEtohYfF5fd+xF7CFnDkydWKVkcn1S15RXI1NCggThELKy0HzkPSJMXIEid8zbr/jW52qD9oiLSDwUMniyr6fFI6ElZKjH+BLYskCaIANlk= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:25 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:25 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 02/11] target: add workqueue cmd submission helper Date: Thu, 4 Feb 2021 05:35:04 -0600 Message-Id: <20210204113513.93204-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 87467126-706f-44a0-afa3-08d8c900f70a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b0LjR80E9e5zjBSkcS4PGOJa44kuJuYISx+mEx0vI9+uVLMZe49+9jYM8smM1c1TjWx7YwusBI9ChetIpT2QN7DDjKGNpV7hmP9Zjgq8V5cu6Tij8pmQcjS9k2cm3eJf9SwATnH/iB0b9ja3EJNQti2TeLIWR7eBgKLdGwjdgZR8RHmrFD6PHroZeWC+WaGcs6IUtGs+Z4OP4ECAEcFAqj+CpMqM/NgsIhswNprWffe1mBUKtX1xQhd01Su/1gieJqWkLExICH1H3NQkrHpfH8/jdDU9364JqwsPa3zE1eHSU8edVZJ9t3On+Lf5/qB65brw1x5jCkXpOZyH+qQF46VRFBO3kql9G5uqosiRLJUNmDA4iRsn6XSDMQziUhxndsWB+kERzpAE/VOmHiDYVFpGG7JfYc7iZqfEiIFWbxwjuGi9EcvnxXYflYu3rkpqgkYfrDTT/huHC7+3d9pidXjwuMdm6yMd2RlFfk8k9Lmkm7paR/ejJxdnpSipT5ObqVnVGAXpcy2Ac3xm97SkqepQk8fAFlOK5HZ0Z1uZqe4M5h3qQHclispvRj/k5SK1khJOVY3sAOYNBoG1Jr5SIw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Vp7/IzenjpxJ1OqHheJkJzuUnzWX7adld4k2DM68W36HCDvXHUgTrDxW4Lx5Hks9fSWZww8gOze2Q846q+YhLnjb8c2AK4YTfclEaQuIllvp+L5mR811Es2uVnTg/6OZmLwRGuNVgx1+eUdhFP//nIAjM+5ypZP2nq4V56uKujoEBKxwySzNI6cP7ksTpJ84Yz3SgAkKLDkqDt7HwFhrfd5hVnjFdWq38LwRYmNCNkZn1kcbgaQCOt7LMC4UZVArgDbtu9YFwlVaeCY3HWkK46u2kUp66+iL1n20TzkK+Sp29k9EWxdPAQ+wDbf4I1gizE+3UsWvwsJJ1em+/kuqz1D1CNdB9i66AZ/a5GaM7fXJnFpO4qX7x+C2U/7gOmbUL+JDGrGWNgiUBRWFinbXFiCDAk8jHhkNANJEeZSH4WFgKGbt1yGlnbifzGQRdnXwzD5LRmoFX9xuN04OhuextUS/cud+ZpxUzSSOZ6ZxZ4DSI6KTU7guQVjxmGFQTAmH+IeAN2KRkxigrs1EeDOiWGg4EkraS/RURGPE0TM1K+8x7OFaUL0b+acpQ5fP6IdgykQ4ezWLRRdImA2+Rjp/rv6PJ4KsIHVZnNOixERRQsdv7mtSFVzWC1UARUZBvBzeabFX2eShRRGdYabyDGKt2rFOJfp1+rFjX6Irqwk0PO6nzeKGhkFpUyUubq5QqhiahgY1nBGw64iQpSizTXTyZoDij4bUtrGjcGxUNZdgoRI0jFwMiSbm56wWvGLD/iPaBC5zG8WQn9o0t9t07FLD5b1K/kkBp0W4aOz6XVf2qM1oEcuDaMg7BlY2/RizY5sHU9qec2rtINsH5rz2reM/y7pR3v+rScG8E1KZEa/vHmD2+4SoTtWwDJcV21/14Q3I2492HTSffNNCFUyiEOsOLiSICYsqOb2Q4q1t4I7oyRnqXK+prc5z8QtZd1z/wmDuKJwKhulrQv++XdyLqhBrkt9V81RApDwiQ3a2BH+kstsPyggUY3Hjzr9YtPmDbzUS9ZHzrZuofr08TrilxtdY0F7oIFftb1xcBw7fYS7NB3yIs29ksHef9kG9x6blKso0UfnkEwi/Mezj+Oeh5CwiLRVW/uXmnG/kvGT+/kSBH785C5/YPr0N6Ky3BR+HBUDEATyFlJL4VqCzF4gIYG/9gseWgPO8KN7fKVCkQiscofDbF/V1Bx5gobgL1m6k+LSiiE2ACAR1MbleP9XapFUwAQI8fnTXNAhvHfN5BsC/tjonZkrUBQnmxz/GMUkJahhIyU0C5qWGQk06eLUJHDEwkJwXT19ow+RjTcZ9wduSq3F7Vx1KdNNUwwo/gh9fonzo X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87467126-706f-44a0-afa3-08d8c900f70a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:25.6499 (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: Xiox5izSx6i6tNCwLlOE5KbJcSdXayZce03DxoiwlYKSv1V0/hn8Rxyf57e+jtgeIZ7r1cCGETkorGHIR5XwS05B7cL5c6Lz/DAiCl+5iJU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org loop and vhost-scsi do their target cmd submission from driver workqueues. This allows them to avoid an issue where the backend may block waiting for resources like tags/requests, mem/locks, etc and that ends up blocking their entire submission path and for the case of vhost-scsi both the submission and completion path. This patch adds a helper these drivers can use to submit from the lio workqueue. This code will then be extended in the next patches to fix the plugging of backend devices. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 102 ++++++++++++++++++++++++- include/target/target_core_base.h | 10 ++- include/target/target_core_fabric.h | 3 + 3 files changed, 111 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 7c5d37bac561..dec89e911348 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -41,6 +41,7 @@ #include static struct workqueue_struct *target_completion_wq; +static struct workqueue_struct *target_submission_wq; static struct kmem_cache *se_sess_cache; struct kmem_cache *se_ua_cache; struct kmem_cache *t10_pr_reg_cache; @@ -129,8 +130,15 @@ int init_se_kmem_caches(void) if (!target_completion_wq) goto out_free_lba_map_mem_cache; + target_submission_wq = alloc_workqueue("target_submission", + WQ_MEM_RECLAIM, 0); + if (!target_submission_wq) + goto out_free_completion_wq; + return 0; +out_free_completion_wq: + destroy_workqueue(target_completion_wq); out_free_lba_map_mem_cache: kmem_cache_destroy(t10_alua_lba_map_mem_cache); out_free_lba_map_cache: @@ -153,6 +161,7 @@ int init_se_kmem_caches(void) void release_se_kmem_caches(void) { + destroy_workqueue(target_submission_wq); destroy_workqueue(target_completion_wq); kmem_cache_destroy(se_sess_cache); kmem_cache_destroy(se_ua_cache); @@ -218,6 +227,69 @@ static void target_release_sess_cmd_refcnt(struct percpu_ref *ref) wake_up(&sess->cmd_count_wq); } +static void target_queued_submit_work(struct work_struct *work) +{ + struct se_sess_cmd_queue *sq = + container_of(work, struct se_sess_cmd_queue, + work); + struct se_session *se_sess = sq->se_sess; + struct se_cmd *se_cmd, *next_cmd; + struct llist_node *cmd_list; + + cmd_list = llist_del_all(&sq->cmd_list); + if (!cmd_list) + /* Previous call took what we were queued to submit */ + return; + + cmd_list = llist_reverse_order(cmd_list); + llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list) + se_sess->tfo->submit_queued_cmd(se_cmd); +} + +static void target_queue_cmd_work(struct se_sess_cmd_queue *q, + struct se_cmd *se_cmd, int cpu) +{ + llist_add(&se_cmd->se_cmd_list, &q->cmd_list); + queue_work_on(cpu, target_submission_wq, &q->work); +} + +/** + * target_queue_cmd_submit - queue a se_cmd to be executed from the lio wq + * @se_sess: cmd's session + * @cmd_list: cmd to queue + */ +void target_queue_cmd_submit(struct se_session *se_sess, struct se_cmd *se_cmd) +{ + int cpu = smp_processor_id(); + + target_queue_cmd_work(&se_sess->sq[cpu], se_cmd, cpu); +} +EXPORT_SYMBOL_GPL(target_queue_cmd_submit); + +static void target_flush_queued_cmds(struct se_session *se_sess) +{ + int i; + + if (!se_sess->sq) + return; + + for (i = 0; i < se_sess->q_cnt; i++) + cancel_work_sync(&se_sess->sq[i].work); +} + +static void target_init_sess_cmd_queues(struct se_session *se_sess, + struct se_sess_cmd_queue *q, + void (*work_fn)(struct work_struct *work)) +{ + int i; + + for (i = 0; i < se_sess->q_cnt; i++) { + init_llist_head(&q[i].cmd_list); + INIT_WORK(&q[i].work, work_fn); + q[i].se_sess = se_sess; + } +} + /** * transport_init_session - initialize a session object * @tfo: target core fabric ops @@ -228,6 +300,8 @@ static void target_release_sess_cmd_refcnt(struct percpu_ref *ref) int transport_init_session(const struct target_core_fabric_ops *tfo, struct se_session *se_sess) { + int rc; + INIT_LIST_HEAD(&se_sess->sess_list); INIT_LIST_HEAD(&se_sess->sess_acl_list); spin_lock_init(&se_sess->sess_cmd_lock); @@ -235,13 +309,34 @@ int transport_init_session(const struct target_core_fabric_ops *tfo, init_completion(&se_sess->stop_done); atomic_set(&se_sess->stopped, 0); se_sess->tfo = tfo; - return percpu_ref_init(&se_sess->cmd_count, - target_release_sess_cmd_refcnt, 0, GFP_KERNEL); + + if (tfo->submit_queued_cmd) { + se_sess->sq = kcalloc(nr_cpu_ids, sizeof(*se_sess->sq), + GFP_KERNEL); + if (!se_sess->sq) + return -ENOMEM; + + se_sess->q_cnt = nr_cpu_ids; + target_init_sess_cmd_queues(se_sess, se_sess->sq, + target_queued_submit_work); + } + + rc = percpu_ref_init(&se_sess->cmd_count, + target_release_sess_cmd_refcnt, 0, GFP_KERNEL); + if (rc) + goto free_sq; + + return 0; + +free_sq: + kfree(se_sess->sq); + return rc; } EXPORT_SYMBOL(transport_init_session); void transport_uninit_session(struct se_session *se_sess) { + kfree(se_sess->sq); /* * Drivers like iscsi and loop do not call target_stop_session * during session shutdown so we have to drop the ref taken at init @@ -1385,7 +1480,6 @@ void transport_init_se_cmd( { INIT_LIST_HEAD(&cmd->se_delayed_node); INIT_LIST_HEAD(&cmd->se_qf_node); - INIT_LIST_HEAD(&cmd->se_cmd_list); INIT_LIST_HEAD(&cmd->state_list); init_completion(&cmd->t_transport_stop_comp); cmd->free_compl = NULL; @@ -2968,6 +3062,8 @@ void target_wait_for_sess_cmds(struct se_session *se_sess) { int ret; + target_flush_queued_cmds(se_sess); + WARN_ON_ONCE(!atomic_read(&se_sess->stopped)); do { diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 50103a22b0e2..97138bff14d1 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -488,7 +488,7 @@ struct se_cmd { /* Only used for internal passthrough and legacy TCM fabric modules */ struct se_session *se_sess; struct se_tmr_req *se_tmr_req; - struct list_head se_cmd_list; + struct llist_node se_cmd_list; struct completion *free_compl; struct completion *abrt_compl; const struct target_core_fabric_ops *se_tfo; @@ -612,6 +612,12 @@ static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item) acl_fabric_stat_group); } +struct se_sess_cmd_queue { + struct llist_head cmd_list; + struct work_struct work; + struct se_session *se_sess; +}; + struct se_session { atomic_t stopped; u64 sess_bin_isid; @@ -629,6 +635,8 @@ struct se_session { void *sess_cmd_map; struct sbitmap_queue sess_tag_pool; const struct target_core_fabric_ops *tfo; + struct se_sess_cmd_queue *sq; + int q_cnt; }; struct se_device; diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index cdf610838ba5..899948967a65 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -80,6 +80,7 @@ struct target_core_fabric_ops { int (*queue_status)(struct se_cmd *); void (*queue_tm_rsp)(struct se_cmd *); void (*aborted_task)(struct se_cmd *); + void (*submit_queued_cmd)(struct se_cmd *); /* * fabric module calls for target_core_fabric_configfs.c */ @@ -166,6 +167,8 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, unsigned char *sense, u64 unpacked_lun, void *fabric_tmr_ptr, unsigned char tm_type, gfp_t, u64, int); +void target_queue_cmd_submit(struct se_session *se_sess, + struct se_cmd *se_cmd); int transport_handle_cdb_direct(struct se_cmd *); sense_reason_t transport_generic_new_cmd(struct se_cmd *); From patchwork Thu Feb 4 11:35:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCEFFC433E0 for ; Thu, 4 Feb 2021 11:39:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A006664F45 for ; Thu, 4 Feb 2021 11:39:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236004AbhBDLjW (ORCPT ); Thu, 4 Feb 2021 06:39:22 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:39714 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236093AbhBDLiO (ORCPT ); Thu, 4 Feb 2021 06:38:14 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ0o4122037; Thu, 4 Feb 2021 11:37: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-2020-01-29; bh=AakTnBcU2oH3AQ71ZMPcSB4AA5mBPEJzCX8nCoSYz1U=; b=eo3sU2Ca9/if7bP/nX05oZpZ3m086iarrYcEYw2UUhd96Y2ieNhvDyuiGzFOjS9v4Hje CJ23N0S9nbWr+Mv9KhoWNAQJLj3BVylBKdcKHvxtoowTA61YsqUYyOLQI5wdkhpOZ84U YFyY09N0/SBWTqsL1MDLqbs05XmrWaWqP+nGn4typMJcCWVIw4vNdKJw9zMtd+jpYcRE UOkLxoqkgewE15KMeAuIz0QT9ggB5PH3/RAOEh9W8OlkORGnkW5kq4SnJfCensjwmgrv 0BDLKvwpv7qc9sMeyWegNDHB1PjDafi4NujETkqiUV4JeFwUNo+8RgJmbepUGSPh/OkS aQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36cydm4rcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:37:29 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYfUL134930; Thu, 4 Feb 2021 11:35:28 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 36dhd187r2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPvYoJjxvx6kDjyQMh+EHfQHk/DvQIX4J4ahMDy/ZhO6q1adpszGsEeYHhnKA5ZWassw1eEq3TLRYsHjzZh7n9bS2Maafdb3hWhM4MFdHjAy2X3o0gwoW9WCjJpHnTIbYcEAsuNGny93Dfl2sntI1V2Z6lhH79BCLnMFba2i2iRCZ3cAIwhs/8tiZMdSSHgaAzrZdI4ZzD2WQPQsA9XZeuQYHRgVSd8hlTWOcwis0wMDhNvmyo3o5syCHV2i+p3rM0kk956j7Vg6SlAhgjlybr6egOKG4CpSjxe46s35y4e/2P50tiAmhm1c1+jdRBXberrk+fWD6i95woO09UJV8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AakTnBcU2oH3AQ71ZMPcSB4AA5mBPEJzCX8nCoSYz1U=; b=DyuIZKN21MRO9cJ5XAH0EOWGTTGrPWcdwvEmbX8t5jd/OOh2Mgt5T01bRjFK08UQNzJYk0tSic00dEcAU0awXiLWUrP6rv0pBSaw3qUueXsSRWvXQ9IbyRklkzsK3XTvwsZo6J9to1mwyKCpywNJLussWLqneCuVtQMddP61QPqv/AnusgNTfRuf1QYow9461w9UV3hUDtcdkaRLqQGeEp5d18TS2zb5Lsmbi6BobD4QkqRye/c86KWsmVtuHCNjyJvnCzAQTy015eoX/oefPtN6UXsEK5cOcmkIRzBCBS7mpHw9tmYhro2Wk/5oyIiRrFSxHZbKkSN/0Uq5djKZSw== 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=AakTnBcU2oH3AQ71ZMPcSB4AA5mBPEJzCX8nCoSYz1U=; b=F8sNNQs4A4cgfVqEUphBs4n0WzEgpykoEsYxU0OGdI8h/Oh7L69bvHGeNNyHw+unUnmdgKJyo9F6eb3Xy9U1aS6+KpMwTPfuAz3jEfxAzouc3lqns5iexbn/uromwfEaff3zQhL5bAY693ybMY2XocDynUYsZavXs+/7JJgDBXE= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:27 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:27 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 03/11] tcm loop: use blk cmd allocator for se_cmds Date: Thu, 4 Feb 2021 05:35:05 -0600 Message-Id: <20210204113513.93204-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 505a757f-4949-4dc8-d740-08d8c900f7c1 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1002; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ye0LNNLif47aFUDq8zf9Vpimm+8edXoSWlkE9BnvSCQqC9qtftI6M6XEmTD7WQ8BD3uXVbPgDWoVIXlnGy+fTl5MvOSf5z/EW+pnMf6U5RhNieCB9QIQhnOH3HayrtrF4WeSnFu7h8tBnRKIAoYFp0jVQylKeKJrxOpPdBHlsC7QAiWSXyi1RrXwmTXkho3wv6T7uiFiSuAHR+V9MpxMPdUFcuqh1ep1+ERgG4/0LIHxJhimEadqB8lrz0Nf+ohQ/gy0mtIhUwRFDlZzsBXSz9xnHBJLVu5UHzzpvbKAHE4WZDXuH9CutTbOnvnhNHX+eweQJNmabYEKW3pljx3c6cKXZqaNYLG4pXVTdDhlbMqgY35zHHvJlsoPqwpPbtMdupqWFflbeJ1qT9LGAE2LQ80XzxlmroCy9HzR3Ahpe6TisaBDV3PBTsV9RVhcWGFABHanqWzliBeKmz+Tk66o4LzLc5vEFKoVU/zEvOXXrowzF4NK9B77VmXbaRBYbjNtByk339JH6tjhZf/Drpg+4FgcbdS1mNJViWgs6YC8/Eqr2PirtPmAg3yIZHc1CDdRDOo6S3a3X3OOJAPuAiig+Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qE8iDmUoS+wRtCaMK4/uQ1dwsrEMMzIXwsEfyWD7ZCYIa2F+XNHjc5w/w4c8L30OJ5XAk9XX5WCN2E6W18I7mY7eCc91fH1NTnfQfpKAOtS8+T8XkSam1SiaePES3ieMEpWkggltvDeZC583EiY2wR6CKgE7qEWZl1nJf3+4doCrnyMpYi+Zx2LLPBvEDQE3ZW9OMnBfH/4vPeWxiI0kefN77EbhoBDuHTZQf+7cUg/WPYqv4CovfDyuAsNS6GBFsBJtCpO25J9uPNZtRya4sQsUp1A8tyvP85bYcaGTG2ZrzBqmMvH+mQwENDggZxYuvaJW4jM8dOBcPOp05cz8e47iI9Yr2VwrwdaM+K2sAEC9KXSb29nekcEiNEAJDJOM64QJiy9gZxRQzboirrOZsu5ad0+wVQm6K0CvawHJ4VFxV9gcKeoUgVM9DYoJS2HVX0djycK3p3hDTCbU+d4JARuPl7nZZar7F3eL2pzBcu/w9LrfXiDuo2/KKrgY00NtHlBCIBCRXv1RLIG7HeBcjrZP/rSVe43mFoxdo6YNPCinvteBqS/mSyEPyfOiQSGt1In/DR+RS368IK8GIRkY1SmXZhSZ27YPbTaxKnMW+Hw8IlzCQkz9xnrfqrVpBDWa78THcBaUbx8LdFSDB3mp1r7GgoW7uLzc6zwucoNL8Jvj+6an7xTjnnoJZfcF4w+Acd8RFiaBbcXB5hQMKtlYc2CeaRhJDafkMvA3HDfwYQ7RaYcILQh7H/ct5mUaS/jtPFkoAyJVk9jpNCfVBKQFG2QDD4hy6EX+ccucxooCHghP0yqN4z562LfSRVQukilSCsT+kLpldlm3IWmoVIP2Es8aeNSS9pgta+Nmi8xz50h2ToKUo0FJRU5fhwK2QA5XYgX4As2qvUHIOot45pInUlY/uFLGyDia32qZsNDY6xngVOIMjbDje6OkSOVGOwVt25ul/7WnOsFK1wKow4QYohQN5qRWXbJ7YMeSvKGfKEAS0VD4y6kejHQXqitdSy67zDAKkBFfihYbhOdv4gXSZEsU8RmuAGuwLMnREFOmsQXdTz00M2PnNn8BT8kMMb5TxaGzgyMlSajWkhq3S1wuBEGwzyByesO/jvMjRo3e0LicGkR80uHbXQoWqTaFq6uzCKfDPQBu1wr1FgDFrifwxfJMf4z7vmQz8gw4cQQEv8R4jwW0y7m9YBG7g4J5nkbhVC2q0CUFkqwGEAqs2t6ZoHUmt8kLDeSI0r/Bq3QEZWyzzPqP9pIYf8HoLZdB39mVC+00tWTuvNvgJCrxOtW4ji8GLRkzAG3qLR+JnA+AWcIRJFIjVoMhdf+8SjoeeXM3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 505a757f-4949-4dc8-d740-08d8c900f7c1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:27.0142 (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: Vd/ikbbaatLQi6HtV8G9OW75xmYVfzNQtz7dZpVUp8sC64EzWFydZWrCmcBLcYnepJail+6pNxuwKQNml1+yTiFk3vEjVhNMYuz8/92gcN8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This just has tcm loop use the block layer cmd allocator for se_cmds instead of using the tcm_loop_cmd_cache. In future patches when we can use the host tags for internal requests like TMFs we can completely kill the tcm_loop_cmd_cache. Signed-off-by: Mike Christie --- drivers/target/loopback/tcm_loop.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index badba437e5f9..274826a2b0bd 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -67,8 +67,12 @@ static void tcm_loop_release_cmd(struct se_cmd *se_cmd) { struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, struct tcm_loop_cmd, tl_se_cmd); + struct scsi_cmnd *sc = tl_cmd->sc; - kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); + if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) + kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); + else + sc->scsi_done(sc); } static int tcm_loop_show_info(struct seq_file *m, struct Scsi_Host *host) @@ -165,7 +169,6 @@ static void tcm_loop_submission_work(struct work_struct *work) return; out_done: - kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); sc->scsi_done(sc); } @@ -175,20 +178,14 @@ static void tcm_loop_submission_work(struct work_struct *work) */ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc) { - struct tcm_loop_cmd *tl_cmd; + struct tcm_loop_cmd *tl_cmd = scsi_cmd_priv(sc); pr_debug("%s() %d:%d:%d:%llu got CDB: 0x%02x scsi_buf_len: %u\n", __func__, sc->device->host->host_no, sc->device->id, sc->device->channel, sc->device->lun, sc->cmnd[0], scsi_bufflen(sc)); - tl_cmd = kmem_cache_zalloc(tcm_loop_cmd_cache, GFP_ATOMIC); - if (!tl_cmd) { - set_host_byte(sc, DID_ERROR); - sc->scsi_done(sc); - return 0; - } - + memset(tl_cmd, 0, sizeof(*tl_cmd)); tl_cmd->sc = sc; tl_cmd->sc_cmd_tag = sc->request->tag; INIT_WORK(&tl_cmd->work, tcm_loop_submission_work); @@ -320,6 +317,7 @@ static struct scsi_host_template tcm_loop_driver_template = { .dma_boundary = PAGE_SIZE - 1, .module = THIS_MODULE, .track_queue_depth = 1, + .cmd_size = sizeof(struct tcm_loop_cmd), }; static int tcm_loop_driver_probe(struct device *dev) @@ -580,7 +578,6 @@ static int tcm_loop_queue_data_or_status(const char *func, if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) || (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT)) scsi_set_resid(sc, se_cmd->residual_count); - sc->scsi_done(sc); return 0; } From patchwork Thu Feb 4 11:35:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0BFF5C43381 for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA20D64E50 for ; Thu, 4 Feb 2021 11:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236078AbhBDLhh (ORCPT ); Thu, 4 Feb 2021 06:37:37 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:54354 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbhBDLgT (ORCPT ); Thu, 4 Feb 2021 06:36:19 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BXcLu123054; Thu, 4 Feb 2021 11:35:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ffy4bpgrlTcrpZiC6UPE4q+MkX+KHRubtnCayUI06Ns=; b=KCxupqKRtB2frU+dp5EJtyQZvh53WrlyRjAjLX1AzlMng1XasDsPdY5MHGuVI6TqeMkh LyOGKpAEERWgwzXw65KczJpfTJz52QJHVGD6EoyvgIngyJrlnbknjyznD8qa3kYzhH/G rbJ83DPrgB2dkWW0B5YYON0ti7aoEkQ3SM2zR6NW/xBNLR7ep97WggYrCWyJI4RIXz/s awcLqndxyRUFEnO5FdOpi1QsJVes+lZjWrvnZe6YHYMCKZknzl96PB4kV/Qdn1DOKH7x oIxXT0Wodd5PkMCsmosX27gid3Ktt2Vom56W9jibJWJoUnYwlXzNb+TFYt0dIBkEksij cQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36cvyb4xrv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:30 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ5jk187745; Thu, 4 Feb 2021 11:35:30 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by aserp3020.oracle.com with ESMTP id 36dhc2jep9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KSC5aTcuQ3NH4s3MHmKqubWs25HvaC2wtbv/M0yGbHshBAGnihDfyiG646SZUJh71JEXkrrt6OpHIxZD016DnEWQXH8MPbXg2F/DYWU9LcMzOBJ8Xessr044Va+TkWB+EDND/PuvyTs1319X6PoFULDL0RH2HtIFg8BsmaqKlZGBuA6reyfwV1DkvFp2qNA3KTh5QijS7ucQw/h6eJIWM32t+B1AIXvHcfzY/iiOhPT8G1hKIq0FFBfKVSDBGIIJlHtO9IWL0Up4NzhEplrHybr9gI1igHk0CBeZM+kU5Fvg/9+cWlbILN8auoCiff/GsrfH7gmdkR3r/ZlhoG7jWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ffy4bpgrlTcrpZiC6UPE4q+MkX+KHRubtnCayUI06Ns=; b=ZJ0FBvUS//5Hvt+DU/oJLu0Ets/urc8irAeYGUtwcKI+gwq3iYZl/jpycVXNsT8dLC3Swoa0zQClI71EvgKeJJ+asLzoK4+qR/UNXefFRoPhDXGM0j8GvV9Ij0Q4LRE//Qh81b5cB5OzMPNpDV7U40WCeDwpGBolaahTt1KC0i0h0rF1/kSL7ZhAeURtz/kBzEw8ceqlToLv/2kbaCo9j5O+TDmEzkZQ9p9TXCjHzMqFrnOBRpHzsktWlGLPDt4jXcKvq0PswdULH/O5McORWT3JCrYX0KVhO3qzPOPfUWvvXNFDqPu7gcaL31kTzO6sTKhgfki5SldMjpvbUw2FZg== 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=ffy4bpgrlTcrpZiC6UPE4q+MkX+KHRubtnCayUI06Ns=; b=VD6rNMBNJVsVGl1dv0Pb+sD8n5US+q83mgg0JbutMgRH6SVny/ZHybzNI26dA4crFzcgT5wFPm06hPQQ+pxWbTgOgDDM7wW1bRszSVwOs4YYsxk2bXNB0Uau5LVnc5z8uFU+GYrMqI46wO9+fw28C43LstwoucfuiSLe6L5uny4= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:28 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:28 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 04/11] tcm loop: use lio wq cmd submission helper Date: Thu, 4 Feb 2021 05:35:06 -0600 Message-Id: <20210204113513.93204-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58a7e1e9-869c-46a3-a695-08d8c900f88e X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1002; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uQXgiW+ObgknjzFrJOare6an7rwwJCix1vk1NVbuY3rMSQuC+eigFgEiU4v3mcC1G5PQZsLLPfQ9E1OaqovnVUsCPkeTp4i7mftU22iKPDkRkt/tFLrWFbsUqtQDOPVo3P+eLdqtONSIPSZ1pMRVR5W4a/EqaJC0eMDrlNk/OQYuvX4sO5F0gaTlaKkzKW6rhzSHhbSANF5HELgBjddtxMe3YTPdxTHt7RFmdh04GdNBA7AxIWnfcRy85fEulBGe9P34hjPKB4JdxQNitWjDmO+05ZnqnXQ+4VRPfOS1V+ff8Zv5QgXWRXHPYULyfHt8gdnBEMqBK7DI2j5F00f9qyAGy9t/IeMxRN3RZlLsQXXibkIFmhKQUo+If5zoRgx30WeVCK6U0EEUDU120kAATRiQIU2YQjoGkFMYhrr4R2bOA7HFp6y4ouInzdg9qM2dhqEZJGY5JASsG80UzoqB9QCnNR2VjQlSS/vpn6YGMbp73AHoT/u9/iX79Bpy9fcngx3yibhPf1bwW04EKU778Rg+mXp2tR9TQ9rOY+ph8nhSq5FRIRlCGI+NUSNv66KEplT4VOtQQZBexQiJyZ2AHw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Gp4s5c7+X8LT6Uzf/0zn5kfxNGgeJjEs8fhMLrd3FvOU3vorxP+HQ9ZtKzxXZjqyFXH0NCnp18gjJ7RcohgD8/cWXcNnJ1qt/2QCOuIrZdjFKitlVdsEK7aHTEjI3SbOCIPh+8MXGwBqWXeJEqeF74J7MIxG9CO2fh1K6bvGXyybb5fRD+J2DTLvxbntRGWMff7tzy0MHJpYbZrtYTipwZ7wkB13yz6YEEW/QA45fVMwXG5IzjYjGjYJBAtsebcb4DfLX4l0exYWkFYcQaGxMoWTXkLYAclextG64d2mFDTi6BuBg9an0FkLW0mL0TJa6AVr6NxlorJAr3L4aDomCtliubMt9LiN4TP4SphfjKFeLy3beqqtf4X9izd+upZvlp6auCkHma358WLw5QbZpF0hQz07bjCnp90kDXj5+dZlGBmH4A+sXcVXBqAsjKeHoXUwyud5H46ILBYiKMjuxH5h3VpA208tH8zUTxn8I2uUqwfpOyB4IorhZ8Xaa/+g4C18+5nUnTvR/Y80yBgdfxg6TOULFKvFDeUz5R9M7jl5C6EZS8eCN24NkofM5MNC5QvvoN+ZLIyKg5TckjHkboCUQLrdxlDp4heq9S8SzZN83BwGv3GrFfsUJLvQXyorGZI2nVVA53dHE6Qjf96kNuibvrbGiKIsNy+I8kr3CF94WQhrxqhJ65g4OvClkgs7rPMarickzdxroZOTUuZ0pK69ahsJrrfkRTqrUBA4o2EPU5q5ZeAGDxoP9dHrBebvvouvPZFMHCYUq+dV0lexOe10YCiGdmgRyjJxvir+rUze3G/SE8s4D4HnnF0BHzLb7P/Gxn4KmLd9T/nEwBF3EAF+QyKXEssUc3NXKbX8Qh1Msstd1bBvW4JhkfJcQnKtVe3K83Rz65Zu+XZywOQnJooAr2QVQLqZKZWCaE6ruOYHKUR4gnuwN9K1iQCIZz0Y0CwOywPh3KXnBIVysF+wtYRZD/7/LRYUBBjewqTR3Z2yOfXxaCFvbWExDErk3B/quSs7AvtwzApbF3VsJG4+TRiqDuaI+Gm3TEj4HQ87IKLsu8GPRtuH7ulsus+w28UMM43bxqvxveFyruXNALTSTzQoWk7l/y12bN2b0EBAmDscE23Ye/X6+hWf/jsYMi4q8v2wTH4E9zISWqCgqSNrguq6K1Ag+f1dYy1VYIASBY7ylh0HTiQUA8kd06jET3arnG9NpRkAej/xUpx1cqqvCweGa0L2CnfjpHnn6snTjcZVtl7VAXZ2RawVPvle+saBSDRumK1huXU+BTVQ49+SLVmCjpMmYWNyr5wUw2eiNobEdd0MDkdWOmiAosFpwyjK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58a7e1e9-869c-46a3-a695-08d8c900f88e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:28.1695 (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: yzQNtnswciFxKqx1ra7nHxn29Xxoqvk4AmGl7gqDL1CdpLXFdmqqPTiU6It0ethJ3/aIpV8+nb77J0anOV9rzl0pg9X5Vi1mbXLKbXIuWNI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Convert loop to use the lio wq cmd submission helper. Signed-off-by: Mike Christie --- drivers/target/loopback/tcm_loop.c | 25 +++++++++++-------------- drivers/target/loopback/tcm_loop.h | 1 - 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 274826a2b0bd..8dc45165d33b 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -39,7 +39,6 @@ #define to_tcm_loop_hba(hba) container_of(hba, struct tcm_loop_hba, dev) -static struct workqueue_struct *tcm_loop_workqueue; static struct kmem_cache *tcm_loop_cmd_cache; static int tcm_loop_hba_no_cnt; @@ -106,11 +105,10 @@ static struct device_driver tcm_loop_driverfs = { */ static struct device *tcm_loop_primary; -static void tcm_loop_submission_work(struct work_struct *work) +static void tcm_loop_submit_queued_cmd(struct se_cmd *se_cmd) { struct tcm_loop_cmd *tl_cmd = - container_of(work, struct tcm_loop_cmd, work); - struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd; + container_of(se_cmd, struct tcm_loop_cmd, tl_se_cmd); struct scsi_cmnd *sc = tl_cmd->sc; struct tcm_loop_nexus *tl_nexus; struct tcm_loop_hba *tl_hba; @@ -179,6 +177,11 @@ static void tcm_loop_submission_work(struct work_struct *work) static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc) { struct tcm_loop_cmd *tl_cmd = scsi_cmd_priv(sc); + struct tcm_loop_hba *tl_hba; + struct tcm_loop_tpg *tl_tpg; + + tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); + tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; pr_debug("%s() %d:%d:%d:%llu got CDB: 0x%02x scsi_buf_len: %u\n", __func__, sc->device->host->host_no, sc->device->id, @@ -188,8 +191,8 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc) memset(tl_cmd, 0, sizeof(*tl_cmd)); tl_cmd->sc = sc; tl_cmd->sc_cmd_tag = sc->request->tag; - INIT_WORK(&tl_cmd->work, tcm_loop_submission_work); - queue_work(tcm_loop_workqueue, &tl_cmd->work); + + target_queue_cmd_submit(tl_tpg->tl_nexus->se_sess, &tl_cmd->tl_se_cmd); return 0; } @@ -1146,6 +1149,7 @@ static const struct target_core_fabric_ops loop_ops = { .queue_status = tcm_loop_queue_status, .queue_tm_rsp = tcm_loop_queue_tm_rsp, .aborted_task = tcm_loop_aborted_task, + .submit_queued_cmd = tcm_loop_submit_queued_cmd, .fabric_make_wwn = tcm_loop_make_scsi_hba, .fabric_drop_wwn = tcm_loop_drop_scsi_hba, .fabric_make_tpg = tcm_loop_make_naa_tpg, @@ -1161,17 +1165,13 @@ static int __init tcm_loop_fabric_init(void) { int ret = -ENOMEM; - tcm_loop_workqueue = alloc_workqueue("tcm_loop", 0, 0); - if (!tcm_loop_workqueue) - goto out; - tcm_loop_cmd_cache = kmem_cache_create("tcm_loop_cmd_cache", sizeof(struct tcm_loop_cmd), __alignof__(struct tcm_loop_cmd), 0, NULL); if (!tcm_loop_cmd_cache) { pr_debug("kmem_cache_create() for tcm_loop_cmd_cache failed\n"); - goto out_destroy_workqueue; + goto out; } ret = tcm_loop_alloc_core_bus(); @@ -1188,8 +1188,6 @@ static int __init tcm_loop_fabric_init(void) tcm_loop_release_core_bus(); out_destroy_cache: kmem_cache_destroy(tcm_loop_cmd_cache); -out_destroy_workqueue: - destroy_workqueue(tcm_loop_workqueue); out: return ret; } @@ -1199,7 +1197,6 @@ static void __exit tcm_loop_fabric_exit(void) target_unregister_template(&loop_ops); tcm_loop_release_core_bus(); kmem_cache_destroy(tcm_loop_cmd_cache); - destroy_workqueue(tcm_loop_workqueue); } MODULE_DESCRIPTION("TCM loopback virtual Linux/SCSI fabric module"); diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h index d3110909a213..437663b3905c 100644 --- a/drivers/target/loopback/tcm_loop.h +++ b/drivers/target/loopback/tcm_loop.h @@ -16,7 +16,6 @@ struct tcm_loop_cmd { struct scsi_cmnd *sc; /* The TCM I/O descriptor that is accessed via container_of() */ struct se_cmd tl_se_cmd; - struct work_struct work; struct completion tmr_done; /* Sense buffer that will be mapped into outgoing status */ unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER]; From patchwork Thu Feb 4 11:35:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45C90C4332B for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B90064F4A for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235884AbhBDLhj (ORCPT ); Thu, 4 Feb 2021 06:37:39 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40182 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235905AbhBDLgT (ORCPT ); Thu, 4 Feb 2021 06:36:19 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYXuX072776; Thu, 4 Feb 2021 11:35: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-2020-01-29; bh=Z0p4kvWJPsQosC4i9Tc+WKZWQItTH4hwsAE0GdTYAgo=; b=FSRby1kI0usjZLUVkJbhgTM/V7UvbM+guWft9zKiBIhO9cYi7suIqnnq/wa9OjWEhtGj 98/hw8tBwoFyFVd6tztL9/ApuxwQtLQVB0YHK75D1ZySvHhgbbnB1CWMSxK0wpU2se9G 6gTSo1yHECcPDZYj5hko3g7rvQZIvDf3qI2eNVu1PN8hLIXsac1vP19y09FMXm9pdIwc LrGmETSwSqVJq2/kJ12nQjgNq6drdyUfPU029J3/vjHvW/Wx93AkiBEjyJoCXJLl1OXc mJopwJ6Wx1zAcSG/4yl+jDiuBnmvGGf1vjXtnKzw7X7aTWtazrl/6CRAfIwv6o+oRzNs rA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 36cxvr7h0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ5jl187745; Thu, 4 Feb 2021 11:35:30 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by aserp3020.oracle.com with ESMTP id 36dhc2jep9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XrJzGdSgz3AdX9dpCkSNYpBL3wbqkavF7ZjyJBLyzI7OTmdG5VZ6HYKxlk1ckB5Fy9SLGvanh8Cf3oHOaB6krVwNU8/uRMMuVeLFxogb++aQPFu29+xtNJemgfNSugNOLDTnohw3kwaZyZfsg3sM4n1QA8LrBV6xQFYc8y67rxD/JOX33dWKMpn9o5n6Jm8mnHSHbCwHkBF4eiaGFDk9Y2Qt/7WUxaAY6ppiNmOOBLSH3Q0DZY88y+hyuSnJqHDo/F9KzehcCYK0HCnvxj6mjyaJhSI7bIAB3i7oNJmak9rqWjzmQfzEsNwiQBEGlZnBzwpJuQ6tW0Ww4PFN97d/uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z0p4kvWJPsQosC4i9Tc+WKZWQItTH4hwsAE0GdTYAgo=; b=DXggHWHHNA9Ixhg6BDP+7ohT8bS/xMkIckPTbgMto0gUyCaNsGFe/7WtilE5ulxKHnyh0XGfsl8f7OZTZbY9BdvsF3/aN6kFeVF7Oi2UePf4p9iiol652UfR9kuU6cSwYWwV+6TSJ135HORPOSxJlTK6wOOxEY5vDs3xKQq1PnkAhEU456EE0P915C4sqT0AF+UPL1mhKRSTnXr4+fqTrh/NXTKEC4moE+86kfrU9Hu9DoPtN2lvRyLsYMhz5cZVATxXlgSCbp13gvmoxDKBnGtw6X2PNnmpscDpOw8GB6VJk5zQDr7t45hzo8Qr6ifRuARjX8lB1o88V0tRWVEXsg== 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=Z0p4kvWJPsQosC4i9Tc+WKZWQItTH4hwsAE0GdTYAgo=; b=j92NTyGDltZsb+kj3FRL8C1TfyZtoxPoG1UcOlu0wFEyMRtFgaTPwpRgz4G6q0ifP3dBw70wdjPpUxp5ANEDJwVfWwodUv57GC36u0oI+h2czWU50ybsJKmUFzL22hrkZSH1sCNY7rrZqfwFf7jqr5m2Y51jlxsbA3Fbxi16cvA= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:29 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:29 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 05/11] vhost scsi: use lio wq cmd submission helper Date: Thu, 4 Feb 2021 05:35:07 -0600 Message-Id: <20210204113513.93204-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c744f9ec-dc5d-47ac-e015-08d8c900f93d X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bED/HuIseJaChlefo4mGM7Hb8MoVNopztnjmOFBXjbhQ2QoH+fi6MloRW3dHPMQ6yFmdcUUc6klVwJLNG5x/wdKf2G4hl9Lz8+vrCzdCYKTL8wTuMuNK4EFI7094Og2IlOFn9peq/f83NwZ+8rkgd2Czlep0F/9rWycsYZ3z0WYPyNNhYUYbDAerWYHLLzvEkYbZGeLS/ne2GAlq4uhw4yi8mQbNwXGYYB9HjA396NtyO5sFh3lBwrKYng5NiTqiIuHM5mk/+hVei5cLsVWi8Tu1bsVO+5MO0xIISyLE8vwJscxRH+1j3iiHDozsnoVdx8Loh18Vy3mkwh3WGBPhKlS4pvoUOAONKTZHlrZCLUcKJ7fCxL5HtsH0VbFMJn80ZNwnqLr7IKOG3ib/fLeZ8OFy8qtp+lFo0Vdad75OyF3VrRlCWiMfZsZ2TvnvqQRckYegxOM2b1UeqBoM1hTeLPntNAnvL9IRi4AB92x7jcu9kA4mG5WauEuADpaApNNZakyfA5xm6wbysgA1EJnAaon8QOanYRYWArTy2Dvfu7CBLqcTIcnE9EvpzWd+U8pqFa2JzZM8JG0ggwOFmkPCwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ItUqFDueIC9HW5MLURUk5d9PTJPvjf4LezMooFc7C+HtSfYBVXKUCy4A5+LMulTA08p8+eVPWQnMJyZALhKBXBMNuTIBJ7ggMPxbVn8TGOFQV5zqsV+dIrH2i4pCJdzdpOd/knkUTijA+qCoSurEXfqxDcWSeZxaW9QSrEV9XzwHhyZDivBu2TYh/yb0laVBVu4ck6eYFDtWLq2s+q58vCMGXEwJSDvtraT1GX32FTBpd5hxwtoM3Gvny1We7dzi77LG4G798ECCDlvTA7Dx/niaSQn9btQ0NUIPX5Xm163Lh1la5H1opcJQWOlx/59ARWZ5io8WRBZOpSAgmTqOou+BfK8Fs7wbF1fPDrrvJpcBmAh6BXxT07cM+07R1/NbZYwIRub2jF6XpypGMJE5TjaUFr0O0libFby01IKzzyqCnQoEnj8S05z+/IIZ8voNhJdwOiWVNCUlXoeOrRsbhToM5rNjFwN8h+1JJTgKe69/sHIXXZEKac9XpWVCMUlYKNiIL5yZClO5zZIuY++gB9XQbLSDOm2RW0ULN9n46k11LHNpeuAOwRYOBfafp47tO/n4Hx4/2K4q3DvVO/f7VSdwq6m3J2Fo1g7GJOWKMrHgTjsDIFLxH1V6NDCZLQz+uQlnm6FxT5EbIjLNFa+iW+pq1FLumU/gUuwe8puo7fu6DcjMS47qUKB5MugQkovC7hTeac1Itb4WY+nYqy1IXy+bzFMYr9hDLUc54OeQ8JKxmTCWunbAHRz013g5R1ynYM1xvCyz5DxXfxAlL21Rn8pVf4SdYgcXOJtFEG68M+V8ysGCEw5vAVpiu7g8nRy2+RE7o8wtStIrYn8C+O+0RjoUzHB1G+OR6zdvgLNNgWvPc5SOyBPJvaFjyskaN6cRZIQ1bzavBJCBqZFPiz8KN2TmTqfdatjAQ15Bf5egCkhPnlvOPUUE/PruReIkRrVgwrP7n9so5rlxt31DgAj/jGfDZS0nDhYtm5vAfOe9uN58mgd/TcpQCEHJlFva+a5nzdmmJ0xeykI+McOpQsvRwhSfibmKaIS2C26ENOWxgZe05s/7Y4i/NGQam5vj6iqzsujvc3OPOIfXfeA5i1lZV46tDWQL4IahcajW/JfRYvoYxNvnBDHQXzrrD52/5FLrUu9uqL4HJPcfwc5oJsFVeRRkAaB/mMS2bOSQ6mbUamausCC6bbCPVZ3CgEsCqlWzFlOHs6gdV+UayKfxD+GaA6ZVQWQzT4eAcMEWggBxRCOIvPGHY2FMikd1IB2xnTWy3JBFK779Umj2Kvsnr3krxn51akF1US/mVNuPkhtnaE2dlbb4z0ck2+hy/4ohbiSh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c744f9ec-dc5d-47ac-e015-08d8c900f93d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:29.4308 (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: TRUAb4WXVYp1RV5/VPi1b+kj8Wm5Z3BJoqcTf6V8YiEpKomL00KEU0gGC5BFcT8vV//U217Mt9ifiZiuQ2dDEYO1n6c2aVIX9MYESvR+Syo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Convert vhost-scsi to use the lio wq cmd submission helper. Signed-off-by: Mike Christie --- drivers/vhost/scsi.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 4ce9f00ae10e..aacad9e222ff 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -85,7 +85,7 @@ struct vhost_scsi_cmd { /* The number of scatterlists associated with this cmd */ u32 tvc_sgl_count; u32 tvc_prot_sgl_count; - /* Saved unpacked SCSI LUN for vhost_scsi_submission_work() */ + /* Saved unpacked SCSI LUN for vhost_scsi_submit_queued_cmd() */ u32 tvc_lun; /* Pointer to the SGL formatted memory from virtio-scsi */ struct scatterlist *tvc_sgl; @@ -101,8 +101,6 @@ struct vhost_scsi_cmd { struct vhost_scsi_nexus *tvc_nexus; /* The TCM I/O descriptor that is accessed via container_of() */ struct se_cmd tvc_se_cmd; - /* work item used for cmwq dispatch to vhost_scsi_submission_work() */ - struct work_struct work; /* Copy of the incoming SCSI command descriptor block (CDB) */ unsigned char tvc_cdb[VHOST_SCSI_MAX_CDB_SIZE]; /* Sense buffer that will be mapped into outgoing status */ @@ -240,8 +238,6 @@ struct vhost_scsi_ctx { struct iov_iter out_iter; }; -static struct workqueue_struct *vhost_scsi_workqueue; - /* Global spinlock to protect vhost_scsi TPG list for vhost IOCTL access */ static DEFINE_MUTEX(vhost_scsi_mutex); static LIST_HEAD(vhost_scsi_list); @@ -782,12 +778,11 @@ static int vhost_scsi_to_tcm_attr(int attr) return TCM_SIMPLE_TAG; } -static void vhost_scsi_submission_work(struct work_struct *work) +static void vhost_scsi_submit_queued_cmd(struct se_cmd *se_cmd) { struct vhost_scsi_cmd *cmd = - container_of(work, struct vhost_scsi_cmd, work); + container_of(se_cmd, struct vhost_scsi_cmd, tvc_se_cmd); struct vhost_scsi_nexus *tv_nexus; - struct se_cmd *se_cmd = &cmd->tvc_se_cmd; struct scatterlist *sg_ptr, *sg_prot_ptr = NULL; int rc; @@ -1132,14 +1127,8 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq) * vhost_scsi_queue_data_in() and vhost_scsi_queue_status() */ cmd->tvc_vq_desc = vc.head; - /* - * Dispatch cmd descriptor for cmwq execution in process - * context provided by vhost_scsi_workqueue. This also ensures - * cmd is executed on the same kworker CPU as this vhost - * thread to gain positive L2 cache locality effects. - */ - INIT_WORK(&cmd->work, vhost_scsi_submission_work); - queue_work(vhost_scsi_workqueue, &cmd->work); + target_queue_cmd_submit(tpg->tpg_nexus->tvn_se_sess, + &cmd->tvc_se_cmd); ret = 0; err: /* @@ -2466,6 +2455,7 @@ static const struct target_core_fabric_ops vhost_scsi_ops = { .queue_status = vhost_scsi_queue_status, .queue_tm_rsp = vhost_scsi_queue_tm_rsp, .aborted_task = vhost_scsi_aborted_task, + .submit_queued_cmd = vhost_scsi_submit_queued_cmd, /* * Setup callers for generic logic in target_core_fabric_configfs.c */ @@ -2489,17 +2479,9 @@ static int __init vhost_scsi_init(void) " on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname, utsname()->machine); - /* - * Use our own dedicated workqueue for submitting I/O into - * target core to avoid contention within system_wq. - */ - vhost_scsi_workqueue = alloc_workqueue("vhost_scsi", 0, 0); - if (!vhost_scsi_workqueue) - goto out; - ret = vhost_scsi_register(); if (ret < 0) - goto out_destroy_workqueue; + goto out; ret = target_register_template(&vhost_scsi_ops); if (ret < 0) @@ -2509,8 +2491,6 @@ static int __init vhost_scsi_init(void) out_vhost_scsi_deregister: vhost_scsi_deregister(); -out_destroy_workqueue: - destroy_workqueue(vhost_scsi_workqueue); out: return ret; }; @@ -2519,7 +2499,6 @@ static void vhost_scsi_exit(void) { target_unregister_template(&vhost_scsi_ops); vhost_scsi_deregister(); - destroy_workqueue(vhost_scsi_workqueue); }; MODULE_DESCRIPTION("VHOST_SCSI series fabric driver"); From patchwork Thu Feb 4 11:35:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4BE2C43331 for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D74C64F67 for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236085AbhBDLhr (ORCPT ); Thu, 4 Feb 2021 06:37:47 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40240 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235952AbhBDLgS (ORCPT ); Thu, 4 Feb 2021 06:36:18 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYqI4072846; Thu, 4 Feb 2021 11:35:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=UIG79us5tdcxA1pQAmmj93qpmV8RiUwAZv7vyNg/YH4=; b=Hn0n9IgkNXo3aDymRwbez3nnYo9+UVKeAyR6MPL7pxVEyO+e3Vv/KVdv2cKhyIiFgROT /7UFjR1pfBS4Ckgexs0Ai8zbCGgur8WHgj4NHzG3uzcyos6Gd3jBNXY2kqYbRiXOZng4 Y4Brynb0SN4D41hBuqf4bTvarZw5YAInQ99dktb0/oPunF3qEwND2XBpc1U7Tx4lrFB9 GcQdrFDHec97xXX0zZCxsnMZWp8r5MRwXRFhd/jzZZtqt3OWouKpkIdKSTJDHlEWW5Rd kDDWKmuld5voj5fCI2ybk7dku1Fuy7fxAmGrXhejAA5f6uDZiLF/tORW22pyfQA1eBr1 pQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 36cxvr7h0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:33 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYfZX134897; Thu, 4 Feb 2021 11:35:32 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2172.outbound.protection.outlook.com [104.47.59.172]) by userp3030.oracle.com with ESMTP id 36dhd187uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LFAe+GffOYx2PGm65Up/VE4laqdS8LHl65NsGdK86R6hpsmumJfseiqdseKIprwi3KfPig2Hzyw2saM3m4JxRrnZL5qwjn1GVM+NvfFczDiXdOqbLh2b2JYosMWT+YL8VpSGp8HOF7Iz0DXeh6jBE/QCbGOmd5sYbXrhK9coF+UXfZplRB7UrxbZV5XgBTNc8qLFv5mjxWfLqqpLvStpn7nID4KZGluJfWC8uSpvMjBPrZ43IK9ERFF+rVoFfks7VEA2v7SQrUofaBOE05Gm6xwJhMZNHZ7IeMO1/xQs9Vb5ISIVBEs3vsqy9I00lNyRJyWCxNy3G3Xdj/DIN1yT5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UIG79us5tdcxA1pQAmmj93qpmV8RiUwAZv7vyNg/YH4=; b=O18/nDtZ8hV0lew2fKV9FMDFXpuQFndxTBGb5L6ZLA2RuzonUJlMUO+e2ZAV7XFSJVGClKG5saVskDKgdwkXDTpbVU96MILMpEI+98878Mktf9FEUg09oU+UTY7NS/UNI8tk4gbQQLaxkV2mPYheISBLF5lsQ3tmrvbRP4mlxRIoELu21xX39M/IFaRt/LSaCB59XL61zkd1KADMzriiN9t4WpTMzh8dSXkW4y3VndeeP5f+KN9AFiw1f27pl7YFr3ExwPFETQc5vi0DAX2hoNayFL02G7LI8m2W5XVSqmgrxuGdJ+yW7GHHl2DnidPJQkHER7amnkld3idLRjfTGw== 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=UIG79us5tdcxA1pQAmmj93qpmV8RiUwAZv7vyNg/YH4=; b=lqmEx9DxJ36908r6yYlUV6vdUN1sOoS8QYhpLl5zkJvrEgmbu4l65I4NUSBHI2ZVZnk0AEdj+egvLdS0T1eawRwLk3ehG/M2BxIJk0orxAyG05Y5FXY17uw/vGPdTsxs88hwih8sTK3f2V+SjW7gyFQmgDBKjLAq7DdLF+8MCZA= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:31 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:31 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 06/11] target: cleanup cmd flag bits Date: Thu, 4 Feb 2021 05:35:08 -0600 Message-Id: <20210204113513.93204-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6702da38-a0ed-4506-80ae-08d8c900f9fc X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QP/G9CYjkWKHxIG7q9oFr6Qc3ZDnVCgH9rWiojsmEWqXTxBoe07rwr70ZcoSkdi2Um87y6bQr35IqLbBZ/sIOcAWH+jNsUTwBNgTSaQYsuMTHt5bnYD1fNJLv/jIBbJQgJHRLYgcT8NlnQA3iguj28b9axIslYc+5w1uzza5+caSgasguBUeS7Ux6TVNAdlHHVBghzsgCxbkQnPCyS2IVLz5pcbRcbUeX7VA6Ul4KLytjYIPrP8m/dkV08S7789UEP6M/e0WDsP0pmN+On0QJHvldoutpmoY1hZjfEDREeEKIaFF/mHQe4zkk3Q1rfVwCBQbwhvv7X9dxpPaDYyv3CPu6VZo3FG4VyF+u4W93+4DGEP1d63pT1cE3st7NHnkN8/yajSU9EA8Gazy9UyHNUoQ4MKBHKhAq1F+9R/0WlJUvLmR0pvCcip1VoIxTH1C09wBFwevozCOlfV+PjUsalkRr5kJohN1io/RDEGmzguSR0k6dl+DsbHyDjxkN3sUmKOs9KPFJBfbuLV8uXc+ef0H2jIU0Ktc15idg1n79r11P36nKhfyHO4Z2kfcmrnVitjFN5xOktw7rNzOSwTpEw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GSxU/IzpEYjXdCO8prjhE0PWiBM7tfsZ+LaCrv2kkbX5EKtrcuePPZtW7n/HLQ/LxUPVijxU3fth8hjTh9gLQsuym6m/Yz5deF2Utw0PhxluKFoeBHyaOlzVppA9JiRWbFdni6qCLQr/zqLXEngM/y60xRbcBJfHTbsmZYy8apx16J9sKC+WePZUCa3CLCVtIijAaI84m6ug4xzYJCmoAzYub5YL91Gt2ilXTyxJRgmPKEM/BouAWpCCaiFcye9wVAT/+VWXZKxg9UpZoMrrKGSxIbkFzpzUTlCk4kBRxV/4tx6ApBlrRu6MbDlshaox+uBSw6ZrmNuCaBhpaMBLKKVp36/f+RPrbmInV3tcHjcTJ22qzjLNX6MtpobPqaJ6HTKkfeYyi2MQ1JmyDSf48kFgpD3xplAVFdRMUnclaA+DnHqnNrHSwlkZzgdTbT9yYOlhdTLmrqGSDxKkD9U+KlnZSFlkOuQMRQlkyAQJR7+MbDAr+vW5RdkLheqefnp6NaQGeamGd0wb+lgXuhUiA2kgiGq3GUramKLHQcMncnMt0uBfub9a+5aftQ2WlfsHowf0k8FCGBo321zx4nqiJXnFVJD/c3q+XLcHI4pUa+zdrcJa2Hq9YtWARcAAtJSCtPGFyTa2x0mpst2h4vuU/a3Uv8RR/V+0J9/8nObNqE+GHLB5jjaGAfON9qC3vKyU2dn+v41K93VBR9Co8AVG+iNei7uT2jIkNa+YzSBaqcSXljihgLhvznBgvce2/mNeOPHJ6puk/1r3U4oBOxad9qC+4r8zQfuec4Hy2i1wTuqCLWVQ+k64F9lMeLNKuTj2yCoMen3ddyZr0ecZmVt7sWUOeHYRflBYqeibor4jF0dQ9vq8tsu9py5hk+xSnlj/vYz6qYzb81HfRkhM8ZskK2QAgVAX6m04upPeIlYYNs2cA5u7gnP8SaCgMBKBkgf/daL9GAJF9NpjNUiD8oGnBdesqNkwVYxujHs/dVSpDG9sN8EJNj4f0ypRegRIS+0COBlCihMG4pbd1r9Rsp5dKjNrLgXl3jmQEs1y2u2umphoOTgu1rAfr2AdlM6QLmnwcGwoE3tMiL5UlzPabu24h8w+lB1/8KZgdPcGV669mtOLh9Z2Fm64drA78V/RrldTdpAo4wIzKg0SRQpnTSDTx0Zin1SyiP5u+0T1UXVmtFOh8FkaMiQFwyhB9PoJKYDHWHCLOti5tKCy/A+sFH3A/ijBb4l75KYt1X36Ej/ySyMYv9PFv5iFlpQG7BlKb15c3+GI6JvRClbYu4elf6+6HQVQ2Z4aau+4GcvUTlEVjP/uI6R9e889TlBTY4rurmr9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6702da38-a0ed-4506-80ae-08d8c900f9fc X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:30.9699 (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: wGR2l910axstBY9JouWG/E2ieA/9Dh+iI/15SosIfGyIZzCDR4OvHbuXmcZrxlqCzDMHCNzEiyUvbMRF5UBCb+aPp3KULEz2ONZh6ChL4xg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org We have a couple holes in the cmd flags definitions. This cleans up the definitions to fix that and make it easier to read. Signed-off-by: Mike Christie Reviewed-by: Chaitanya Kulkarni --- include/target/target_core_base.h | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 97138bff14d1..b7f92a15cd1c 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -127,25 +127,25 @@ enum transport_state_table { /* Used for struct se_cmd->se_cmd_flags */ enum se_cmd_flags_table { - SCF_SUPPORTED_SAM_OPCODE = 0x00000001, - SCF_TRANSPORT_TASK_SENSE = 0x00000002, - SCF_EMULATED_TASK_SENSE = 0x00000004, - SCF_SCSI_DATA_CDB = 0x00000008, - SCF_SCSI_TMR_CDB = 0x00000010, - SCF_FUA = 0x00000080, - SCF_SE_LUN_CMD = 0x00000100, - SCF_BIDI = 0x00000400, - SCF_SENT_CHECK_CONDITION = 0x00000800, - SCF_OVERFLOW_BIT = 0x00001000, - SCF_UNDERFLOW_BIT = 0x00002000, - SCF_ALUA_NON_OPTIMIZED = 0x00008000, - SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = 0x00020000, - SCF_COMPARE_AND_WRITE = 0x00080000, - SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC = 0x00200000, - SCF_ACK_KREF = 0x00400000, - SCF_USE_CPUID = 0x00800000, - SCF_TASK_ATTR_SET = 0x01000000, - SCF_TREAT_READ_AS_NORMAL = 0x02000000, + SCF_SUPPORTED_SAM_OPCODE = (1 << 0), + SCF_TRANSPORT_TASK_SENSE = (1 << 1), + SCF_EMULATED_TASK_SENSE = (1 << 2), + SCF_SCSI_DATA_CDB = (1 << 3), + SCF_SCSI_TMR_CDB = (1 << 4), + SCF_FUA = (1 << 5), + SCF_SE_LUN_CMD = (1 << 6), + SCF_BIDI = (1 << 7), + SCF_SENT_CHECK_CONDITION = (1 << 8), + SCF_OVERFLOW_BIT = (1 << 9), + SCF_UNDERFLOW_BIT = (1 << 10), + SCF_ALUA_NON_OPTIMIZED = (1 << 11), + SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC = (1 << 12), + SCF_COMPARE_AND_WRITE = (1 << 13), + SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC = (1 << 14), + SCF_ACK_KREF = (1 << 15), + SCF_USE_CPUID = (1 << 16), + SCF_TASK_ATTR_SET = (1 << 17), + SCF_TREAT_READ_AS_NORMAL = (1 << 18), }; /* From patchwork Thu Feb 4 11:35:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAB90C433E6 for ; Thu, 4 Feb 2021 11:38:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AECF564F44 for ; Thu, 4 Feb 2021 11:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235799AbhBDLiI (ORCPT ); Thu, 4 Feb 2021 06:38:08 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:54144 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235851AbhBDLgW (ORCPT ); Thu, 4 Feb 2021 06:36:22 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZabO085641; Thu, 4 Feb 2021 11:35:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=QvHfCjMXWF+ej1Mva1HpJdfSYxFcxh9AkDlgaYiKMss=; b=P4MaXXhj8CGERkKf52W2pCfGwxjy6DLJ+Te3ahwdaS1G3ohmwehVyY2bv0cOep9Z1sPa N6BKIunoe7dL8ETn42JNv8csbW/6Jyo9R4XhSlJdR7ldgDx8b5ApzXsxChco8xJCGDgd g9b4RQXAZiVWJGYGzjjSE/oumcLOV3C/vj0UL7Biamfk+0DRfjScw7LJyXVvLJlUHVuZ fYK/siqoqjYdPkF6LO8g6qX/S/IRZfoD29mlcIt4X05rF53sFOr0D/Ksx07VDHE+F52N 2kJe0wvyKlaS+J3g3TSu7qeKU2racZ0a8aJ58qGsH0HpCgCawx/CTNvQYS0MFER/klf2 hA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36gfw8r08t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:35 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ6al187848; Thu, 4 Feb 2021 11:35:34 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3020.oracle.com with ESMTP id 36dhc2jerf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lacfTYKRX35PPaptZTxIwwCaAkblRbVKin6gEz+QK9/p9F//4jgJf1aVL5DxjaNNpssHM99RdR6fQIIrzq2EkpObrbEfWWAQ/JwYGl4tdoMchRv6UkwQFPBIXzK5zqsnB/Nf82yq/ZWFw03GDCMxSZ6PWXEtNIz3KPbKNn6LxPrnGk+RVp7a8EpgKfBm4Bh5k2j8K38PO9o4DnxXS2+CItg22ye8K856to6aGsYKMMrVlOhPMmjSXAz/E204Miwd1fMeONTTINI3XcxLB967nRb60brqxZzQC5tAlvbhD8465girusb1EYu2GjkL6iBgIfROPUxGcWk+nWIzwN5tBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QvHfCjMXWF+ej1Mva1HpJdfSYxFcxh9AkDlgaYiKMss=; b=WDsRmsi56Z87aHtqVNwoBR+7tawu0lUqCabFrfNzX/SApAJf8ixKYupSzcsPEUN/o8d17Iv5iP/rU32C+/Suk6bXJDQWTXi3F1PjgZVn/MRkg6QFYWIw00rBmLppmJX4BLAkzACfD1Q+lO6/vaIgMVzLsuHAcsy1l+r5pkCqcTJmQHo1QoGPB64deRFLgh2g53fO041dGuKAoBGqhZE879UyKLsuM5/u3mE3ky4XNr5DGvVeBD0JR8CKuOVCysef8fKk10p7xRNSmQf1u6vkY0Fm+OL/E29wGxRBES0wmG2ZRSZwOI6TO+IzHTkoVdT2HlCbJKSSGGU+dTm2hGU3sg== 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=QvHfCjMXWF+ej1Mva1HpJdfSYxFcxh9AkDlgaYiKMss=; b=tykTlxZnuCE9n8v0XH+mwXqz5XxhhW7TajRiAz9iovSFikgn2+VS4019ZhEi4HNzhkk6YpInM42CSVBf1NcQ/7m/C+QrNa81uqZI6qy9teoTlP+vx/YA3aBml7ArNF8BAxV97RZbn1BqlLf4GTV/EzTEmHLvDlJhgOkLtJQfiNA= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:32 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:32 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 07/11] target: fix backend plugging Date: Thu, 4 Feb 2021 05:35:09 -0600 Message-Id: <20210204113513.93204-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5237766b-0125-4cc9-ff84-08d8c900faec X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yNQOQGhx8u7auVA38iTn5f2M/T0avnPRm9M6Tlfv2ytRtIX1qZrOjAa6GCsg6GNn9ZITWzuDXjtZJfP4L5DNep03EzpmjB486oVS8N80XcimeZkBQJz47JqRjWmJ0zIItvS5X37NuJxlJ+UMBveVuAGDSZ9zBE9SXbdPQBHvR35Lai+Ms1iBLNtCAtZy/GQxK9OrkC/OTnOs9gjiwOi+LpWdMyndrcNh6pKRwd95pczY4JUjf/O9L4rHMZb07edveneZHCDXEtnMaXBeKgO2N2ESLzsVIDZVYBKVJoPfwDsOFzN7rrtby84y99+8NDtx/4jVuMbMmO0i6OqufZIquf68cunawFQZDF2Or9V1lYgUPjddMI2p1JgQPbORFVqh5oIJfFKRuUK1Vx8M/BtsmeneU+6IHVh2RGqGX4T3FkdIizxA9RHw2dlqt5lvtZoQDWHdGmnLQO7JYXm+5rMcU7ilyJ7ZjGcQthTMvIfRuaUHVVMjX7y8NyrsCNric0OEvTMGrzhIZvTkVQYObTHOmC16SGQW+5kiXLg2tlQeON6nPiXwl4f4FlqM22aoJXlveQRQ6Isp6Gz7f8shoEQofg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cw40RNkxqxkVI6YFsVs8cGR5BUFppQDrhZufCl2EUDEWNkxj/PWxy+Hog+vKDL7c7q85NEMLwFS1fMg+MamyeC3ra8Jk5HkSrDkCscf59xwzWgCBM1okPStlPSUFam98aBK5A/oCD8JbctR3+2z0I91yA70QzpwrPHaY7koli4lEZ/mo2y8qMk3tE2ItSrX6OVK9mj/EluUKWeuVhZJs3iPtChdibl8lZ/0Rb/9vjV/IiaQ5YlRohu/1VeG1N8YEZWduXSqWxdDvklYDR7+/S3INLtmzNxki6jeForWjUP/B+RTwmsvQQP5zjikYFFj6gIGHCDsT2ZatR3x/TeGKg6A3DxnGdg2VElnLsN+O61oIiB/uCbP4GIxKkwsRV1sTr6j3v6xuHSNtyNJiMN8w604I09HOEIvtMBdaF32u+1IZx60uogFiP00VKkeL7NAUoztYTH73yODnZnV3gLK/s7LNv4z95FQ7U39b74agHkZJs89A4ObdYryokHlKBNdmKgnLfZUZrkNdZTUzLiNs7xqLnTBFY1Xfi0OhfZS8QFqtuCo2uP479ofxJddtzZ8bK5swS4CPz6Y9NqKEYwAYRrXqKvI7gIA6n1zILv+0xeykE+K+fbIJjQtBjaHatQNdzn9laP/EoUyrIeEiiP4hvn+Gy89yhQ06YQYsTmTM/nGpKvJPmNiUJiUJTcJHMPVwBFwqAvpK7zAqliPMeB3qyfWWUi9YxeNI/oinujA+ElPyrGImz089+LiGNTQXmONKK6rhfPQA0sVTgB/SXf/X7IEtv3eAEBH9knHuy2PtSntBmPM3WZu+sUcn/C4d6NMsdxaKonwtrnhCV6bGezIf/zFOV6sEw9+YSi9RCRXNFhR7wktrx5O8mjC++nDuBe5nxrkMDZBn5KizfMZvsPPQIAiQ7qlLH+TV7WTvsIXjeXY7Ph74JxJvShQZTRd8pbNT9h+bedtxxrRMF3QTiXrwNnsK+2w9ZCzGd35wIyaVFl4t1TKPKYrgE/cotzmF43n/0T9KGqGv30QxRD4qaeWywgYBa5PULNoCmGLfGdWLd1/i5nj6MWobw3PRhMrPfFN2Zib4x1xhRG8vEaeYYJIbegKwbApanJv+S7BhL2OY4g8eFCtOJSP7LKtShCjkMz2V424eWKY/n5VTAJO/E39WResvfVNvhF8+5714rEUj63avhH0WFi2MURsvQ59sULGVglrMfL/fOe72VLCHZjJXKUxMftiaWqJ7u30tNRLKZ9tnTaeUTKRoB9troTuKV597ToR4OVyT0TGJMwnlWhJ6GExMYQDQkA/BWitITK0/6SST7DgzJ5IjXS+LrsEWNY1o X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5237766b-0125-4cc9-ff84-08d8c900faec X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:32.6380 (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: RavrIg3F4/KzvTM2dWGivxvINc0ia7WBAhxjJfRUUOU2SBMZBCXYzBjP+SMZTObvgF9dttAGtENz+HyXERxrdUejSPSquJnOkIkMKhJ4vLg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 impostorscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org target_core_iblock is plugging and unplugging on every command and this is causing perf issues for drivers that prefer batched cmds. With the last patches we can now take multiple cmds from a fabric driver queue and then pass them down the backend drivers in a batch. This patch adds this support by adding 2 callouts to the backend for plugging and unplugging the device. The next 2 patches add support for iblock and tcmu device plugging. Note: These patches currently only work for drivers like vhost and loop which can just run target_execute_cmd from their write_pending callout because they have all their data already and they have access to their transport queues so they can batch multiple cmds to lio core. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 53 +++++++++++++++++++++++++- include/target/target_core_backend.h | 2 + include/target/target_core_base.h | 8 ++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index dec89e911348..35aa201ed80b 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -227,6 +227,48 @@ static void target_release_sess_cmd_refcnt(struct percpu_ref *ref) wake_up(&sess->cmd_count_wq); } +static void target_plug_device(struct se_cmd *se_cmd) +{ + struct se_device *se_dev = se_cmd->se_dev; + struct se_sess_cmd_queue *sq = se_cmd->sq; + struct se_dev_plug *se_plug; + + if (!(se_cmd->se_cmd_flags & SCF_BATCHED) || + !se_dev->transport->plug_device) + return; + + se_plug = se_dev->transport->plug_device(se_cmd); + if (!se_plug) + return; + + /* + * We have a ref to the lun at this point, but the cmds could + * complete before we unplug, so grab a ref to the se_device so we + * can call back into the backend. + */ + config_group_get(&se_dev->dev_group); + se_plug->se_dev = se_dev; + llist_add(&se_plug->plug_node, &sq->plug_list); +} + +static void target_unplug_device(struct se_dev_plug *se_plug) +{ + struct se_device *se_dev = se_plug->se_dev; + + se_dev->transport->unplug_device(se_plug); + config_group_put(&se_dev->dev_group); +} + +static void target_unplug_sq(struct se_sess_cmd_queue *sq) +{ + struct se_dev_plug *se_plug, *next_plug; + struct llist_node *plug_list; + + plug_list = llist_del_all(&sq->plug_list); + llist_for_each_entry_safe(se_plug, next_plug, plug_list, plug_node) + target_unplug_device(se_plug); +} + static void target_queued_submit_work(struct work_struct *work) { struct se_sess_cmd_queue *sq = @@ -242,8 +284,14 @@ static void target_queued_submit_work(struct work_struct *work) return; cmd_list = llist_reverse_order(cmd_list); - llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list) + llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list) { + se_cmd->sq = sq; + se_cmd->se_cmd_flags |= SCF_BATCHED; + se_sess->tfo->submit_queued_cmd(se_cmd); + } + + target_unplug_sq(sq); } static void target_queue_cmd_work(struct se_sess_cmd_queue *q, @@ -284,6 +332,7 @@ static void target_init_sess_cmd_queues(struct se_session *se_sess, int i; for (i = 0; i < se_sess->q_cnt; i++) { + init_llist_head(&q[i].plug_list); init_llist_head(&q[i].cmd_list); INIT_WORK(&q[i].work, work_fn); q[i].se_sess = se_sess; @@ -1759,6 +1808,8 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess return 0; } + target_plug_device(se_cmd); + rc = target_cmd_parse_cdb(se_cmd); if (rc != 0) { transport_generic_request_failure(se_cmd, rc); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 6336780d83a7..45b5ae885af6 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -34,6 +34,8 @@ struct target_backend_ops { int (*configure_device)(struct se_device *); void (*destroy_device)(struct se_device *); void (*free_device)(struct se_device *device); + struct se_dev_plug *(*plug_device)(struct se_cmd *se_cmd); + void (*unplug_device)(struct se_dev_plug *se_plug); ssize_t (*set_configfs_dev_params)(struct se_device *, const char *, ssize_t); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index b7f92a15cd1c..10ac30f7f638 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -146,6 +146,7 @@ enum se_cmd_flags_table { SCF_USE_CPUID = (1 << 16), SCF_TASK_ATTR_SET = (1 << 17), SCF_TREAT_READ_AS_NORMAL = (1 << 18), + SCF_BATCHED = (1 << 19), }; /* @@ -513,6 +514,7 @@ struct se_cmd { struct completion t_transport_stop_comp; struct work_struct work; + struct se_sess_cmd_queue *sq; struct scatterlist *t_data_sg; struct scatterlist *t_data_sg_orig; @@ -612,9 +614,15 @@ static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item) acl_fabric_stat_group); } +struct se_dev_plug { + struct se_device *se_dev; + struct llist_node plug_node; +}; + struct se_sess_cmd_queue { struct llist_head cmd_list; struct work_struct work; + struct llist_head plug_list; struct se_session *se_sess; }; From patchwork Thu Feb 4 11:35:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CBE7C4332D for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 627EA64F45 for ; Thu, 4 Feb 2021 11:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236082AbhBDLhq (ORCPT ); Thu, 4 Feb 2021 06:37:46 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:54404 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235736AbhBDLgV (ORCPT ); Thu, 4 Feb 2021 06:36:21 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYisJ124256; Thu, 4 Feb 2021 11:35: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-2020-01-29; bh=lHfIuCWnyvJSzhcGT5VKdD40jqEtqB4CXS8mRpf4oGY=; b=VfqUq/DbHvTHueuszQPwrB9wkISgyoDqPhoJl975zPaJmcLGhf8a2cgTmrYVpFykCHij Cv5nMfbmOZhNJ6AZBPD3Vfrjrf5Fep3+wKBNctC/x8jKDl60REIfwHdUFTPTy89sMtHX CBJRM8JzVblCWZL0UE69zdshqW4/mT0ufMS38SOzi0lnhAJ0eNrNPZPmTQslcwi3ALwr KmIh5iO4ZQxj2brwAcmALU9EWHOKebKHHss49tUCIguzbPKF7hW6fRsrvl69hp1929Mx jxo/wI08pZDSMtETFnLePVY0WWMoeekQnH71wP4iOwADWy8JVbakbtMvqGGyNh0ObzDN ug== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36cvyb4xs2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:35 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ6am187848; Thu, 4 Feb 2021 11:35:35 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3020.oracle.com with ESMTP id 36dhc2jerf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WTVHyFKIn8bDLBAajDbrL5kuhxHoj3FdjlXhzzKaBHpUFo6oBnIaiCSwxMkJt5GJUcnVabHQo6WRSquBXsluS/ZXPSbMz77JmSMfMnHti6D6UpfBKWZhtsbtpXC21gFu8eWis+Rzw6VMxs+1Henteh1U47uNwUKZ976VP1Om1sd3sBVhLwc7n28N3A3xEnsF6elhHKuHfkUWijyFeCSFZoXYJ5a6yGrYqMdYwljGXzWqTDQn+vPGAgQtxUlj6gKyW/6wUAnHLeVxrJnKWmcaq20mIrfq4NzmY9ESITyR5pXqLAGSHjDo+VG1IeKJ/q9yrQsNVzkJsSS4M3Zg9MyM0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lHfIuCWnyvJSzhcGT5VKdD40jqEtqB4CXS8mRpf4oGY=; b=GUfiO7sYCANUciPSA12w9qeEOOTZq7H/zgR/MB9yPwkIjCMr4qKv3M8Fu0wBTOM/MOYPP0CVcLT5itu33Met23mi2FsVOXSqggBZadJGNMq6UXb4STepcwmXlG6/oip2XvA1opVCTIJVGhIaol9kD4laMVu5XrbqoBRprDQvwdySSiZeIVLnwxtrXQWTYxZry3a+Ikra/4pXrXg9QhJoqcoc5Zm7ihpxKefz+lLX8BfM0Rek3cFxxk3eTQyBWmQtRhJR5/KwhjC2PIxuuImM8tON3wdDCgUtiBCMmripPejf/OAoh8JWpQY5iCwy+xG3yL6xs6fOZcUZq7WILCh0zQ== 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=lHfIuCWnyvJSzhcGT5VKdD40jqEtqB4CXS8mRpf4oGY=; b=zkHIaRUzGar51zCQqgwqPSnHMHbn+Iou5M0Te6MFmjTgNFaQGveTZHgAz55RekGdhD4r0oH9e3qN498O5cCv109f3XYec7HaJqSPtSVa5e/UfItRw94uAN1bJO5Q9HzCR/qNeDF47YCMj+4AMrX6LUXbgkiz+6pgFS3P5FtpK1k= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:33 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:33 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 08/11] target iblock: add backend plug/unplug callouts Date: Thu, 4 Feb 2021 05:35:10 -0600 Message-Id: <20210204113513.93204-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5962df66-96cd-4d4a-793a-08d8c900fbe8 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OyBiK8097D/zOQ9Q/WxdiXDOkweXQDr/GCqzS0TCW2GwL4VnhuFDXFVZMrmI3lmRAWI20yKYnF8rWmmuT7h4uqux89AxssXUjz2n5DJO/8Que7GCA9FwHgT7X+uawbQlfTYizEfHvCXDYNHPnvwPCOUbGdssxlx7x+cPch7U/Wj5XVIxlg48bheue1aafMJQtBCS5vmL3LXQfGSadf0NS5cRLJf/z8yi/HT4RHyHisH4RR70J4naaqafkN3aO1iBOZwNPtvLa+2GxATzXdQ6cEBUARvEV0FMPTv+ZDBmmYTahN24JOD0bUfL5OiGPt2i1naWa0SM8FZ5EFBqQHx3HYFxYUHQCIlvdWiLN8cei3HdjDZluXwRozdhj+mZnKwpYgrQrlgExbn/3Doim0Xy0m6A5O7F9STI8JZcGhCZTpyAEcLJDlsZqyVCIGxxSul2K6W4VzU6/K99a35Hg+ln66UJWWCUGiqgTZKlDUl/FeVJ+/NPnGnXpduIZCQpGpdC39vYMYccqbbIAFQP1k1S41YNkDVQjzBHXukf9IwvDHKb5cob24HLQeUnwYEvJGUw9XUiBb2K4iDY730JTBl9jw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: uJnBLnS+PNjJmHS3+bwCAH1HmExZSMoOvlQ1IJp6G9vlFiCf8gIZPJ11iMid54opRFUevLXAjrGuYc/zdYUJFHSwKIq2aYLDS6uob7ck0JpJiEFgn8kQC7tL7+8/va3/iEFXz7bnrUF+G69hVMMuM/eVnTybJvxJ3eBUXbH0fwitgKnJqgWWVrB9nB+muWn3jSrBFFIU1ajA5x8wPLEpX2+492z1Oxs2lS6gzggCGgSY43Ks65qCo/0biu2LD3GMSPuTJvoDJ5C8a14UMWwAm812RpBX875m+Ckce5GXoB1cYMTO9VIzRwOa/UDbFwUis8LNu5obBs4zRftAIeSiOGQqV2T21N4BECD5vLbiZW2MzWmoQRInC+tFrQHn3Oir4k6ckdIXdMK6g+pvgwKxRyiuYde7NsyzX/h+3AUxZ7rN3HgVEfs1F9Erv6oCRSmN0yPNrU6oIta3WNwWslEVBa3Um9FfRndOMBd7MRWMVCjSFy/sFmsUbQWtTbQjs2uWp4+S6f76tNnlg6jMlsGZ3EOc2gyj7vUwTPlgPE+vAwbweNKs2g1jZgCsj9SuXzxPszCS+O/IfkviChXC6faO+tonJUZ7oqRNtzfJzx3rP2B1cfS3PPI2lnRZjQUnVMELUZihHvvzmNVIplTMAfhhdxzDLuA2qnUQaRKHKhrfx3/m1UNUKojfkC2bHW+yXXhPtg73UddA0t8n6peu7QX3tN7XH2Cl/2CF/TKr3lIwJvt7Ht5dlcYQHSGFdNU6FFXiO5w6R8xS7aQkZtFtatthv7a7LqTMsn+KIiQmIJi+sQfShOCASTSUNdKME9xsEvWbDzPul6XCYi8WQ28B3IJ6aYAgZwLfbgs6XZrUzzvkbqNbaSDa50vnkoxFbFBU0hoSPaUwXl0TvU/tlblDRdx+LrayBNDt1H0Zm8sWxJ8PHJ8MuYo/80B8UBK7lD9y3oQMN8SnNBmxVGR6zMGy/xc+BS35iFtq9uyiIxDDCO0ydTnbiKRaxAWGASE7Kdq4ZJ4sS3ihBStLD4pxThSWwFhbp5o8CuiijfuTtmZBjfJGK2idb0Kq7Oqz6pdtacvz5hH/Us4V48NzSpjREi+mpCJo+VJLauJBHilj1xgQLPDfoj1ivf1Wvr3KKG8QGGbILyTtYlQ05e5do98tvKLLWMmkD9b1APBd9POo6K3hV1r/r+KCuqMAPnlby9W9aEWgci1f0iNjV42ArURmZSxho9Q8H+j5wSODRmf7vCGVbIyOQYklJM5Z1DAkKaJ46/NhVdRjPg+UUVEJ9S2KIuZN9RI4pX+7f+B2E+WkJ5xuGo4ZJcbPMa013WFj5RdEo99fYMks X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5962df66-96cd-4d4a-793a-08d8c900fbe8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:33.7803 (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: uA1CT+clKhGdVFQ/KIsTJUP9jpwCoV1jsysxzZ+YvLrmwFQNnOCiH21ULkbex9QHkQcMj2r1COzVVuNvbW50ZoqWpVHyG9Ub903cKDs1A5E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 impostorscore=0 mlxscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch adds plug/unplug callouts for iblock. For initiator drivers like iscsi which wants to pass multiple cmds to its xmit thread instead of one cmd at a time, this increases IOPs by around 10% with vhost-scsi (combined with the last patches we can see a total 40-50% increase). For driver combos like tcm_loop and faster drivers like the iser initiator, we can still see IOPs increase by 20-30% when tcm_loop's nr_hw_queues setting is also increased. Signed-off-by: Mike Christie --- drivers/target/target_core_iblock.c | 41 ++++++++++++++++++++++++++++- drivers/target/target_core_iblock.h | 10 +++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 8ed93fd205c7..a4951e662615 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -61,9 +61,18 @@ static struct se_device *iblock_alloc_device(struct se_hba *hba, const char *nam return NULL; } + ib_dev->ibd_plug = kcalloc(nr_cpu_ids, sizeof(*ib_dev->ibd_plug), + GFP_KERNEL); + if (!ib_dev->ibd_plug) + goto free_dev; + pr_debug( "IBLOCK: Allocated ib_dev for %s\n", name); return &ib_dev->dev; + +free_dev: + kfree(ib_dev); + return NULL; } static int iblock_configure_device(struct se_device *dev) @@ -171,6 +180,7 @@ static void iblock_dev_call_rcu(struct rcu_head *p) struct se_device *dev = container_of(p, struct se_device, rcu_head); struct iblock_dev *ib_dev = IBLOCK_DEV(dev); + kfree(ib_dev->ibd_plug); kfree(ib_dev); } @@ -188,6 +198,30 @@ static void iblock_destroy_device(struct se_device *dev) bioset_exit(&ib_dev->ibd_bio_set); } +static struct se_dev_plug *iblock_plug_device(struct se_cmd *se_cmd) +{ + struct se_device *se_dev = se_cmd->se_dev; + struct iblock_dev *ib_dev = IBLOCK_DEV(se_dev); + struct iblock_dev_plug *ib_dev_plug; + + ib_dev_plug = &ib_dev->ibd_plug[se_cmd->cpuid]; + if (test_and_set_bit(IBD_PLUGF_PLUGGED, &ib_dev_plug->flags)) + return NULL; + + blk_start_plug(&ib_dev_plug->blk_plug); + return &ib_dev_plug->se_plug; +} + +static void iblock_unplug_device(struct se_dev_plug *se_plug) +{ + struct iblock_dev_plug *ib_dev_plug = + container_of(se_plug, struct iblock_dev_plug, + se_plug); + + blk_finish_plug(&ib_dev_plug->blk_plug); + clear_bit(IBD_PLUGF_PLUGGED, &ib_dev_plug->flags); +} + static unsigned long long iblock_emulate_read_cap_with_block_size( struct se_device *dev, struct block_device *bd, @@ -337,7 +371,10 @@ static void iblock_submit_bios(struct bio_list *list) { struct blk_plug plug; struct bio *bio; - + /* + * The block layer handles nested plugs, so just plug/unplug to handle + * fabric drivers that didn't support batching and multi bio cmds. + */ blk_start_plug(&plug); while ((bio = bio_list_pop(list))) submit_bio(bio); @@ -870,6 +907,8 @@ static const struct target_backend_ops iblock_ops = { .configure_device = iblock_configure_device, .destroy_device = iblock_destroy_device, .free_device = iblock_free_device, + .plug_device = iblock_plug_device, + .unplug_device = iblock_unplug_device, .parse_cdb = iblock_parse_cdb, .set_configfs_dev_params = iblock_set_configfs_dev_params, .show_configfs_dev_params = iblock_show_configfs_dev_params, diff --git a/drivers/target/target_core_iblock.h b/drivers/target/target_core_iblock.h index cefc641145b3..8c55375d2f75 100644 --- a/drivers/target/target_core_iblock.h +++ b/drivers/target/target_core_iblock.h @@ -4,6 +4,7 @@ #include #include +#include #include #define IBLOCK_VERSION "4.0" @@ -17,6 +18,14 @@ struct iblock_req { #define IBDF_HAS_UDEV_PATH 0x01 +#define IBD_PLUGF_PLUGGED 0x01 + +struct iblock_dev_plug { + struct se_dev_plug se_plug; + struct blk_plug blk_plug; + unsigned long flags; +}; + struct iblock_dev { struct se_device dev; unsigned char ibd_udev_path[SE_UDEV_PATH_LEN]; @@ -24,6 +33,7 @@ struct iblock_dev { struct bio_set ibd_bio_set; struct block_device *ibd_bd; bool ibd_readonly; + struct iblock_dev_plug *ibd_plug; } ____cacheline_aligned; #endif /* TARGET_CORE_IBLOCK_H */ From patchwork Thu Feb 4 11:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22517C433E6 for ; Thu, 4 Feb 2021 11:38:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7C9F64E50 for ; Thu, 4 Feb 2021 11:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235917AbhBDLh5 (ORCPT ); Thu, 4 Feb 2021 06:37:57 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:40286 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235780AbhBDLgX (ORCPT ); Thu, 4 Feb 2021 06:36:23 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYHmt072673; Thu, 4 Feb 2021 11:35:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=mHGGgG2d53MLyUkuEIqroziYw7ExnQ/ohqpxpxpOr4M=; b=Y0hCE+2i8jxU3+8q/GAjPCfXQPIbpRPmDpqoph4SWO/bMCb6qj1KaRl5GSuL+pGJ1sOM 0c0q5Ps4Ol3nABL165+caOv488u71K7bJgC3ScZf1SUBHxO27h3yYnhWJt7KCxS8J+Zr tHoESsJwHHyAhuISC68Dbx0TtcAl53jhX4nJSR3fgkuTE3azgmcqRmmlyhsE4vH8LSap w5a+ORNdlyQQ7IyAVQFtX/Tfp6IiLOGwUP/6GXG18ex4q6ZALCGZ14wnaBl+Ssmpfhfs URdDznIJH2J0B8S2ulTpRBKw6HEpVlPa9knDOwGT6rK3myvYXIdOb+TtBDAjTtvWiVAc iQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 36cxvr7h0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BULCS037141; Thu, 4 Feb 2021 11:35:37 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3020.oracle.com with ESMTP id 36dh7v17ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cobSs7SZBWKX5B5lej4kREK8pqJR+W/5rzlOkp5i0QpUIOzneaFYw5fqaCMzfXwCnnqDAmtxQBtOH7slY4OPKY+6hNK/ZH5WykEa4PdnpEQRFkOsgFmDrX0zF+Bc0GHaBjrDZORw5RTtD9wgsuqFuD1NjNl6jb2UFbVXVTTnpw2BklbffjmGp+5SZ8y44rH9HP+D+GXItdV+ylwrYR/oECsuflqlMyh39ShOY5btG+cXhByLIqoKlThZj61Mp5oecVwkPuw8PPUhn0T9AlWMzfwQ0YT/0ec6pSCqCRN7qwGR7cavwCuHAT8uXOJ3yXYpPDWjoMfF8Eddc7udOqjeBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mHGGgG2d53MLyUkuEIqroziYw7ExnQ/ohqpxpxpOr4M=; b=b0t5Om45b9FOdq/W4LzSnhDidZUIYZ70CNvIRPIzUSXUALvQXarHakRBnpnmuhoBYL3E6kGAuFIROudkfaltgBy/xH06trHcADHo8AuxxSeHFe2DbA+ztT+OlkaU2Fm+qF/B6jLnBiG06QBCAoRfdEvvv1mZr36w/UvpnPY0KKDGWaTuaPjWawZbKoKa08bgMp12pXLes4DAdliWyi5EJh8ErCRweROIqkqjnBhOr40VAmH+2jTIISy8RnbS201LC4oJbk28lNo9AdP1WuMAz7c8N51fPzJYmXh9x+iEcPjbLNS50l+jpca7E6VvhM7CyN1nyCK54jeZcgAEo/vBpg== 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=mHGGgG2d53MLyUkuEIqroziYw7ExnQ/ohqpxpxpOr4M=; b=ysKWWMogR1zXgXT/L54rDpOU0Lo9q3Jqdv2TUUJxd3TdbrFhQRreFJpDILNlZJtbJOPSgK0wsaTIUPxOmlMG3owHfE6hauKSygr5k4+0AsOgz3/3hYWTRnOg6W5uNCiBtYgO9LuWQ3tGw8z9zsL8O/f0KD5HsMo8i3BdjIVN61M= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:35 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:34 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 09/11] target_core_user: add backend plug/unplug callouts Date: Thu, 4 Feb 2021 05:35:11 -0600 Message-Id: <20210204113513.93204-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85368185-bd7d-4c7f-a5ed-08d8c900fc94 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qpwvW8mTZhWIkEU/tkov5jxDX41FhgnWviEoMYKFv49xbJ5WDAnR3jqhvbal5sz8SixbFmhZFdgT+Q9Imx8kPZArmSJlQqS/v+/zTm3WFzKZ72JG6Ri+ndnLPEIsWOC7kWA8IBQL2OmmYledg8ttyb0TnLqLLDhLAdKTAO+Rn3zCtaTCnPBn6otZl2vlbNTSpgNAwXSt8W9Rj9J8C7ytesyG6gv4MQPKiZl/0D6saG42IaihJXIXNcPqKHkWKjqoctCT9RCFzw3Xs6/ZwC3e/ZdvQpQI2NdzEK0Si+PsaWB6r/ROOKzE0STypcvxMxCOLLiRz4N/4rsKEEAH4kjtRKK7C4Z1oo1csdudWigPZyEste2ddNTci/hFQ7ca2jSxJYBKqNnuapyztt3p/Dv0CeLqb6pkVuaIY607xdt52SwkShQaNEqb+EpweLlXc3XUOjT5cK/Yo+ssDhnhSjDAge3IQdwbSsryHRok1fQ3dk4/TTM27nyWRrQbGTS1A2GDRHJQ+cAKjbDr8lhXegquovtiM+jwpLaNcX9osPndMQvuiJxQa4jojBzLs+GB+iw4I2PBp+Z+lyq4JvGMHRbNBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rMu3Kf2HX01WWPrGJtazTCsUx091Em46nxn7TPcengAzfmS4feEk3FKAv1PK8cBJSRePMjQ2MvztRxp4xXbKeOeht2NX+MorZ3iDmeFpgZNT570NPS94iFjXp3waTP/HJLfNON8hCxGz8GYmnhkpvvVXbfGahWADe0WyHvIme61xoVUHcvvL56ykolGQxwtuuvCCP+euzvNpaeJq5rjREQeYIMOGld5ySn4iiot8nQh3U1kyxx5lX5lUF6Xlua64o8Tt9bgxLS72WwaRJ5gRqk4HznvuPQLBDx07hJ0SPZvKeGvHlqKfoodr54f1t6Fp8YTGM1o+1J0sEtyPr4dcqtEAtGc+r+Upta45hnDU3VOK7xHmE2c2KsGDJlliDpYj8ELnpLbuADAwcJCzpJ0krKXCMVd66RbZ1SO6qALE1D7bMQiJaEuToWlKRfOhjWaZXgL/LLb7d4ot6nQFCen6Jyr4RkfwDYJi2R6Hw4358klSPKad/szCZh5XGh/BRreVKiitcGqnRmLoEcTvFrVJi1xR97otJpDOIoayV2OT2FI4k3j2KGnksfMOIZZM4Ou1HlB4p42p+tSRgXj2zepQtNgKTTAyVKZnYXQUGXO94gCL1xnAgsF+73Oir1m9Av1szUM4VRCwqvXtroI6qNJmkdEQX3q8+2UdE4KyEtaLxCTTpJgFr/v/jnVWv1yeCKRFFDzPqms/DSpXtx+LgqFnvAd5CLR2kc24FibgnoajXG3z6Vfczeb7BU4qM8JbkwDjTXGYjMUzfwtbuFsoBLmuhNFV3p5tCojVVzirtHq56r2en1SY74oY7LTkBnVqmuJA1xcb0csEm0w4beRFwd9T7+6nLghOqZApf9LGGl6qFt/U9HKIemnLQgEE2o09TpVi6/SvXxPoni6D2pFH6OurlAA/B/jugLEG3KLuRNg+MGz41Kmte13Jy6Ztl3T/1WybL/RlchMPbtj77XFpi/GT/qvEBgVlDUfu0I238QUcUE21HnQ3w1nRtUJS6EmnlzC68O/WYUmRFfqwax9tuMUq1g4u2CCbQCa0ZPBmgXjyR5yQIyDXKeFTB/chLrDK1k9sgRou5IWpyqK9/81ENNfaHFnKqsDQz/3BKU6QUywt1P1M7lNt/8avgNFU8IQy/nZNCkTYqoFaUicUOpFVZIDWhi2kMGx7bwI/q0md4vHKuCRYVYoc0ncMsVKer2IO0pvwg8rjZmgYUeIU8PVY0uTTfyojK9qVjFlnpByilBNU1XhsWUIPxTYDvXK1r0KfSr5ISGbKr1MOxDwm1BnpW65yJaWJnMGbKiiK509vRe6hbuJeercdKx2nfiJZP8eimxMe X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85368185-bd7d-4c7f-a5ed-08d8c900fc94 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:34.9007 (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: EyzAYovtk6GNOHJuyQ2JiO1US8y/ZVz9IYYpFcp1aY8kK3v2Is68LBRLAC4XGe3iq3wrwZoDObS7euyEJNVm942e+5b49TL0whtLN9NcQ6E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040072 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org This patch adds plug/unplug callouts for tcmu, so we can avoid the number of times we switch to userspace. Using this driver with tcm loop is a common config, and dependng on the nr_hw_queues and fio jobs this patch can increase IOPs by only around 5% because we hit other issues like the big per tcmu device mutex. Bodo, because the improvement is so small I'm not sure if we want this patch. I was thinking when you fix those other issues you've been working on then it might be more useful. Signed-off-by: Mike Christie --- drivers/target/target_core_user.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index a5991df23581..d67be2f959b9 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -111,6 +111,7 @@ struct tcmu_dev { struct kref kref; struct se_device se_dev; + struct se_dev_plug se_plug; char *name; struct se_hba *hba; @@ -119,6 +120,7 @@ struct tcmu_dev { #define TCMU_DEV_BIT_BROKEN 1 #define TCMU_DEV_BIT_BLOCKED 2 #define TCMU_DEV_BIT_TMR_NOTIFY 3 +#define TCM_DEV_BIT_PLUGGED 4 unsigned long flags; struct uio_info uio_info; @@ -959,6 +961,26 @@ static uint32_t ring_insert_padding(struct tcmu_dev *udev, size_t cmd_size) return cmd_head; } +static void tcmu_unplug_device(struct se_dev_plug *se_plug) +{ + struct se_device *se_dev = se_plug->se_dev; + struct tcmu_dev *udev = TCMU_DEV(se_dev); + + uio_event_notify(&udev->uio_info); + clear_bit(TCM_DEV_BIT_PLUGGED, &udev->flags); +} + +static struct se_dev_plug *tcmu_plug_device(struct se_cmd *se_cmd) +{ + struct se_device *se_dev = se_cmd->se_dev; + struct tcmu_dev *udev = TCMU_DEV(se_dev); + + if (!test_and_set_bit(TCM_DEV_BIT_PLUGGED, &udev->flags)) + return &udev->se_plug; + + return NULL; +} + /** * queue_cmd_ring - queue cmd to ring or internally * @tcmu_cmd: cmd to queue @@ -1086,8 +1108,8 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err) list_add_tail(&tcmu_cmd->queue_entry, &udev->inflight_queue); - /* TODO: only if FLUSH and FUA? */ - uio_event_notify(&udev->uio_info); + if (!test_bit(TCM_DEV_BIT_PLUGGED, &udev->flags)) + uio_event_notify(&udev->uio_info); return 0; @@ -2840,6 +2862,8 @@ static struct target_backend_ops tcmu_ops = { .configure_device = tcmu_configure_device, .destroy_device = tcmu_destroy_device, .free_device = tcmu_free_device, + .unplug_device = tcmu_unplug_device, + .plug_device = tcmu_plug_device, .parse_cdb = tcmu_parse_cdb, .tmr_notify = tcmu_tmr_notify, .set_configfs_dev_params = tcmu_set_configfs_dev_params, From patchwork Thu Feb 4 11:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 371FFC433DB for ; Thu, 4 Feb 2021 11:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBC0364E50 for ; Thu, 4 Feb 2021 11:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235780AbhBDLiF (ORCPT ); Thu, 4 Feb 2021 06:38:05 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:38660 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235799AbhBDLg0 (ORCPT ); Thu, 4 Feb 2021 06:36:26 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ00h122042; Thu, 4 Feb 2021 11:35: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-2020-01-29; bh=DUsGq8rQVt90eljYA/wSFh5hK7WjwbWj/lAPfT3zKfk=; b=Ji7xDJQO0zVCeiUoXdNREv4KevQCtk2v2AC1IeAllOIwIK+S2GbTXUuLvSYd8NaaI8pC nOUg6B+MEQvedSmSzjyFQA44Z3kLi0SBHFkvWk+tl9f5mahqRINU4z0ysjHqMoarw5PL ajD+Yn78fNSVit9B8h8bCUz6HwXkP+RA8UKG4+Bis4cxEdIZz/9OY54xS73Tdyk98XFP uo1CMw+d7o8QNU6I9XoS+ewBvh8JIuVmKv8eEu/tlnX4ZJPTXzDzI1YHkq6+zymebLY8 gn5VhISYiNo/opLlXW+J1qybxW/ptH+Wb1GiXsbqKvkHpaa7uWgezijSDfjhCciahRVA uQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 36cydm4r7d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:38 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BULCT037141; Thu, 4 Feb 2021 11:35:37 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3020.oracle.com with ESMTP id 36dh7v17ss-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnfNLL6yjkse/iz8TW7hNh+yIxspKJbcoemhjwgEDDWTcOyyMvSbhIR3J6psL5FksrRerK8aRjdKIGsw7BzHRQBcnsnfCNtWRJDHp6IAy7Y0UZ6yy9SYchvg7e9xW9N4Y/xXR/foXVMvPBm8Wd8uOZs1weM3J/26yfjCyMb12fT3x1KX9DjhNsFIs1eSL2ZH5SvMuchQ4d0VQb5QD5msuBkaFSK1EEEdfuJEChkMJ5Xlt2r0ZiJ+ckdZtJuTNQQ8BKIz2hNg9Ch95WmpYWHPzPR64/2780HxTcYb1x5h+OtNsfIhoCAB3kwpoRi52SSegtNbxdjzYzUR6eaAI6itdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DUsGq8rQVt90eljYA/wSFh5hK7WjwbWj/lAPfT3zKfk=; b=hqNzwhNpZYEzVi/92Y3s1Xf7w1LRv2gTwxGu6JIuS4TIwNAc58bLVdMV6UUEsAKoPiGkQIR7BIFph6oHLkNnveAhupGCUKsGUmERb/k8sL4pAw35j3UUbeRcdlKHlteUrA6aOMnDxyW5Vpnj+ceZ346VygOSFTsTLQSRQu/cVQhLisrDY7R5dlBTTbxRc8ZSnB33WSdixL02PUr/L6cEW+JEdLOHxI2R03+H7rUoUvmdqbrRfXtgUd1ov/PJ1Pafndv3bXF+rWsiiR+bQTkDh8neLpzNXxg14tpe1IjVIVCNZKJy/NcZrewE0EBu7CgN4zBLZwv56UVDBS1mo6duZw== 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=DUsGq8rQVt90eljYA/wSFh5hK7WjwbWj/lAPfT3zKfk=; b=K1o6KAi2dGL4BYiSXBV+9UCTQoEQF67Okn+PtkFy0+acPbcO413LNaYeneDUnmICXiqMb9oGcRj+2iEGivBGRSYNiVhyVUPJH0uDPd2PD5wI8Z5mErQ4X4IfQ6Axjux4ub2o0HZHt2sJ/CAJv/sfR+gZ1+3PgkoqW+3ltthIvQg= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:36 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:36 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 10/11] target: replace work per cmd in completion path Date: Thu, 4 Feb 2021 05:35:12 -0600 Message-Id: <20210204113513.93204-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e1aefa1-1c5a-4ec3-4c3c-08d8c900fd3f X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QO1P9eo0A252068jZbkJ6oGnHfbAw/ufC+bCR/OY0FN7DuP2k7LNwwpYBZstkw0evl/PAingCwFJZkYxk70U+jKQ9UAKulWu7G+mTrGFzVV5roQTCnBUgvsWNq4IGhjS49gqWLu9IfpKfGONRZ9252F25rQ6vdm/qJghuwAWEVF+RmWcOx25ZRogM/XpiGZHv5FZMUT3eIIhR8lm2tUAEVBGt7Xb2dVb28QVzam4/qoNlafUD8OsFYMUyaQUxsdJv8LOWX4TWz1hRh9UObQL2XrSPjeyJ0q2MNp+RpHM/pWCMTpbdarHTwLHaC9NhYO98G5H2mksF/26dRzjIzBlbu3dU2BDcpO2UaNfhJ3oqg1ghmMAaFjvIMxEjhC73PV38M6FirDoOhnqBUMNOrUG0Zn2OP0ULMZRUtto4hL/4mErX1Xi1SooHL9DcvljeegUxk5tWx4Pbuq9eXtt96M2FHrsKfhSgSPmwEziKEgCUzBfv/+lOR86/GuTQ8Il+eDBU+J9aXB0eMIrN0OXv9Cv1okRTbNRoez53dCk5hmIuYoKUquTUFvDSJSkcKICcJohmL5it8R6oyx2Ok62BUsSBQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: GeQADNlTYooVYkqRvw38OlMEpkRnXxonSCfLWMkBYiueC42KHEnECZy2MOTXZ5az49yELyMwCrVPT6y9AHSjgIZ+87fuospl/ZcI2NpNc5Afx/gsqX/OsGqMJXInmW720lbiM2KGrEHa7r6EQf+xnTLuVKinKVgJ0ATOw8jGZqWnZHL90dtwug/V5MRdQ3B8eXVCH+NVaqqGRA8Vss7IOfxKX/NQAKgQCqTtgfmzPc4+rJvU13YdPP6i4mJi9N2faUw6BcC/G9KA/AAbnVXGwY0iQAcICAQ+hyy2aA1F1JhkroaaJgT7l80H5izbWdAOOTLp18o+a+YhBMGxZchAMfchnW17sxrw469GEArdyh6PbVRhql08myCBcKfEH0LQd+suHHFvObsHzHT2/+5DshjSa/baFcsh5TTD2SJ5syakt7z9dVxueB9JGhv8d9tUryRkcpHZqZ+47Tajg2aEgo28Y+KZr056Yg1AH88MVh6Wh7V6cDE5g0zsSUeA5VOdzHjkLUc9GatkcKNOmADfnWxbO1eeeMAxaGLOEcVO2tNkkJ1gNdcbZBk5K4554Qmh2WotTjYVwo7ev6HilWk10xoFcNIGx8lQR/Vf6I3+dzlGXYYXF3bp+p2uzUkTVBD6mv8gml1snbQyBDh57bD4umxhtxrhxr5Y6VbWrWgXF2mm0twsGPmW12ZCpoUkZc7ZzZngpBecyUeKQ+YqegGjUh6X9Et+fh2xsJQ1YLVEBg369Ty6uMJoZG/S7XCnl9ZazBnZ1LwE4SF2SVMBtT3lJ5iZIBeQtGRdT+eEMuVAVfa3xM3Un4N2A9D+1z1t971BkcbDlcb7jMPK4RNc9OWd5u7TADExWUviJXq9GPmgjtuDfWVceF6HOQWtMDJY6p0a+0wmGbtTRMlJ6KzVuAKRm9tIxpMrv9r/gZq9k+/VWjdhZ4a5SPpxUXztwNXgsBdBdQDNX1uuk3IfvUURVct/ECqyva9EQWwLQ+cfD8bHas9Yr0yo/8kdOYIwXNa+qM0NTrSkOtRtRUNuoJfBWnQ/lXIcMRNwMVajm2JIqjcFaWP4h5xRfUsQL1P2hYSIiJBKFTSRyyp8Fiu80IE2uS/dK1bofksghzS1DpBOsvvGkGedahFIWApRhhvFALLwTXPvzUr++QL6V23t+/ySLog2Bc6Yq3Uq2expOEXWPdyjMq42m5xbEv0H56b+BfZEAdQg3YSI1DkMColva9GrE3l4NWP57m6R2FkVv7+axKMedGf4lvkiaGRC417VpH1HfqR6Fm/17OFC8OGrW4vVmubtWeCvvuXodhiOq19CI6cbFeNrMa1iGNYI+DSr9DVF5R2q X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e1aefa1-1c5a-4ec3-4c3c-08d8c900fd3f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:36.0890 (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: Nk1lNWoyE6Y9I6lvvnwyrdYaMmhRatC28bpxv21bu8yEjrgSrrBa6cNNprvk+n5OA90e1OUG3SLnmCZtbYXwPwl4edgwaJO38gi8ivo+FXY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040072 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Doing a work per cmd can lead to lots of threads being created. This patch just replaces the completion work per cmd with a list. Combined with the first patches this allows tcm loop with higher perf initiators like iser to go from around 700K IOPs to 1000K and reduces the number of threads that get created when the system is under heavy load and hitting the initiator drivers tagging limits. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 124 +++++++++++++++---------- include/target/target_core_base.h | 1 + 2 files changed, 77 insertions(+), 48 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 35aa201ed80b..57022285badb 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -55,7 +55,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd); static void translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason); static void transport_handle_queue_full(struct se_cmd *cmd, struct se_device *dev, int err, bool write_pending); -static void target_complete_ok_work(struct work_struct *work); +static void target_queued_compl_work(struct work_struct *work); int init_se_kmem_caches(void) { @@ -295,10 +295,20 @@ static void target_queued_submit_work(struct work_struct *work) } static void target_queue_cmd_work(struct se_sess_cmd_queue *q, - struct se_cmd *se_cmd, int cpu) + struct se_cmd *se_cmd, int cpu, + struct workqueue_struct *wq) { llist_add(&se_cmd->se_cmd_list, &q->cmd_list); - queue_work_on(cpu, target_submission_wq, &q->work); + queue_work_on(cpu, wq, &q->work); +} + +static void target_queue_cmd_compl(struct se_cmd *se_cmd) +{ + struct se_session *se_sess = se_cmd->se_sess; + int cpu = se_cmd->cpuid; + + target_queue_cmd_work(&se_sess->cq[cpu], se_cmd, cpu, + target_completion_wq); } /** @@ -310,7 +320,8 @@ void target_queue_cmd_submit(struct se_session *se_sess, struct se_cmd *se_cmd) { int cpu = smp_processor_id(); - target_queue_cmd_work(&se_sess->sq[cpu], se_cmd, cpu); + target_queue_cmd_work(&se_sess->sq[cpu], se_cmd, cpu, + target_submission_wq); } EXPORT_SYMBOL_GPL(target_queue_cmd_submit); @@ -318,11 +329,13 @@ static void target_flush_queued_cmds(struct se_session *se_sess) { int i; - if (!se_sess->sq) - return; + if (se_sess->sq) { + for (i = 0; i < se_sess->q_cnt; i++) + cancel_work_sync(&se_sess->sq[i].work); + } for (i = 0; i < se_sess->q_cnt; i++) - cancel_work_sync(&se_sess->sq[i].work); + cancel_work_sync(&se_sess->cq[i].work); } static void target_init_sess_cmd_queues(struct se_session *se_sess, @@ -359,13 +372,21 @@ int transport_init_session(const struct target_core_fabric_ops *tfo, atomic_set(&se_sess->stopped, 0); se_sess->tfo = tfo; + se_sess->cq = kcalloc(nr_cpu_ids, sizeof(*se_sess->cq), GFP_KERNEL); + if (!se_sess->cq) + return -ENOMEM; + se_sess->q_cnt = nr_cpu_ids; + target_init_sess_cmd_queues(se_sess, se_sess->cq, + target_queued_compl_work); + if (tfo->submit_queued_cmd) { se_sess->sq = kcalloc(nr_cpu_ids, sizeof(*se_sess->sq), GFP_KERNEL); - if (!se_sess->sq) - return -ENOMEM; + if (!se_sess->sq) { + rc = -ENOMEM; + goto free_cq; + } - se_sess->q_cnt = nr_cpu_ids; target_init_sess_cmd_queues(se_sess, se_sess->sq, target_queued_submit_work); } @@ -379,12 +400,15 @@ int transport_init_session(const struct target_core_fabric_ops *tfo, free_sq: kfree(se_sess->sq); +free_cq: + kfree(se_sess->cq); return rc; } EXPORT_SYMBOL(transport_init_session); void transport_uninit_session(struct se_session *se_sess) { + kfree(se_sess->cq); kfree(se_sess->sq); /* * Drivers like iscsi and loop do not call target_stop_session @@ -877,14 +901,6 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd) percpu_ref_put(&lun->lun_ref); } -static void target_complete_failure_work(struct work_struct *work) -{ - struct se_cmd *cmd = container_of(work, struct se_cmd, work); - - transport_generic_request_failure(cmd, - TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); -} - /* * Used when asking transport to copy Sense Data from the underlying * Linux/SCSI struct scsi_cmnd @@ -972,13 +988,6 @@ static void target_handle_abort(struct se_cmd *cmd) transport_cmd_check_stop_to_fabric(cmd); } -static void target_abort_work(struct work_struct *work) -{ - struct se_cmd *cmd = container_of(work, struct se_cmd, work); - - target_handle_abort(cmd); -} - static bool target_cmd_interrupted(struct se_cmd *cmd) { int post_ret; @@ -986,8 +995,8 @@ static bool target_cmd_interrupted(struct se_cmd *cmd) if (cmd->transport_state & CMD_T_ABORTED) { if (cmd->transport_complete_callback) cmd->transport_complete_callback(cmd, false, &post_ret); - INIT_WORK(&cmd->work, target_abort_work); - queue_work(target_completion_wq, &cmd->work); + + target_queue_cmd_compl(cmd); return true; } else if (cmd->transport_state & CMD_T_STOP) { if (cmd->transport_complete_callback) @@ -1002,7 +1011,6 @@ static bool target_cmd_interrupted(struct se_cmd *cmd) /* May be called from interrupt context so must not sleep. */ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) { - int success; unsigned long flags; if (target_cmd_interrupted(cmd)) @@ -1011,25 +1019,11 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) cmd->scsi_status = scsi_status; 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) - success = 1; - else - success = 0; - break; - default: - success = 1; - break; - } - cmd->t_state = TRANSPORT_COMPLETE; cmd->transport_state |= (CMD_T_COMPLETE | CMD_T_ACTIVE); spin_unlock_irqrestore(&cmd->t_state_lock, flags); - INIT_WORK(&cmd->work, success ? target_complete_ok_work : - target_complete_failure_work); - queue_work_on(cmd->cpuid, target_completion_wq, &cmd->work); + target_queue_cmd_compl(cmd); } EXPORT_SYMBOL(target_complete_cmd); @@ -2006,8 +2000,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, cmd->transport_complete_callback(cmd, false, &post_ret); if (cmd->transport_state & CMD_T_ABORTED) { - INIT_WORK(&cmd->work, target_abort_work); - queue_work(target_completion_wq, &cmd->work); + target_queue_cmd_compl(cmd); return; } @@ -2433,10 +2426,32 @@ static bool target_read_prot_action(struct se_cmd *cmd) return false; } -static void target_complete_ok_work(struct work_struct *work) +static void target_complete_cmd_work(struct se_cmd *cmd) { - struct se_cmd *cmd = container_of(work, struct se_cmd, work); - int ret; + int ret, success; + + if (cmd->transport_state & CMD_T_ABORTED) { + target_handle_abort(cmd); + return; + } + + switch (cmd->scsi_status) { + case SAM_STAT_CHECK_CONDITION: + if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) + success = 1; + else + success = 0; + break; + default: + success = 1; + break; + } + + if (!success) { + transport_generic_request_failure(cmd, + TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); + return; + } /* * Check if we need to move delayed/dormant tasks from cmds on the @@ -2578,6 +2593,19 @@ static void target_complete_ok_work(struct work_struct *work) transport_handle_queue_full(cmd, cmd->se_dev, ret, false); } +static void target_queued_compl_work(struct work_struct *work) +{ + struct se_sess_cmd_queue *cq = + container_of(work, struct se_sess_cmd_queue, + work); + struct se_cmd *se_cmd, *next_cmd; + struct llist_node *cmd_list; + + cmd_list = llist_del_all(&cq->cmd_list); + llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list) + target_complete_cmd_work(se_cmd); +} + void target_free_sgl(struct scatterlist *sgl, int nents) { sgl_free_n_order(sgl, nents, 0); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 10ac30f7f638..6b32e8d26347 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -643,6 +643,7 @@ struct se_session { void *sess_cmd_map; struct sbitmap_queue sess_tag_pool; const struct target_core_fabric_ops *tfo; + struct se_sess_cmd_queue *cq; struct se_sess_cmd_queue *sq; int q_cnt; }; From patchwork Thu Feb 4 11:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12067171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02E41C433E6 for ; Thu, 4 Feb 2021 11:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4F7D64E50 for ; Thu, 4 Feb 2021 11:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236034AbhBDLjX (ORCPT ); Thu, 4 Feb 2021 06:39:23 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:39788 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235675AbhBDLiZ (ORCPT ); Thu, 4 Feb 2021 06:38:25 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BZ0CT122043; Thu, 4 Feb 2021 11:37:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=VMZxcFvzwLNYHH9m/5wgDVBDSjFJj3E6tS5Qnm5WVp0=; b=tbykdFqMv0w9jS3tTxsu+NMZOD81UYtpOyHWj280ZKmsIxoROAZFZkOLxCqQS3uIBWFr KKnaRBPoW3Nl+TbmkzytVwgJ9Z5pZw1VQ5AdPqRNIHZaQ2p42u6SqOuHETtn3ZHqoXeM 6rxsilGGDVk8+28RBN1qDm4nys052spBLDY693h6n7GkYShP1MxlAVmOLmoEs148Ptk7 3kevJNZOcPLds2puqrSK2l/z9thDooWPl79FSjEK07NH1eXmT28H20CUn7GbdDgKe9w5 Cl5MdOzRxNbfD0fLD6dGVKsqcBvDz91OmoR6H1rgX5uBwevSEF69i9wP0LRez217a1AP ew== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 36cydm4rd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:37:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 114BYerK134836; Thu, 4 Feb 2021 11:35:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3030.oracle.com with ESMTP id 36dhd18811-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Feb 2021 11:35:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEKAsaI7eXM8ERlfGvZlijgSqs2oZInNQ8fN70kaNgLEAYElAWDHhsnyBnMbLacFkjd/U+x7Fuubd/kTpN0eb1RdUIokvpkkbYMgjlMUHBSyfGaNeHXCP+ltYNRl8Mcvbo4MvbR/SK/jrD2gXE5MQDaqx9R7Z7lUhL6hW42Elfjbn2ABre6ASRhmHQPV3FMaJhfrl2bxHnAgju3hhpRETysAmg2XQFrQt52Y5k+GhRxKWH+mfLbptiAt0CW0Kv2xiFQxSOOv/t1906tZoMJcCrdWPkV9wzvVeRki1ubDKPfjYQmbohuzKGHANM0thtejl+CYn6Ive0DZaeICQd+Nag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VMZxcFvzwLNYHH9m/5wgDVBDSjFJj3E6tS5Qnm5WVp0=; b=N0um4EFKJQfzl1qat8V2ktwwLoKbHMEVhEHDswUWz2SwxoxdR+zXw13NQoGitk0DS/TYg127l3m3p+3Nb9GaW9Exy/Vqtlwc67uE8U2JzCjKoyn0G1ASrlvwMBasTGI5OWQPiRgjFVOXfnna5Wsf3EFeA8FpCYpoQ29XsR8YZYp4j0AZ0Yk/sQxtErRpLnPczi1vz05OC5vhxBe7bKNUMqrCrquPDz73fGlKQUFKDft08FW/+KED8qRkVYMzsm8SXf3Dtqov/jM7ABueBEKpfDfVfatxOzAT5zGz5mhPXe83AJ+89PsaIwkPdylQmmTZRvwNiG7PrdYWLzt0gzGeDg== 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=VMZxcFvzwLNYHH9m/5wgDVBDSjFJj3E6tS5Qnm5WVp0=; b=0SXw2/ORTLTfn5pvy3nmaFYVHl5N1qONYpkx6W2H0aVib3wHdJQoAVtdm3mp5T1wy9eLZ7QEOlirgGLEjZMFOHyZ/iD2Mirgz8VMFRmUjT1rEN+E5mqdWReDWsXb+J0+a659DPUfY1Zs0rzMadVXACNqBtSJQgQUOblb54+hJKk= Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by SJ0PR10MB4480.namprd10.prod.outlook.com (2603:10b6:a03:2d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Thu, 4 Feb 2021 11:35:37 +0000 Received: from BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20]) by BYAPR10MB3573.namprd10.prod.outlook.com ([fe80::1d86:b9d7:c9ef:ba20%7]) with mapi id 15.20.3805.028; Thu, 4 Feb 2021 11:35:37 +0000 From: Mike Christie To: martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org Cc: Mike Christie Subject: [PATCH 11/11] target, vhost-scsi: don't switch cpus on completion Date: Thu, 4 Feb 2021 05:35:13 -0600 Message-Id: <20210204113513.93204-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204113513.93204-1-michael.christie@oracle.com> References: <20210204113513.93204-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) To BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (73.88.28.6) by CH0PR03CA0084.namprd03.prod.outlook.com (2603:10b6:610:cc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Thu, 4 Feb 2021 11:35:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72ad7924-b932-4f9a-0a4b-08d8c900fe0b X-MS-TrafficTypeDiagnostic: SJ0PR10MB4480: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zsiETygP0Ra/Pi5/WypQwlENFqj8PxAFpiw2cD4x5PfQ0RSQJsDm24cmjqlKC8w6NSXhsM+RbSux2L/E6MfVKFI035Zkp3KlOzcdQd49ss9gFlLm5NOC69q0wtX0mVT8ET8Ae16BW3hUDj4STxIR4TTfO7yq3XPD0afleAHqTBTdTABxwHKIKdmmzjZJ5RaiRwyQYeeHfjyJfS/16FXOP/lebIFTI5b0GniyoaWYTzsGOpG9MnnmYNRD6TX6BZWoWnL45qw8XWMrrxQCeVxMS8TSW7/AG0cXrgoY0u2dvYb3+xXh2HQvAS4d15VZri3v1iXQGFmvZMsTXm0Mkt4K5JC7RYG0Pc82qLlA9k/yRvDTqHPyRnaDhHIv375pEX1s5shkk7yd9TuBYak/pNsfVcJN2LQdMriqGrrcWxPmQAVKF3thMRCpmVDGNtlzd7XtO0UfMgHdqziDIG1gSYxdt4TghCeIZ4JdkrrL3cjolb6VHFBrRyBRJx8xOO2u3WBfm4ZsTlprxyHHIvXPrOz59RThpVnsc2J+RQPDmQrQP6JJx+8iLQOc7uR40HzqNUC8cTnUFIL+FGTBrbjMSA2k5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3573.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(346002)(376002)(396003)(366004)(52116002)(66946007)(66476007)(66556008)(26005)(6512007)(478600001)(16526019)(6486002)(8676002)(107886003)(8936002)(4326008)(186003)(2906002)(6506007)(5660300002)(6666004)(2616005)(1076003)(956004)(316002)(36756003)(86362001)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: gtKEuKNROxEXV9oZqe6Ltp3JKDzrIYEEBLsQZc/B/HzhwC06Pz/TRbTCRaa9x0MdmQ6sUSjzlLOmI7RgP+hn7J8bi02lZNF5nai6sdbH5Anj2312IOSRia0rig9JbBGfKBjtrfU6LY7C+jY2KXfVnkTMwYvzTMgWq3c24lo1CvM9ZCdHhrnLUjO/4hChpW/cqfScLW0L34NAY/sMyqC6wp17+//YsWO1OzGB1OIPyVbft+uoeAKLXq+TvfSx9Mk7o0Mp/fQnZh7BzCEy0WLLuZTY/5K45G0pCOljRP+odXF02BQr4tGzNGzh1pdG7hKR36EcTi06Z4naNUV8UmzSqSheY5qj41sj/t+K/1Evt8wIzCbLyOwLE0WW4UJTwwowdfifdjdnVIwk1MmKR+3ZO/nhYrzXw02FZC9N/51EcYLSePl3deoHSHJhUyt8faHmt+7l/oWVijZnIG3vov+l5jw4Hj2dfRWdXDSHBvp3/CyeECcjFgWuX9seDa+FPXDE9KNuygXzQ5HjyRQaJ+fK262DdChwECIP1JDYbF5jEai9uH4d5vG4Bqxzl2J/wqWZbm22nQfKC73m/quXwary0cKsbEKSG+7mEtwCW/9N1YQel8kh+FWgA25RmFzDlAK/TYYuuxTgRI4hUd575RZGU//qCFsdQgC13QcLDlaHl8YQsaWTmzld6f+evNhZIXJXre6xPxACaYuWp6VhM1/NUpU/kqWjLIuqDIS1M5WzHZtR8hNrwpSqrGzI/272ceyHSJxIIbqTHK1As3YrD62k9xgUDE80Ob84kfhjTV0Efb5xBoMyFQbv3PBPAU/UVOpGhgn0FXIz7rUEGZ8KLaIi0sUW433nokoU9H7hi25uoJ3jCUJZp6LpCOTMmAZPGr2o0/R3G0LKViDxRoutMgXEMBiuUhDV52sKEB7Hm4vVdrXmqJFdbV978k0xUFK265DfK6zPT6JhhNScncTBt1q+PZpuahvH1C7tjQi4HFMl9OkhHlCGB4oZ/IaancH46lagevtfQAuRkIEiqwv98WQbT2wtvv9hkxQtRP1jobuExteiglSRl7fsJQr2fnSVq78aEW98zlDn19tZCQ3KFrixf26bwVhlZmCTy7eph3s0NTY1rVs8fkMT4LPz+dneyCL7pugBp7iigLWm/ktz5GBzS4gLvM+X7ZRmT37oxqj7GQIlrccUzUPlpclpG74mNo+soyMoEEY5JEZnnL+U/xzNmaOVIkk8TxoyQNZTsKEY0uYm9z5edXbG4D3aiTjIkI5c0WvbnGbz7rUL8c12BT0/sKUJNLjhy2L9R0M0IP8Lv+/uyU9w+XSnk2OMpX7GgLC2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72ad7924-b932-4f9a-0a4b-08d8c900fe0b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 11:35:37.4033 (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: FhAzZTe2uZnQ8pUSYRRPX5MZkLvu4VfYJqmlnd5Bf0tbOlgvS/5Z7I9BaoIcxXGMtl2U79luefgQlsB3OBUt+MWFhmjjGgVDETHNhRS6vAY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4480 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9884 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102040073 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org LIO wants to complete a cmd on the CPU it was submitted on, because most drivers have per cpu or hw queue handlers. But, for vhost-scsi which has the single thread for submissions and completions this is not always the best thing to do since the thread could be running on a different CPU now, and it conflicts with what the user has setup in the lower levels with settings like the block layer rq_affinity or for network block devices what the user has setup on their nic. This patch has vhost-scsi tell LIO to complete the cmd on the CPU the layer below LIO has completed the cmd on. We then stop fighting the block, net and whatever layer/setting is below us. With this patch and the previous ones I see an increase in IOPs by about 50% (234K -> 350K) for random 4K workloads like: fio --filename=/dev/sda --direct=1 --rw=randrw --bs=4k --ioengine=libaio --iodepth=128 --numjobs=8 --time_based --group_reporting --runtime=60 Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 10 +++++++++- drivers/vhost/scsi.c | 3 ++- include/target/target_core_base.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 57022285badb..5475f628a119 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -305,7 +305,12 @@ static void target_queue_cmd_work(struct se_sess_cmd_queue *q, static void target_queue_cmd_compl(struct se_cmd *se_cmd) { struct se_session *se_sess = se_cmd->se_sess; - int cpu = se_cmd->cpuid; + int cpu; + + if (se_cmd->se_cmd_flags & SCF_IGNORE_CPUID_COMPL) + cpu = smp_processor_id(); + else + cpu = se_cmd->cpuid; target_queue_cmd_work(&se_sess->cq[cpu], se_cmd, cpu, target_completion_wq); @@ -1758,6 +1763,9 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess BUG_ON(!se_tpg); BUG_ON(se_cmd->se_tfo || se_cmd->se_sess); + if (flags & TARGET_SCF_IGNORE_CPUID_COMPL) + se_cmd->se_cmd_flags |= SCF_IGNORE_CPUID_COMPL; + if (flags & TARGET_SCF_USE_CPUID) se_cmd->se_cmd_flags |= SCF_USE_CPUID; /* diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index aacad9e222ff..baee85dbf97c 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -804,7 +804,8 @@ static void vhost_scsi_submit_queued_cmd(struct se_cmd *se_cmd) cmd->tvc_cdb, &cmd->tvc_sense_buf[0], cmd->tvc_lun, cmd->tvc_exp_data_len, vhost_scsi_to_tcm_attr(cmd->tvc_task_attr), - cmd->tvc_data_direction, TARGET_SCF_ACK_KREF, + cmd->tvc_data_direction, + TARGET_SCF_ACK_KREF | TARGET_SCF_IGNORE_CPUID_COMPL, sg_ptr, cmd->tvc_sgl_count, NULL, 0, sg_prot_ptr, cmd->tvc_prot_sgl_count); if (rc < 0) { diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 6b32e8d26347..13514c59ae3d 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -147,6 +147,7 @@ enum se_cmd_flags_table { SCF_TASK_ATTR_SET = (1 << 17), SCF_TREAT_READ_AS_NORMAL = (1 << 18), SCF_BATCHED = (1 << 19), + SCF_IGNORE_CPUID_COMPL = (1 << 20), }; /* @@ -197,6 +198,7 @@ enum target_sc_flags_table { TARGET_SCF_ACK_KREF = 0x02, TARGET_SCF_UNKNOWN_SIZE = 0x04, TARGET_SCF_USE_CPUID = 0x08, + TARGET_SCF_IGNORE_CPUID_COMPL = 0x10, }; /* fabric independent task management function values */