From patchwork Wed Oct 5 03:16:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7270FC433FE for ; Wed, 5 Oct 2022 03:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbiJEDRd (ORCPT ); Tue, 4 Oct 2022 23:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiJEDR0 (ORCPT ); Tue, 4 Oct 2022 23:17:26 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF7CA70E5E; Tue, 4 Oct 2022 20:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z2/DZ9Qci7JdUF5+sGUEY3nRaDbNsWDyaJDWW7hECVa6NR4mpTepblCfx7y86Qs0tV6Z0xeaQRTfd7JWguJDf+Q6dt1AEHCuhvwqHTRFj5d03kRe+la65PH80C0fzE2n21Q2aT+OlA/+Kdke8QSsgwqbAfdhHPZ6q4frYyCV4/6AIJzvy6dELmacOwSclqxVHSBY/jj7wNrGrqPR1VOPtRF15zqOmqJr9JCkwWFLZQ9l0LPO9BOEtCzjXPV9rTdNAcuN0noVBreo3TqRqKzN4MebAEH22TrqnyPpu22xQoG11iYU22pE7XWpbbwbh5BUgUIe4XvEhiZt+3e5KAwjTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nyxT5L72cfmTiZ0Lz0Oo9N+HKWGDddaVBSnCu0PbFxc=; b=YmRQa3pg2B1HFIxGwbFNjSwcvwmwMCMOXWkFdcbEjYrzLSpcoNJCBABGL8/TyRvu71MPxwjUN6U6WO3+wx8LzSdYCHkuk9KN9MJ1UPA8maQMC39vgo0RX00TMWzq9tFbKeq9iGqMmavD4PYwOu8g4/PhB1SA/bxOonG8VxOoBx9TxgJO4xhmlSS34lNB2JHMmuSyBWggSqh9VNsxBy6MY3nSZMIvVGdffOlckc4J2XtvetChCwjKO4Lp/AacuLKIcmyA0zWI8LJjxBphFWJo9PYeoNpgm9afX0lGav1ttN0sitk7h8lfq0PuNmboZTrymlq+jWA7ginPi7y1nZZRUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nyxT5L72cfmTiZ0Lz0Oo9N+HKWGDddaVBSnCu0PbFxc=; b=k2ZILX/8Nk3WzakKhT9nezV8jzoGOVAw8Cyr53G9VMro3wzM/GiyB6JaJBF9tU/vtfGlpob+/QM/PhwlDeEYTVPhoJlnsnfs1J+Vyxt5lkdfbVU1l4MMLYftm8f5sg6+CKpt8XBzU8wryxmew2DPMJnV7sLo6Cds7WyERHXDtl94xzh6uCxa0wYdO3Qi7BfPDmUWYmVo4j4lZFumAUTn9gwti0ODO0Pknt2qzYVtQKZgICc62UrrAZeKpOW7oXCXT0fi644o5GyLgYcWa3SOqIfpkR6dQ3bx4PTtstRBpfnh4KDpck8Rd0fYHFPDqRk+MMkiONk8IlQyIfEAUiEeoQ== Received: from DM6PR08CA0011.namprd08.prod.outlook.com (2603:10b6:5:80::24) by MN0PR12MB6002.namprd12.prod.outlook.com (2603:10b6:208:37e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31; Wed, 5 Oct 2022 03:17:23 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::df) by DM6PR08CA0011.outlook.office365.com (2603:10b6:5:80::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Wed, 5 Oct 2022 03:17:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 03:17:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 20:17:21 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 20:17:21 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH 1/6] null_blk: allow write zeores on non-membacked Date: Tue, 4 Oct 2022 20:16:56 -0700 Message-ID: <20221005031701.79077-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005031701.79077-1-kch@nvidia.com> References: <20221005031701.79077-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT013:EE_|MN0PR12MB6002:EE_ X-MS-Office365-Filtering-Correlation-Id: 3897439f-54ed-47e1-f6c0-08daa6801ebd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7jjNdR7nGi2mnYwRf4NkduSv3Oq/ei/sU+gstEZvdCZMQuS7pECUVB7dEWW2eU4RHSj6jCrYsCZ6SUv0q1hBkuIRScmHMzwSn49XHkclKUCugxKAb5WtcFUUQkWEci8wk9jBZBfIfiaD7i8lqwg0eCuTdprAjdICvv9tWVg6MufEsFFcQk8Z4ywZbgyJ4Hkh/64OIAKsyTXK46UVz1yLMXTL4zZL9CTyFYr3B6EPAF1uVv8YoQZmW32ES9Arya0ZK+KGpHc1RQrEV1DZKxg2D8vbxDyPqFOqiheF+XEqwD3gB03M5xlQasbO68eXEGOTfbaFzaKX1hUp9DXAdLvP+zwxga6Hi8CBnMkYbouEWbvG/0pml0KUsNckYvHTHm58U9W7YupOlGfheaLrHc7gpZahqScLyDZBpunGjL2dWH7f14Q67iD2MfdegBM8c0toKeAfK00EB06L6AWMYT40dmU/9Wjf4rVnz493wBxxK2LKcB5IvFkipjsZdjq1wME+BVSTlq+2kpI6+VLJhq45f57hEZREpkaZIUzmnmuDWoSIbdjsr4LdLkN5frQju5YeP1+kX3zZdQ6ZmR/uQn0qUK4F8wSLrK1B00cfnhtf3H/UA0XXbDvicq2DAim0Eblxvs8ZKVVaEkhdIg5Ed6qQvchwbMqWpdvD4M9hBENk6U99mL47etxLPeRnXcdzVESCMMuKz+IvNu36meMwkoxg6p5z8tNLVnX5O6L56JpTBD/vpt7KQsCn6QDZm10PcZjA3MigkxtSBwsdpFZmWv/zsg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(346002)(376002)(396003)(451199015)(36840700001)(46966006)(40470700004)(1076003)(186003)(2616005)(16526019)(82310400005)(2906002)(356005)(316002)(70206006)(6666004)(40460700003)(54906003)(70586007)(110136005)(4326008)(8676002)(478600001)(41300700001)(5660300002)(7416002)(7696005)(7636003)(26005)(336012)(426003)(40480700001)(8936002)(47076005)(36756003)(82740400003)(83380400001)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 03:17:22.6262 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3897439f-54ed-47e1-f6c0-08daa6801ebd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6002 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add a helper function to enable the REQ_OP_WRITE_ZEROES operations when null_blk is configured with the non-membacked operations. Since write-zeroes is a non-trivial I/O operation we need this to add a blktest so we can test the non-trivial I/O path from the application to the block layer. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 13 +++++++++++++ drivers/block/null_blk/null_blk.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 1f154f92f4c2..fc3e883f7b84 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -209,6 +209,10 @@ static bool g_discard; module_param_named(discard, g_discard, bool, 0444); MODULE_PARM_DESC(discard, "Support discard operations (requires memory-backed null_blk device). Default: false"); +static bool g_write_zeroes; +module_param_named(write_zeroes, g_write_zeroes, bool, 0444); +MODULE_PARM_DESC(write_zeroes, "Support write-zeores operations. Default: false"); + static unsigned long g_cache_size; module_param_named(cache_size, g_cache_size, ulong, 0444); MODULE_PARM_DESC(mbps, "Cache size in MiB for memory-backed device. Default: 0 (none)"); @@ -678,6 +682,7 @@ static struct nullb_device *null_alloc_dev(void) dev->blocking = g_blocking; dev->memory_backed = g_memory_backed; dev->discard = g_discard; + dev->write_zeroes = g_write_zeroes; dev->cache_size = g_cache_size; dev->mbps = g_mbps; dev->use_per_node_hctx = g_use_per_node_hctx; @@ -1800,6 +1805,13 @@ static void null_config_discard(struct nullb *nullb) blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9); } +static void null_config_write_zeroes(struct nullb *nullb) +{ + if (!nullb->dev->write_zeroes) + return; + blk_queue_max_write_zeroes_sectors(nullb->q, UINT_MAX >> 9); +} + static const struct block_device_operations null_bio_ops = { .owner = THIS_MODULE, .submit_bio = null_submit_bio, @@ -2111,6 +2123,7 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_virt_boundary(nullb->q, PAGE_SIZE - 1); null_config_discard(nullb); + null_config_write_zeroes(nullb); if (config_item_name(&dev->item)) { /* Use configfs dir name as the device name */ diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 94ff68052b1e..2c0c9c29158f 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -111,6 +111,7 @@ struct nullb_device { bool power; /* power on/off the device */ bool memory_backed; /* if data is stored in memory */ bool discard; /* if support discard */ + bool write_zeroes; /* if support write_zeroes */ bool zoned; /* if device is zoned */ bool virt_boundary; /* virtual boundary on/off for the device */ bool no_sched; /* no IO scheduler for the device */ From patchwork Wed Oct 5 03:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7DF4C433FE for ; Wed, 5 Oct 2022 03:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbiJEDRt (ORCPT ); Tue, 4 Oct 2022 23:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiJEDRm (ORCPT ); Tue, 4 Oct 2022 23:17:42 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E681719AD; Tue, 4 Oct 2022 20:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gUaegdD1LwUY9kwoyWEleGvfDJ5No0VCl22+vCV13LeJ2slFfB1JqRui5ZHDg7AMFG7gzHA3X/HAJyV5PRUatq9OxS7Pn3CMWmzrAaDqxPxJYDAcHUHBxXJXHivUxzgAOFDhNOMwIjWZ4F59f8YKkfjPMJFE1WmMUf2rlr7fhF9+2tvURXFHJx5hPAFCj6+WCRbZid4wjhSsDkdICEbvNcl8+n+QnS2/mDlcv6KyjarWEQIqnvl7JCHIwgWvYmmiLgaJiiskwN0pygoK0zjoPP7UiVojbII7UQky2GImiyHqpY7jywShldymoFuGtUpClh+XzaknsJztVXADH+YNNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CeiX4viiHDFd5u/mwQnYqmQtoX77JIvmvAuld9O/lCs=; b=L3LbZH2q0jHOt90nzeAc2y36QHIcpcUYXhAdaHo1KsE4cTHr1ug03jKVTelYpuzRoZ+qCCDAkHYcXxgMglUWYhW4Hm2LO3G57JWxktH6qfPJMWtdwA0xQMfno6ejCb5lG5JTjugUWDJntqsVHsQ5I66QLpvbXO95qpOKZNTcLoekax/wtUbF6hwrFylzZlXJvQInOHNKnQWrKw8tlpVGsmhnnCLJw0zgR/TAEkzBFkgT7Yxx659FNWQxGY0YFXFPe27Z5AT9Hqm0iLcgoMDLKLDmgIia+eQYLI1adaVpeJndyz+DuV/B/dJAegk/OXPltLBTuLhTRjFvD9MNduDMXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CeiX4viiHDFd5u/mwQnYqmQtoX77JIvmvAuld9O/lCs=; b=hHVZLGAevxbaY59x1Rilah//L+reAqarfupHpy2jhkUNyKte/DnjFnXW6gi8KdBrMGxIMsFLZ0b5XrCCKyanAOt4jhwsltoLxmeuFVJC1ef0ocxUplyZYywuqc3RTQB5kFezUMfioonpCVGFskaNBKKio/M50dPLfRNDheu7KhIteake/T5V8y3MCbkMmv8uqB0N5qsE5r5RO6gLejireBhm3L3HLWxI57hA6eBVz4Ta/4wpBIXodv44n/Kg79CxggKqvVe0gLqYMjEl8H3fmyk9U5izP17r0lILASL2a74c4Ubw4ZEaVdXZu7c0PHXuWLPaM9ZC/W/1LkNy0LZN0Q== Received: from MW4PR04CA0198.namprd04.prod.outlook.com (2603:10b6:303:86::23) by DS0PR12MB6630.namprd12.prod.outlook.com (2603:10b6:8:d2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Wed, 5 Oct 2022 03:17:35 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::ef) by MW4PR04CA0198.outlook.office365.com (2603:10b6:303:86::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.30 via Frontend Transport; Wed, 5 Oct 2022 03:17:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 03:17:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 20:17:33 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 20:17:32 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH 2/6] null_blk: allow write zeores on membacked Date: Tue, 4 Oct 2022 20:16:57 -0700 Message-ID: <20221005031701.79077-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005031701.79077-1-kch@nvidia.com> References: <20221005031701.79077-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT008:EE_|DS0PR12MB6630:EE_ X-MS-Office365-Filtering-Correlation-Id: 3948006a-e3d9-4343-72cf-08daa6802633 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZMGlggu7tnv0lP0PVzTtlK10di6qJO2tZfmP7EELsm3i50hxo4uOKMfIDaddkgBe79hOqIbEWkTH6V3WhAAt/aVQMEMjLHeWyyHXGK/efS2Q+8/fAxcCtbRgHrgxZ60E7BYjNPMuST/FYY2kyRqNTrq3TLs0i2gWv5LY0zAmilhB725oePYpd2WELoO1rBnjS2dH6qzPB3xESinyLrMlqUURxeyPX9b2z99P+tG1IkUMUBsCJ/KFMw3lfi5S5iQazXA7Zk2C8A4QZNBeeOLZS5vuTEMPwFS3/2Ut6a0NlgSEQGQSzcY4+O1bBc45kKi50r5qdzTpPdUTFbKn6CFtUnDA4b/Thc7ll19bJRu78hDHOxrbfgF02ApT0Btf5VGKzCUbdohqbKvEltpa0Ycls4x449SmDsoGJMeIgGormdpSLqI651fla02+9s7G6VqLWtW5e3K1jPHDL8mjQ6Hu9djMzQzy2ToOMwTWh7OedmpShAOCnBC3zupyWdFZ3VDLm4hlRnG2MNRgEyH0d0+wkUOMoHjjB1q3yWhJrD2LUIvTiwD84v90fXcIV/hEYzc3rzOdzndX0G5kCBCI/VIHykig5oijQVZHp4fSPGSnt2W+hSDVPCUlRx344TqyyJjCvOtEMV2iwCJvpBRYko0InV4qE2mLuM/KvVAbVa3uc15M9zT3mEXH8yBJDEMhUH/a0e3gRKVxrU90GCGO3bXG589OA28McJ7qP2qOhoN8F4MIPYKFXc9GeQ1Rr+LnwljI2ki6UniL46ta8jMjtmYhNQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199015)(46966006)(36840700001)(40470700004)(110136005)(82740400003)(478600001)(36860700001)(5660300002)(40460700003)(7636003)(186003)(356005)(2616005)(16526019)(8676002)(82310400005)(7696005)(47076005)(54906003)(2906002)(6666004)(26005)(4326008)(426003)(7416002)(316002)(36756003)(41300700001)(1076003)(70206006)(70586007)(40480700001)(336012)(83380400001)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 03:17:35.2183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3948006a-e3d9-4343-72cf-08daa6802633 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6630 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Add a helper functions to enable the REQ_OP_WRITE_ZEROES operations when null_blk is configured with the membacked mode. Since write-zeroes is a non-trivial I/O operation we need this to add a blktest so we can test the non-trivial I/O path from the application to the block layer. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 46 ++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index fc3e883f7b84..2d592b4eb815 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -420,6 +420,7 @@ NULLB_DEVICE_ATTR(blocking, bool, NULL); NULLB_DEVICE_ATTR(use_per_node_hctx, bool, NULL); NULLB_DEVICE_ATTR(memory_backed, bool, NULL); NULLB_DEVICE_ATTR(discard, bool, NULL); +NULLB_DEVICE_ATTR(write_zeroes, bool, NULL); NULLB_DEVICE_ATTR(mbps, uint, NULL); NULLB_DEVICE_ATTR(cache_size, ulong, NULL); NULLB_DEVICE_ATTR(zoned, bool, NULL); @@ -544,6 +545,7 @@ static struct configfs_attribute *nullb_device_attrs[] = { &nullb_device_attr_power, &nullb_device_attr_memory_backed, &nullb_device_attr_discard, + &nullb_device_attr_write_zeroes, &nullb_device_attr_mbps, &nullb_device_attr_cache_size, &nullb_device_attr_badblocks, @@ -618,7 +620,7 @@ static ssize_t memb_group_features_show(struct config_item *item, char *page) "poll_queues,power,queue_mode,shared_tag_bitmap,size," "submit_queues,use_per_node_hctx,virt_boundary,zoned," "zone_capacity,zone_max_active,zone_max_open," - "zone_nr_conv,zone_size\n"); + "zone_nr_conv,zone_size,write_zeroes\n"); } CONFIGFS_ATTR_RO(memb_group_, features); @@ -875,6 +877,24 @@ static void null_free_sector(struct nullb *nullb, sector_t sector, } } +static void null_zero_sector(struct nullb_device *d, sector_t sect, + sector_t nr_sects, bool cache) +{ + struct radix_tree_root *root = cache ? &d->cache : &d->data; + struct nullb_page *t_page; + unsigned int offset; + void *dest; + + t_page = radix_tree_lookup(root, sect >> PAGE_SECTORS_SHIFT); + if (!t_page) + return; + + offset = (sect & SECTOR_MASK) << SECTOR_SHIFT; + dest = kmap_atomic(t_page->page); + memset(dest + offset, 0, SECTOR_SIZE * nr_sects); + kunmap_atomic(dest); +} + static struct nullb_page *null_radix_tree_insert(struct nullb *nullb, u64 idx, struct nullb_page *t_page, bool is_cache) { @@ -1191,6 +1211,27 @@ blk_status_t null_handle_discard(struct nullb_device *dev, return BLK_STS_OK; } +static blk_status_t null_handle_write_zeroes(struct nullb_device *dev, + sector_t sector, sector_t nr_sectors) +{ + unsigned int bytes_left = nr_sectors << 9; + struct nullb *nullb = dev->nullb; + size_t curr_bytes; + + spin_lock_irq(&nullb->lock); + while (bytes_left > 0) { + curr_bytes = min_t(size_t, bytes_left, nullb->dev->blocksize); + nr_sectors = curr_bytes >> SECTOR_SHIFT; + null_zero_sector(nullb->dev, sector, nr_sectors, false); + if (null_cache_active(nullb)) + null_zero_sector(nullb->dev, sector, nr_sectors, true); + sector += nr_sectors; + bytes_left -= curr_bytes; + } + spin_unlock_irq(&nullb->lock); + return BLK_STS_OK; +} + static int null_handle_flush(struct nullb *nullb) { int err; @@ -1357,6 +1398,9 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, if (op == REQ_OP_DISCARD) return null_handle_discard(dev, sector, nr_sectors); + if (op == REQ_OP_WRITE_ZEROES) + return null_handle_write_zeroes(dev, sector, nr_sectors); + if (dev->queue_mode == NULL_Q_BIO) err = null_handle_bio(cmd); else From patchwork Wed Oct 5 03:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C2F7C433FE for ; Wed, 5 Oct 2022 03:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbiJEDSG (ORCPT ); Tue, 4 Oct 2022 23:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiJEDRx (ORCPT ); Tue, 4 Oct 2022 23:17:53 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071.outbound.protection.outlook.com [40.107.244.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EB4C71BE3; Tue, 4 Oct 2022 20:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nk/KaTaDNrwFV6hFXvavWXrLJW3cxgpL3ZFsIfuBEKfQOAI2BsAdDLEgpZCN5AQQGIEUkiCsSe5MLILPj8ZNhzmpjnvFN1s68vAYMoG7y5Pe/dN7pFC9TJjSPafEDSUWVCHnCPIA8eb++eZlzquIX9u7sae47HWQF6mZtCK6p6O8Ybl8TrXuBkrqvTUS8kmK/ZyQkhfGF31PzjD1z7Ycx0/XsM7H2XInY9p3FBFjxWYj/VIWgprI+EUffB0/DYsKeUe+ZYr634u/jqD1dZEy0fQeAzX/wWdec0Nf8bxMdE2sMF6xhvgvz812n7swTIiojTcDNeJpdVqdb6rwYLxQXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e+4DuxWT/CpfWrrdm39C/ZtzTKY8JSdhQLNAfF7DIG4=; b=Pd2IlxF1rXTPzcnRlTb6tW1xvELFWepmPQuDh6AX3E9Tzz+lmr/v4CYRuyFBykslKjCC4Gda2z3xe3XVYeZvi6k/wdT3jD2RkKdUQJYVgFYOYeqAXUv7QBt3SJNDth6wqlJNWKGfh6ACJl8hhl1mGcpIMh/WU1ht30oiGuuvj/ygywTZPIDZkzntT5mFrSgQZfotHNgQ7Ie3QAiTbMYxxr/AhM08B2zZzWX4eanLEYJuXfZEAvGVriPadN9leRQRS1ycNt9uoM665aLW9eQ/c6/X7yW+ijMnNsKek6X99ETIPQJNtxXVNsrXNriUnYcN7pkVVUdv/tw411GzsKhfmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e+4DuxWT/CpfWrrdm39C/ZtzTKY8JSdhQLNAfF7DIG4=; b=jxSPUz6mRg/heGTaXuE6vSn+mpgj/LREmyG5WYmRDGv8+PTh/7cz7J8xOV4xwDjSMKZVzUPx1nefIpmcbASHLsJj9oeBkg9RUFhic6UJqyatxIF8CKqO8xVVgbFEN69915qIvXHOxZyqQjSePCTmX5yvL0mUblQbQBJP/5wsKT5/KZ445wJWMkV3X/fBjObAyKh3qBJqVB3IyNc8W081hmTzC6/tdoNyMaxfSW+eXs/k2lrharNUSRkt///x6C+LkW770H2kuJZMzSN4TFhXBgLbYkZcqa4br8gkkeAUFhxBFwI59uFzAXEl2rrq2A10V4CAAHAQ0v+O4gJZ818L2w== Received: from MW4P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::12) by PH8PR12MB6962.namprd12.prod.outlook.com (2603:10b6:510:1bd::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 03:17:45 +0000 Received: from CO1NAM11FT104.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::c5) by MW4P221CA0007.outlook.office365.com (2603:10b6:303:8b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31 via Frontend Transport; Wed, 5 Oct 2022 03:17:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT104.mail.protection.outlook.com (10.13.174.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 03:17:44 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 20:17:44 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 20:17:43 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH 3/6] null_blk: code cleaup Date: Tue, 4 Oct 2022 20:16:58 -0700 Message-ID: <20221005031701.79077-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005031701.79077-1-kch@nvidia.com> References: <20221005031701.79077-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT104:EE_|PH8PR12MB6962:EE_ X-MS-Office365-Filtering-Correlation-Id: ec9898b3-17b8-4f6c-cd34-08daa6802bf4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /+7ZdbZtN4QKMgJ0d7RSTm6p9QXCVSGuy6L0X6XXXguRv1ZuqhOFC60VqYcB6WLpd9GPYzCJElnUda8PNcuVW9bOgmeT7jVY0rr9v4KVIBkXnR4Ehb6g5psKOP3OQnofl2kYuVeEHqLbZb1pAy4ORgVQAIH5HSDCEIBKYDLk0oW2WDG4rMYyJUz74JR5c0/R8gIk8r1PU48rvEQ+5JRyCTZYgBOdrNy1prDQv7zhvlHwYAs3NIVCKak2PU14psZYC33L5579z0Stz59nmPjo3U2KXUaIBfsLfgVfKP4FxJv9oMLs3ZpI++kkwOHg52ePKE3cLv7eVjfe4PE0GF4uFJEMgv3CzQyMqm4/YQrzgDGERCNFNuCDuR6tU/Ml45KmOYhlh9yP4my6lctkq/KY5p+L7zR6cQmat9HTZD2kIm5Wow+L5+kc2Yk0C/QEKVWC1s4+L/pxkfXZH3kez/mGUFMaBp1eIckGSUYGM4/Uqa8veob7MomnBim5OwZIqQ+r+AtaEcrjDoIUxd7qSW1Or6Nqtys99C5kTbHssQ5UTqsA/RQ3A6aNXEPmM9M/zIQi8vHcokqIXkq2BWEv+LPPd/XXZN5Y4TVE+JepducoQBLe9PrjEiQZ7dHHtnP5Vh4QJbPPSLn/3qIuZlMZwUDwEtb7YQmira8LZLGlhU99J9CTpggNCGgHfM/oNCvkPvkwo/utyAowUd/Y3iaqI8lwmQAe3dSURdp2ffsy1iEhE00ZVEOx1qDugySuTdUnzg1jSzxUIQx08MRjEQuqbSITOQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199015)(46966006)(36840700001)(40470700004)(82310400005)(356005)(82740400003)(7636003)(478600001)(316002)(54906003)(110136005)(1076003)(6666004)(186003)(70586007)(41300700001)(70206006)(8676002)(4326008)(7696005)(5660300002)(26005)(40480700001)(7416002)(36756003)(336012)(8936002)(47076005)(2616005)(2906002)(16526019)(36860700001)(83380400001)(40460700003)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 03:17:44.8897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec9898b3-17b8-4f6c-cd34-08daa6802bf4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT104.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6962 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce and use two new macros for calculating the page index from given sector and index (offset) of the sector in the page. The newly added macros makes code easy to read with meaningful name and explanation comments attached to it. While at it adjust the code in the null_free_sector() to return early to get rid of the extra identation. Signed-off-by: Chaitanya Kulkarni --- drivers/block/null_blk/main.c | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 2d592b4eb815..b82c2ffeb086 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -14,6 +14,11 @@ #undef pr_fmt #define pr_fmt(fmt) "null_blk: " fmt +/* Gives page index for which this sector belongs to. */ +#define PAGE_IDX_FROM_SECT(sect) (sect >> PAGE_SECTORS_SHIFT) +/* Gives index (offset) of the sector within page. */ +#define SECT_IDX_IN_PAGE(sect) ((sect & SECTOR_MASK) << SECTOR_SHIFT) + #define FREE_BATCH 16 #define TICKS_PER_SEC 50ULL @@ -860,20 +865,20 @@ static void null_free_sector(struct nullb *nullb, sector_t sector, struct radix_tree_root *root; root = is_cache ? &nullb->dev->cache : &nullb->dev->data; - idx = sector >> PAGE_SECTORS_SHIFT; + idx = PAGE_IDX_FROM_SECT(sector); sector_bit = (sector & SECTOR_MASK); t_page = radix_tree_lookup(root, idx); - if (t_page) { - __clear_bit(sector_bit, t_page->bitmap); - - if (null_page_empty(t_page)) { - ret = radix_tree_delete_item(root, idx, t_page); - WARN_ON(ret != t_page); - null_free_page(ret); - if (is_cache) - nullb->dev->curr_cache -= PAGE_SIZE; - } + if (!t_page) + return; + __clear_bit(sector_bit, t_page->bitmap); + + if (null_page_empty(t_page)) { + ret = radix_tree_delete_item(root, idx, t_page); + WARN_ON(ret != t_page); + null_free_page(ret); + if (is_cache) + nullb->dev->curr_cache -= PAGE_SIZE; } } @@ -885,11 +890,11 @@ static void null_zero_sector(struct nullb_device *d, sector_t sect, unsigned int offset; void *dest; - t_page = radix_tree_lookup(root, sect >> PAGE_SECTORS_SHIFT); + t_page = radix_tree_lookup(root, PAGE_IDX_FROM_SECT(sect)); if (!t_page) return; - offset = (sect & SECTOR_MASK) << SECTOR_SHIFT; + offset = SECT_IDX_IN_PAGE(sect); dest = kmap_atomic(t_page->page); memset(dest + offset, 0, SECTOR_SIZE * nr_sects); kunmap_atomic(dest); @@ -949,7 +954,7 @@ static struct nullb_page *__null_lookup_page(struct nullb *nullb, struct nullb_page *t_page; struct radix_tree_root *root; - idx = sector >> PAGE_SECTORS_SHIFT; + idx = PAGE_IDX_FROM_SECT(sector); sector_bit = (sector & SECTOR_MASK); root = is_cache ? &nullb->dev->cache : &nullb->dev->data; @@ -1125,7 +1130,7 @@ static int copy_to_nullb(struct nullb *nullb, struct page *source, if (null_cache_active(nullb) && !is_fua) null_make_cache_space(nullb, PAGE_SIZE); - offset = (sector & SECTOR_MASK) << SECTOR_SHIFT; + offset = SECT_IDX_IN_PAGE(sector); t_page = null_insert_page(nullb, sector, !null_cache_active(nullb) || is_fua); if (!t_page) @@ -1159,7 +1164,7 @@ static int copy_from_nullb(struct nullb *nullb, struct page *dest, while (count < n) { temp = min_t(size_t, nullb->dev->blocksize, n - count); - offset = (sector & SECTOR_MASK) << SECTOR_SHIFT; + offset = SECT_IDX_IN_PAGE(sector); t_page = null_lookup_page(nullb, sector, false, !null_cache_active(nullb)); From patchwork Wed Oct 5 03:16:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5854AC433F5 for ; Wed, 5 Oct 2022 03:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbiJEDSQ (ORCPT ); Tue, 4 Oct 2022 23:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiJEDSC (ORCPT ); Tue, 4 Oct 2022 23:18:02 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF3A71BC2; Tue, 4 Oct 2022 20:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TSG/5f7LDiieX8S5xkT/+Cid/H8enLL99upAYwMOzhzTQNVKZjkPo8SC8TmpF/EgJnSzMpiMj1U8wk59L7DPSAlOUHPIiEG/ebvErVHFXfiD9HY7PDctRz8zP5sIIhb5ww8zt5rYgYTuz2GKajohTOogWrBXoJADCPrQe2nscyVwZUG92MNlKilcvhy1zev7vTpMemKncsxjbmszvUQFGJHnZPMp7tkHUQxjQ0L8qNOfVKOuOM7yYFzvUjx77ek2Q4gSY1hc/U9PSsTuSkwVi3t3d+nNEBArdegmcRyDfnnPn9JeShhBvm9uhb2ioVGU72FsqPf0r7T1AKIdX9qvGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qu7w/oEg6+DPDhMB1iJ3xtdU1PsDIweTh1KJ3p1wXBI=; b=b4gAT4tnjKRq50KJ69kfuCFtNNzzi3LUwAw/XHbzaQxFHTuaoD5BURWqGk26YTR5gjal2Q8tnE5yGHhWs0t/wx1OR0BCkGKSkjgBP1lpbGkLzO2rsADuRTloz/1HJdUTvDJWMtgp8ECoZhWhqTL53KCee2zw8nfDey93jkiA6VcTsDobKslFGAuaMjHYaW2cBvEKnTM4rPEHoSYcmUlJQxLW/aZoUKEG3l1Eeaa31J0PxRby2O/RRn0r1vuEQHuOTc2sBeTbHcyi3DEPQHCs2m9qhxn8x6zYOTNGGtC0uOYBPv+iXLW5wlxcvGlvl8NgF4ur/3FgiLrg6LipGYFHjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qu7w/oEg6+DPDhMB1iJ3xtdU1PsDIweTh1KJ3p1wXBI=; b=rDenH2DvI5ctR/FGm71Oyj8QRoMbnC7FFkwHiIMm/X/owoARSUXZkVIKuqK6AL1gSHK0eNkNyGvZu15cMsBzO8bzbzz9uUKM7vacW4eOFsTGyiOwhLd1f9PypWAWefoZKPJm5bSr71EdXj5KTpFxbcRlh+p91eMQWRPQqk2CgrZRKtzmbqLJ19H2MewlesBcco3f8CWIg+lneET+Ejg+0wgjT/hhIf2+gjWSHZbA0i4Eiz8X5AevQBNZSpi1mgNgaYwzsVKRNTakDz95B4Meb+wvbnI1dU3mIhLKuOIwqs3s1I4s9hDP3hFnbgj74R5w9/NpSuWelSNppo1aAWJvqA== Received: from MW4PR04CA0141.namprd04.prod.outlook.com (2603:10b6:303:84::26) by DM6PR12MB4926.namprd12.prod.outlook.com (2603:10b6:5:1bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Wed, 5 Oct 2022 03:17:56 +0000 Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::50) by MW4PR04CA0141.outlook.office365.com (2603:10b6:303:84::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.26 via Frontend Transport; Wed, 5 Oct 2022 03:17:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT038.mail.protection.outlook.com (10.13.174.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 03:17:55 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 20:17:55 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 20:17:54 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH 4/6] null_blk: initialize cmd->bio in __alloc_cmd() Date: Tue, 4 Oct 2022 20:16:59 -0700 Message-ID: <20221005031701.79077-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005031701.79077-1-kch@nvidia.com> References: <20221005031701.79077-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT038:EE_|DM6PR12MB4926:EE_ X-MS-Office365-Filtering-Correlation-Id: c3c13d38-8adb-483e-16e4-08daa6803294 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LVA8b/PrOpT/t8zKdTQkUwy5tLqTb8sOKiN+s6cBQspAxMWtSGpIQIivSBSzk2q8S5HimCgs34ksOrsZ7zavH3q2Cde+vwj2MI1xEbnfQL1gVq50mW4zzPWoU+OsfVhfwQVG9QV1rYjM09F43Plh9+i6IFuw61ag4zYD47MlKbgMl2q0blsMaMf5mfz42vqXLR1klSx9Lw/wurR1FNBMaio8R9PUW9UJGv0XSL3zLI5TVfmWOCT5vQNeCYGvWqBpfv4qPx5J81H3QhJDkAfsGbRjMnUACaEtUREZpLgr9GprrYx/26BlnA0ee+ub/dk/vXDvJT9n9TMPwLQtHEPPwNaE4mA1xAAwnmYbcsMOj3OG1/BUuUGEW8vlV/63tSoFLfUkZjvaXl5udRTqUJ6akNwoSksz0Ko5rYdSf2FgwrawMX+f9tLOvy3JkSYaK7lZSka7hf/omUYfUQsyRGZ4yGuEaJnFfb5+Q5l/cR08kTXgm12kiwZmpo0jXSqQ9VJKbCKlytkugCVEM32dpoTNz4t+RQeNgI74XWYbI5aLnYSArwno9Xi5iv0nG8Ry8xU6aAnKlSig5fDl92nibJ9IiCMkHlXrwkTk6Hbwq6Du+OGsCBh43VUHORQRkrvydFiUnoR7BVga55GsFSfn66RZWQSn89D+Pgm84VoJ8WIDzXHfwdb1SitPKfQvLtAHSpyPbm9FQhqq/QVay6MVdUNWPn1Ik/NgNSjz8eAW1dE4FtXpqfYzIH0tFMHIGUQh3Ed4p9vgmC0pEKnvV9hQHmMtKA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(396003)(376002)(346002)(451199015)(46966006)(40470700004)(36840700001)(186003)(16526019)(83380400001)(336012)(82310400005)(426003)(47076005)(82740400003)(356005)(7636003)(36860700001)(41300700001)(8936002)(5660300002)(7416002)(316002)(110136005)(40480700001)(8676002)(70586007)(70206006)(4326008)(54906003)(26005)(7696005)(40460700003)(1076003)(2616005)(2906002)(478600001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 03:17:55.9843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3c13d38-8adb-483e-16e4-08daa6803294 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4926 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The function __alloc_cmd() is responsible to allocate tag and initializae the different members of the null_cmd structure e.g. cmd->tag, cmd->error, and cmd->nq, Move only member bio that is initialized from alloc_cmd() into __alloc_cmd(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal --- drivers/block/null_blk/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index b82c2ffeb086..765c1ca0edf5 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -743,7 +743,7 @@ static void free_cmd(struct nullb_cmd *cmd) static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer); -static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) +static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq, struct bio *bio) { struct nullb_cmd *cmd; unsigned int tag; @@ -754,6 +754,7 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) cmd->tag = tag; cmd->error = BLK_STS_OK; cmd->nq = nq; + cmd->bio = bio; if (nq->dev->irqmode == NULL_IRQ_TIMER) { hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); @@ -775,11 +776,9 @@ static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, struct bio *bio) * This avoids multiple return statements, multiple calls to * __alloc_cmd() and a fast path call to prepare_to_wait(). */ - cmd = __alloc_cmd(nq); - if (cmd) { - cmd->bio = bio; + cmd = __alloc_cmd(nq, bio); + if (cmd) return cmd; - } prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); io_schedule(); finish_wait(&nq->wait, &wait); From patchwork Wed Oct 5 03:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29A9EC433F5 for ; Wed, 5 Oct 2022 03:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiJEDSs (ORCPT ); Tue, 4 Oct 2022 23:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiJEDSb (ORCPT ); Tue, 4 Oct 2022 23:18:31 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2080.outbound.protection.outlook.com [40.107.220.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5526A72B40; Tue, 4 Oct 2022 20:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6myo9NclVCMPblcNsvAZ5EmzzztLkS2ltELZqVPaGdCB6Kji1p1ZAhpOP81d1ftJVTPyd4vNfflKuS+HDODT/wkxuWmNNp+mJuAKLie0URHRTT+mkuPY4aYgHGlBkJwhLrga1isOBgCH85F8YkjWyyNVedtj5tgI7Q5YdD1W/tHn+XXFBv743civyBQfaLn4R0v8lToVWOzh4X5SEeN19nokpWTCkX+6wxUR56HenEhY4Zum/5fxePw5z4oJCxBPP0Mj39PanC0YT9dMuifXTD8gOJX+yaNN8uxWDiD07vVTslTCWw+KkckvkAMlQIKJ5Y5twnnLNJ/VkNiTgNASw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=exeAseTkzWgC8ke2liF309aQJwvXrcgbHoddUpSqxdM=; b=YL2gwqXolufCVhbH1/kp5/cW5BFQMjo3/0v/FhjGqMw4TqnmsGZptDMm1vVrSbf3esSdPZGmgsENr/Qt+GOlZPmKBMfylG8HeXSKEZWGQofAOd5tMBU42OfUcqafwHFxLvUQPo0A8JoMTI+wA0Y5HGkT3/kc+K359/V4BFDo8QR85BnLcrpX2enIerKxQfTXq2KDWjg4XDcEAbmfVyxGGBFPTEUa702HDQcTQ44I35kuKIdeJGHGMwKoC5xY8ygeYuOKhulvwCvj00UcHi3JsPAL8aPaP7wEjzZhhxGHUVDm0c/JaJ6w0xh2Uu20fUBd0h1eTwTeL1xU1XH3HWkubg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=exeAseTkzWgC8ke2liF309aQJwvXrcgbHoddUpSqxdM=; b=J1E7h+dZyREp1xSKwTcQezAHvtzUdM4NsQxE19GR79E4rD4H85OI7uNkdGqzDE+ZlJDHvuH1TKM3hGiINHfliLUAU79NBeiw0XGZzic5QOJs1/hnYEIj310W0Zeh3D3RWJdwqb+kHiEPK8ES1bt1pOe8SAXMcLjDOzg3i0F7/S5mcWeVvjgog6pSu4nRADwK3uZncFIN/BkIxaGSCN/6goCnRno5vIg9uAnKqIDXToo80ybnXQpCgRnRFvah61Abst/KrcOOtnICUoqlVmD8tC1rfeWTA+C+Wxf9cvIu9hCA9eWD0RDxXKEhQDKzsk9iZZUKTNFdeo2v5Onztf1UEw== Received: from MW4PR03CA0046.namprd03.prod.outlook.com (2603:10b6:303:8e::21) by DM6PR12MB4370.namprd12.prod.outlook.com (2603:10b6:5:2aa::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Wed, 5 Oct 2022 03:18:20 +0000 Received: from CO1NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::bb) by MW4PR03CA0046.outlook.office365.com (2603:10b6:303:8e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Wed, 5 Oct 2022 03:18:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT010.mail.protection.outlook.com (10.13.175.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 03:18:19 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 20:18:06 -0700 Received: from dev.nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 20:18:06 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH 5/6] null_blk: don't use magic numbers in the code Date: Tue, 4 Oct 2022 20:17:00 -0700 Message-ID: <20221005031701.79077-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005031701.79077-1-kch@nvidia.com> References: <20221005031701.79077-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT010:EE_|DM6PR12MB4370:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e5a69a4-9459-40d0-559e-08daa68040d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LjtezFy/xcAqOGL2LDLxZGgkfbaNiTTSrp95bxXv9+n18ooDZh8PPZz36CFyyM8/tfVXqYCb+XYihmFPh3VdvLL/+/ALKLf+uFY1oJ4JcRlnGteaEUY6fnrzDrXdMWfAPw9WSHFF42k3mnHQs7oDinp7wM1l13B9gCz/9j9ms5GrcYCrAgvIn2Y+wqK7ic2B3mER1a5RDyeH/HW7icw60ToYqXFyJVHOumSk1uJZYYqLWf9GwLLQygr+tGny0pARGvGMPVjrBP0UWvgFIp9DkBh/O8KchFWpKbyP14eosQdr5uJSzVCTvsAIxCurMRi7iM0oz61acEQgW9jgzj8lyxLM1b5Tk5pn2rJTCRZ9yCv7HoF/qYhx5gm7Y78lyYZtDeazweS2mGOQn2Cgi/MtcrS2jIHKXn2k0djXI87RtYPBcnMZeCRjWHJSgpu1nR6IA1KOes6Vgn5ZyUhTm7XR7Zk+VDSU6wqwbJwy3iH5D5kVh5gxINnvLZKaYKYcO24caSY39Yv8bf6wFU/X4gUjypUe2OmGglFgunhC3I+bw56BslJWYIOWBm4+6ik3w4Gr/TAPH6WhxBzVgntVzkucA9z5Nu/246dG2Vf9h6M+lxYcA8LmsTjhuPesMRx7X7odITmMLF1PaaFYO2Qs8/3ZgYDofr1B72MW5s54YHPalnWWOsCkH5iwzqI2wnwmDDkvYEUccMqhSpTvxFWJgnLeQHvAYagEqvRIO2c3WwNIdeKQk4cIuA7RbEGRh7Sq732jkyFroP0LExqfwQMX0R+AdA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199015)(46966006)(36840700001)(40470700004)(47076005)(83380400001)(7636003)(40460700003)(110136005)(7416002)(54906003)(478600001)(336012)(2906002)(316002)(40480700001)(82310400005)(5660300002)(356005)(6666004)(7696005)(82740400003)(26005)(41300700001)(186003)(16526019)(426003)(1076003)(70586007)(70206006)(4326008)(2616005)(8676002)(8936002)(36860700001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 03:18:19.8869 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e5a69a4-9459-40d0-559e-08daa68040d3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4370 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Insteasd of using the hardcoded value use meaningful macro for tag available value of -1U in get_tag() and __alloc_cmd(). While at it return early on error to get rid of the extra indentation in __alloc_cmd(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal --- drivers/block/null_blk/main.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 765c1ca0edf5..eda5050d6dee 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -24,6 +24,8 @@ #define TICKS_PER_SEC 50ULL #define TIMER_INTERVAL (NSEC_PER_SEC / TICKS_PER_SEC) +#define NULL_REQ_TAG_NOT_AVAILABLE (-1U) + #ifdef CONFIG_BLK_DEV_NULL_BLK_FAULT_INJECTION static DECLARE_FAULT_ATTR(null_timeout_attr); static DECLARE_FAULT_ATTR(null_requeue_attr); @@ -730,7 +732,7 @@ static unsigned int get_tag(struct nullb_queue *nq) do { tag = find_first_zero_bit(nq->tag_map, nq->queue_depth); if (tag >= nq->queue_depth) - return -1U; + return NULL_REQ_TAG_NOT_AVAILABLE; } while (test_and_set_bit_lock(tag, nq->tag_map)); return tag; @@ -749,21 +751,19 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq, struct bio *bio) unsigned int tag; tag = get_tag(nq); - if (tag != -1U) { - cmd = &nq->cmds[tag]; - cmd->tag = tag; - cmd->error = BLK_STS_OK; - cmd->nq = nq; - cmd->bio = bio; - if (nq->dev->irqmode == NULL_IRQ_TIMER) { - hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, - HRTIMER_MODE_REL); - cmd->timer.function = null_cmd_timer_expired; - } - return cmd; + if (tag == NULL_REQ_TAG_NOT_AVAILABLE) + return NULL; + cmd = &nq->cmds[tag]; + cmd->tag = tag; + cmd->error = BLK_STS_OK; + cmd->nq = nq; + cmd->bio = bio; + if (nq->dev->irqmode == NULL_IRQ_TIMER) { + hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, + HRTIMER_MODE_REL); + cmd->timer.function = null_cmd_timer_expired; } - - return NULL; + return cmd; } static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, struct bio *bio) From patchwork Wed Oct 5 03:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12998853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F99C433F5 for ; Wed, 5 Oct 2022 03:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbiJEDS5 (ORCPT ); Tue, 4 Oct 2022 23:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiJEDSg (ORCPT ); Tue, 4 Oct 2022 23:18:36 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F84E71717; Tue, 4 Oct 2022 20:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gvVpw8Ci137NTEKNeyB1jTiu8qmAwGwo5z65V8/Us/IWhbK2m/9qK8x8KtHsEdThKfNcVOFgVWu0wi7P+umEME9JnfFFBZbH+FAO8X61NbZmejSuPuCqQUuOdAq60JPduviZZhVAerSLNpJykyWJC34SAEZERntdCcPuRWTwGAFbrDRQRLVhkphZQF37EajbY/UhQn2L2zvSdLbv27k9DA+MF22ShEdUBxcY8+NqCJSY0b/SdZJUdnzrH46DaOtUrHMjLOgMGxOf6T5/Dh8E5/K4ILId+/ZFjnDHP+YdGoZpoL0cSLCgnxbyW5K4li1T4mBhvQLaJpCfvt2h/UNEFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NbCWYKu7V8cahOE1sEcOZv9ewpr5xEMqkRh/j7pg9zo=; b=XtO38w3rnoDRLxWsaWREq5nh5odb48qBktNYRkT6J+XnI7G1kNgeBbaBY/twkbINvP4dDBci9nJkrET/9CKAMcCew8/j3uTN0KQ0MukiCVbY58gVGzHZ3sLiAP9CCtdBJv4V/KpoMmHfbXg3jM0t9CTjUYz5UU1VHFnPcHRZ3xZzerjkU6KXrWLkwq12kSMtJngys2sRRg1GpyEhbDsZghDQLGXyoZLiOSERAXBwMAO7k8gYMpspUCPFidKz7PW162Q2V58YkcWs4PIbF7sXE1DBALT7PaUvAym+8B5y6r5DZ8A9AQGu1jsnaFLDIOuMze0dV7WaPrUwpvoLtxeYOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NbCWYKu7V8cahOE1sEcOZv9ewpr5xEMqkRh/j7pg9zo=; b=IJ/nMNdJqFmWarKNrek4ggN3AqLMV6+qsiPWIZWu99h7I1No1RvLPzBbM40PHimK/yOCs/RHMOBkloJ5jQCjSzrKmlAG97Hei8PLb/uxpJgjGLcYRKc3A8ItOpFaOnTgTErROFJK2r7Pbxrz56i9Eg3Ol0XhqYF5ks1wfYzXn4bxjzXYFfHrUCLe3cRbZavdEwQqag5If887ukhLYF2JpnXWHiTIHPITbgA/K/KahxFY/hUyPzHJvZLzo55RR5BjYSrag/w70tCK201gbl6zs79LA6iYpTrXYbc8P3qTP5m5p/LVJyFZPFMSftdN+jGoSxQNDVEdH06Y85xJgZuL9w== Received: from DM5PR07CA0055.namprd07.prod.outlook.com (2603:10b6:4:ad::20) by DM4PR12MB5357.namprd12.prod.outlook.com (2603:10b6:5:39b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Wed, 5 Oct 2022 03:18:28 +0000 Received: from DM6NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ad:cafe::90) by DM5PR07CA0055.outlook.office365.com (2603:10b6:4:ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Wed, 5 Oct 2022 03:18:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT056.mail.protection.outlook.com (10.13.173.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Wed, 5 Oct 2022 03:18:28 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 4 Oct 2022 20:18:20 -0700 Received: from dev.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 4 Oct 2022 20:18:17 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH 6/6] null_blk: remove extra space in switch condition Date: Tue, 4 Oct 2022 20:17:01 -0700 Message-ID: <20221005031701.79077-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221005031701.79077-1-kch@nvidia.com> References: <20221005031701.79077-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT056:EE_|DM4PR12MB5357:EE_ X-MS-Office365-Filtering-Correlation-Id: a20426f6-dd3b-4fc7-9ff1-08daa680460b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B5S69MvaJDCgoZexVJFi82GvtbBVE3cNzuZ1gwOVtrNF7K0FjngWHbelLs3X+0GjNrvYZ/PdJcubvHajLh0VO7KSHTwm5K/YVQEpxUvZBWLIBMOrwc26F37Js4gnXPSyM/bEo8EQsC+ea2YPIe+JpagzVElIjNCuabjRt8HVWmgesfSwFgTTWer0YEA1PBBuSYXGaOqdQXXW6zXzw7lvzkhjVz0mjvZUEqnba+SpnjjCvbVPNbF8ciCX15PrF3mBi9PciUKvBiRNWiWWotDlmzDc5FBb0sslgiI3M2XYPeoNQ28jHFc9HCvSdX+kKV3hc25wGHNqDONaNz9IkgNhF0ozR6GfIf8o+W31UzuprYu+RVQT8sQFj2nWD7l1LloolQYcVneL67gtz92z6VAQCM3oYphvUAJQuWMcTunafSWYIxdmXEj/24AmFH2w5g1IQHWf/l21A8VjTRIn1NPLHxWDQcrxs+v0m8F7b+3F8juELL6gybti3C73b1La1UhkX9Ozv3IX3R2SP6dKUB5/UExJYUCYJPPPcnHaen5XxAheRRiPKzw2PF/TI+Vj8m0Yd35qjkHgN8r4j4g4wpwTP2BZIp1+V0CcA4sbNKjCHag4Io/u8NLgt7hjM8FIpo6YAvfF3UZ775NwBnrq7Wf+Mt/AJURM6JfsiCaWzfKO1OVPzMYky+xYH5oPUFkh9RfLmpLpVe/78/Qvx4TN+zWWHjDz6MHl2h0eu4MJ7AFdDda7MNUdoazNgubavDrtuXYmUuUpCH4OeU0BMajP1l7LDg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(39860400002)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(41300700001)(478600001)(54906003)(40460700003)(8676002)(4326008)(70206006)(6666004)(316002)(36756003)(110136005)(7416002)(70586007)(426003)(82740400003)(47076005)(4744005)(83380400001)(36860700001)(40480700001)(5660300002)(26005)(8936002)(336012)(7636003)(82310400005)(2906002)(1076003)(16526019)(2616005)(186003)(7696005)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 03:18:28.5819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a20426f6-dd3b-4fc7-9ff1-08daa680460b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5357 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The extra space in after switch condition does not follow kernel coding standards, remove extra space in switch condition end_cmd(). Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal --- drivers/block/null_blk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index eda5050d6dee..e030f87d0208 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -789,7 +789,7 @@ static void end_cmd(struct nullb_cmd *cmd) { int queue_mode = cmd->nq->dev->queue_mode; - switch (queue_mode) { + switch (queue_mode) { case NULL_Q_MQ: blk_mq_end_request(cmd->rq, cmd->error); return;