From patchwork Wed Feb 10 04:55: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: 12079755 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.8 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 CB9C4C433E0 for ; Wed, 10 Feb 2021 04:56:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9442964E45 for ; Wed, 10 Feb 2021 04:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbhBJE4V (ORCPT ); Tue, 9 Feb 2021 23:56:21 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:43246 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbhBJE4R (ORCPT ); Tue, 9 Feb 2021 23:56:17 -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 11A4ruIF003701; Wed, 10 Feb 2021 04:55:32 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=mwRx5RJwoINrrW6DHSPguPEI22CgZPzUP20hTWdabpQ=; b=sd+iILC3h0zyWu+f6Vh6n+FbDOtxkPI1Zg3j0pT4htTisnSQDbvPOr100RYGCC7upbHZ 0iB3HXmoMiaefBEJjFWxRw/WaX18d6v4qGnrDAur/umA5K7+YmkVlDs9tRZJ0aCBcuyH 3+G3KT6GVnjtL+PALjU3cTTebQC4Pc72GC4HBH4cmg94ywdJuDBAZwOWnTwRehsDGSRK sqy2PyxRUaxEx5fc2eaoDAApMMaEMLAJrxoNMX7Sc9QlOUi02qa6+NoQoQrD4YFWLPPB 1/iixhYwY8U1IT7mM5VC9jzE9GlxoQWEtqfX0ElwFJm++vCPI0Z989/17UZZTGD+rYFJ dA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36hgmaj0tq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:32 +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 11A4tRB3048727; Wed, 10 Feb 2021 04:55:32 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RuKqOwPvuqzCriwRdlKNnmVnlTE9WTTkfMV3IEiT7VTFqkQvYOsxZXh7VZNgJw6zsPeQVeG5Ycfxjd9XcTvaNg/w4Lbr66Tj1WtodFVeoBiw5TOwn2JyZvP5QbRotarSMN4fArTolNAExW0uJgt00ofHKTZZFb/RJ6ql65qDwmQr/rIG22F9m2TBVVNqBT1JoAQMdg7WuNxy1seOnAYA3Q1Zgrh3LdU2y8RFi876+5TZal+6O4uGJHzhoGCJdap1jEEPs9AGlJ7+skXT8FHAeZBqkkMKrJfueFvmG5y1ciXBvgwep4TJUiRHKZFhy08d7AohIKyenrNyPTxfBwav9w== 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=mwRx5RJwoINrrW6DHSPguPEI22CgZPzUP20hTWdabpQ=; b=d0cBiJvTqNwoen1S3AiuhYTGTLjnxF7L1c7ksMS3q7KI13uDdF1srLsmMwBQ6XtQE8FUZyC8zXqcivGT3hfwmMCQxdAaOsa90LliDJDOq0tI7tM/UkpskuLR0ny4/PKd9S103c/8oB7q6O2vSL0CumU9LMNPkyFYiT80InRlQB6CiQOQi+w4b5MhOoDMb6sbMaE8jSOPUPnGRh2z2IKqa9K9P+BOPX7EivngLhTrhfS1dX09MxUuAwGwTL8BiMk4evFh5fDX0+JJ2WZzIeWCNSAueKewjvX/g5kURJbQCja00s0hOxFuy7OoqcUqhC30zAvQn3q8omNkcKzQHJAmpg== 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=mwRx5RJwoINrrW6DHSPguPEI22CgZPzUP20hTWdabpQ=; b=RShrE5J6qyi4769K6cLt+aDfBww1y6nn6JW7YrrFtY9XyooaF8wMmUxj5RsS7wDSfhXdpps8eAg89o87qD8FHEbT87cco2BAZSmAFhTrV3qmf4mxge9IqYqfTe7gVmL8D2UVxvWVil28mCuOWAt6KNLozgofqUGwqpPdtSr4xT4= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55:26 +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.3825.030; Wed, 10 Feb 2021 04:55:26 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 01/13] target: move t_task_cdb initialization Date: Tue, 9 Feb 2021 22:55:04 -0600 Message-Id: <20210210045516.11180-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 895a9596-8a3a-4677-e511-08d8cd8014f7 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: irV8xJlWOUyMrlIFwZR1JnvkwJWszVC0HKn71/9Au57RlEBTF7KQSBpLI1mjlL0sNf6raFh3LsfCMi7/fdvGVK3WIBGwvZgV9CmtErkX/zZg/Lx7r7pennydB+/MbBGGwXNqT2d2al+IPfO9f/R4JHPlubkmaMgidcwfmS+wJPAez/rL4+Myhc+1J/Ukbv9fUr9vLRYE3PuJTdeVxmZ4qj5ruW9joTwveP2N9YA+itNyBv4rmpko4gfRWra5/oRHXwaJf1WUU76PjFsKKlwEk2lwURrr6beLu7CZ5oppxiBX/Sfz9FFRUedbddsjEKM73kyPigsCkXGZNQHvb/BUKja0Lxcjx+d+10tyAt3MyPzykGjbIjiTfyOODIqqgNU8QYLEodJ9uWiBMc/Wv1LhuhsjjgcZ0li932pvllxi0dYnQr+6DZQbuU+07tg74mMwKvEgYZVI8Tr1PuqstR6C8YiRiYJc5NwD68XH4IY35g8ThzZJ8bCSFcAqqIt6SVLL78A+GW1qOHDRPVBNAXxJkCKxJitW5yk/QSEh/qHrtxpgGLK0wN6sxcoPk3yPqRGu3SikGCOIikZ+RUaRPVsiPQ== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1MAheIYwQDJpciqHbe13Uw0pHKONlVO+sZADImoaNmW8g9S9V+ehKNC8aN4hh6AAVWKstCNDSZvuS5zSlMSc6LFOq+XyZ7aIX/fZ353o/HwA3WM5SejXJWTcpPmSOzBVd7YBF6gXFKbfcYSpMrFts0nK+d/gPKyyfoJJG/Vag4UlPRmhjCockjlDVad9l3iBOQI3BsEnwkm3Vtnz5696yT9Tv9RtoyrRtksfHIWJNm7TAC9s1y0KnQTOKCSbJVnkaGtt5MLCw1IqA+nkXSyCx4kzQ/z30dxS7MPa02muu05gtxfqatKH8HElciXUXkeyNSrMJPG+ftn8wR83fKErWNQSWm1NeMSqebZqHJV3EBVk+G1NKCcKAKdpF+85mG8P1pBWZAEtk98ghfOwYsC5GLoH7F6AgHoePFumfysYvtsL+aap5BMtBhqPplWarzYWs06MuLwLW+ZqHx2nc+VajRYa+alIuE4i2y0Xac+GkYgRBLNSuDzu2XWnmeI5IRMq1LlDUeqX9WckT58BBXPAKtEfDTUFZaHu+yNluhSQ0GqhRJxsjxEigd44H8yEoK3Wt8OMIFIomt5r9Y6SwOkcOC312tL/FE06+a2ptWKqSCbw6q8TWM7Lm3r5aT3Q1Pp0eiyKOhu+oxR++fOZn+8HMN8HfZryn6/xEOI2WvPdJRZ1ZtT2ElE7HP/y0frnKo/LX8NJCr9T+QwGmVttBTiSDON5U73zpF74BCQxRcl89JO1VHujPwDs01nio2BOZZv6TeBPU+mACDtQYXCvdBFmCjMQbvsn1VsQb/oDvYOTxRUOjbePemPyD1w3Rfv1wLrtuxTC/NfPdo4Ge823VM9Q11wrOn8EepJw/ffkGn7LRhRPc3zapPvee+9Qg7t6kUZWb3riqmcIN/qeoPJoU6raLs3iZLqsPh7wtq8y4nAeRY/6a/KsNugDp/DoOMzWhJA0/4HM/YmejRRxgRw3Dgi7PJI1jCNG03OhxWymrHVIuxH63fZ64vVqHx7VuYvJ9eDgpe4zsUHEdcz1NqHRvhqD4oNcwLUMF6NdiSN8dXi50DJS3DKrFMPQAooEkh3njMZvGV3Ix4Y+03zCcirRjweWwppBJQ8rylrh87arOf0f2MtmuBMXbH9HC9I7YIzOxgB7xnc8yP/kuXWIBbe/tNtcWjxJggavi6fx5lcMr3SlIX9ao1RJWrWWmX2PX4z0ht9B/WtJBWd6uCdveZWwz3EWuc+88oVnrX8+8T077iFd3kOQ4F3Vhv0hFXa6dCmIcfLxHFJybnuBS7BVB0iipFxy/BiWvGMenBg8Hlajyjq4QEta1vR2nvvyHrlNA64wXJGF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 895a9596-8a3a-4677-e511-08d8cd8014f7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:26.7351 (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: ADvEBevN2liMbKMftce4rTEYqdOrJvS1fBFM5S+aQ+WMwU66m6MvgC9FJK+xKB4EOmMe9n0mFPnjIeDOMQq6/aiey/v1hZuIw9jG0BJwtbQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org The next patch splits target_submit_cmd_map_sgls so the initialization and submission part can be called at different times. If the init part fails we can reference the t_task_cdb early in some of the logging and tracing code. This moves it to transport_init_se_cmd so we don't hit NULL pointer crashes. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index d47bfd8b0f87..5c4adde96d5e 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1389,6 +1389,7 @@ void transport_init_se_cmd( INIT_WORK(&cmd->work, NULL); kref_init(&cmd->cmd_kref); + cmd->t_task_cdb = &cmd->__t_task_cdb[0]; cmd->se_tfo = tfo; cmd->se_sess = se_sess; cmd->data_length = data_length; @@ -1430,7 +1431,6 @@ target_cmd_init_cdb(struct se_cmd *cmd, unsigned char *cdb) { sense_reason_t ret; - cmd->t_task_cdb = &cmd->__t_task_cdb[0]; /* * Ensure that the received CDB is less than the max (252 + 8) bytes * for VARIABLE_LENGTH_CMD From patchwork Wed Feb 10 04:55: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: 12079757 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.8 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 D4B7AC433E9 for ; Wed, 10 Feb 2021 04:56:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC31364E0D for ; Wed, 10 Feb 2021 04:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbhBJE4W (ORCPT ); Tue, 9 Feb 2021 23:56:22 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:40994 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbhBJE4V (ORCPT ); Tue, 9 Feb 2021 23:56:21 -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 11A4tXtv139912; Wed, 10 Feb 2021 04:55: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=w0bkrPorxBkVypHpKPWa3rd2csO7WNGUL6M2nensSN0=; b=eDc8DXjMwBUaPABmN5ibFnJMtnNf+ntaMZjtj9iYy0cZYhIxZ40GqtNZOJ4uDAYtzKz/ 9xsX6uOPjAs5zdihpqKBA5G5uID0vNPrWPon7WfEXDeBclTX1CHZ/oWKjED67+XesM1g gxwwefdVK0kUpY9v9g6H+/dD2FpmAMUBIWFcLHzFqGPFbJVWD3iexdvHpDFcdDw4OMs1 rgzTiQF4T14KXwYXFNQb52uX4YSKDmGQDwMuhT4BoM4BmW/MYPftmVyH9W8GTLFtrBQ7 oJxSi0zZLHk+UzJomPWf4+9yaYHNrAX5tW7ZAFUZbCVdxaNIMmCvKjLnPCRr1Xip5nV2 1g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36m4uprdf7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:33 +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 11A4tRB4048727; Wed, 10 Feb 2021 04:55:32 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhRCKbd02HdMWkceeXMn+2sCFxwo3Tl/o7+sJK8h+q4zeJ3KX4xaoMO01DWw/US2bDVbZfHe6vAI5bJra2exKcCdLq+fP1YgXHzxzqL0K1HWTSXseq/uwN5D7OwTMbtf5zNm/iObsPaD4PTaDu6B2EBpfygzTEqf7uYLeWPJtM2D/8YYS25P4covZ+7RWSTJjbbf6eEZxyQbkSTIc/wfBTZ4XLkfZ6UjjZpDD3pZQceY+kc5PknZe+yOWmpHgg2j7Z8rT3DKGmGLK8XDfsC1M1TU/9Li5/nH6nY2bdZz2F42FVBltogHeBZQixn1wviG3HtQGTX0rDa0RXta9QWOBw== 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=w0bkrPorxBkVypHpKPWa3rd2csO7WNGUL6M2nensSN0=; b=nJe+OMKJ/gHya9Js/Kd2z3W45Zbnb4b/r6TyZrRChwhkNg5wSIpCWFIUOzCiq0hj9NmATgO7mFTQGcnmxKOygjvs5ypdGfTLKgM0kfv+RZMOAnOPmgRjLx+Ep73NtMWy8mDAHJ2+Jd2s022Naf4mOJ2mj+X5TuSbYnHRpa62yu42qkwrNLa/hPr2XwwWh6lJ3q6S0NzBjc5Er73GyMaswyiJQuodUvTdFEZjEqFE8pIloWSQccbcmJjrEK9oodIL5OnSNo/me5fEJXpV1X4iiy3a4+W9RBEQrrXVrrf9E3UTOnZ0yjy6r/z0ixUPjvWWglQprTGB43LR3LwNL/V5ow== 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=w0bkrPorxBkVypHpKPWa3rd2csO7WNGUL6M2nensSN0=; b=eVllznnVZTCZeBUprbd9aiDk3sLrtuDhry/ajFQWdB/UpFTNKo7BbreyH460O+KpsLdcArBGaK9tec2VmKnQQj8+rNjb4umwrlE9LRqDHBu7UGUOLGUIi9B03lyLL0w4owpQI8OWakRYZIIWBsRleE5tKg3/zHTN57fW5nWT3No= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:29 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 02/13] target: split target_submit_cmd_map_sgls Date: Tue, 9 Feb 2021 22:55:05 -0600 Message-Id: <20210210045516.11180-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11ea16f9-e7a8-439f-6653-08d8cd8015c4 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: Lr4lCjZk2PqSk2wvdAbEM5jStNLpsCh6ngUkds55aptoPGYj0H6Ksakt2POn6+k3qRZ4gqDER+yjXUHYZhUrpC8JeHJdllxtEVH/rGuYTLPdN381Z1ko8ATvkIlaD6Xpl9J9ML1D2UQygmnJsrOIrIEJidyHhw6vl2eowWnLiBTya+FQpxsJS2Z9z91LvWSdGVGptXI78b865+XdSjbzdKByI89o4EEx4GBraKfDY96oY/i+ad/7bostFh1qXLOZUH2VQtKOPbeRvP6ChK5jF67UzR+VlbxYs9OwV5ZveEYz8gWZVKsSEzjBTE2aD6mv01wOZ8vuOp+d7r/ZU+7eHvl5polZGERYV/41rxmuXwH9cq5tRRKoWGjgFNlw3GFLWCbdd06ikSnfsvvoZcfBqIeJC4L6uePKaAgiTyeJoyZAmguSGYNXCmHaGYQeaLX+WuQuM5neVPvdHGRPpPFRo2OCEXUyzXHsi4O7yjju01kuMO/aPXR+DlCFB1F0QSHrZsLVTIJfe4ldc9+SPppANPHW1/hOGzLNsJowAKM2Y/fVFn2CD8UxrAkcio01vrbbshNdyLDVpmfynvN5zO0rnw== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PnMchR/nxs/dNjOcXjGdBYpqVOEGb2PWqE24e06Q5Uu/B360DCERm/xi7ct9/f0+pyCva9NcFsMBOlD/nh8ST7k4NwIkKAe8lkqUFiFG6FBhsVLF+6uZThLXpBj47hbWsMdCnmUnuj4ZrDdLoQ4NfgAdoBLOH3P8RjCe1QwDNInuoQhmKJR5i1daTGgbkDkQ6/HJwOyr7UOena3Cl5H1SxM+Q1evVYfHMCoWeOIfsYAH483MlZTpZx84Pt/aa5eJAVy+YAf+PZFZ6KM2TPN2SC6QCp68ZLzJyoXUewiojqJHAxZbiPCHjU1zOLYqX/1v2gJ4rtuNN1uyTMSSqc7E4PKIMA9Dn44F26EjOrvzuU7t7FtDH5Y6os2OYYA9Mf/ITTOhq3uQ8CkIQTZp0tPna7OCyFXyj9vObiIPT9YDBr03b/Uh5X1oPvA+MmCmb1W07Hlf7ppEJC43HTOskwVGTGzG7LuVtd5Nin45h4IKZLIKCxM2CehZEBLwanPfO+drJ61uW/Jlvmsj3vUP8BALr8CQ/DbM6yxNnov5RaO+as0B7iPPwQwKssA44g92dHwqrHBD3612IzJ0TTT2IgjAwjmFA45j5hXRiLfnNm9akqMWxZzll7b7fTtPmIdOuEQAHyzcfGxgOS+fUtueKMh64KDVAsV5Ydt05fZMHC9lSM6apyCEuAu9mVid5HUsrqkJqYQqFAVkvxJP2hy+9DoTerhb+L281xJj0e3Z4POdCKwA4izKYUG1G+DqUdRV/AxDWnEQWAI83UVG1EOZC+vXp9TtAtz7FCRalzECFn2r87kLeKxckQOpOhfcis2L6TBrAAk+eyxa4HiCwFaSdbRdRMAFZVH5KmWeOCr+QFkd8drc6SnRATdxJmkwl5R6pvLRHDoP/yAd+JVKbx7IfaRMoDZEthpu/0apebhI06LFmVNADkG50Y16tsIF9k/mwyXWHUygnehFMmk8cl+Dveu9Yl04b/9BeD0ecT3s10uOuACLtX7Hmd49h0k+KNT153F1HXTgQhCiMx47JFkzhn+GcaeOS7ynvQ5cVJ1oDKIgbfr6rD2XjwZrMhHYmdCAfmCXfykJIbvJZrtqca/CJWV2E/l0GZjePaZwFWVDAnn6wBsIWAhg2hMqP0VwqeL3HwijxDT+lRSvpb1tDRvG6lQMQmnT3VzoOvCTxbiNlT+e9GgDUY2aTjg4PEOkzCxc3K5s6r30n3oBWOqxjf73T6LU1XSYPdL0gkeoRfb3SNj/5uvgCgWw5lkx2WsN8H0+nRaBD2mU+dpFGJkkAvzhtDuBUr5QWhvAlKFlAntLqf5M9YxMIvGMrBuAPFjETr5pCIKW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11ea16f9-e7a8-439f-6653-08d8cd8015c4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:27.9764 (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: LaDvGvA6WJ2LExNfDFPneNDERh8IJ1u7cWQABl2o6UbMGLTnU0BQLAkLpJlIVGZc9uO/DkQHcnH5ZqiXPWeCdaX2s4h72O7/UYGHl1TdVEM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org Separate target_submit_cmd_map_sgls into the part that does: - the initial cmd setup - will not sleep - and gives us access to the se_device and the part that: - can sleep - handles the actual submission This will be needed for loop in the next patches which needs to add the cmd to the lio workqueue and can't sleep in that initial submission path. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 149 ++++++++++++++++++------- 1 file changed, 109 insertions(+), 40 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 5c4adde96d5e..f19b4b81e3b9 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1571,12 +1571,9 @@ transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *sgl, } /** - * target_submit_cmd_map_sgls - lookup unpacked lun and submit uninitialized - * se_cmd + use pre-allocated SGL memory. - * + * target_submit_prep - prep cmd for submission to lio core * @se_cmd: command descriptor to submit * @se_sess: associated se_sess for endpoint - * @cdb: pointer to SCSI CDB * @sense: pointer to SCSI sense buffer * @unpacked_lun: unpacked LUN to reference for struct se_lun * @data_length: fabric expected data transfer length @@ -1592,26 +1589,29 @@ transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *sgl, * * Task tags are supported if the caller has set @se_cmd->tag. * - * Returns non zero to signal active I/O shutdown failure. All other - * setup exceptions will be returned as a SCSI CHECK_CONDITION response, - * but still return zero here. + * Returns: + * - less than zero to signal active I/O shutdown failure + * - zero on success. + * - one for all other setup exceptions. The cmd will be returned as a + * SCSI CHECK_CONDITION response in this case. * - * This may only be called from process context, and also currently - * assumes internal allocation of fabric payload buffer by target-core. + * This may only be called from interrupt context if the caller's + * queue_status and release_cmd callouts do not block. + * + * This assumes internal allocation of fabric payload buffer by target-core. */ -int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess, - unsigned char *cdb, unsigned char *sense, u64 unpacked_lun, - u32 data_length, int task_attr, int data_dir, int flags, - struct scatterlist *sgl, u32 sgl_count, - struct scatterlist *sgl_bidi, u32 sgl_bidi_count, - struct scatterlist *sgl_prot, u32 sgl_prot_count) +static int +target_submit_prep(struct se_cmd *se_cmd, struct se_session *se_sess, + unsigned char *sense, u64 unpacked_lun, + u32 data_length, int task_attr, int data_dir, int flags, + struct scatterlist *sgl, u32 sgl_count, + struct scatterlist *sgl_bidi, u32 sgl_bidi_count, + struct scatterlist *sgl_prot, u32 sgl_prot_count) { struct se_portal_group *se_tpg; sense_reason_t rc; int ret; - might_sleep(); - se_tpg = se_sess->se_tpg; BUG_ON(!se_tpg); BUG_ON(se_cmd->se_tfo || se_cmd->se_sess); @@ -1642,14 +1642,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess */ if (flags & TARGET_SCF_BIDI_OP) se_cmd->se_cmd_flags |= SCF_BIDI; - - rc = target_cmd_init_cdb(se_cmd, cdb); - if (rc) { - transport_send_check_condition_and_sense(se_cmd, rc, 0); - target_put_sess_cmd(se_cmd); - return 0; - } - /* * Locate se_lun pointer and attach it to struct se_cmd */ @@ -1657,13 +1649,7 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess if (rc) { transport_send_check_condition_and_sense(se_cmd, rc, 0); target_put_sess_cmd(se_cmd); - return 0; - } - - rc = target_cmd_parse_cdb(se_cmd); - if (rc != 0) { - transport_generic_request_failure(se_cmd, rc); - return 0; + return 1; } /* @@ -1684,6 +1670,43 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess if (sgl_count != 0) { BUG_ON(!sgl); + rc = transport_generic_map_mem_to_cmd(se_cmd, sgl, sgl_count, + sgl_bidi, sgl_bidi_count); + if (rc != 0) { + transport_generic_request_failure(se_cmd, rc); + return 1; + } + } + + return 0; +} + +/** + * target_submit - perform final initialization and submit cmd to LIO core + * @se_cmd: command descriptor to submit + * @cdb: pointer to SCSI CDB + * + * target_submit_prep must have been called on the cmd, and this must be + * called from process context. + */ +static void target_submit(struct se_cmd *se_cmd, unsigned char *cdb) +{ + struct scatterlist *sgl = se_cmd->t_data_sg; + unsigned char *buf = NULL; + sense_reason_t rc; + + might_sleep(); + + rc = target_cmd_init_cdb(se_cmd, cdb); + if (rc) + goto fail; + + rc = target_cmd_parse_cdb(se_cmd); + if (rc != 0) + goto fail; + + if (se_cmd->t_data_nents != 0) { + BUG_ON(!sgl); /* * A work-around for tcm_loop as some userspace code via * scsi-generic do not memset their associated read buffers, @@ -1694,8 +1717,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess */ if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && se_cmd->data_direction == DMA_FROM_DEVICE) { - unsigned char *buf = NULL; - if (sgl) buf = kmap(sg_page(sgl)) + sgl->offset; @@ -1705,12 +1726,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess } } - rc = transport_generic_map_mem_to_cmd(se_cmd, sgl, sgl_count, - sgl_bidi, sgl_bidi_count); - if (rc != 0) { - transport_generic_request_failure(se_cmd, rc); - return 0; - } } /* @@ -1720,6 +1735,60 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess core_alua_check_nonop_delay(se_cmd); transport_handle_cdb_direct(se_cmd); + return; + +fail: + transport_generic_request_failure(se_cmd, rc); +} + +/** + * target_submit_cmd_map_sgls - lookup unpacked lun and submit uninitialized + * se_cmd + use pre-allocated SGL memory. + * + * @se_cmd: command descriptor to submit + * @se_sess: associated se_sess for endpoint + * @cdb: pointer to SCSI CDB + * @sense: pointer to SCSI sense buffer + * @unpacked_lun: unpacked LUN to reference for struct se_lun + * @data_length: fabric expected data transfer length + * @task_attr: SAM task attribute + * @data_dir: DMA data direction + * @flags: flags for command submission from target_sc_flags_tables + * @sgl: struct scatterlist memory for unidirectional mapping + * @sgl_count: scatterlist count for unidirectional mapping + * @sgl_bidi: struct scatterlist memory for bidirectional READ mapping + * @sgl_bidi_count: scatterlist count for bidirectional READ mapping + * @sgl_prot: struct scatterlist memory protection information + * @sgl_prot_count: scatterlist count for protection information + * + * Task tags are supported if the caller has set @se_cmd->tag. + * + * Returns non zero to signal active I/O shutdown failure. All other + * setup exceptions will be returned as a SCSI CHECK_CONDITION response, + * but still return zero here. + * + * This may only be called from process context, and also currently + * assumes internal allocation of fabric payload buffer by target-core. + */ +int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess, + unsigned char *cdb, unsigned char *sense, u64 unpacked_lun, + u32 data_length, int task_attr, int data_dir, int flags, + struct scatterlist *sgl, u32 sgl_count, + struct scatterlist *sgl_bidi, u32 sgl_bidi_count, + struct scatterlist *sgl_prot, u32 sgl_prot_count) +{ + int ret; + + ret = target_submit_prep(se_cmd, se_sess, sense, unpacked_lun, + data_length, task_attr, data_dir, flags, + sgl, sgl_count, sgl_bidi, sgl_bidi_count, + sgl_prot, sgl_prot_count); + if (ret < 0) + return ret; + else if (ret > 0) + return 0; + + target_submit(se_cmd, cdb); return 0; } EXPORT_SYMBOL(target_submit_cmd_map_sgls); From patchwork Wed Feb 10 04:55: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: 12079761 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.8 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 7E38EC433E0 for ; Wed, 10 Feb 2021 04:56:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C0EF64E0D for ; Wed, 10 Feb 2021 04:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbhBJE4y (ORCPT ); Tue, 9 Feb 2021 23:56:54 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39126 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbhBJE4Y (ORCPT ); Tue, 9 Feb 2021 23:56:24 -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 11A4rirU025870; Wed, 10 Feb 2021 04:55:34 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=AgZj8k0aWTTZX1bk7z8LxElakEjStW0VF4gymLtLLEE=; b=lcWl8uPXHCeYpNzg2LfzDYPDHu/yoCQCP8FbtKSmOXn78IydWhX49NFBy4uyUmGXvxeO JsFgsr7uAtNVVMGQagV+U09dSZMOtgpU3qYzjknwfoCWSRVAF9drRGL9fQOKk1w5LxvC rorq638fGOj0W6GDkftTPybOvN/4h4TejcM6VnKQAhejDJ7omuVSsxoktjG2lLw8LJuh kepIoP4aP4jrny0Hw8EqmsFJeNiBJ+EFHYNlUX2FzNz0KcbKmwMZ0/AM/vuLerZldjoc StElzd+z8fu9m1M/dvuBZX/NVyDPmEYmXyM9/Q1nutKBd/wzmemeXcFbs1v7G3DCjK8R DA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36hkrn1uag-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:34 +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 11A4tRB5048727; Wed, 10 Feb 2021 04:55:33 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3KyU5tDlstpvlwvPT6bd3k4LzA/vKAfAXc4CPGafcIR7Y1fHiwhwHduJRrZl6ApdwXmrYBPOp8y38eMnP2b2Y/+9Px58ZcAZlSPk29oNE/OXdtoePd3erO9cP+c41SzSW2CMrFXPSyx65wXJJv/YL4UAKGfrbyznJBSe3e9lJ1clJekml/Jfqg4w7Y+hwm+SYpiCf2gu7KxDQ1V1hvMmdpkEhVi+UBqR5G1B8WwouZhqc07dzS3DY2djI8sivSozFhJ/QeIM75ss3t2jW6/rpT2i77NM4Q/rMHKtlGk4aOXtp2w+Q1HHDBvMDkHkT6pHLT98diJsLfpSqrE+29zTg== 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=AgZj8k0aWTTZX1bk7z8LxElakEjStW0VF4gymLtLLEE=; b=MBkeW98w8SMUn53n9Hv7IYKIdArQBfh82YjujQabZ1PB4A2/WFlm+6mBYknnfgL6/Fl7DhR8pWn6swxGqHeHmV4Iedfo6s7tbsq8BWtTRPqNFjHT+hORpZ0vyLnFlNCene7uYeuH21UIZfS2dbgAAncqS89OXj+nwSDVMnuerQox+elgCZkUxvA1HdkMHcvlfQ3DwZeaMlQt5BQWx6C7DPpX0A0WM7SNQqgrUbdTqR0GOT/4RHV45hOhepUPRjXpIJTlxaQrdf4AL7AUfdI6BQnOcAHPbT0sTtu98KMmhd4x+5MIFyCkJBqwb8OPrzFpKd24cHSB63k7ql0YGs4l9w== 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=AgZj8k0aWTTZX1bk7z8LxElakEjStW0VF4gymLtLLEE=; b=s0DE1xYlOXEK83OiOUZ3e0fMXhRjY8fWzUc6vl5cFlVTDWq4a2I2NGoId05ZhPt3pE5sudeKuBshzOcUK0zifjnzJr0G32NAfA7w/1RWEX0m3O2HVopgV9K2JAazrfx3hIIIsrmBuLDnSjei3FoXC4cQQqGp+LZipzEXWM0L5tA= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:29 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 03/13] target: add workqueue based cmd submission Date: Tue, 9 Feb 2021 22:55:06 -0600 Message-Id: <20210210045516.11180-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02500bef-84ae-433c-5128-08d8cd80167c X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hQhbphxf8V+wGEGSfanD/slFAEGMu0z1xrpkFoEyKJ3TeayzDgLyWWJpTE1CIPeaLcqvu4mN9KaL/iPdGpCNOmlacn+7d2kYuh69GaZ6lQAeLs8puFpfebjkrEJgEbbZ55HNXmM5uaQAVRoRiWl5GkbiHik44pRYXNvG7D/+LhNiOKA1Qx/wA5KOwk+mNPiSFv6TMulrNZQosGe7J+MllTD7medxgikJEjVDhnjD5pTy72wRlArGXtNNGM9ePgZ6UzS1XtZXMT+yLPVRn4hz2cq4OdnFPN8aGHYUG9ORxT/d03DKEsULlq80f1v2bo2Ye2M6RzV/SfX0DYuIXajsT2I0QZWgJT9HnH8pJthcdeIoJF6p+hDHtWcNeWhsJMct3X6Ksak+zHMAbO2E8IduEgONiLGX+s/rllUemXeitQMy1X9tGMC2RUWabbCCkL6jpGuLnKHHkgTkZwwQGhdp0WFd0vLxdRVOUEya8AjLeXnpiEo8lJmhs4xpmepUUa6rArWi971EjHZW79KbblmRa5+YSGrFVd6D7VD2rFCylICp4Q1FlVkAUZpXXoBzmnTbkGbzPIzUpsEeDCCmy81EUA== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: r+qtuWsAGKXopZ2WYxfvShVmfaaBop7TSYG8Uk1SNZ+ajEF3ISTG61BoN6xhfImDupi96JQS/C7FuYDHIo+4/us1XkT7nuHoFml/BI2mvSrgiHOjVtAterxZers+KZv+eEfw4hSu3JHg3jnMrRNYJj8q0QmL4Beq5Pk7niMRiDdC7jRyKYR6a3kj5frmOP6/7xIavFVo5iUn9UVPRKzi168bynEjSsbv+IPjNcxCeebOj2D/R1Iezpe84drIMJsD5SFnspFKcBi+jX9purkte9YTti+QenWzfbOJ+6s4SGJdNqCVZD4YGm+io5ed4GTUTZeiAcl0Co31sZ3MC+DvJRtr4pXImSLmDyZ375hkzILLeiycrY8rkq+VVETXLIZ3m9nIL3UrdipWrc64F2QSW0SVIU3q7NAkPfEQJOPBaUN6vGyRnZzTF7pNJu1j+lcPqLA4/BWnexYxrJP2NCjwBYL1muIp4+KPxXSHxerjVg1d5YOxEYnSqIqcudqUdxr7IrgMHVxyGfvoYguGOC6GoomKQNWePXDdwDkLxJi96ks3RJp5uBGfWYqmKxhDyShjmn7krQw03GIX+ES7CKCbv8bAMEdrqEKaaw4a4jCNDDDY7uoH0RpL2lGJr+5+l+PRDaxFY2N/tkdYjldMOeQg/k6nl+E+bmjpnEx7WAfRTKVtFb6csg7XCageHw3zy/hEMNaaec86Rjsm5fwBa6UiahvhE43vFOB/wr3+zIyetJNBSTvKYu7kpkn7qPj/6eefxnZGNg80WU8FgTy1WG+WG/ltpP4uERERHx1h61WzaHhz2tkITqLBqk9RmHzZMYse7P1zRxwIdXX1u8TVlgo/GI9JJLeuzoXebeF9ed+507lGA81XcXF5k8jSa68OCbTihPcj+rb8ACH+7NUvwpTr2AZYV0maSl3/uqABmOKQYGp3FRO5WWcO8qX3ftkkBq64NEdt2aCruf5i6m+C96F/EIi43SOm3Lhot1AVxcD/3iBqZ3PPtjw8NsLIUYSuvwolhlluZtnBwTwFxdIFWEyU7k7FcHygGeuCRqyijFbtg7fFj48eUjXQYPSKHC9/AUO5ESMUdGZP/eUTtQmKY9nYmA0ZHOkKFh2omxq78i0A5AvzPqxVMTk1Wa2x184cOb+Pa6zXSQ9l0LLsiIeDbhHX0ddTPimbmYnDfRdYhJCalrlKYViyWwQ9Gt6hgvdgJVDwoIEmvJwkPyOHOvVexTPA5nIBsaRqOM4Wcj4WwWGEnw3BctZFpcbCHI+rU/fc3c6m1kumL1UD0qdUVTWAsoOGgZvO36jUY+lILYLdVLrOr3nzVjQyXBiGJjUMiRypwwE8 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02500bef-84ae-433c-5128-08d8cd80167c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:29.2387 (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: pn6Qkad61USh/HhiFjp3XmwfCpw1VHSElBDXimE1esB/W3avcr5+OaNSCXuDalaJFHbGbXEEWWrzYrk/fdPscOFHVvUtCnYVXhBExDxXmR8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 drivers can use to submit from a lio workqueue. This code will then be extended in the next patches to fix the plugging of backend devices. Note: I'm only converting vhost/loop initially, but the workqueue based submission will work for other drivers and have similar benefits where the main target loops will not end up blocking one some backend resource. I'll port others when I have more time to test as I think we might want to make it configurable for some drivers. Signed-off-by: Mike Christie --- drivers/target/target_core_device.c | 10 ++- drivers/target/target_core_internal.h | 1 + drivers/target/target_core_transport.c | 95 +++++++++++++++++++++++++- include/target/target_core_base.h | 8 ++- include/target/target_core_fabric.h | 7 ++ 5 files changed, 117 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 7787c527aad3..74d3a4896588 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -735,8 +735,14 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) dev->queue_cnt = nr_cpu_ids; for (i = 0; i < dev->queue_cnt; i++) { - INIT_LIST_HEAD(&dev->queues[i].state_list); - spin_lock_init(&dev->queues[i].lock); + struct se_device_queue *q; + + q = &dev->queues[i]; + INIT_LIST_HEAD(&q->state_list); + spin_lock_init(&q->lock); + + init_llist_head(&q->sq.cmd_list); + INIT_WORK(&q->sq.work, target_queued_submit_work); } dev->se_hba = hba; diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index e7b3c6e5d574..56f841fd7f04 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -153,6 +153,7 @@ void target_qf_do_work(struct work_struct *work); bool target_check_wce(struct se_device *dev); bool target_check_fua(struct se_device *dev); void __target_execute_cmd(struct se_cmd *, bool); +void target_queued_submit_work(struct work_struct *work); /* target_core_stat.c */ void target_stat_setup_dev_default_groups(struct se_device *); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index f19b4b81e3b9..5f33730e3d27 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); @@ -1380,7 +1389,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; @@ -1827,6 +1835,91 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, } EXPORT_SYMBOL(target_submit_cmd); +void target_queued_submit_work(struct work_struct *work) +{ + struct se_cmd_queue *sq = container_of(work, struct se_cmd_queue, work); + struct se_cmd *se_cmd, *next_cmd; + struct llist_node *cmd_list; + unsigned char *cdb; + + 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) { + cdb = se_cmd->se_tfo->get_cdb(se_cmd); + target_submit(se_cmd, cdb); + } +} + +static void target_queue_cmd_work(struct se_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 the cmd to run on the LIO workqueue + * @se_cmd: command descriptor to submit + * @se_sess: associated se_sess for endpoint + * @sense: pointer to SCSI sense buffer + * @unpacked_lun: unpacked LUN to reference for struct se_lun + * @data_length: fabric expected data transfer length + * @task_attr: SAM task attribute + * @data_dir: DMA data direction + * @flags: flags for command submission from target_sc_flags_tables + * @sgl: struct scatterlist memory for unidirectional mapping + * @sgl_count: scatterlist count for unidirectional mapping + * @sgl_bidi: struct scatterlist memory for bidirectional READ mapping + * @sgl_bidi_count: scatterlist count for bidirectional READ mapping + * @sgl_prot: struct scatterlist memory protection information + * @sgl_prot_count: scatterlist count for protection information + * + * Task tags are supported if the caller has set @se_cmd->tag. + * + * Returns non zero to signal active I/O shutdown failure. All other + * setup exceptions will be returned as a SCSI CHECK_CONDITION response, + * but still return zero here. + * + * This may only be called from interrupt context if the caller's + * queue_status and release_cmd callouts do not block. + * + * This assumes internal allocation of fabric payload buffer by target-core. + * + * Callers must implement the target_core_fabric_ops->get_cdb callback. + */ +int +target_queue_cmd_submit(struct se_cmd *se_cmd, struct se_session *se_sess, + unsigned char *sense, u64 unpacked_lun, u32 data_length, + int task_attr, int data_dir, int flags, + struct scatterlist *sgl, u32 sgl_count, + struct scatterlist *sgl_bidi, u32 sgl_bidi_count, + struct scatterlist *sgl_prot, u32 sgl_prot_count) +{ + struct se_device *se_dev; + int cpu, ret; + + BUG_ON(!se_sess->se_tpg->se_tpg_tfo->get_cdb); + + ret = target_submit_prep(se_cmd, se_sess, sense, unpacked_lun, + data_length, task_attr, data_dir, flags, + sgl, sgl_count, sgl_bidi, sgl_bidi_count, + sgl_prot, sgl_prot_count); + if (ret < 0) + return ret; + else if (ret > 0) + return 0; + + cpu = se_cmd->cpuid; + se_dev = se_cmd->se_dev; + target_queue_cmd_work(&se_dev->queues[cpu].sq, se_cmd, cpu); + return 0; +} +EXPORT_SYMBOL_GPL(target_queue_cmd_submit); + static void target_complete_tmr_failure(struct work_struct *work) { struct se_cmd *se_cmd = container_of(work, struct se_cmd, work); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 63dd12124139..815de4c97230 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -487,7 +487,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; @@ -764,9 +764,15 @@ struct se_dev_stat_grps { struct config_group scsi_lu_group; }; +struct se_cmd_queue { + struct llist_head cmd_list; + struct work_struct work; +}; + struct se_device_queue { struct list_head state_list; spinlock_t lock; + struct se_cmd_queue sq; }; struct se_device { diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index d60a3eb7517a..d7b54f3e04da 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 *); + unsigned char *(*get_cdb)(struct se_cmd *); /* * fabric module calls for target_core_fabric_configfs.c */ @@ -160,6 +161,12 @@ int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *, struct scatterlist *, u32); int target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *, unsigned char *, u64, u32, int, int, int); +int target_queue_cmd_submit(struct se_cmd *se_cmd, struct se_session *se_sess, + unsigned char *sense, u64 unpacked_lun, u32 data_length, + int task_attr, int data_dir, int flags, struct scatterlist *sgl, + u32 sgl_count, struct scatterlist *sgl_bidi, u32 sgl_bidi_count, + struct scatterlist *sgl_prot, u32 sgl_prot_count); + 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, From patchwork Wed Feb 10 04:55: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: 12079759 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.8 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 2FC30C4332D for ; Wed, 10 Feb 2021 04:56:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CF0464E45 for ; Wed, 10 Feb 2021 04:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbhBJE40 (ORCPT ); Tue, 9 Feb 2021 23:56:26 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:41000 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230258AbhBJE4V (ORCPT ); Tue, 9 Feb 2021 23:56:21 -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 11A4tZSQ139922; Wed, 10 Feb 2021 04:55: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=u+xiQn5GyXdQkBxVmYnI8zNMC01FeeMnEGS9mCrFlsI=; b=Xv5m7clWKfGi7y4PVf1b4QCtPcmRnnera27cPL4bne7DaCJMZIfgLJXqqHILRY5956rT ykSfsG40tPrJ/7kva8qvdfElPMeJj/TVoTNjuQoHrs6vwbMumf/t/24d+GHvMQBXraDG DiK2TJWweTil1JSPFPYssdIdCQ80IKa21a1gVDy6Lxx6MYlRyQXPyYJkFUY/HZ+WrsxE d42vXPguLuZOpJnzoSOPKiPkIrA8pbhT1rqdqjH5Kghv6Pg/qI4A2NB1/b5FpUb4/X8b 78qVES78Jlj5nLQt2YcMpa0Y/12nbtzeXAdlQEk5gbRZLorh5WSNwttjOaO+m+nAwjZI eQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36m4uprdfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55: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 11A4tRB6048727; Wed, 10 Feb 2021 04:55:34 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P2ur0JM+Yb2T63gdyV8H/WVNYn95iPSm5kYNY6Y5dFQfdG1zI/KMJlFeACfvV5489597w4A50jIe41jw4Oh9x33gR/yqGyBy2duSbp3+Y/XYf/XNZHS3Cwg6d87avKReC5UqS9WNbnd9RqTVuw8JpE8pXz5bXo9/p1RRFPb8PaTImkGQeWZ7g2xeBA2FMoBUulzmq33TN2RYKjfFgqYiFf7gkt3rtsePe/403Y2dsIILxT6g9iyXx9JN0S22KHQSLx9uBicCbsgenup7cEWumZtkO8g1fMOKc3TxXgGSDBELf9fUdZLWdDNU3lIk8WKo2tV5r3eOtm5tOgD0e7gFLQ== 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=u+xiQn5GyXdQkBxVmYnI8zNMC01FeeMnEGS9mCrFlsI=; b=g16n1GsMAbVWwMi2uJKP5FaE5FaRtR1S/uhKQPij+DlD9gsA6HJBFh1hlsMSW+c56hguV2pmSt31Fal9kVn87MiQ1pFKHBm9P+0prG6NPLx4dKbFdTVfu7YU7JzD4E7hDl9R3MTfatxwxZIbK9ubA7vbUZLRrxbYk3/cOpJgDOO8f+CxEhU2zTt8nv5T26ldjT2d6LD3z+/BJmQIv1zJxTYRbpwa8jfaNS141S/TGEhO//D32YT4vvSEqzx9CT80Uy2qdaEmQOMkngKkVXgKH6VH5yaP2+e1ZTtt3nxHOqflXIU3SdMRWNcfSPAhAPxsok3vTlK7oZQFeSNcUISqqQ== 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=u+xiQn5GyXdQkBxVmYnI8zNMC01FeeMnEGS9mCrFlsI=; b=jegxvRXDPPTQNbTxEM/TK7uJLwAvH/VSbXl86VTVJ/EoypUE1uKrr7HpvgM2SFWtH8osVLNaIxNpaYRmI4Mxh+aAI0edoN+LY8zYqLAxABKp9HxbSqkJipNVMHavPJ1rMTslG0p4kqJ/28oxgrQWg1/49YUuilW6ThCIEL71Xtk= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55:30 +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.3825.030; Wed, 10 Feb 2021 04:55:30 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 04/13] vhost scsi: use lio wq cmd submission helper Date: Tue, 9 Feb 2021 22:55:07 -0600 Message-Id: <20210210045516.11180-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc0862d5-4b87-46d8-1cb3-08d8cd801742 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: Aiuth+1DVtYb/u6IL9ynU3ZRErJIRXe4tUf3zoZue/R+w8H3UnPSmRUNBKnHLwS6cLZqfPfxSAoEPVxdrEi+/BH6grVeqn3yyamNWQaVqynQr4lZ7CAVNIDsoberCijkm0YTQgE4ITA/LtpA/zbnbh6PAhx61DqGMQC1m7OQoVleIfGqQtcvDUHwKDYngKbxPa9rZxHqRfJGTt2T6j7NIY8vSe+bUn9U4S4oUCPoTdFmsvKhxtP6K7/sVjostEeWD+ZQiWGI+jJkAR/SRqhffR09wTv8aw1hvZI9pMB/CdSABw3/PmNz0sNYZsz5oPL9X2uR/0kPh3CCGVPQg3uVTOAW6Mqok07rkB14WtH2JBp9Rp/rFwxQwVIMwQKbfdA9DTVmZ8Ob3qhHMXRFtcrRAc0XZ67WDaqstO0JmycCeqit/YRx+nt8kbtT5KMJ1MqON12d9XfJtzwbWKw8KGIO74GxbGhtF6p2dYpTJ29/rlff/zOK088ojikdyg+fxX5vI57EvCk23eirFteBFvtKFNTQMN7BHzyc1EWC1W3nzCPWwlquPSGMatcmFOmyX3TELp8Bp4iOlgYpdUOuDORIxQ== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CyQ5LWgI4VFlNhtzwCJVYwnkJEXbgv3xKULm2TrmH6t5XTs8gKZPEdejVTGbPIv/xhSCNNYkCrcQ5x/m7eR7qPvKuI73pwgYWXtqO7QJuUYe/adYHsLvz1gN/yXUeJzD8uYzy0/5MkFT0tfONrufgioMX+vywTgKfd/GDfYccbOygZTdtu5d0zjOnZgj+Bxy1QY2K+1YGSj+ALAbnYhQAgT3kTA7WeOqcBbnMCIOx2TymFvI91CVmtQ0r3XXeIuwp4KBbdgpgsZ9oNVpDlbtPYEtnM6xYjkcHjjMxIYlMX3OBWkAYNscXu8fm2lsK97khBPsaVTmp20GmqqTy0lc3rAZgaA+FOkmyd5mi8C8d2l0n3yI2kPgJnyExObMzkGlb3sOxqAhSgAFbwDuwTuKT1Je+7hN77HVQTx47CiOEYqPQQms6iYSFHG5tmMq0qLX8H5Vsnlvzr9w3pe2bfnKCqd2uJh44nSBkKIlJK8W+e6jhMWEwGbtogev5JeOOqQyZvFEFCIkNatw2OtqG8zKD4Vt/u7+g6/gn6U1vMwczFpDxTpMK+tuUuKr+PcVFUPHwGkugMw5kmOGUSVbaZxYtWGcXHhJsXClKKbNQxq0CxcY5+9/5JxJf1a2SvuE40jtj1Wq9Eo+BRjIRz+fjr16Hnrl+u2Xz+jqGwM72hk5vc3MlLfasDHTx5ashykml13Q3yRZQeLSWaeZQB5I6Jl7NNGNBuvn9sCQo82+M3dMeBzrYguvxANXW2grXY+Suv1W1F6ymyp0oOx05bn2dsHrS1xYajIO5HlcbDtEQtCIyc987J4MP3QwLUGnjs/C/sIHvQXsbSueMmlSZVptaNgzHO8UR7SPM8DXueSepIwbgtibZsYT7AuKGdjE3bDzGuM4Xd7o55mJSfLNtDBK5MIyW+2KS99ppc5aDxyxY/q+tXeACG3Dh0J6sZw+RrUz5l9rqw5SYfu2rbuE9nccjLiBSqyDHNo6dAXrYGBq/dSBBdJmC/+veTq9B8fXJml12YicNOvCYFfEUcme2aZEjqM/pW/FP4JC9lXvMmA82IPiQgVLB8g5dVRlVPV2P2AGpsrIbeekhbRijcLgLMIU0zosEH0EshoI9QmKPbIKOlvRt7F9a90BqPxlDepfPVyRPlPkp+viSAAppn98b5uWvgdwI1mZpWbja/OZaHHalCcIuVJ9JeME4XjP5r6XGTUx/WVNk63cHZvoyk7KUtmysJIZdrLVlNlC7cc1FiO+Cx8kWBLhCLmqPf1c1isKRJEKN/yucKlqQiOQc4ESX4rzjAaXGJ0ljclf13KwtGUCoGf/LuJNwgGs6Fy95mrq+zk8bAZe X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc0862d5-4b87-46d8-1cb3-08d8cd801742 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:30.4001 (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: kzB80ZhoqFt2EleuNMC8vmdm++MavO+Br4BLDY3np5kfDwMH+mpsT2Cz8bVPfsiXnLReyqRHEufmz+tibcG84IDOOHwq2i8cmNwFUhFoMuA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 Reviewed-by: Stefan Hajnoczi Acked-by: Michael S. Tsirkin --- drivers/vhost/scsi.c | 49 +++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 4ce9f00ae10e..99909c6f3960 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_target_queue_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,10 @@ 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_target_queue_cmd(struct vhost_scsi_cmd *cmd) { - struct vhost_scsi_cmd *cmd = - container_of(work, struct vhost_scsi_cmd, work); - struct vhost_scsi_nexus *tv_nexus; struct se_cmd *se_cmd = &cmd->tvc_se_cmd; + struct vhost_scsi_nexus *tv_nexus; struct scatterlist *sg_ptr, *sg_prot_ptr = NULL; int rc; @@ -805,9 +799,9 @@ static void vhost_scsi_submission_work(struct work_struct *work) tv_nexus = cmd->tvc_nexus; se_cmd->tag = 0; - rc = target_submit_cmd_map_sgls(se_cmd, tv_nexus->tvn_se_sess, - cmd->tvc_cdb, &cmd->tvc_sense_buf[0], - cmd->tvc_lun, cmd->tvc_exp_data_len, + rc = target_queue_cmd_submit(se_cmd, tv_nexus->tvn_se_sess, + &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, sg_ptr, cmd->tvc_sgl_count, NULL, 0, sg_prot_ptr, @@ -819,6 +813,14 @@ static void vhost_scsi_submission_work(struct work_struct *work) } } +static unsigned char *vhost_scsi_get_cdb(struct se_cmd *se_cmd) +{ + struct vhost_scsi_cmd *cmd = container_of(se_cmd, struct vhost_scsi_cmd, + tvc_se_cmd); + + return cmd->tvc_cdb; +} + static void vhost_scsi_send_bad_target(struct vhost_scsi *vs, struct vhost_virtqueue *vq, @@ -1132,14 +1134,7 @@ 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); + vhost_scsi_target_queue_cmd(cmd); ret = 0; err: /* @@ -2466,6 +2461,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, + .get_cdb = vhost_scsi_get_cdb, /* * Setup callers for generic logic in target_core_fabric_configfs.c */ @@ -2489,17 +2485,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 +2497,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 +2505,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 Wed Feb 10 04:55: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: 12079765 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.8 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 3445FC433E9 for ; Wed, 10 Feb 2021 04:56:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0345164E42 for ; Wed, 10 Feb 2021 04:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbhBJE44 (ORCPT ); Tue, 9 Feb 2021 23:56:56 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:41042 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230402AbhBJE4Z (ORCPT ); Tue, 9 Feb 2021 23:56: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 11A4tYpO139919; Wed, 10 Feb 2021 04:55:39 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=bibvLdvh7ddRrmJ5/mzHEV5UGwgIOEnoXpzXIIaXNXhQDl10kaRC7eIg0ZGDZEt3j6F6 VexX6qs6z+l7npTBpW0YAVvYGFql8Aw6VVDw5DOaajdRCVGafHmZjFMiVUHbGatbbvyF z9ZWkvQOAGarZTTZr/WtOtGtGntcD15FQ1l6K/npVTRPvRE9sDPncXJYiRL6lJxLDPVy wuTXKXYsMwzmNaQYCJH3JRvt0AmOIKXglrnIc4U8uVu5/2pXOaJ81+4KXRPYyNmzxDtT HCpDsq3yC+Pr1INUyXiMNAHD9h6EzQmCdo74sC3hb46SG/AJfsf0fjhtzSJmJz4uUM60 Eg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36m4uprdff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:39 +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 11A4tRB8048727; Wed, 10 Feb 2021 04:55:39 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UxKrZSyPEB9H/0Z7knZ2Vrkg+K4+NBweXNMnM8CjSLvTnX4+Has4DpM8eVOM0FWO216TSg2bdI0pfqX9WkA/e4AQYTS9UfRIie6Vlrw8nWQJxU76e8i2M3Y5EIXOblbvkb9FdHI1wSXxlBLoZQLJr6cFWHcUz6lUJSFTy0aFQ94jToxpGy9QZyS9UvU/mdnreXFBxLqIqnsiPwLuZyhnnOq+IGB4N5EsiPrkuT4Z+c4iqsNzy8Fq9srBKCf1RI9tOm0CGC3+g1UrskP5i6hflrfgNVNpEKGHV5NBMKF1fZ129cIzkZLHCB9vX257Ygnt2pZu/qjuE2lnq4EsuA9IlQ== 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=hHvC5I2Lol+pBtSPqydUDqOcWPHGZQqrXIekzHyTnwpmShdCvslgUA3o0rv3jzxRZQ5YEltewx4guyYqVOurIJpkd8keKTxTRYmKukNswE7+ujJU5nTelhCKdI5nwigKucLYXLGMlJpwyJnZdk5WwEEu8Y1u0lQa/0W8hZJ65XCM2eVBTrWV7dyfhfmEyGWk4hBW8FolId5ahG3q52T7fHrz1yLiSgroDWD3KViveopD5gf36qxYf9ui5dIYCJFPI4YgjHXiv7WwcVbEjcpdW8xatCUzvdIj/XfHvaNRJrv+rv5rRkMIR4iNExyZ06UUqpqvQhUGQBm73QDOLK48dg== 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=ZbA/6Jrgfwea87a02wjRLpiYMGB+qmmFmQ2jGjJ0zkNrytJde9dIXEVAWGx0lbv6CAWXp1UW/FfPvj1MeAkmQ835X2PbOK5ziX5g7ae0ppjAiy80f1k0XooWRwE8yGaMzmjjFggFU1ez+PC0IQ785oSy8YvX1jAHL1vtP/zdkM0= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:31 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 05/13] tcm loop: use blk cmd allocator for se_cmds Date: Tue, 9 Feb 2021 22:55:08 -0600 Message-Id: <20210210045516.11180-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95e43460-fdf1-4e6e-e114-08d8cd8017f0 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: qdHjSzmK0X2M0Zdun5t6RZpm4VlwPWwzeyPJRfaJ8g8LSnS9d3YBNkhru7HWJa6Vt6nTJWqT3qwrXrVk6Oqx8L+5o8KCqXAZdqckPum36UIgj9JSQS8X9cjOvBvwHGRoT5JvgOdS+Ibu0Fy6nl04YNGZUBKO0YGBuIdejMUVMaTE8XRstCFdIfHwQIoA7eU+7wtByYMwI9P1trYn0GmMp85KQ0zJ7lXF9E7mih1b5sY0zUwSFASYjdiEDm5HyjMLqoKztKEjkgNY/j09DV0d8XDODF2mBIxPkPxJyXwIUtDyi5cQL3dZDFdJywF/zJtiOVH2ivy9VmsfGgsKRAnXpHg6aK/tDaweWsWH36sSKGY2RZ/b6UWR963ZLrSWDRF7WMSpK6Oa/1TBxCizG0ScX5RbxuUKrYz40dx/4M3sFiX4/fjIrZE0RpENiQCEBNjo7K5Yxgc2Y4iNolKyhwiz/frHfmmZ/wFiQRmX2KYNLuSY+WOKA+NWBQLZeWrDBqtDZsygRvp391GAj9bQCV9XodXnDbkqx9q21VxzQfIxyXaZCcv+QFHGgF4MJVz+tVvK98TBi/RBeWj0iFn1ikNulw== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +J2T4zxhFwGufG7Ca7KHCvnUnBTW/m7EQgiC7FCYAVP+VcWh87aAmZyBBY4lWkuga1Jf8i8suoUQnpZ45fCPjU+c+MxB61mH1/oRGGXAw7pUl6azSC6pV3cP9kvsIjBS1rewlW/jfAXnMm4pDT5z+qeB2J8wjXbialfz8v3mFS9MZAlTKdQ1cnohtdElJzKA1akYLiUjmFaTXtng6iCbjCViQ7f60U6e4v0lrgl+ES3iB0cr3ZdZS2uYGvGqBSBXMcryvnNFpKbcnzCbZo5ipDhoOdMOOJhLJ6qEv7MIB/f3PMihF707w0NFBxV3GJDv+lpSKXVavFqa7oeRnPwenIeYeYZ4zTbg318FwGq+i1P+7BhAzqRjcxkvSWtVcTqQ+ksRDmvpIi1CUbgcuRi9sPKyLN59+5b5tScCKeBAHwBh0yzBwK/c73i977zy2X587l3s6D8co0pzuo4lMc20qpdIcyJj3ltQn9QwR4mb+Ga4BPPkq0UPS5DqcnHIdHY4N0/0wRzDXOE1qbNnEjFinxre0LEZwvuPEQhd6x6G6iu3n2WS4V/0I5qrY3rjHXRjQ4QDsFUyA7V3eLPg64LkYunLd0l5QvFNlg3kLnpSdBUrWts1/TWjtSnvAYIKhBc0TLU316F5TSXQV+Hy98yLnuwQ3u7n04PfYYa4qz51xLODylAJlATn1aqttKaAzsKxtNmCsh2d+Qx9WM/9w/PO4QekwIlnObqvGRMP2vmn1rJ+fLIvFenO6f/b5EZL78E5yKyIkaudtGoW+rty2eWs3+VH24cpCDCVo4DWQ9PfIwOXNtd5OdmqCUkRv4XGQpTzgSQCloONGhEZeKBT8bio1BpyIXdzwYuMr9vMf/WGt/i181fEAyQPPyqntmsM1SCW6kKheAtUl3eV7RAHHE6WOf9EqB1I/6rqbUehb8hYno0rgYMWyPxc8dySWE5Q9K4tVYCoBmbZizcynAtStAc1Zs1eIROJeYyFKp607Bc3iECLVfApQubtSxawjb5VgmzQVnlWt1xkuoKNiYLEYumxOnidm7s6/y24nBtqOCVetyr5oSwlH6l/uHPBlIK59Ct2qRdBbKLv8MoUag1WzlWX/8IebCOrqCkZ+H/mDXqWUyh3vhHDHQJioN+njBEv4WL3eH7aL0A8+sipob+aUnoEVcH0QLCqCX1auDfWBdJ7gO2yHJ2ghbWo5GZ73ecLTibpnPM00MPNru9BhiSj/UTwEMP3tU6vRJ/c2VLLpsDXX8SDL4zgWAiEfR+zd2Y3ctBk6FtX1SbK/ba61g6ssu29VB1Rx4bKU2npeptKzxPxLi+mOKmxjmJxlc4unlOBoySL X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95e43460-fdf1-4e6e-e114-08d8cd8017f0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:31.5944 (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: 7ls/43Rwt0u0p2c4LbJ6e411ERkRXcZtd8lxfcy5PYJWmOpoTippWbzyYDf+lJDnvxlhLDDdJzJ05/B8IvdQKDh/YrGTyzUJYU3nqh74Q7Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 Wed Feb 10 04:55: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: 12079763 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.8 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 41F4FC433E6 for ; Wed, 10 Feb 2021 04:56:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1784364E0D for ; Wed, 10 Feb 2021 04:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbhBJE4z (ORCPT ); Tue, 9 Feb 2021 23:56:55 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:41038 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbhBJE4Z (ORCPT ); Tue, 9 Feb 2021 23:56: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 11A4tU8t139900; Wed, 10 Feb 2021 04:55:39 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=3EuffiF5sRnNc3qwHTF4uaOvGDDnCS1VAU16x1f3+os=; b=OkkmGOK0fdFyGIe2WmlHTG/7hbvU/BEl/4/Y99T15c95NVDqPaaOeP1hy/BU7zA1tXVE jqPPcCxvFSt7Scp8DZ7vdJjLo7m3DKKdlNiQCpMVOmatkKge7USRkYwEHAk1ktdDp6uh KYptPXJjzt6+lh8bqfYdvaR6VhVDUCpIYmf5hmYkz3+DVYCH97fW9FAW9VBSoSj2ioz0 5mXTpPiVupN7kPj5K6OxHscq2Zd8eHm1t2FOAeHLQ7BvXjfxg98SYb8n2VfvW23f+B8h /eseTtERAh38dfS/jRl4kmaA+5R+bRSOSqVNfD82fjV5thnepbbM5j6hJqaJcKa7qiQ8 Ng== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36m4uprdfd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:38 +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 11A4tRB7048727; Wed, 10 Feb 2021 04:55:35 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VG4tcETgqafOaZxmWss35pfXEYcsay0uZcf6/Pga/Zt9gBWZ6x5qfBRrKwY5Jvbka7RjqXNjXXhMofUTUU9XrIZCBglpBkfBy0KQHH/RiR2iIPb5tsB9w1jCDcD8h1ohzZpeQCQAImwA0gMazRdZrVmHK/mVflwJp8+/jKHXv4+bvByDT+QOxOjrkGuyORujlrxO+9Qkqh4UNHQEshni3fZoKAVrZpB7fgkQBvXhVNRLr/vtzOFfhutEfbG1LYzP9AzRDW8O6kHZGtLPMKjMOfBcjg4hTb5gp7wD/7/NiAlFRAMJ/046XSziw2Q9ACMxWovWIADOvLkSkJiU4pAb1A== 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=3EuffiF5sRnNc3qwHTF4uaOvGDDnCS1VAU16x1f3+os=; b=IrMrtZxUSsR+J2qGg8o+OrRDQPpo0uHiKX8NTmLvJ3iiYGP54MXIYY6OGH0dHyhmAEQehyLb1EOwmUwwVSF4olrmI4ihWx4QQoF4Kduap6rhlAsTrgkh3dDzT+d92niPxtrIPKk3+LRlYokG1fsE/Mww/p9n/LCW/NPrCLFBZMzkeKLgOan/LvMwZydEcWe8xlbko9qJt0jmbLwnSG358gMYLLJP8jNQUnc/cJwZ4CuFWdAVt1ghekDto5C3GDa5AmsQRa1aTHBRvac54eAJdTzCRnYTEB/TKVFkZSpRJII6Agpy7Ixg4Q0BRuxpxzeYITo67ebu4kwfUk2189TqQw== 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=3EuffiF5sRnNc3qwHTF4uaOvGDDnCS1VAU16x1f3+os=; b=LjHYpfMgGcAE8QaliGv7jfIOe6p/a3Gx2UXKEhmf1shUbqK3ZtDhj6HkC6wZmfm9KqQWHJrOBdZquzQJqQrbWZVomKlW0XgXH2VdSX3+PJX7cdZQ8ummPgCPtRrtO8BwqYC4ef1mv/j2GmODZWIG7sbB1bXWHiQra0h03R04udk= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:32 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 06/13] tcm loop: use lio wq cmd submission helper Date: Tue, 9 Feb 2021 22:55:09 -0600 Message-Id: <20210210045516.11180-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b9aeeb8-e8b5-4af9-e62b-08d8cd8018a5 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FWNsXVW3Nn+MS7+wS2mdfjiZdBhmAAibFKTypn+kNOBpyW5fXxAHnhQXrG6h6fwx0sblI5VezS17J7FD0JuT/WZIMNudKLlfcK0uK1f7ut64otBeSCo7xKfzy0aHGPv3ULk5VsvZ2Tl19R6Isibo2FlqQIxa21nC+QIn+uwY6Arm5/6KO47JE1rHcJaVXUcG4Kj06mwL5Pfkre1z8Vbuh6Ae91YjNeLjyT18L8l6H27ttZbuYfgNB5XUSqvPSy7sYXd2WcvcE5eA6l77f1uNofijLCdGwYtV1wPrFPssodK+x/XUctcYrqq/Dq9J2UenlNkSdgMV/5fmqhVrEb8tTO/X8/qKJLuGkAj1T80chJbBzSrRZ/e7M4thf7Atb4lNtlFAyNPfF3j64mMnGBt/Tc/5YpBfSvn2nhXK6cbaBkeifVgSAbaCO7RhtVfzBvyvrpNiyvnL5AmRKG8tK7wW0LqxzP8qaj0jJBqXCVhPv7o7Gxzo8SsXFpgCG1tVmI1Ckkrj495bDxH7MtBn9blxmN7jsOK/ws6xIJGJ4X1JpX/q0S6GJtGep66ZnMwQG/wHsQGY+by7Y3X7yLVu5+5xuQ== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: K0XKrN6dNmRf/W1W5P2rAhtNxXgfqBm5acdXCO/TW7X5cU0MMX/zgtTIj6Oe35kbHfVnVy61LEmC1P8sDkGFz7fhgbrgMAXDQ1EFIj4Wn13nNs/e6PYz+UhHLBthfxzuLx15trr/cehz2OKgHaPrNCGGv2RTJJG3tLqAP7d4yUaNTnViGrAgYlrxUfapmurcGqH50T9d+IvYlxvnQZrqANs1D56dR/3AYryQMwCXTpBMwet9wHhREwycvnIjXs81iK88A+085upoHUn4Cwk/4u9JrYFt7EGz7ALnUd0LgEtkH/mxIpCziIAILdoG+wOSHVxBwmg3P0O17rHfeOM6n562ylAENiEOAFYnmU64Ewe7TCpPPGf5ZbzHdo1OxZi4rOi8CmfI9LoBHcIVNuM+j0uBOQCg3AIw+VgSdKdRDGSI3AHlDT9vSQI3dwXEf+M9dZtRTs9HGUos7FSmgapHu+ioBwx+DMyjNbH0XAzvK1G0GREFQFg/45ObBpXcgDL9gxAmedmwwBJ+dh7vmLcLLCE2p/muLnMuixpFTfZPESN8m139QO42eYKQvjpjvDCZjak6/ejFSga1QykSBs0wtY0tscsZYu1zlvWuSxtK89/FRt6hVj5oCLnPCUVgbBKycKOP3dNXAsmI9msPbK/4EEToSeJ3lCgtiaLliB0iC8jR9bzDZyT9HMDYm+DIMS6OavD1WUPqw+ivVlMcxCS7D36u+4q8L2Y1o7a1EY7g3M2OA68MFyL8z32LOrypFykerwoS+OxWc+H7DQ9JKcFXosWC0GtgTEy1YFqXbd6xXndQgsJwPPGhqKZyNISZl2HOroOxHbpw/X9bKq25vHcEPwR2St1LDPSM3s8AndxijZkESp5k2n3jTrwvuLWRlnPweomtjTiot4LTqaVpDVM8QTVa3NkAmWDDbdnWgAJ9Ov/pi6rQm67y8iKNnoQ6ZnWNwjKzZArnt1lsRM83CatfUszFq+9knxoR1t1Kr8VfHdTZK909jRdnmxL1tXJEI7hfQyw8KBkrmxDzFXcryhtPSsjj8BHKO0OzAavrjjTkHyqGWETgwMPkqJuuTovjqGQdO0bsNbYVY/h9eSmXDJAW76OrQgJHKZ9B86XFcVzpG7isZY2sMZXPoat1r8bpZYnrgX+RYNju/kUX5oAeVcSosRCGnPO9r1KLMsD+oIfk76hsCD6C1ICLNSrLmKs161dCf9H6IiRKeMAvu+kAT8JfAPhNd+sk5lH/APxHSd1ZSiqcvTiV+9YzlE9dDyzGa3X4zm5wTKGnYABe1WsrlawVjS40s6j2BDsMOHn9sTL9ChjFYKBYjRI0xU5h2f9xctJh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b9aeeb8-e8b5-4af9-e62b-08d8cd8018a5 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:32.8247 (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: 4pEpj7ciL5X6FABuHb50Lu+12n8QEIAW8QgIAs8bkvLCTMu99iZSM2u+WtCYvS56/xE8ZRXf3qlKVsRpK1rhF7w9BL5Fsu7X3VEhOlw1FF8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 | 29 ++++++++++++++--------------- drivers/target/loopback/tcm_loop.h | 1 - 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 274826a2b0bd..d4b008f5b7a6 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,10 +105,16 @@ static struct device_driver tcm_loop_driverfs = { */ static struct device *tcm_loop_primary; -static void tcm_loop_submission_work(struct work_struct *work) +static unsigned char *tcm_loop_get_cdb(struct se_cmd *se_cmd) +{ + struct tcm_loop_cmd *tl_cmd = container_of(se_cmd, struct tcm_loop_cmd, + tl_se_cmd); + + return tl_cmd->sc->cmnd; +} + +static void tcm_loop_target_queue_cmd(struct tcm_loop_cmd *tl_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; struct scsi_cmnd *sc = tl_cmd->sc; struct tcm_loop_nexus *tl_nexus; @@ -155,7 +160,7 @@ static void tcm_loop_submission_work(struct work_struct *work) } se_cmd->tag = tl_cmd->sc_cmd_tag; - rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, + rc = target_queue_cmd_submit(se_cmd, tl_nexus->se_sess, &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun, transfer_length, TCM_SIMPLE_TAG, sc->sc_data_direction, 0, @@ -188,8 +193,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); + + tcm_loop_target_queue_cmd(tl_cmd); return 0; } @@ -1146,6 +1151,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, + .get_cdb = tcm_loop_get_cdb, .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 +1167,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 +1190,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 +1199,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 Wed Feb 10 04:55: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: 12079785 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,URIBL_BLOCKED,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 EFFA8C433DB for ; Wed, 10 Feb 2021 04:57:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5AD564E0D for ; Wed, 10 Feb 2021 04:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230407AbhBJE51 (ORCPT ); Tue, 9 Feb 2021 23:57:27 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:54972 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230405AbhBJE42 (ORCPT ); Tue, 9 Feb 2021 23:56:28 -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 11A4sqrl034274; Wed, 10 Feb 2021 04:55:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=ZrhSxDpGiuoIC3wgDeHHH1SB/vn9aAiRH+pEFj/pm/M=; b=R0IrUvTYet9iTY5kJK8V8OjstnzSdbVc8i+VWmnUKmhYVagAcve8dE9ZO3rq3z8bnv7U dP/LbLDizWtQKS2hFGYnW7vwksMaGAz0ql5oA2dz38j66TjkQe9xx11+YC9lvcQRsPUi Zyb/4g4MVe+g3v1AmNl5jNWbCDTBKd5ytuhNB78dXJakzJEDT4fHmsMENTiBQDP+rH0w BVoqHcXkVKSTLpSrRxJUXMp8uFDkeVHbvuo0TCiUsGfaRstptGLf4fNX3gLyr7v78aPd E1dDhfNprRAZUAJaETJWhymixaSD5O/CH8AV+d4JEnIV8vH5mQ9V/UU3OGyxPaEDZbCv zw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 36hjhqswsc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:40 +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 11A4tRB9048727; Wed, 10 Feb 2021 04:55:40 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOhfRCiNqj76H7QI4Ha+7tp5rjThTeLt7sIUv0+6JQQ0Iyd5D3nRp6VD+2nCRljwmmH1pj/PEUIe6Hgezv4W6aFzeBzP2+9B1EwvGfjDmRIGFhd7NDFZPVhVFd5Kl6r96T4CwyoxBI1VEtQXHuM+XTx1gF4NhOVHvrwYYsHrYUoG18gLfG5ABeEXMBsvs6efh8rYBIUCcT/z0tDph+HcnK7hBfNMEyk/vgcKpzsECmi9YN4LQcpaz0ouzIK6I0IqWGmvllJjK8O9FYpj/V2yM8o7z39WKXcJr5Zs0Ow/SNGMM2CIhw1k30x8l+FaWvkb2z1nm3cVostdT/Hz7FbIIg== 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=ZrhSxDpGiuoIC3wgDeHHH1SB/vn9aAiRH+pEFj/pm/M=; b=HfI73nFHMmzAIKjh9xY0Oe6q+1AjFRgEWI8MiDmvWhpj92NKz5CZEAQoVnZBxIs+qLzFnvA1iIHqNBWpNXndGfEVv2GiAKho7Zg7K8fUwkJEUEDLU8iPrKNDLYmS/Fxuusu12GOD5Du+9u+IdEGc+vyWy1knxQzagLEieY2TW6fyNFagFPSUbTt0lPubhoJgJRcGpcRabIw/5z4mjRwC/HZM07F0Frsac5Zp4QEVa6VPSrG6foqWZ0KIxTstelv2SI2zdbg7j3y1TQ6BaAkCIxIDQikfeVMaq07+Y7iPX4+7NV4pe8EH2j2vJpzPkNYU2nvYLXqDrBZ8A1SLuBYzCQ== 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=ZrhSxDpGiuoIC3wgDeHHH1SB/vn9aAiRH+pEFj/pm/M=; b=e4mW6OLkak+MbbMpD1X19V+z5/QDYOfc90wAiKFX8539GMAHiinCI6V7EUyA9QNFJBszpUosF1L1Z7ESRtPMs/DlvOoQIJjRZnLXHYqIarC9gzglEXZUHXoegqSFOBnQ74ioI8i9yQ5JfIZqAkW67DQ1q/MYm6JLFRNPoQmxQNI= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55:34 +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.3825.030; Wed, 10 Feb 2021 04:55:34 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie , Chaitanya Kulkarni Subject: [PATCH 07/13] target: cleanup cmd flag bits Date: Tue, 9 Feb 2021 22:55:10 -0600 Message-Id: <20210210045516.11180-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 769fbde1-8886-4fb0-5e81-08d8cd801976 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: i+pzvr+KQCK2Yms0nTUpvj1l5m3TuSOADz/x99SFF7StDarFBdpOgcQyycQRJK64kNmgyQA2xzJr2MwRzy7ML++1GkwaEILJMv6ghKtT8wlD1N9f9jYBzAznGzlZc5Xa5lTYalIdh5dOeRLYKLGnk5GY+ndx28xFnLTfzTJg2CfexQOiS+mGFk4beLiG/IK9G0SOrgJ0ZF8Z6e2s8qbnIrR18ogBbH2RxGiESqp5nD0nrDoYE1btbgvAtNCzjqR/r9J/FPSLQ3OWmur1+sK0jW/kUAop4Z7sMbN04rDUxd+2HrhAdWIDSrMA4c3o6PyLzryZvkWHwWiITRg4QYN2kFjaDmmOWXRqTFkZvIP3HicfwS2a5ARwWqCkJBabVj4TXtHJ7Ofw82oKyuxSwrZg7549oPHdpnZDvs4R3KlNfbHzy0fEf3vSdek8e817AnqBh2ig6QLmdNwtnNhWFuYA3glgTykdCaKaAWpzMin5jvrnoEScrAlCtgE93LjK5B24JfgaCwpxNObYdD47LI4Dgk3xHWicYTTtI01Jwi4e8AFy/H+MTpiJDWkSt7I+p43SuKOf/CDOQUpIevnj5tp1CA== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(54906003)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: k5lI//pSk9HhZV/Hyx73yC1OLsule75ZrE2zk3et4I+oqj5unHXVVBdYFhyDHpz40pwnLIxInp3NsqcZZrHEQyMBGWXZFrahwO5ii15ZmPSdtg/RGQVICQYGWAvqaogT5SFucTPluQ7dlzpQ4GlS/XHXu3zvElHyJ92O1KS3qetJ3DH5TVZYD19329DvDHGi3n/rwAn60Vt/XTJ2g9EH94jIhmezEci22T9IsIhpsfcXpELhMj99Nj+hMhExMgVGPkqoyP/RfuEjf9VsyGzs0eorPSAblc6fgBWQLstNBrToG9JaQZQOZXeA27zGYcBPwbAa+O7OrQWR8l98GBAh/3BMFjUNXo7cJacV+kl6Lgwqb6y18IYrKJXMd45JQCRUtbRo3M1lwdCiSEDepWlvYalnGr+6RgOiNZ9BdbUwJcIBx05rOsGvWetFQpTJ8wjbfG52l/dZNvw4GYJOaZytg0TrKWx+aHBYQSyniJ6JDmwApy9meNbyzmQHfCSWLQsXmESsjE5TXomJh965G7aiedHiCzLSKcHS9DLXSPeOoI4oMCpNzEfiK0B1BFJOGzBe+MLzf2EnzNbldb9YVcocBBsqcLpqdgStdwGiii+hrtYY7/GYwsniZ8lE2uUjrKYf0tKSmmYSmcXg+P4Bx3/Ujwm/Ry0pJYSzmhR1J6g9vkRVz3nOQj88noo+9i5ODj7XI0FA8Z+zv1qpSWEhfTLspsg6/okuzWfmz+2L2z6mkfzKmYTjiqDibpFKQqDmQ5kULDzowbUujfbNdsaan6QzJHTk1MJGsC3sn9aXI5vijSgHIBId/c2GLyL7i0BgqKf3iozyL+06+hstRLp0Sk/Yk/kR1aXyOLFpYgjjEcRzjq4xQkN++QPI7h06qQuBoC2SjXOkhVrD1goUaxmaGnTngKZW6so9W5bDkMy5yHphKZ5VXIezMXgz+cRoXxVEszwfttykiR+/PFMND1Cjhp+i2Q090sckqrtrE6hvRPaAwGpJv8nBV+lFhAjrObwkz987ZNDaD+NHfl4EPRdwiLs3O+0K+x5CQIDukN4ay2wp7LG8aOJ0Jg2Bf7C4tCHpFkKkq9MLFejNsvW8zIddQnQSBO4twugzxepbiJxj6XRSF+w5vxR5JsgeXH+hPUzF443AEwQDvu++7/mGAyuy095WTzxzxzCQxvZf8a6R7bRfBapzL123P4xQYr1Y0t356CV/MYnwiUaUAeQ6mVSErFvqeKp4o60OZe+ODhyurelPuwsKMnAYSueEPnUruDNGQJdXZPF8lpqdtaAny0ZJlCqzxwVdrIfbUMkHSGaafX/WMC6eHS7elMxt3J7tGtyf97og X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 769fbde1-8886-4fb0-5e81-08d8cd801976 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:34.1769 (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: 2Qcj26UlNhQk1n0PZNjD51bNQf1VxH6+jnpmwsgOhEdUG2P+BMa4M8MytjoFd8cNzGP8hK1cfsrOQra9qzoH5vYCFhLbMnVTeCSYJ3gz0FQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 815de4c97230..5e6703ca102d 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 Wed Feb 10 04:55: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: 12079783 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.8 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 E79F3C433E0 for ; Wed, 10 Feb 2021 04:57:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD15464E42 for ; Wed, 10 Feb 2021 04:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbhBJE5Z (ORCPT ); Tue, 9 Feb 2021 23:57:25 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:41058 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230407AbhBJE42 (ORCPT ); Tue, 9 Feb 2021 23:56:28 -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 11A4tf1F139980; Wed, 10 Feb 2021 04:55:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=RoF4+pus+pCIcA/duU0uic6Eh7s5ZBtjtzLLAHYCAcg=; b=T8nLCIcoa3HwHFyQi0EBAne+bgJOPMyczic6k2yvBZxwd84z7UDHjhprWzta9LIS5hrI xuN/eLvpj8Tyunpgz7C9JPt6/sL2N2LfL80f3yIWxjDaVsjf3aYKCw8geT3z3tO/il9B Vcnp+UShM2BYKWeSmMU03+2MyExibR96Xp33H/WCaont15c987G8PbC5ylo0+Bk9Ir4g Yaknwgwg961Nau4BZb+aom8KYXSDamHWyKHwV3EJsR56lYYOS0hIy0fMqk10pMKYCZWg 369U+/+YiwPp8XEQjBFu4TyxQzWPLo0uASgwGQBN5wbaKtDQIhzT6wZu3oIJbLhtRffZ rg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36m4uprdfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:41 +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 11A4tRBA048727; Wed, 10 Feb 2021 04:55:40 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=odsK9sjcxe5HazT1HiNp7oAz0qxog/T90GURVToCszU5PDir63jYktldAzgVUskKEGJ2SgYPVGJAJNvh6H1LpCmXo+JgXduPc9uhNvOKESUww2SbLlnQWDkKt8m/gxXT6JAIu2/ujhKbqUYIN6p2CmYov/vp8NRN9SilPErggEecxXtXA3Y3XonI+vcdvYaXtnH14pc7fgbZgGeUWmoJ3lKIFIcUWCGCvA6FvCHgTmUpi/uQYd31I3640aMdn19qSIBkn40KEd3u4DxVRXGT6SPmpAJJCeHgE+TEFKtPRGZDceQMlSYDlIUhlOXMEcRwGieKG6ucNcrLfMzvSZQpWw== 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=RoF4+pus+pCIcA/duU0uic6Eh7s5ZBtjtzLLAHYCAcg=; b=f/dcaW6ZClK/XD4kPdbba0eOB3vGL+zau2HsfL93UzwAJLKNq9iVaOGSvae/Usr+miEoQTPkV/3fIqWxb/ZL6xDU3JVV5ViIClvb+5IB2iqsnl1VTjK3vS7K3hMqLP8bNDJaKC4gPhYrREjZGRhFdIt2xTJ7XwKonranFSLwHY7Cbob5H6Qbx121sV/8caHFfwiptonATJy9LvvLK/ZaQ3Olgf5ZJGOB9qFiul/XfJdhrhtPIyfQ6+apAYE/tr4QZXaWkv52r3pookRPCPfrl5jCAqGz6zSD5fzNTUx3sBT/B8awWKjwoU7RlTwtIDL4dbDglJk9AikVLqahae+ffw== 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=RoF4+pus+pCIcA/duU0uic6Eh7s5ZBtjtzLLAHYCAcg=; b=kQpaIFXmHWksTtWrUJEpU4iRdJYUn8djyhjeRYsogUcbKT55v4TGbHZKf3NMOQHd9EGOZgGz1QBtVasRf4jxxf+xv2BB5pTouiSSJ5zCiLBpN8FCFAyjLoY9pFXtftKhYCUtAQGE1z3Tv+KP5USnI/bjjgpBW1QqpDsH46q8oCI= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:35 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 08/13] target: fix backend plugging Date: Tue, 9 Feb 2021 22:55:11 -0600 Message-Id: <20210210045516.11180-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35693bcb-7fa4-4ec8-afd0-08d8cd801a46 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: 7e81UyhyIrYjUYOb/B9dQJRfdjiz9JIaLrOnwkZf2kpuQ9/cnsVddK2pdKGHKsxlS0eVUew6VE7HXlFI+AyLYyEoJ6LboWL7w7IxSVWtewTar1Isk5mxnJ0rPDRTzoFGqRddJ+0KVsXCJHePSqMh8nXWnBQTZgUA4+/i6kfDzL3OhWZldCgbt/vQhsCpKQJ9mSLRUaGtlI0iGMfRBvlB/G8ueMTj2ZUUQl0oQZoAqC9AU60tUQNBpBV9fI/bn4E6mHPFPZbCQCDrqn6j5ImsDr81iwIEN4rBA7RiKcE3wNVX/DmwVwTyyXbmNbqj9CaFc4SFb7b9Sigft74YNCtrjiA8s21Jz0uMjCkMRYQJCsAKxZ8Txwz5AvQ1lI6KlKmmTesV9/My3e+zfOKn76T8J+fXQKzRi2AIbuGilzw3Rm2zFIgzkpDLXLZC1QfmeltnV9ljtXHdyMopt6D2rjMR9gdzHSuv9KYJfZinkpL+uCxsmGVGtL12CSUSaTZPmD6/wIym06SB01UxnA2nVytVEYZN6o1KsAPB2HqHGX/rKD2EVNl9x1fgcWKGVzQG1U87 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fCdqfuGt7IUhdts2hYjEHmezSllTpYajwx2sx8m94D7jCj8kzSWxjyX8QFlbzcLCOGb9XpaVcbkv4muIJuJzfYjUjWLCqKMkzE8PmJQCiwGJX72aVJHO1HHmxMQIjobp5SK670DBl9l1cwXjxXcO46so8LioprL55ihf493TP7KosSIfUleUA07L86QK4ZvKrsdZl2h+8DeY3pWehD1CbWoxsoesl5Yp1PeTfPtxfYdCtVfpLU41eGT8XPThgB68aanOmnqM8VTCznHLinZCfQmjpz5FlTrxm6Wpm/uBvIgGWDJVl51Q/qkmH61z7G+wfjHeZavGpiqqsee+j8QpND0cBhe1WMJzLdq1S4kLRzbFa8J9KzaUJ8Eng22JZZN6PObfaJwDCLHfPgT1jm8dqlh0RnvpgKYTJzt/nYNlr5iPKMBFwHWMIFqZIvlUXLWu1NqPr/LQTfZyayAm4TWOnsK0PxBHxQv8yJ1gkH8sdprnRCYZU6Y9LHIomOtN/7shcSC6JxU6mOgekrAQGsQNBgK8AGSEQP9hAnd+qkUTt+f9Hi4U5+9p7aB/BCJS79vmvmCuyJBBazwZwmyApaL3TUzRBGMEA4Owy2yoXJE9k44Q87YX0A9+nsJKUuCQuqKQkuL12bwX6BcGBihxafDzU5AhJ8xxnAxe44HlwvR80fP83Dzhv5NZCMXWHqCK6U/jq2W/MkTqrFGMxnhygMJ80cSd2hDUtvkn3PiQrUJkdx903Mw5JIxkdI8LC08mfrB109EFc1mh7sauCKy3pC2Z4uwbiWNRXn7CsdlTzcoB0MMuut02et1GJ9gT94cSdL6Day/s56niSxy8hhPI48DmO1euFGCF6c7YyEIn5sB3Vj/rMMt0Zmi5lgpL9cxj9wM4NbhaxewUYOj+4Cw3deAbpQOiH2L/zd1DE98LZwcKFCAu4UXK8gxWnyZW44rET3ypV9DllVEfEPsAQID5pNR0UMT/hFJyWF5lgf5UdIB1G3wCZ2Gq9aiNjoqE9OLn01x8tBOOQAxNGs3qv7m1ADsN7lNmBFCyDL7lnPEDz8QeEmAytezs8t/zadhHm98wTKWR3U4KSPGHZ5KYQSEPzijhK+fxCGXpSv875N8bIctBI0gDNJ3ZGtXqSDhuJviwtHUgW9nY+8iKBID4Jh5AnNE6IrH9Q+9Y5+nCbPVT6U6XrMb1izPLjDRsN9knbuOy5g2WfT9KNOJLp7WLy/B718nd7VLL2NlZBjRqzBA9Huy5Z7JDR4uWR8JkFnZJElrWanTmAPn5TUP+aIUlyF3R5nQkDtyHxuvCGC/M+tAcUvq1O0obS4O2L/BprWTUicXCo9wn X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35693bcb-7fa4-4ec8-afd0-08d8cd801a46 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:35.5102 (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: NaWunwLEK53dCoXadDL4Kuav8hGl2AYgwWTnKgYS3VYA4Dpb/h2dYwfZ0PdUg3DUfbEfWtVbmHIXq3B7KBOLTqHfiAuPkP3Y/yhd0JqL0JE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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. Signed-off-by: Mike Christie --- drivers/target/target_core_transport.c | 40 ++++++++++++++++++++++++++ include/target/target_core_backend.h | 2 ++ include/target/target_core_base.h | 4 +++ 3 files changed, 46 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 5f33730e3d27..c4bc012fc215 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1835,10 +1835,42 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, } EXPORT_SYMBOL(target_submit_cmd); + +static struct se_dev_plug *target_plug_device(struct se_device *se_dev) +{ + struct se_dev_plug *se_plug; + + if (!se_dev->transport->plug_device) + return NULL; + + se_plug = se_dev->transport->plug_device(se_dev); + if (!se_plug) + return NULL; + + se_plug->se_dev = se_dev; + /* + * 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); + return se_plug; +} + +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); +} + void target_queued_submit_work(struct work_struct *work) { struct se_cmd_queue *sq = container_of(work, struct se_cmd_queue, work); struct se_cmd *se_cmd, *next_cmd; + struct se_dev_plug *se_plug = NULL; + struct se_device *se_dev = NULL; struct llist_node *cmd_list; unsigned char *cdb; @@ -1849,9 +1881,17 @@ void target_queued_submit_work(struct work_struct *work) cmd_list = llist_reverse_order(cmd_list); llist_for_each_entry_safe(se_cmd, next_cmd, cmd_list, se_cmd_list) { + if (!se_dev) { + se_dev = se_cmd->se_dev; + se_plug = target_plug_device(se_dev); + } + cdb = se_cmd->se_tfo->get_cdb(se_cmd); target_submit(se_cmd, cdb); } + + if (se_plug) + target_unplug_device(se_plug); } static void target_queue_cmd_work(struct se_cmd_queue *q, struct se_cmd *se_cmd, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 6336780d83a7..aa5f83e55501 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_device *se_dev); + 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 5e6703ca102d..b8e0a3250bd0 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -769,6 +769,10 @@ struct se_cmd_queue { struct work_struct work; }; +struct se_dev_plug { + struct se_device *se_dev; +}; + struct se_device_queue { struct list_head state_list; spinlock_t lock; From patchwork Wed Feb 10 04:55: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: 12079779 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.8 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 8404BC433E0 for ; Wed, 10 Feb 2021 04:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EF3464E0D for ; Wed, 10 Feb 2021 04:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbhBJE46 (ORCPT ); Tue, 9 Feb 2021 23:56:58 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39188 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230410AbhBJE42 (ORCPT ); Tue, 9 Feb 2021 23:56:28 -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 11A4sDSi026528; Wed, 10 Feb 2021 04:55:42 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=vkI7pVbjPpUYMdhGnmWZkin4Vzj3OtMnjwsUvl1/w24=; b=drum5xNzJBUEXU3n5ro4CyyO8UrXtN9NvQ7m15RoPyDXRuq/qj8xgxZAbPPR61Kragel zDxJzJyx7kRjmC1ZmBDjnhsCvka4tztlfIngjn86BcuzDhJU6dDO0ffvRGgfeCMqr7Pz dO4asplqFj+QrJHRlweLNa3PLT/VfjLCC6mX325N87sbJXJ3ki4OtgTefc6WSWM3E1KO tsNIobzAP0ZJkZfD95dZBJRPXJY3hIM9rFjfrcsXLAmgV/QtbdJlmBFh81Ka3ranGbxy pePKytNq1GyXA80zF1A2XsqbpUndzDiGcrobORJ7n+rFwOF0RBnjsTM0di9dE8DjbB1o BA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36hkrn1uam-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:42 +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 11A4tRBB048727; Wed, 10 Feb 2021 04:55:41 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EwOD6WXc2tZNJ9/o2hP8pfmxV+PiQ6AtUD1/ve5Ff/d66YQu/rmIRZ7xs1wNKn+viD0G4dF9JuoIxpjaKLqUiKoPQVmQT6mJVDxEO42TgX8qPWoN341lNZmNkRnLPOrmnMVLDLU/sK3YETF2q5SwvEASYopVZaEV4mFYcjFLMB886Ul59LJ7ty4+XECwbKa3IqLkwfqdJE4dAOnnUm3kUHqfMsRbW5Lw6exLnWhFmbqW/gwPcxPhJP0TNA6Y2jETfAm0ziW9HXY6WnXS7fqWnHUIyORiVPoZfRENPIkDlPVZ4L11Rx5HUGKj33IuBHRbVLmm8d0QqypjiVuzdzTomw== 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=vkI7pVbjPpUYMdhGnmWZkin4Vzj3OtMnjwsUvl1/w24=; b=m+AWuU1w3lRbk95oUvoGqTLyj2dKgMQxBSXIp2l1JdylWcUIg3byCunAq3jmxLzJvDjLcwMuBw7hEBejIOWQJzz3jevvgZK53C9mnhrWSGvPscgbpGMWCaHKLjlJwplhDoeT853mcsl6lpZfvFPR8mrv3zWhMahxNWlvlNuhSWK3W3AjGDG1LJBM2i2n2Ftxf1cw5NBVYNQ+6EGJnv8oVOPkKPn/1+26fnounn1sJBkqktv05WitZm8PG64j50Oy7lXDi07eXnWMl20hfcCV6qv9RNZEc6wyzp/QV5PHoHKUHS/tXhwCLiG7tJz5CG9196xkRcOSx9rx1pXIspxdQg== 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=vkI7pVbjPpUYMdhGnmWZkin4Vzj3OtMnjwsUvl1/w24=; b=YC/D44mLbBkNdpp2hV5gyRkhMzUKlScT8dsURy4xL8zKbQhXpDztZaXpQ481mKKBfH5QKQcVSUODu/Jk/Az4WFK4FjvqymnSEHy6mkpayRDHJ6u/v31cP7lsWWdo8DuMlY/6Aee4oAtYrMaQ+gWC2luc9/APsrAxFiVxI0UhqqU= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:36 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 09/13] target iblock: add backend plug/unplug callouts Date: Tue, 9 Feb 2021 22:55:12 -0600 Message-Id: <20210210045516.11180-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb85dc23-a993-4ce3-02ec-08d8cd801afc X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Re/2DLC+N6LzZij1YhIoI0pdoYsLHC/b+SGGzna41qK98NJjpNelBvinUb6WpzLG5UDJfhsyyPQxEsPh2yjGoi0WsO1UN8JHYjtMhIzZboxrQwChPhKp9w9BmGYKXpCnrms7scDdACGjRerJNHpk6MWQ1tDpqg27ylcQEBw8LWCCemyNChgEdbOnEaZ7hkfBhN7Paw1vlkCFeqez55kqz/ScRA1pJX4sXNv9FrkvVonufbz6cidsz342OaEqdBPvYLdR/AS92xIimid8Y9y2C9AURLhJDHOXbxwqzj/4+E2Wwb3d8BnFnKyD/6bG8S+P2xBiV4m4w+Jn/i5cW8RWaM45USPciUAdWpftHb1ThbTIHIbjcNhpoGzjfLxleqWd5pPSSZKpEwBb7mdNJ6x0pca+Lv+LhCj55cP1ZVy1MOxmt6n392GdiFlePn7sqiajFh/KZpfuUehymRXYf9DlMJpy+v9DvVjpujYpr7Z+F0Jq9iqTUgiK6MkSwMAWL2M0VythPQRGLw9f6GBXe8yPrfaafvOZyeSY8h8LokXbWwHy8D0Z8NkSPTud4hHrnpC6mZgyqW0/j1lT5v87ylSnQA== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IC7cyoq30YUvXjIzijjyrjfc9UabuBn2q19P9MFcNzIOnF9sd77V6DRLkObCkqbqQuRycozMCJkPjAFfkh+fS/GA2WdfGtOlVxHWY1ejMbPkTXFlf2az+QOLOmAEJ4Dk3RjBO7mNQLLhWaNryPp+QZxltl5z3I+EVyJkQgvBpyxhUMGeR4IqcJDBRfcrrfmDFJ3pMPiPw3tlnikGzB9aufvSShP0xzyMb3e5RZqybAqOwJygJHgpuBXszngXsPxvMS11qpWmSoKTozoy9GUBwzXzi1JkxZK2cp7AorPOsGaDFfL4So1YV3BW15glk3AhXlAuiNZ5dO/cR3UjjPqqsc+iKUgPtoRPJc5sn7CIR4bIKdDsxZuFD8plXKC5Fbgbh7qoMtb3mMRYCmR19IAhnrE3220V5d4GmHShFcXs4KtDBVEzWwfcEgWLfl+pXQpMg7BK26IOUegpJBufo6YnCdD9fhZg/al30xfDGmmZPJZLcihG2ccC4gAo1qREedBbz+5O4nhBZCksVA3NVhKFUwEKR8x/Ds/104rQUIa+di+gS4XipUi8WGO/y5smZvQTl4k/MFKfkPtHzU5uJk6E2cG4fxa8rWXggQhNWLGR0jWYBg4MURndqg28Pw6uIJxxuIGyYJ0dSY5T49MYJhPNUB1hZbS+qG8aVJhUhUmK5Eaor/J9bm+21jaJIQYXuEPaols5rjubDelDsFyz8sXpWOGPd6V4JiJKy2zx5ImQrl7kVFZ2DlGLVPWoQcstZ2uUJj4eHZX5stPTRm/4Ly4KIUc/swvd61717p53AbX0RQXj+PG6v/J1izSySuHND5sYKbQHsMNlVuS315oWET1OMG5Zz04XJzNKW0CWaUjRfjpZTeBWMzd5I1L0jLigh2jglxSDgq8HSzXKy3a5JIHCcxdTfcxEtgM/hLy9c0jtlkY29xDwsU5qPVGV5Qhm43yq6RtWEQyfg4ovddxrcEsqHTA9Hr1yRQDlRRLdANLo1KOsftr23jKTeylidSWhDfIIHZEXZ1NkJyWLjirsKf5f2HqsqvfNA4NaslKqOGrrygQmrzZMXaMdx9lCF9a2Y+CTtURAtdpB6+f+WVT223w9q8q4NdwIHzH56THh1un8B01hWHl2ANG0Q7ZERGNZElHs7QtAax6LmowyjoQtFqT0Ujouae7xF84JBYbkE0rS3/HkAFb4k3Mv5Xeue6PAvL+eQaJm0xa6XPR58FJTIl7r7fd5JZQhi5PsXGjq8jqoeNgPbOWNdHIzJvpmD+evIZZkSumY1bAuheqPkW9e/IMdmYFDKF6Y/hBK0Pyml4+LWDovDqjqwS5aEIfOwvhj0pbB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb85dc23-a993-4ce3-02ec-08d8cd801afc X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:36.6685 (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: ijMcnaZicrGWg7GAJoyR3So6BzzM8FcYr/eZAtaV+LrVqgOG1LJLCq1fWi6bQy9L+Uom5L1UOmFzEc3qfgcpHYm8NlIwJExpIEIetepgx1g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 | 44 ++++++++++++++++++++++++++++- drivers/target/target_core_iblock.h | 10 +++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 8ed93fd205c7..33c88eca090f 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,33 @@ 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_device *se_dev) +{ + struct iblock_dev *ib_dev = IBLOCK_DEV(se_dev); + struct iblock_dev_plug *ib_dev_plug; + + /* + * Each se_device has a per cpu work this can be run from. Wwe + * shouldn't have multiple threads on the same cpu calling this + * at the same time. + */ + ib_dev_plug = &ib_dev->ibd_plug[smp_processor_id()]; + 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 +374,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 +910,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 Wed Feb 10 04:55: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: 12079781 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.8 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 BD3D4C433E0 for ; Wed, 10 Feb 2021 04:57:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CD8764E0D for ; Wed, 10 Feb 2021 04:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230410AbhBJE5W (ORCPT ); Tue, 9 Feb 2021 23:57:22 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:43324 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230409AbhBJE42 (ORCPT ); Tue, 9 Feb 2021 23:56:28 -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 11A4sg3o004468; Wed, 10 Feb 2021 04:55:42 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=1iNoXyoC4xa0O0nQ251es2Dfg6INqaheeFO8Sm6kIQ8=; b=bNT4jF07aOLU+YCqTRyA/wDH94bJ60ceXt8GAJ2h+4CzR3HGB/M7XwzxGPvnqNXkeOa9 x4g5O+HvBKYXbGfDjLh7tGmaZIQLVr78X1rIhBaF5dDnuHJBOiqM5/LxYXJDvr5PINN+ S+rIZCUWxZPxfKhMwt8DVeSF/ru95budIYnx8/H90pO+6SUqmP42w/J4klp0jAmTcqDQ tf3zG6GuVzpkSxyiKxcD5JOAg7JghvMAej5NIGIiXhMDC2J7k9nBVOJ5iumnsLFQMCnj poAvBNOhAsrmspzCI0YNXnNfIFlKGZaBaIt4UWEOMtfshEWObrlPG1srx2oL2uypkhWy eA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36hgmaj0tu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:42 +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 11A4tRBC048727; Wed, 10 Feb 2021 04:55:42 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ejtQYhUFbjkvypVcJLzJ9VdTAv0qGwhAFA+lo7DwsrLywLt+AZX2PmQjnpI43s5p/4f/G7YvopWTOb7PkNzg8I6fJ6W9/u5+IXYBFF6rdfLeMkbr1d0yDR3dMr3hSbdQBUeFw1n1jHRt8jOXSG+ylEdYOGa1MH22A9YnN+aah2tmnZQmmgkzqvlwfFRT/wrsYGfryDYucQZRgS0aYP+g+q+YJ4iwm/JPWM/Q1XM3S+CARGZXsRwI8Uji6gw1TME/J9jBDVfa1FU13luJxSLygLBo80P6RHFQ+s7KR1thJbsqJaVthW239ma75pMmAHxTZjnNZ0pv4Vgkk/aP/oocPQ== 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=1iNoXyoC4xa0O0nQ251es2Dfg6INqaheeFO8Sm6kIQ8=; b=GjzLKfADH+SPzvpdoWFLizUV/SCNLB28KzChBZqhCJvSYfe8i9ZU3cal/OKN7/7tAAnxLnfFW0si9hBQIScDAtombAHUdeAk68PF5xOtUyJ6OEFTxOD6WBE1ccmuELoFPLhzDQ9nEdkCaX+bsNHBY0NHOirE88/vhXeqVuBvYVOSCYCxWNyKvl4Fe67sHhFYRkCf6K4kbkapCznQstSF2awlVvg+ZljmFZQ3tC/1qBBNFI+mZR8cn/rUhN7mt0T44VVeZD2Hr4Yl8bNpxtyOCEm9GzDRtTDiVpihYuv/e5pOVqEcbS5J5LaqOTQtJNklkl5+Y5tBv6UFugRDhcP/QQ== 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=1iNoXyoC4xa0O0nQ251es2Dfg6INqaheeFO8Sm6kIQ8=; b=iB7QTRhd5azrDRa1hrrPjQPTeDnjGj//8h21QYYvJtsLR8Nn82sQ6ey6nlBbnY3+uKLv2/qfLSlg3JP2In4jmzAXNVHo7bJHMpUT+uDVlyuRYsuBzi7PKdu70aXNmovINuo9zTXnkmey+cXPPBih2GUH/kGYr9gpWyLyXrMrR+8= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55: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.3825.030; Wed, 10 Feb 2021 04:55:37 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 10/13] target_core_user: add backend plug/unplug callouts Date: Tue, 9 Feb 2021 22:55:13 -0600 Message-Id: <20210210045516.11180-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b1638ef-88dd-4490-7db8-08d8cd801ba8 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eLBLDeUemB84DB1Cd1xr4Zd/eWC+GVwk99m5uGq6w5i1JJl33r1OYag9BqVwaFYEzEV+rNQz/rpzohn0H5VejwMwnhatD+Zm25YMk6zydBE6UxnmfopjET7BveWL1kPT5gnvInSfxav6KD/jSzCMa54QxZ/R+2cX079u1WaKjChZ2KK6Juktb+tfmte6c3VqXHN+QEAQcWJy+oJ/GGZymdB9CbgHVGhOkIOYrCVkA0kseZ1WF2JPi+KIB8QZzSS7dTO0jm5xTD/MMMGL0GqU53sqM4u+Kv0jI/gSofSJtmDGsix2Moth02sbvg5ssHFsHiABHt//BIv5USG6AZGS9gFcJkh/uc/YOlwwHqS0fadUHTnghOaZMVa243aJ8jlTWBefwm4zWFpYfwyUOunUUywsOFTVCxsWOAdcdX41MpFNhVonpe7P4/0wpBakFw/dRadsmUdONZTZGDhumA7NILD16VYbSwT/PzNE/LcrGFcLvHo+lCkV6+qOJgpIWp2uyTpsD2xVC6BfiFcGleaNTAIlbTejn+J9id+xyKHpaFwY235NdcvQm3yAC6lCZgz4jEzNEUxk+0anNDHcEMozJA== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Y2z0nExpvZf2WLXKwp7iEF7iTXsxaVCCqzCZJbcanmz/Lw7wlXefUXBsJTiHASNFSW/+3US8mSXESySmT42/G413uKZ+kkVSzz0Oa8RCMFDVZrBg2hG1J5xQjQj+jaTfZHdo4gOsSbTWvOM+Z696rav12xujWtGumJl98gAnU6BK/BXpwW4GlIS0pGR1VuMhGxgiF2hwy4uMOysp97F/YW9J/oWcEozEGEL0CEnTW5E6HHnGrPD962LxCi9k6whP9lQax8kbYttaceJ7MBjBJccidg3KGl149BtwYCr3NUgWHC4K3ch9RlTWmvxEEOEBKEWsuIFKApqmi7b5/1xZDLf3rverpk3of/f0Jm50p1XfRh8GbFv0jVKkPrumm28nTnuHVo8XB4ikY/i0ydYwE84FyBChXhYBKcnR3AgSFljGctG0L/0QLAZaS/0Itrxff+34JqswdP1J9sTClr6/CtR2CtZ6cJ1j7Oilury+y0kGgppoTLrJTZDftSJe4X6M8brbfLJqGTVmZpNA5ZtzSHVlTc7cvQJKgFA5oaadinvuPom3R/anTOqpVzyaSAruwVra+2Qkjhdx7a9FUOwa7u1kMhn97AFZ7YMXorpp/i/aVwd1Db6Nw18SF88N3sjiilYlhZ5o3Kb/bA0D1AdHTVGWB7f/pERDFLNcBVKoj+zSqDzoVJ8noELdlmkoo+sX1HDSKdbxlxIL+2SCpeewTmvYBWDPs4i5/4cIHjlPXsE/QGFzxmNB56kjGqhlLqtfQ3QfPk86w5tZvW/JcbTdVx5vpKrvQqfSeHF2flL+jHmWE60k/JN4zw7QObNRhU934vYYETOeIHhnigbgprsGXUThgxHFH+kq1e+jHJq7afv6+GM+8Sr/vUxnHdh78ryqBm2MivO8hExIKArpHPcztpJYd3tMnBbV2yRjbcQKEMdDpu3RDJ+S2Wgnap5gC10q4UXG2F6YT8TRNdGxBJgwn6CYsYgtaLa4GEAGM6dkRnLL7zgVjrKxY+XLhBWVR49oLJTARqmYBq7wJMlYGZw4dxmfh6BNS04pULtcK0NPxuPf6m0jhJERgRCka3JrQdcUSh8V5u5uCECoAp7pacuGnRUgg1iSVNOYnq1USmlKZLkLK7xhkQL3NKYL4giVeW4hI8BXYPN3qCRiNUvt5So8Cj9YqqDq6wGCONkZYbTaTHSukQglQHVFnIJkBLrYEDt4m/0EWeVDpR/3W/6o6mEn3/iFPbCozo4g1onggOawFYa/U80JQ/L4ourUZw5CNnlkd9rjZ96yAi4Ub9Q2Ppr9vD1oxTPbHGLDbFi1DGbHaC+mFj+vLApcYFUsMsplMI8K X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b1638ef-88dd-4490-7db8-08d8cd801ba8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:37.9058 (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: v8iqH6P9G4mrG+fJvCT/3YxNq3dMSzMIBY1Bp/SgK7T/LropwfjahpQYEPXYqSKsTWrGjZGtKrycnGTgg8q7LgqRArVSzP9QM9Y9Q38CpeA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 (nr_hw_queues=1 performs much better) and fio jobs (lower num jobs around 4) this patch can increase IOPs by only around 5-10% because we hit other issues like the big per tcmu device mutex. Signed-off-by: Mike Christie --- drivers/target/target_core_user.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index a5991df23581..a433bda56b89 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,25 @@ 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); + + clear_bit(TCM_DEV_BIT_PLUGGED, &udev->flags); + uio_event_notify(&udev->uio_info); +} + +static struct se_dev_plug *tcmu_plug_device(struct se_device *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 +1107,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 +2861,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 Wed Feb 10 04:55:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12079787 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.8 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 8DBD4C433E6 for ; Wed, 10 Feb 2021 04:57:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E29964E0D for ; Wed, 10 Feb 2021 04:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbhBJE52 (ORCPT ); Tue, 9 Feb 2021 23:57:28 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:55010 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbhBJE43 (ORCPT ); Tue, 9 Feb 2021 23:56:29 -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 11A4sviT034280; Wed, 10 Feb 2021 04:55:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=INTlTQgNJXzj1hRdzb0zN24QAK4cf1rfu3xQgu1jKmI=; b=pOXhIBE6GHSOJONlLrjiQ7Xuh1KasdHmjesuxFRYLOQikqiKaRK1rjOFc/+php1+eoO8 cHIhJFDJq39Q+W+hpneS8oMGg0Xb5cn1ftJAP1bU7BZ73ESMordnmYqmlQHkyThyYWEp yfZauxf5vk1rKIaPXl5UCyFg44SW4lnzg+JDF6gEJihR77xPV8RUsmICat3d1+mkzV7F mGqO5ULOrtHfIQIqLJp+gh+OKR3tXyTKRT0/sXfNWuP7Hitho4pKgMDTQNQ5EN2HAwUj DMMiL+IQV5yYeQkEiOmxJKFh780vSaCK0d5EGHfdmUb+4Eqf0v1bxt+dceNfBU6LiWzB Fg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 36hjhqswse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:43 +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 11A4tRBD048727; Wed, 10 Feb 2021 04:55:42 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B1QWbkDWQb6lshYeFZYJH/pF+4cb+s4yxE6PhYA37iusiobW/4Hihip4oYH19fyx3rogfU8LI0MmHilFGlkcGNgJ3uH4esDCfBQsxThKBPJJ72rnZnOdCQHx/Aa+AZBk6bW23KWm2gFWuWxlT7i1eoYBzhud5mBE3Idv2L7h3TnmO7Umpf2VmTurA5HH31JDsT2tnPldr+tU6kTppYA7fHNbQQ+GbrJPtKCotFxXr/QHwXIQsF73ka5JYu8ycq6KPYZtvDDqoFrrLALKOs0DZG0sdMTKstzMw1Dxi0qqRV/369kWwoWrgWSzQzf4a4e8eixWD4lLO81fDtUaNnpZWQ== 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=INTlTQgNJXzj1hRdzb0zN24QAK4cf1rfu3xQgu1jKmI=; b=hd6KCkbWqwTxopSA57dhqzBzauy6CfYXNxeZOwOAcg1WbDO+kj2NGkTkl3Ohya7ss7k25GJphGcBTRLw+FbOPWDXrZX4IKjC6SJNrVbci2ytH3zN2GuLFdRBjYZIIIFPYOIIvEAE/N/XDUOs+Ncp+4gyeuxxQ69hiSjEpdUUmp/qs9wvGS4Dv3j4BJe0q5YuLDRJ6A63wxAtIlHmNwfhiUJTN26HIGqomTh0NrItwEzTOfSAdeX+jArBMwdihHrblgT4MNMIarBlwMXQfKzEUvMyZihBSGgWSl2qRiLo4sdI687fx3xZDP80GOoB2RhAfnTjeaBib8vGVYBXIcUlfQ== 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=INTlTQgNJXzj1hRdzb0zN24QAK4cf1rfu3xQgu1jKmI=; b=nFhxDzfriAdvUIWkItsAGxvXroTxNQDggo0XcPiCAG0uJQm4yMmc89huHc9d2rq/w4kQgKTCSSw606pBux8WyEKuXbhwcSFeZuRI7lQ8jRsM3Si5GLq7fyrBA0rwqljIdXnD8XCprPbi+HUhfO392Kx9qck2O0Q9dfriNSwUhQc= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55:39 +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.3825.030; Wed, 10 Feb 2021 04:55:39 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 11/13] target: replace work per cmd in completion path Date: Tue, 9 Feb 2021 22:55:14 -0600 Message-Id: <20210210045516.11180-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aae5134f-afe0-42d7-c2d4-08d8cd801c6c X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bl6AG5HMM8F4iygqo1Ww6ucbEcwwfaG+BV87Qy5DMG9Bf4Iqgpf/OLcHdZrwdnaFnHUW/NYfKsIn0KKPd1dMcW0b5l9zpttTq4SrbRME7jtUPJrMhGVGgMBzuqbcMvxRNzAJ8+upsn8G4idcoNT37LcEVWAF3+LWtz3sSR/o3SU4fymkHhahVMdW1hBAqAIy8gSZL61LL9KlRxyCYHjgKJmhpsmW4UGFL8tIJV8ZO/gbCj1PvIcdaSvloXQJd66RiH3EwSx54ps6qR+xBKoJNeuUN+bAU883ymafGiUhlbXI/mTUrdRGdDh9Mb9g5Qjny7j3oI6vHoNgMZq5SiLCB38tSpKoMV+zSN+OANRBBG76/DRSIEsKBAx9fiKDFoX1PMMR9EpK6sKpAXP8+nu4UAh8WmNDDxIU0D00f1z7NAc6yuawyJJnwebUcgLnco6rZ2T4lQ6O7wXQl+aGXkWtpv/tXK/q7SfJEu24cXXjKtaLzqadhZTg3LWripDYyHx8cEBEFt8lNm+RCqE8UdtzUBG3Fu/G3DSa0t1MFHjzn1CcqjQlzzEmkbFnANQkwa0ilxRHOwyzB0XuSQHNCMnuTQ== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6tnSTyq1gankUy/r3XS8CzrhqUJzbqpNapKuCg3rEhcBChx0GOipRUeycosaQLzYmvjqjlnr8/rbdzrKDIFUy2+3MACgWv+QfLFjbLJTXF4cT2LN6+NgboAwEHcjDFhW3IkPmrPAPV42y6XtdCeQQ6S7Nla1+leW5wwPpzsnDzqFxei0eytJITwmLtHyUqhoNSUSwBonvdDsYCBW+2tz2+/Gwj87zCe1ym0y2c0BNxIN9jgqX+72FLdT1rivmGMMuoR1RJoTrUTXjhV9QfagVmfa5zlqC+hOXaHKd6iQhOysswWvYe2bW+qwWY6o/FRMIMjps5dG8mN+kPHCDQTg6o1Iiv5aeCqUUNGUbv1tcBGQeRXKHvkk3yMvsm+5CzwHSjakBVu+ap/n6RA93+HbVcd5evyDMiqOjN316LpdqOcQD2NIp3gCAYPK+fLPuLoxIes0TBuuum5RaFvgT5IapxhSvlQfsxpFFrkOkFUbFN8WGLcooZmIKKuxxT2dK9X9Dx6VDWfN4Al1FsQrIqo9lAYL2A8ocq1+1RnYimIxY1YJaThjJDrLZUnlUFsEWfSImDN5FWKRCnSqwhxBuRelx4lJ+Bxo6dxXeIjvfUdi9bWGhtbdBrv1WSSsgmUQhMa1RA1ljE0cz5VbFFQBVVmvrgECmm4gZBxR//bzKmBBcaeGbdnEAPmReKuacnQJvWuFrXuOrRbS9oMvgKtis7JpqsVpqDYgHj6ENd4cIL9Y1dEBqrnOG8zMEokMCNftRmWI8kF0HV9RbXc7hRHnI3R2CF2XwBmDhgw7wSZ/zHYmJkTg8yb5rPNDlg31F3EmzPejd3OjZG0aQt8LjU7f6Hul+cAPWewq2aaZAXEjCot8ZHLw43sfKFpT6msvOOPdZM9lHRPguf9/4jQFa4NqvIGNPmxXT9wTAtRTdNa/zzpv5WA9cp/am/TOgWSWG/OItUnwl2xHrGbh8woIwTicz2wH/+Af1AZh5p3IAFG2KaG/NVAHZbiWhvDR5zIWbFbqhdqPoWNSPOuJLJpp3BxnPOGZrpOqVNVBohBHgHAr9klKeKsWwYP0x9n9Efynn+VzZRBaGdgmW/78gRAn+UVd9PG6Y6efBcrs2F1rUjkJH4e0IKVpnuV/RGiNn+9VenXmgHp+xsY8mtY5NxRkr3A/SlBcbcK9lcZ8GgiGUUQMrQ2ibqq+8GIzinTdHGYUtJRLw8m8BSXFNvkyGMHyf23E1f26kmIWyx5XrMU/x83/xZwiuV7LBMxSI74PPx3VXXrpza3AQZE1BwOuaC3pb1wPfhlW3R4PmBrqv65spQFqpNWEVEZZoWYH/TeaqVwI2ckvHQfR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aae5134f-afe0-42d7-c2d4-08d8cd801c6c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:39.1421 (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: TAxdmQq60TjP+2cha6gypClyTG4uL+xjZhvxpzxb8vXVd9InRNqXpK9M9UTO4vratAoqorpoeR26rVlVHO5dyOs5aloZzpoN6jLLhD2XILo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 per cpu list. Combined with the first patches this allows tcm loop on top of 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_device.c | 3 + drivers/target/target_core_internal.h | 1 + drivers/target/target_core_transport.c | 103 ++++++++++++++----------- include/target/target_core_base.h | 1 + 4 files changed, 65 insertions(+), 43 deletions(-) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 74d3a4896588..eaa2323843c0 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -743,6 +743,9 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) init_llist_head(&q->sq.cmd_list); INIT_WORK(&q->sq.work, target_queued_submit_work); + + init_llist_head(&q->cq.cmd_list); + INIT_WORK(&q->cq.work, target_queued_compl_work); } dev->se_hba = hba; diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 56f841fd7f04..e54d05ae8dfd 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -154,6 +154,7 @@ bool target_check_wce(struct se_device *dev); bool target_check_fua(struct se_device *dev); void __target_execute_cmd(struct se_cmd *, bool); void target_queued_submit_work(struct work_struct *work); +void target_queued_compl_work(struct work_struct *work); /* target_core_stat.c */ void target_stat_setup_dev_default_groups(struct se_device *); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c4bc012fc215..039016ab7a77 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -55,7 +55,6 @@ 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); int init_se_kmem_caches(void) { @@ -732,14 +731,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 @@ -827,11 +818,20 @@ 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) +static void target_queue_cmd_work(struct se_cmd_queue *q, struct se_cmd *se_cmd, + int cpu, struct workqueue_struct *wq) { - struct se_cmd *cmd = container_of(work, struct se_cmd, work); + llist_add(&se_cmd->se_cmd_list, &q->cmd_list); + queue_work_on(cpu, wq, &q->work); +} - target_handle_abort(cmd); +static void target_queue_cmd_compl(struct se_cmd *se_cmd) +{ + struct se_device *se_dev = se_cmd->se_dev; + int cpu = se_cmd->cpuid; + + target_queue_cmd_work(&se_dev->queues[cpu].cq, se_cmd, cpu, + target_completion_wq); } static bool target_cmd_interrupted(struct se_cmd *cmd) @@ -841,8 +841,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) @@ -857,7 +857,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)) @@ -866,25 +865,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); @@ -1894,13 +1879,6 @@ void target_queued_submit_work(struct work_struct *work) target_unplug_device(se_plug); } -static void target_queue_cmd_work(struct se_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 the cmd to run on the LIO workqueue * @se_cmd: command descriptor to submit @@ -1955,7 +1933,8 @@ target_queue_cmd_submit(struct se_cmd *se_cmd, struct se_session *se_sess, cpu = se_cmd->cpuid; se_dev = se_cmd->se_dev; - target_queue_cmd_work(&se_dev->queues[cpu].sq, se_cmd, cpu); + target_queue_cmd_work(&se_dev->queues[cpu].sq, se_cmd, cpu, + target_submission_wq); return 0; } EXPORT_SYMBOL_GPL(target_queue_cmd_submit); @@ -2058,8 +2037,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; } @@ -2484,10 +2462,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 @@ -2629,6 +2629,23 @@ static void target_complete_ok_work(struct work_struct *work) transport_handle_queue_full(cmd, cmd->se_dev, ret, false); } +void target_queued_compl_work(struct work_struct *work) +{ + struct se_cmd_queue *cq = container_of(work, struct se_cmd_queue, + work); + struct se_cmd *se_cmd, *next_cmd; + struct llist_node *cmd_list; + + cmd_list = llist_del_all(&cq->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) + 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 b8e0a3250bd0..f2ba7de59da7 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -777,6 +777,7 @@ struct se_device_queue { struct list_head state_list; spinlock_t lock; struct se_cmd_queue sq; + struct se_cmd_queue cq; }; struct se_device { From patchwork Wed Feb 10 04:55:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12079789 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.8 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 A886BC433DB for ; Wed, 10 Feb 2021 04:57:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CA7764E45 for ; Wed, 10 Feb 2021 04:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbhBJE5b (ORCPT ); Tue, 9 Feb 2021 23:57:31 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39222 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230417AbhBJE43 (ORCPT ); Tue, 9 Feb 2021 23:56:29 -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 11A4riVw025873; Wed, 10 Feb 2021 04:55:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=aCMC5bXAPAL1eMwDWGN98u+GpghLdGNZe/Em9lHFEQQ=; b=vvezbDNyvt5OnaijcamUjq6eeyQfDzX83RqokFNZ9A84hhP2hyrJrMlB5U+Jrmmz9uZj E0vglyAPekBWtdm8GSR9+znfzohiik/2meCE5eLBBA0gfuRtxaw6ZULpi3wpMgE8kbgT JQEsveoyPuOLo6+v9EGGOG/jmQr7txEm4oiaihr0FIsWFO7h/FRXTM/EmK/+LU/FVZiV zQraMgTtwtDXXJOKGvXGFTGD0v7Rzd9vsyVQsgyMKZ30gTrbfFitvYG0Pz2VrEfpHQhN 3AjaE2udGZAuB+N6s8jth4zxLEhjKgADw5nl4JCmVGF3nlNFpkFC70H+HRnWeEuRGNVo mQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 36hkrn1uan-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:44 +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 11A4tRBE048727; Wed, 10 Feb 2021 04:55:43 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-13 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z94r4fdYvup7BozDBJjDT2f631+1zGlpzO4N640ouybfjLJkfOzyLUEg11zL/4C2syDHNYWbCcP7LzOOgB/uHvwJeIL+ZrAQSix/PtajNFDYurzi448nl1vqXVzl3nqydfImc8Qy5AJX1RqSkMpq9f55dDBVa60wkQnjQa4sLR5A4BAPJFxtjxd53Z8LmuLp+O0H6ciMAAy6PzarNcAskG0EdLX3RfA2zO+OGF8JZ3k2/GzhV185UeavSk+0wgh9mFA3zd1aIHpzJ9lxTWE81GpIQXq0yXF0TgN3KlucmePBKd6goIj7GlaaOc+muxD5ljLybO7Qzx6fLb0N1iq/8g== 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=aCMC5bXAPAL1eMwDWGN98u+GpghLdGNZe/Em9lHFEQQ=; b=KgSgcwp/jOj3/jq9cEZ7n0RcWtLWK3IsPUppN7PP0mJ4aNuzY2oL0/PebhDdG4Sw5MgXXZGeuzOrGWlNCaLnpQvn566SJKdf49jRpVajS0aUQ2LoTL0sYL73NHW9G2NvBs/2sgw8KzvPlj0cUAJxGzVL8jA7fYYdMmdLdErEpc8wX34dSZ33I1LlAYWTdjHi4xXy6n4caqTnT5YrxO8vNNjTs0Ms/9jpU/PE3+Pzf4gSKKbd0ZJm57f2gTypy/+0v3OjQlQ3LOgIzffmbeiRXa4vdKWlcui0bSYWdoQRNZnZpm4KVrtbfaiOU2Uttj/QFOsZcctLGmxIhqP7hRCRcA== 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=aCMC5bXAPAL1eMwDWGN98u+GpghLdGNZe/Em9lHFEQQ=; b=k1sE5Vko3ijjbmU3QhL8R88TqgATs9eQwPlC0rKyLYkwyMusrSCjppeNI66Hys54jogo+tqmW1jGYXfkmabB16ZgV+joL+ijWEDbnwEnc01aJt9WsJDpiOQI6Gi4A74slIstLJokVYXs3PReV/XsAZoAqR18P6AP8ODmkkNBwVw= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55:40 +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.3825.030; Wed, 10 Feb 2021 04:55:40 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 12/13] target, vhost-scsi: don't switch cpus on completion Date: Tue, 9 Feb 2021 22:55:15 -0600 Message-Id: <20210210045516.11180-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a169ec4d-8c84-4e97-e601-08d8cd801d25 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: SLWljq4WA8x8BsCl0vP9sC8DwB9TJznbMQuNWZZiAP9eaqA7Ugi9XsMifaliWJWnP/gtNEONUEkV3LE1FwgFa4pXfQ41AVlWX1igFmWpTse5I2wthsQ2VjCQNpgmjHnm/McrSmWNa7zMmlgj9lbbM8lcABRqfcC2AMk6lZRdnQld0PCjchnkQeGjh1DADMslA6uIBSTdaM2XuL67emlwiSop3D6BSbvFLNaaNCmRAna2+pZU9JMbznx/EfSCb2dd7g/cLFDLSTozQlIMCj4X/FBteP8Glxa5oyWaoeH4F4WA/8C22Lb6TWR1AKYGh23bwCGN6jM2BG91YOLAfkyA8trOBkswj3dMlx6BHY1zX+Gn5DY6pxcmgKKgGe15j7z75JJmv2o5cT+xwW3dFnz4T0TUwQiRe3/BeurO87HQd9c+HOBIQgAMO3PJivCk+w0bv7K7rXcIOf0+pQawnYIszFAMNkAdR7tO6n+32s00JNP7DchJDNTKa4fbsDTslwRr2sVCkYPHgBsF1GJ1ddnSl6sNNgJ88KDXh6cIBDSLxXqBHNB3837WrDDZvIXDE1oYXLYTDo9huKsYDNPR5BZ84w== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0kfYrHHNVkjrU8jBkKpiUK1mGoBdiuDTe8GRGRqDbc1bRCNYgXwxuvypvYewWjTfkk0tkjcsH49EmDQgptB/bPw1AvOslPpP6heVTU9BSyJGMvQ/rZknEDSyFBjsusY3Ey1IelnUWnPQ+DVMzG1MTxbETfyI7vFDIXeXICqlsQ5UjWtTp9Pca/8fV2KH5TWTfM3KQgpWe3yUXKEfrYl52nCBhFnQe3zLVKXhCFpkVmReDsWdZIE+WDkvtZKSZR4P3Z0MHbjSnx1mGPcNgqd09UxI2Mi2XS3x0WyCp2lZgionVHfgrjkpayhfq9TFBqn67UF0SqXTKKeLP1unb95QV/ouHyDtIpUfhWQZKUFudScHc3BAJF6WBNOw21bf7GX/srq+h3D+HqIJWQYcBI1Q+Pj5mKG5kDYa1OQZ+Eg1AoNK5Oq1aQsHWflnyPlfEnhAQJqHH1YSB/C2ROZWU8OY9P5x6xZ/9FGOXJYX55mVuMEr2MdonVv6lGBMLsbWbSE5Cpa6dq7atZ2t9/W/lUAbZsqpbuGdY9z6w/qBH6hTi+s0+em4F7IZPnU4ZEWIioofs7OPVzVqf4fqHjOACuhxoyVYT8zDnTPQ9nqujpx5gLqXPNzsWpC/OYC2sUo2kMqnuJgUfphDdKsb7nu21v06GaNCnjSEPcC3ZiO7L7kJrNvDMKkcXNx2i89rLDted3+6+kc2lXbQfp3Exi4tiBMXrvD95qj6xG74N50ImicNeM319ejuYAlNRBFH2pnfK4AUVbgdjeEWYzAbCU3d79IDbSf23hcUFw8eNOVENZV4MdGVrxxUL+BjC7T/Lt0z4H9wfIQbNXN+wyZt5yxLR3SNWgc8B4MSjjs9Pn6PB6NH9/hzXrKU8dxlsarlUIquCfBRTf4qqJ0UFfLtdYissjkg8WVvCna5WjLNrtAz5OMxpdt2+qiaQt5VKoLmhiStLDSwyujAfHfSWd0Q1E0d3GIUq6mXpTKbymPCvWPWlkIOlipgEo5xNqLQGEuciIg9CQN6CHoGok+EPCcC6TDEg45peFr/seG7VHIq4eu0Gl0x9NNicE5l/+q6fJ6TerGI8Yq065iUAvbtaquhm472926Ta2Islqa8dS2A+FtN3KdgtjqZZiB31ac3nXB8Xc54RS4NPSGWoSOx7eLtx7W8m/hNIc/YVxCDlIOXix8WFZohfnqnYpFsq8i7g4lewF73Ie6WgaxKNbmiflyRFRitGAJ0qzyqqLtmVI79zuLuU6/hUVgOPnF02Hv5xjEm8teETCiIWnBcjU0pXJK8tTWuGAbWdhzFBXx6XAyKYK2XpDms/MBG3N8lNkXr6/eClgwDWxHw X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a169ec4d-8c84-4e97-e601-08d8cd801d25 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:40.2935 (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: 90MFq09WbKlv5mBvCbPg/o8WVlZXaDW1fJx3zfdosNwTXgyMvlrNop1lYc3Y2W5CMa4tKV3y1YeMd/X6kU4dg4TDkXULF7VmrYPJzH6vIXo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 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 Reviewed-by: Stefan Hajnoczi Acked-by: Michael S. Tsirkin --- 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 039016ab7a77..0f5f8a2d101a 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -828,7 +828,12 @@ static void target_queue_cmd_work(struct se_cmd_queue *q, struct se_cmd *se_cmd, static void target_queue_cmd_compl(struct se_cmd *se_cmd) { struct se_device *se_dev = se_cmd->se_dev; - 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_dev->queues[cpu].cq, se_cmd, cpu, target_completion_wq); @@ -1609,6 +1614,9 @@ target_submit_prep(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 99909c6f3960..b9addd5fdd28 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -803,7 +803,8 @@ static void vhost_scsi_target_queue_cmd(struct vhost_scsi_cmd *cmd) &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 f2ba7de59da7..bb4ac7e6f560 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_IGNORE_CPUID_COMPL = (1 << 19) }; /* @@ -195,6 +196,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 */ From patchwork Wed Feb 10 04:55:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 12079791 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.8 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 579BCC433DB for ; Wed, 10 Feb 2021 04:58:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FA2564E42 for ; Wed, 10 Feb 2021 04:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbhBJE56 (ORCPT ); Tue, 9 Feb 2021 23:57:58 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:43346 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbhBJE4b (ORCPT ); Tue, 9 Feb 2021 23:56:31 -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 11A4tiSi005006; Wed, 10 Feb 2021 04:55:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=nE7X6Y2WJE8jMeetfbralCqoYoDOSmH6oPGYGkLKl6o=; b=jsqm693wILx/mwIxJVihZscliIIwsi/zGUMkMnUoSYL1Op/JaVC8qs07thOh+v0TG/nq po9BGJrTWMaZlWeZYuAJvt/TBZ3z83JoAcngayZEOFnIHc1LFKQ2xxj/UDXO7N23zqtV UK6ptpBcNBQ1qHLYbVhoVgV6vFMejhNVdK0L5RXOX51PacWiDT3K9HwPuLXIilz59Dhc mci/pS/ZQccna0zSi/AcBv5LXhMqlfT0Hy2aWS/SzyVpKVTomkZHeUyctov3dWZQYEFE vlk7ilDyux9RRDEhJXCrqJpwJQUSpVfHG3wHIyEZ4Y4Am67oW/AkQKDrv0fH+a4u3sf4 OQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36hgmaj0tw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:44 +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 11A4tRBF048727; Wed, 10 Feb 2021 04:55:44 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2174.outbound.protection.outlook.com [104.47.73.174]) by aserp3020.oracle.com with ESMTP id 36j5126403-14 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 04:55:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XDlDDhGI8z7EqjBda3/BX0bIkf4nJ73Y7i/oPjcFDE5ufgKE4ehb08pfmLQoXNS9SD04PaIIuFh2g/0MTrdK2WveBU7OMEZh1wGHtEA1qXCuJR9kqx2l1VbrJmjc2AxlHvulOigjtees0m22TyUiaK8FavawpUOYqQ6RyVKMRmtf3BlfV0YoDsH74VotuKBA2P1O5oRkJCRtQYKEufnF8bep4UIfXrvduTf3vAXnlruZnQUnJAv3N/RR6Bli8XIxS5eUSeNMIZ9dqCbe8L9A92lzErfpk1eNaYckBXvW2yKLVCRCEYP2tJpGOAr/4s20L8RTS/BrETU3wPmUQW6oSQ== 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=nE7X6Y2WJE8jMeetfbralCqoYoDOSmH6oPGYGkLKl6o=; b=jTGb2bfBLj2SPW63yX/+7eQeBZCke4UvUXOVy0n2ZqQMYWjvdAeC4Y2GQQYWxueoRr3WzMYkDEyoStmVp8/Gm98nsCYYSwOLsvv/wuiINQNWFFYxeowdW7v4Xlot8RS53RSJayt+vvE8nmrZ6yNOl61pHGbZDZegv5hWxU9QqB90EDT/JThM3y6v49trbWCy1y8r9ySMUIfurJZllnnh3iQOyjI5W+8Wl0XnugZsr/S2+9hu6nSyLAlQimI7IM6pKqGj4zdtYtJjmw/ADnM2XVbkPpe8XdfquKWkb25t1JGascq7xOKL61M3m1QgntVGdEQo2Dqb6NPvMPK1k7dcTg== 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=nE7X6Y2WJE8jMeetfbralCqoYoDOSmH6oPGYGkLKl6o=; b=g1Sj5vwGxafp4KxQ1uc13axf+fyLImZkIAfQxAWz0XSPGIVIbHfieyb4A7VHFORg42kc26/aA+A3MFGsSGlLCIee/Om0PNQRHLbOnWMN2sOkSAO6RFYYaKYrChSpvlsD7j8yudN67M6IJjy9Knbad40xk3QtV2S679bxhmJ/v3U= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3573.namprd10.prod.outlook.com (2603:10b6:a03:11e::32) by BYAPR10MB3366.namprd10.prod.outlook.com (2603:10b6:a03:14f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17; Wed, 10 Feb 2021 04:55:41 +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.3825.030; Wed, 10 Feb 2021 04:55:41 +0000 From: Mike Christie To: bostroesser@gmail.com, Chaitanya.Kulkarni@wdc.com, loberman@redhat.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, mst@redhat.com, stefanha@redhat.com Cc: Mike Christie Subject: [PATCH 13/13] target: flush submission work during TMR processing Date: Tue, 9 Feb 2021 22:55:16 -0600 Message-Id: <20210210045516.11180-14-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210045516.11180-1-michael.christie@oracle.com> References: <20210210045516.11180-1-michael.christie@oracle.com> X-Originating-IP: [73.88.28.6] X-ClientProxiedBy: CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) 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 CH2PR10CA0029.namprd10.prod.outlook.com (2603:10b6:610:4c::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Wed, 10 Feb 2021 04:55:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91390144-b315-4acb-87ce-08d8cd801dd2 X-MS-TrafficTypeDiagnostic: BYAPR10MB3366: 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: ReiFZrDdreP93MrewtF6COq6JvT65sk4dr46ySLPepyt5igI/cDOJk7DviqFcIjGI4CPF2zvRi2krRF2HMwn9+jHpmXLFSoSrq5oMqQJo8rECnSL+8wRJ0VOBI9mNzm9RsrNoP+qsMhvm5dEK/f03xt8XGtx0T4I+dOOLNk31X6NUZeqSX43PLe0GIB/IzT9QhHoKtt9lXpIhL6e0G4K9RK1KCXPGnN/lXTcSe5rgKFi87feUFwu6wI8qVVGmlNqpaSK3Aym3jt7gXXpHXCaxohrCrte9kS4Edx05p6cVOgBeLnnespbAmxeXp95PP53P4ub+GBQ0Jca9xQtHcPSPPibqVOGXkzHNOshVBT60HzSnd8eDkIk4bJPU9yjRgLgfRi4R8VZSaPQfrdqR+BuD8ixw74SUca0fGSv0BNXxtUNP8q2VHxw6q1vKXCh/ZI8IXVvNQl/Sufx89p8tROCjA2FO9Scq1Cdan98v8Yd59b/StpV2cI+FhLSprDrUxRbzmParQMWA/p4+tE7gQw5IDIiib3S2Xrm+PKAv0xCrmO+dt9jF7ckiIsS6WrFHHq5mZGHfsGylBpt0LLPZ7wKFg== 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:(366004)(396003)(136003)(376002)(346002)(39860400002)(86362001)(26005)(5660300002)(478600001)(52116002)(1076003)(2616005)(956004)(186003)(16526019)(36756003)(6512007)(8936002)(6486002)(316002)(66946007)(66556008)(66476007)(6506007)(6666004)(4326008)(8676002)(2906002)(107886003)(69590400011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: UWXo4M/W08wGU618OpNWLN6vOZ8CsZ+BRSFKoODJYpfa42Ix/SjXuqQW3ilaLtD4xb+AszeXohHsOElA0rKbIUEcsHzsAhcmZ6FFg5ZwkmnqvzFbWS6eyiH92XBoErshvoPuVxF6cUtQQzLPqGXVr2tfGDncG/33asvWCeAcGiI8qliLvD9EYHOPZ5XMtgdyu1JDoNWG2KjYTT6Uf4YbBsD4wCzLgnBgvsfy/3GItaXJiyaG1kPFy67WHS26Wow1eqUtXq/d+8WeXbrFEtUVDen8PmclbTEWLiViQeg4Sq8FhkL+4dY4sXDh7Gz344EKbdyq7q6MyF+O1i2FS9xhk0oTZn4m4S3un6pRBQHfxispl0g/Lr3Vl37q0I2MOWvoIKi+KDmr34AZRNW70KeGoPhJjZ0y3+31uLLUyT+/rYpjIsXgzkbrcPc8M/u/EjMyOtn/ZJCkyAhapzSb/lV/w95XA3eIjJUCBseReN8FVte8UvSjGU6tX5IHBlMI2bSxcUS8vhC9fsnFylwIrWQMkpAA//cUnfYAHUoldS6PkZIGiIL1twdSy9P1eLETsVsV3JeuJrSmHnhPUQltApS8Ww5Mxo+8JdEDJ1w2YAZa0bA9wI86Q1HNmOoM7cuiBymWJlG31sBR8CIjhxbMXQrjwBUvh+K2epFGQ/koDyaAJ4tR7bnZhzXvnFrrMAXJ8Lsvjq5OErEwofpXUFgHN5TX5PTbVjavEhrG7lnF+fuU1F+DGmYewokFv58UfH1c6yiB36/c8q50fDkO5X7ILQY+Hac5LTt1vFXxJQCKXROhJDRM6qU8CoP4oSprDP9VvL8J5My8oNzFNWngLbxGTIKR3xEuc5mzEMxxznXJNJNv0WAZNGUs/0XdaO2tQ5qwyeJTdTgtqrpX7L7GqC0GBJRK/C4n4iBR2cSMZ5gR4Kk0lM7yqHSlpjemzPtI+lJMJMNvwB9/Dre5o47J6dE+qhMh+Y0TRQk+UjygaeD35FDHtjggSZa6E4Y68BGHpARnx48/LACVpelsrWXLULGSVhcTGCuZCzOPnrS2PI4rFGrEZoyziVn8bGDCOKgSQD1bbMXg6zqiW0TcL8HndftZdvO4Lt+EicWi1NLZpo128ugFvuBwlvC8B3R6Q3abcKg9r3r/RHNcASHTpE9Hxeouo0enopMiDPiJUepwyvoozG3TAPyKm5yoGvWV0lpw+pREWl5OzZiwH++Vd6ce2jadKunN0OO1sZ/lafKIzBpw+QH8A4uMZp2160xNyje2+hUWz7CxPdQHhm972+AaErXGZi0gLnCVSfwdr/+zJQpYT8OYvFzPc1WlwsLjrsR8iBj0uKD8 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91390144-b315-4acb-87ce-08d8cd801dd2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3573.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2021 04:55:41.4938 (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: GK9dBtt23/1eXEO8k3Odq6qaHMMGtMaIAUqxwC27uirSbbxX6oBaSwySDCRP3OJjAOnweYf6NUwOE+P3/Qhocma/B/Fz3lEOYGOd/sA5z4o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3366 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9890 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100048 Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org If a cmd is on the submission workqueue then the TMR code will miss it, and end up returning task not found or success for lun resets. The fabric driver might then tell the initiator that the running cmds have been handled when they are about to run. This adds a flush when we are processing TMRs to make sure queued cmds do not run after returning the TMR response. Signed-off-by: Mike Christie --- drivers/target/target_core_tmr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 7347285471fa..e7fcbc09f9db 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -124,6 +124,8 @@ void core_tmr_abort_task( int i; for (i = 0; i < dev->queue_cnt; i++) { + flush_work(&dev->queues[i].sq.work); + spin_lock_irqsave(&dev->queues[i].lock, flags); list_for_each_entry_safe(se_cmd, next, &dev->queues[i].state_list, state_list) { @@ -302,6 +304,8 @@ static void core_tmr_drain_state_list( * in the Control Mode Page. */ for (i = 0; i < dev->queue_cnt; i++) { + flush_work(&dev->queues[i].sq.work); + spin_lock_irqsave(&dev->queues[i].lock, flags); list_for_each_entry_safe(cmd, next, &dev->queues[i].state_list, state_list) {