From patchwork Tue Nov 29 23:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059325 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 6AE43C433FE for ; Tue, 29 Nov 2022 23:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbiK2X2r (ORCPT ); Tue, 29 Nov 2022 18:28:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiK2X2q (ORCPT ); Tue, 29 Nov 2022 18:28:46 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2045.outbound.protection.outlook.com [40.107.223.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2BEE6E575; Tue, 29 Nov 2022 15:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FcbKGwjOSOCkElwUttJS2jRYLZye1pUnj5wKYXd0CWsx4/9O3HVMg9Q0DVy3ksysO2auxRBBTzxG/pvTimrFkU3zb0gdJA+Qfyo7Xzy3aczSykXsM3nqrCShMr8gxMyryQ3iV75tX3KdtKwW1z1SaKPYz6QeE2DuA6/Gc2sjTHYZ2GWYwqTS4UN2o5VWLrotPQEoriFh5kxel/SxlqoVq0zaAJo8rnDSa07y6SyTP0uszRxDMU5dgQdMnbIlCYuvnKt5YfbMl6bTxe+VjhQu7CEzpG1XjZlT7JnC+G1IQ7LxB1njfw0uZ1vuCFRlsGzJ/4Q6DABb05mWlFrI9UbBbw== 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=TQmv64da+NeRasr5CDRQ/fRlLIjqCt0lt59FOgxkGsA=; b=T7JOW3Ic23tlkxB16H/09fe9a4/ARumo5g8miGqlqhWDJo7jH/Gg7OacT1xRFIHuHXK7qqPMYC4iP9l+0B4RI1s891zHf866CS89EgvjIqcvkc5AFMOj0efMUVcQMc36cyjsazBHKk0jzhqFGObg6gDTFOwZZ5Z1L69onN0G3Zv47yGwX6Yy3oCappAxWue2pUhG1Q8n+NGMB8AmdpT9QLwOZzjrkT3l/yXpOyjVlySrsRJXgMSN/LV4/7f4FDS8ecKuwZan88IMuGp7MpuuGFdQSMcQQzGARkmrKchx9Z8z9k71FwR6DNyjcXDl0Io4fjnAx8jg2LrZmk0UDuWASg== 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=TQmv64da+NeRasr5CDRQ/fRlLIjqCt0lt59FOgxkGsA=; b=MepFH9UnfnEUEszWK8738xulL5TSUqKrqxPHoCHQxKmEhlKlO49y4FA8lgnpVbPU99uFXOV99AvluA9BjADUtsxFLZR8tYqw12UYUBYcP5cbOZ0pOYnvLV8GoIjkJRoGVmkSAAYZhd+LD/RGig4Wdck8D/T7Kx+8WXvWYsSYLY1pOwBH6z/ekMC1xbkI8TXtBf/vDlvvRr9g78MsSgfBLpb1YOwMhQ0FkNNQjxyPz9E8ntAXniN0Oj7yN6pCsGSQi2gQCdB9G/7dftKiHTG8iD6ZY1DKnPXRni//TR8fUbD5GHty/nePIWIMeQnRA8QjUAqPXG08SPnTJMZGL/IPNA== Received: from DM6PR07CA0039.namprd07.prod.outlook.com (2603:10b6:5:74::16) by MN2PR12MB4237.namprd12.prod.outlook.com (2603:10b6:208:1d6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 23:28:44 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::e6) by DM6PR07CA0039.outlook.office365.com (2603:10b6:5:74::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:28:43 +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 DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.18 via Frontend Transport; Tue, 29 Nov 2022 23:28:43 +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.36; Tue, 29 Nov 2022 15:28:33 -0800 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.36; Tue, 29 Nov 2022 15:28:33 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 1/8] null_blk: allow REQ_OP_WRITE_ZEROES Date: Tue, 29 Nov 2022 15:28:06 -0800 Message-ID: <20221129232813.37968-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: DM6NAM11FT025:EE_|MN2PR12MB4237:EE_ X-MS-Office365-Filtering-Correlation-Id: ecc8fd12-1137-4ebb-0f25-08dad261747b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XIV/OimGYvsmtlDdvWDk5QDnwXz2h5IEkKxjkOZYfmW9F+PBXdBUtd6gW33z9iQOZx5cbmukhJ1r4iCkAQSbAhEupDVCa96HTu/k5tCow+LcBJBx0dfGibxdTXv41uMrJ9jhCor4vZHQgzLegbaXRYtBgRMrLSu11CUJ9/0sOzGKP7OmblNjAhl5tu0qd3W9DVkUyXekpARs50RIdVeO76kw9oAdComt2tgL2aA1H/tT6RsNMKB7C9TwFi/Sa99XuDUrmraMQU6KoMnp2foRMZjQhdES2TEGdJFG99LGmFnUhb4FZUXaSaHtcImDcOOcFM6X7wQkHbSyhhAkbL1Uu3w273ptsR8Eh5CEMwVJbdGhyOQcaVKNg7KcdDNWURVW2/JEVSkxYqmnwjBJRzS1lbpyoqdPAXiZHKD1AToWB9U2sqtZtpDasQm/HGDGj5RarWb++YCXcE/jTvupNxtulBdedIz17OTJ7dcoFBpRF2pHrO6UCFxZbxnmES9rQEkNbvViSedX32Dxa0cXx5+dPw1lqpslXEz3vDishapoVz/KSq837dYXaP/eRiVA1PXSr59dGDyGlyi35IpJL+pt/bCzN+M6MEg0a9qr1ATF+HlwHXA4kCZKuPiIBm8sPUm0eFp+MRPuzoCVX0ix5R2EsiRqRZoQVcqPe4tfFG7kZ57esGqRPKNoIRvtrit1D1zthMBCDNXfaOUaCLUbuQjT6w== 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)(136003)(376002)(39860400002)(346002)(451199015)(40470700004)(46966006)(36840700001)(47076005)(36860700001)(8676002)(83380400001)(2906002)(82740400003)(7636003)(426003)(356005)(41300700001)(40460700003)(7696005)(82310400005)(8936002)(40480700001)(4326008)(5660300002)(336012)(16526019)(107886003)(6666004)(26005)(186003)(1076003)(316002)(2616005)(54906003)(70206006)(70586007)(36756003)(478600001)(110136005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:28:43.2510 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecc8fd12-1137-4ebb-0f25-08dad261747b 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: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4237 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. 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 Reviewed-by: Shin'ichiro Kawasaki --- drivers/block/null_blk/main.c | 59 ++++++++++++++++++++++++++++++- drivers/block/null_blk/null_blk.h | 1 + 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 1f154f92f4c2..2d592b4eb815 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)"); @@ -416,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); @@ -540,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, @@ -614,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); @@ -678,6 +684,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; @@ -870,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) { @@ -1186,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; @@ -1352,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 @@ -1800,6 +1849,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 +2167,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 Tue Nov 29 23:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059326 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 D2D68C433FE for ; Tue, 29 Nov 2022 23:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229875AbiK2X3O (ORCPT ); Tue, 29 Nov 2022 18:29:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiK2X3I (ORCPT ); Tue, 29 Nov 2022 18:29:08 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D0E71194; Tue, 29 Nov 2022 15:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fLNun627wrPKgUSxmnVojrt7G5p0JXW+9xp0s3HFLpLfP7Fbv7bx8pgLI5uA6YV0fwmhhbTfTNVYDWSCjWEPnYdi5LBhKCD89wZy6LCQPuPravWOU63TroLc5UgKdsLlXuDyFemwT3Jdv8n2FDVT+DeuoO9JWa7knUxcfqLu9jM2UvePVxyDQIro/wUqORBW0Ubbf7Mvp7kEv/JmZu80CutWd1uCeAkJ1IDNsEtQOKCOzVMJyYubd8fX41rncWBSycfvVCITsZN5xFmIN05vQrkQtnW3FcMFSVwB5FZumAYo3mLQ+GgK97b1WXY2Te3YuiygzwVAEvXt28vdMrQKww== 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=e11AYUnWIO4AX5Cfxa7Oob/PndRG79OvGGQMCbBVEgg=; b=DgypgLjXVohC1f1E0wJlXYg3O5XfklVy5CnpgKBRVenWLDT3jkD8jtxQ3Y665qiDAXHJcOg18v4N8jWgeQIi3pLtKZ2NsdDwbs7ZA3KvZUYYlroCLyFPpGyD1hZyyLP4Hu5bgV7MB6WinAwksBIyfRjbE0Yy1QencG03PsH4UI0Pj2z0nt7H6+qxMT8jfjlPUhgUZOcgJ/p/jP9nY1n8MbKEJe7nlDI9Xz39L3GjN2VRmvzRBQ/R404qAgYvVqB+E+tP0YrR5OLSFlHMMYnS0QYD+uqG2IqmkF4zbUjB8apT3rK/EkjXZQhShR4vMgUgCgKW23JHTiDmhsBeMVMHmw== 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=e11AYUnWIO4AX5Cfxa7Oob/PndRG79OvGGQMCbBVEgg=; b=fFJAVBbx47knC/f83OuAp9YrmxDbv2JZF4gJWWAeh3kkxUN7SXjY29kHPkxxGuIQ2JrNiKMV1Ojrw1FDmIXCOTCgpEM7c7Uj+hIv9FBky5oR7UeEfOaJUKm25JU7Zs8dHPHK0wwgv32C6DHXTk5i4GOX/2K2IguQSkf3x6cs885LuNDXzSNisLVzfmvKkQ6ETJapYh45oo7SLceK4iEQYN+XQxfD9V3mvIoxyh7PVMIOSZ0O3Ks2ZrK7/btwgWbGYcGos9/jqCajJIWbKS/FYgbqWXRJZTEj3gE+PGxHKfli1KQWe6w9Q93orgSVewcetBHSfAzrjt2OuQO1rZ2A8g== Received: from BN9PR03CA0158.namprd03.prod.outlook.com (2603:10b6:408:f4::13) by DM6PR12MB4896.namprd12.prod.outlook.com (2603:10b6:5:1b6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 23:28:55 +0000 Received: from BL02EPF0000EE3E.namprd05.prod.outlook.com (2603:10b6:408:f4:cafe::f3) by BN9PR03CA0158.outlook.office365.com (2603:10b6:408:f4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:28:55 +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 BL02EPF0000EE3E.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17 via Frontend Transport; Tue, 29 Nov 2022 23:28: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.36; Tue, 29 Nov 2022 15:28:45 -0800 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.36; Tue, 29 Nov 2022 15:28:44 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 2/8] null_blk: code cleaup Date: Tue, 29 Nov 2022 15:28:07 -0800 Message-ID: <20221129232813.37968-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: BL02EPF0000EE3E:EE_|DM6PR12MB4896:EE_ X-MS-Office365-Filtering-Correlation-Id: ce26b894-e317-4ee0-49f2-08dad2617bac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NriU3H0N5asmSq6q3UXFWtHOtqADJknRZGG65NNln1yCnaqcD3wkMIzdJyBW9m+umdpuMLcNT7KG4+BEmz/NDglJ46RwRnYKexB2orvGF+oMsXJf5KEEURSiBj82yqc6aiy8A4hpWhUSDcGyx/ur+HSZz1owa/DjfO+87XzKwpMmEftHFvoIjqnIMXG/83ymSqpxEO92ueqPAeO6DXmeM+y5eKt8ABfolQ7YGLvD8oBr81lb9sQIO8IMiQs2yH837WytTxziXrEF7FLgLWi5d+vouuQwpQ0yO/WffwjO25mr5UlQZ0Cd0C0AECae0oNI7jylp0mEHAGqkoIpuhd2BI75CaGjaEZ3xI3/w7LM5JfQU6DdKZv+k6elowDjGrKzesLJGxe6mHKRgZbQlMTDTtRfAEtC6v5kD751V8rguLpFnhYV4mP8rlUum1/3urUjjYBoxF719j+X2Qj/0n4DrhVHQ9fkZXVym9pcjxCNiS2wQKUNd33VYyeMkBxlMgJID/Mr9T+L6SF+aIyViiLrVGwDi0TYvNcsOxiosFplIFKBbLaHztCv8ULS9PVEdVxfbsBUHrH+74RPFTjXXpOhU+Kfgo6kvx8D/FKaUW444xoLP/ujf3pdVecLyB1hKumLrf1NJjWauArCka3Ll9HscSFqmGA1oRsGUnq5CvPHrabdTKp9nBXH5xJvh6Ze5YAtSQ0A7Hlw4yCawBNb6txfFw== 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)(136003)(39860400002)(376002)(396003)(346002)(451199015)(46966006)(40470700004)(36840700001)(40480700001)(7636003)(186003)(356005)(4326008)(107886003)(26005)(8676002)(70206006)(1076003)(8936002)(41300700001)(2616005)(478600001)(70586007)(336012)(40460700003)(6666004)(7696005)(5660300002)(316002)(110136005)(36860700001)(82740400003)(426003)(2906002)(47076005)(83380400001)(16526019)(54906003)(36756003)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:28:55.2864 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce26b894-e317-4ee0-49f2-08dad2617bac 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: BL02EPF0000EE3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4896 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 Reviewed-by: Shin'ichiro Kawasaki --- 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..fa47fab279c3 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_OFFSET_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_OFFSET_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_OFFSET_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_OFFSET_IN_PAGE(sector); t_page = null_lookup_page(nullb, sector, false, !null_cache_active(nullb)); From patchwork Tue Nov 29 23:28:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059327 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 59127C4167B for ; Tue, 29 Nov 2022 23:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiK2X32 (ORCPT ); Tue, 29 Nov 2022 18:29:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbiK2X3Y (ORCPT ); Tue, 29 Nov 2022 18:29:24 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6C686F349; Tue, 29 Nov 2022 15:29:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuiQHGEPxGwhbntb1f8ZGpllQW2iRMry/HF9urhPB0PtKVAnMsgMsemhAVOSjBF1TCPmnCKlG9Mi/xnVnt2CehyHEXVmATTTDP7iKJwDKdRmmoO5IioTWmf4/jaVSzqEJTDu5mzWoI5dFFbc1jlgT7EppEGFs9AxDX11yK2Nc97IgLKVahISieL8Q0HMy21uboD/DZb/Vlekb4ujBhuvGBOJhzbs+wWj/OF376lvaqBa84A7Kznl8PZqiFagSxeuw/ulioieEufUu4lHHIzQMIXQO37+eQRulOt0IUjC4jNa93nwgALKEnc0ixwOzgTAw+nxSYM2O1nJCo//74Yxgg== 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=PZZJAecIDxYJNi/PEEW6yXAKM5a+NxESkCX2vkJOAAw=; b=mjLyK9xnBp8h266j51b/7u4yaEUzxBhRfK0ifp+4AGRyv6XFrmfInDRhft/T6gdtZAbsc2OEZLPSancewjaQWD7JCXFDzaQcx9+875O4zPZKqCrzlYjrrZSUUzEdvEAJHcWrK7MY5Jr51OHJJp896nU8uYdHmMIcnCl/ylQDNSQ7qFQUaeostqZNPiBF0mLqadD1GTp6sXKfX0THC3cXeMLakZ01Ya6D83imtxoVooJ6vk5amYvKVI1QtjUTAKSRluCpcrQixp/7NGye5ESXp4vb2noSp3+vgu1/Jr9sTBkphhqDUmszr0oNfQ2XqnV9zvV5AO9z3q6a5jhwFV3isQ== 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=PZZJAecIDxYJNi/PEEW6yXAKM5a+NxESkCX2vkJOAAw=; b=stAldM5I9y5cWbf99HqyrK0vIxsQ3a6qJExSmrreLvmZJJw4aLx2pFs4g30C/XLheIGLfsXj6uBrdwRMtylQTrd25obYxUIMqCrpkNW+A+hDxqciAQfavtjSZ/9bR+hnB5UH6aKBpjceT3qQY2ZFo31NQAtd8qRO/P+h9ghJSaJ2CfTwBvZqiYSpRXA7zlEnTNi3vVUMxuPTigqITMpNSVTKyv6HPd4mddXofpw3f6Jtc5oPrFhzfTF489YEl2qaXg5W0aofSa1AEhBroLq4Cv82yTrsqGyTJRAGLBQDrHa7btQE9AB6KJytVIamOW5iFC/aAop+Y94kZk4gERTrJA== Received: from DM6PR03CA0094.namprd03.prod.outlook.com (2603:10b6:5:333::27) by PH7PR12MB7986.namprd12.prod.outlook.com (2603:10b6:510:27d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.6; Tue, 29 Nov 2022 23:29:05 +0000 Received: from DM6NAM11FT067.eop-nam11.prod.protection.outlook.com (2603:10b6:5:333:cafe::9d) by DM6PR03CA0094.outlook.office365.com (2603:10b6:5:333::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:29:05 +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 DM6NAM11FT067.mail.protection.outlook.com (10.13.172.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17 via Frontend Transport; Tue, 29 Nov 2022 23:29:04 +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.36; Tue, 29 Nov 2022 15:28:56 -0800 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.36; Tue, 29 Nov 2022 15:28:56 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 3/8] null_blk: initialize cmd->bio in __alloc_cmd() Date: Tue, 29 Nov 2022 15:28:08 -0800 Message-ID: <20221129232813.37968-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: DM6NAM11FT067:EE_|PH7PR12MB7986:EE_ X-MS-Office365-Filtering-Correlation-Id: 27c37351-2862-4a15-3d76-08dad2618120 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOTc4ByalVjYl2zOmmG4CXOnzE4yMOB7poAnYqXBegPD5a7VWR0hC/SJm5dNeVMJB7fc645hML6OV0JZQ7LHm8llC4eGBCtP3dOgaJ79pjYAWyFG9l5RzU4MkT3IXF2mhvB9kV91IMPl5VDfWL6VjgyhjNSStQrg5DdUeemLYqwDmhp8ssvQpGDzSM3sxA6GFP1VbFvl4qOEAk1/hE88wVQuMVtM558yfvAYNPMx9WaE+0b1pAByj5oTrZ6WSxV2+EJBajztr14QPu1OwZfDkyxp7yn1nOI96WSmZPxgQ9cqmL2DT4cKj30eggRamZjgLS7GOP+aT5dfOvHGVYh4oeQCD4MJuOS2O0KfuhdNSuH4wlzDJCrVbibg4vKR9bARbXkbvmWho8xRM8MLPUZzWNarfHv6tXFWc9DXtjIRIX2yySvB40xDnlib6QBDmpx7gsQtI5jeZucc0VjLE5nQJFRDIP6w1w6nI7gTouw+sDNHZxpmDsEAbGFcGgXCEsEM6Ww9gSvyp9rF3re/wX96VYteMtdQmgMWlgyDRREq3/UJRW7yonRMUs49tI2fpMnm4HZ2gBfnByxwz0FTHSyjg1zADVJUvHkOnKd7Be4wg4PH0PJwNCu9FeEqdiWu+Lw4TrJ0CvPpNUVKEvX56fn008cX2vvuDunCDconqjuuIMNXtUYXkm+k2rICVCnxFtfh6ep9EJvhjIZnGv5kwu3FCw== 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)(346002)(39860400002)(136003)(376002)(396003)(451199015)(36840700001)(46966006)(40470700004)(2906002)(41300700001)(4326008)(8676002)(70586007)(70206006)(8936002)(36860700001)(7696005)(107886003)(54906003)(36756003)(2616005)(110136005)(1076003)(186003)(316002)(26005)(478600001)(16526019)(83380400001)(82310400005)(336012)(6666004)(5660300002)(40460700003)(40480700001)(426003)(7636003)(47076005)(82740400003)(356005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:29:04.4818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 27c37351-2862-4a15-3d76-08dad2618120 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: DM6NAM11FT067.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7986 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The function __alloc_cmd() is responsible to allocate tag and initialize 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 Reviewed-by: Shin'ichiro Kawasaki --- 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 fa47fab279c3..84f5ca0cc79c 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 Tue Nov 29 23:28:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059328 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 89664C46467 for ; Tue, 29 Nov 2022 23:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiK2X3e (ORCPT ); Tue, 29 Nov 2022 18:29:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbiK2X3b (ORCPT ); Tue, 29 Nov 2022 18:29:31 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2063.outbound.protection.outlook.com [40.107.243.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 214466F35C; Tue, 29 Nov 2022 15:29:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QFu8Fc7pVCCbIAuyo4yUGRfcFG4JdM0rdmiEpJGOqqICIyBMmXHFHxKH8Nh+NpWae8cjwiqC/5C2emNvI3B8roVlpeJ6V/oOC3G9g8w5LBTowyARk81IcQvEAu707Th1OPQSnz2JBAi/sUrNKybCIyalP45ObjezRvveCC5cNkUnBUvy4XS+KlKOBA1igpeC4dWw3aA4E8A36CApZW0g6Zpz//oit4S7sWFecfaMtXaA/tGq/tFotEUBx1dTYPoIOMH3Csk8dEuuzFSLRVYVDtKW609CvB7crjR5vLLNBkTES8WhW53lz37oNCXVCq+68KRwmgcFRT4du74pfJcuVg== 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=nhqnQ9+IRStfTM1paQcWDVCdN1oRNJogWVL+ureO1/w=; b=gM8NqtBYHRp3gQP/atRhJsI/+5F/7zPLJYiOi8lCDOgAS8mIs/sI+p7SpP7GDidbZKDAUDAnoRIu3ATivQW7DSPedxQszwkAe012MVD9ymkf8zjhR3filiTKnGLcE1HU47j20DuVw/fsz1KmO6S4btczNindOXYzqMu53+w7byIPzX0LmC51y6qr8ZFkWxx/VsNW4j9RTqe/BJx4YOiQt1Z0aH38JztFsEPK5GWPI03mWBKqgWIP7+tlH0nXJprtJfpg9u3brAaHgd/IYDEeAbO9f2qGAze1z4hG+9npliTTRII6NoCGEtmfLSVExYzUtcbrwWJMVBND8Kna99OoTg== 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=nhqnQ9+IRStfTM1paQcWDVCdN1oRNJogWVL+ureO1/w=; b=euvtf9Q53YkvEPGbOKE8riWKhoiG0JDyVVcDWMDdV0l+3LIKXNAKKohQd9MoKDnZJlD780Z20c5EyleT3/r+ImIPWF4J1T1Tam0UR2KD5zZQuePTEZQo9zuua+qmPZf7rby+7TQjL7TrwmbcDueaRBvIKOciMhz8ZxRyKKHLdO8H6TcsEdFVoMWUXoB52RRaKefb+AMyFZSiG7YgP/9vSJ7KQ8J7Z5opxYKQPqxlUhukujW2DuEWpJ/D/OWpQ4FmWCZOFIZ/PBXgW8jozb9xW662KOZtxTi4g0+bJWKszIQ41U4ToeXD1plikfdn34mOfk6NdBGXYFGoFJlXk9NL9g== Received: from DM6PR03CA0069.namprd03.prod.outlook.com (2603:10b6:5:100::46) by DS7PR12MB6008.namprd12.prod.outlook.com (2603:10b6:8:7f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 23:29:16 +0000 Received: from DM6NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::c1) by DM6PR03CA0069.outlook.office365.com (2603:10b6:5:100::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:29:16 +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 DM6NAM11FT114.mail.protection.outlook.com (10.13.172.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:29:16 +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.36; Tue, 29 Nov 2022 15:29:08 -0800 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.36; Tue, 29 Nov 2022 15:29:07 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 4/8] null_blk: don't use magic numbers in the code Date: Tue, 29 Nov 2022 15:28:09 -0800 Message-ID: <20221129232813.37968-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: DM6NAM11FT114:EE_|DS7PR12MB6008:EE_ X-MS-Office365-Filtering-Correlation-Id: 0087c2c2-909a-4b42-83f8-08dad2618875 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fno9e0uUwovtI6vG3qknSsN1RN3GrhyVizEdNy9jDWfsRXl2x1Er4wA0exv2Zvml1sN9G6Lp4hYIjqxQcXGaiPABBsWx2ZfWwigDPa3ekZJ2IfjCfYGEAWuHAesCpwN3Xss5BOgecHvTYxnvY2+ejumwlH+RYFc+wML5gX7RvdPfMGcXEz0Dn0EBPmilascWa+LKYRlxxx4Nki4TOAqkwCFgCygCDXeMTSpIGwL2GQk7jYEs9FhS8W/3Y9tp2yQKDoZMOIqV3SCjwzJ3dqWZMOb+gvwcl/44uwIDqhIq+zJQYUMG0Q/1nnAbuyelxzGr76apVotHoePGKBgyLndDBWsBXBQGFwMMjz+SgM0X+6M7Wow18JpOqvGAXuy6Imc1R8Hrdy0KtK7lo1n17G7FIDap1rR87MHH3W4vb5+KgwwRpdvzriHA5UN5VX9BhR2A4wmy7MI+WdeQEo9JDcuh+W5MWJfoZ5bikrXFCmF55H++zKr/LAJjbZ7N8P6HgBWv8Wj3+KehlCIW3tFEthCU25tAx7/80bYnZcZKGOjXUl62ECPaMEAHIQb/J2H4ayB5MymxCcBcwgeF7TqdYp3E3Oi5UzzId01MuoVx85lpW8DdhAU8nSmWyowqF9E4x9GuW8TvGOSTGRd2QZ1w3J1rLx0a/CUggeibuQorYE1kAB/AOX0VJyt4KLHPZCPbPpmMX8HCREQDHalSJ30uqWTXWg== 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)(376002)(39860400002)(136003)(346002)(451199015)(46966006)(40470700004)(36840700001)(2906002)(8936002)(41300700001)(82310400005)(107886003)(36860700001)(70206006)(70586007)(36756003)(5660300002)(40460700003)(40480700001)(7636003)(316002)(82740400003)(356005)(4326008)(8676002)(478600001)(26005)(7696005)(16526019)(186003)(110136005)(426003)(54906003)(336012)(47076005)(1076003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:29:16.7847 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0087c2c2-909a-4b42-83f8-08dad2618875 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: DM6NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6008 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead 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 84f5ca0cc79c..db849e6bc475 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 Tue Nov 29 23:28:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059329 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 505B3C4167B for ; Tue, 29 Nov 2022 23:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbiK2X3v (ORCPT ); Tue, 29 Nov 2022 18:29:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiK2X3k (ORCPT ); Tue, 29 Nov 2022 18:29:40 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B3AD6F0E9; Tue, 29 Nov 2022 15:29:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OSzzlrN2blHqxTzwku1OtO3ykocWNsIUByEJ/yUDgUyQcXUVqLcCACAeeGhmN7mVdSF+vkXd+E11ivuTNmVqlk/PHgjpDwbCqjYbfBjLFKEMZVIaXP+WwUlytFcJGcCG/PdIYAVLMVd67s7BiBt4L7lKIh8TYFOhKuYd5cVBqbN6N0zp/ZVEvvfc3j0cPLAMybyUMO3Pj0Tjss8+k8eoKtYDESyW/PoQ9Q1LsfUh4ieRm87HHNpcbfu85ThuqrLrJWSqNPl+OJTb9NVAHPrHU+aMv8D8ETp9w8ZYaYfS3cRMZUq1Brp20fB7/y44LU1sPhepqGA+P0QM6ZVccFiD4A== 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=KiLAjJ+YWiKO/cZsJFmLCEH8r2kiulS+akAiHUDdbmA=; b=fCcBFEg/kp4G6iJEk9lY7xy+LRpy+iZ0PaY2bEcpVJANt2pr20shFb5QkMmx3axpiMb62rCDpINvaZTCdBCi6h5rupSHgYS4vaidc8l787t+xUxHQ/aZAgTu7Bjk5jKB5QqXXYQrf+iezPE3VMtSLwDZrVyrLWIUv8cJUMKQM5P/zYKngBxh4LF3KJUVjH5KYoRCoM6K6rlUhzTfbcSzwBCJ8yyLMv7Ca8OSOWrBTyOB5vlfUUQp5vYS/HMDxGJwHiaKALfqAnKkYtXiZakTrfwypvKCtNgjtJAN8uWKwEREWvMPXKbE6wzMLhb0yiswqbuxIDY4X2TGYJ4cwLGqMw== 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=KiLAjJ+YWiKO/cZsJFmLCEH8r2kiulS+akAiHUDdbmA=; b=YBvIj7YOnYvQnR8p6+XcDwIRSIiskI0NhPWYVaVluKEVqXtO263MxNYwK2SGAD2mUFysPGDC6aSSs0VUtz5Q5HpnzIHNtJAHp1KDLUPISuLZuBHNUMcWPTDdFD9MvJDjSz08tjvxEh+IvNCVIxmnKWAAAoxVW14eC2gkOItjl1VPKOxgICrUvzKr5hxLE9KfFnxK9M9EnK45bjCc/g44Bu1QjywclJt6Vfdbc8ZzV9QS/wgBFVnju1hsi8DI+GH09ErOrhj0289mpT5K3XE6v31BWnXITxkaXYJuPtG6diwDsTtLelIWXNHQHWZiaqpE8RgfU+O2etLkiQSS22H4mg== Received: from BN9PR03CA0172.namprd03.prod.outlook.com (2603:10b6:408:f4::27) by DM4PR12MB7501.namprd12.prod.outlook.com (2603:10b6:8:113::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 23:29:27 +0000 Received: from BL02EPF0000EE3E.namprd05.prod.outlook.com (2603:10b6:408:f4:cafe::10) by BN9PR03CA0172.outlook.office365.com (2603:10b6:408:f4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:29:27 +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 BL02EPF0000EE3E.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.17 via Frontend Transport; Tue, 29 Nov 2022 23:29:27 +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.36; Tue, 29 Nov 2022 15:29:19 -0800 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.36; Tue, 29 Nov 2022 15:29:18 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 5/8] null_blk: remove extra space in switch condition Date: Tue, 29 Nov 2022 15:28:10 -0800 Message-ID: <20221129232813.37968-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: BL02EPF0000EE3E:EE_|DM4PR12MB7501:EE_ X-MS-Office365-Filtering-Correlation-Id: a347a6e7-91d9-4e43-e06e-08dad2618eee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gPpF+uSj6OCRV6CHpJt136tRVc2M1MrzQH67cfWXaBlusKiAw0jqU98JUugZ9IXxRX+t+tX/ISoPazKP0uYpq40KnXYrSfPY0FILoX/0mFoJESyyx11zdOCqmq1b4+DYfGiA22uP9Q66rkVZHaHHp92vwO+JwRi228YA5dAJFfUKbOw6aAilMHUG4CuoJQffzkjmAEaQ36XVb62QKgNp+KdjPQJrKSTUX1AfDBvP/4E90aFUo/WEELOQA9uhSu0snDH4/WItCxY0jO7Zsmv8mbnr/wDflLbcaxkrkWTSeziLlWO0AdODpKu4yRFml775ls5ZHZyc6b/nThTrT373NZKRP6CiDx//y3jtnHoGm60F+/9iiedh/23RdT8wjh9N9k+XZDH28N4dwu6BifQlRCGM/EFOhx4ox6LuF0FkKX06tqwQ3F3EIidDJFXldxrqEmE/pq1kd8PTGqmJBOKVSjgpaw9JPOP81NziOuhDQweZ2m88cHwsbwhqa6t6gArfUXk9V1wV8oZVry3b473dOWXpGFkzTwMHq1oGCTctq5EMWX5ndnvzk+lSUu7/SZl0bhTNtsbX1k8EVG7kqzaZARzUMKEt9iwGlOFSnEGE2Xnj1Rs3N3kDrgA0pJYfYDZmStxtR8DcY0lkoqrXcyjEQ7FTRyyd94X7n239QjshiFzGFgaOQtZJ9K11G9oOOTnwp4i++03i2X8MKj3Oh2M6cQ== 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)(136003)(376002)(346002)(396003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(40460700003)(8676002)(2906002)(36756003)(7696005)(36860700001)(4744005)(5660300002)(41300700001)(8936002)(4326008)(6666004)(47076005)(107886003)(83380400001)(16526019)(26005)(1076003)(186003)(336012)(2616005)(426003)(54906003)(356005)(110136005)(7636003)(316002)(70206006)(70586007)(82310400005)(82740400003)(40480700001)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:29:27.5214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a347a6e7-91d9-4e43-e06e-08dad2618eee 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: BL02EPF0000EE3E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7501 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 db849e6bc475..96b8aca5abda 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; From patchwork Tue Nov 29 23:28:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059330 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 6DD18C4167B for ; Tue, 29 Nov 2022 23:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiK2XaN (ORCPT ); Tue, 29 Nov 2022 18:30:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbiK2X3v (ORCPT ); Tue, 29 Nov 2022 18:29:51 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2042.outbound.protection.outlook.com [40.107.212.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E1B71195; Tue, 29 Nov 2022 15:29:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZZDjsEMLTSEpns8GiNKL03F3M2nWnJMheq5dg04Wugz8Erczh6F7xzAXz8tkvTanuy5fO1opDS4f7tKErV7k4Mzzkof49QTnxh0pun0lBiVtZ/Gmf4NynA7IxMTczOgSglHSEixJGUSDdg29hlfQ1WdCmbcVihQLm0l6GRs4enD/XnJel84WYoV94UV6mGMuNcbEhMlR3z5YXfrZVZvY4h5Nb0wyFQuRYzia6x6f+fnNGtPHOuJOPJQ/qv1QbZXXa2kfqwIfd+XCPyPuBTVsqLmZxRc4M5p72VZ0LRZjtqpdBRWXLWJ+6cCBzjdLj3fcWp9XPYp6ji8erNaAmmWTw== 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=AIe4mKOyn70BXMu9ewRDR6BaGZiCjfn7IR9cPrqCt9M=; b=L5N+ko/MoXO/PSPX4oqNCPe4zwnz5CcG1wbIEH+HIxDk2DubN+39zgdZTWng+VlFmoddiByQvu0aH2dLCN9T+JkeB1JitvqaWLA5NTKjBFBef86fiFM2Tptc2c+xAYrFGYpGbJv7avLeMa7TjPXRZa1ExIwwGSx0SgfHEbcInXx8mTJmawibVAV2eJJ9j3Ukg7/JSNq2ggtUVEdmmF5byICVsk2HOiSNV8e5khNPILFuXPyy4Is6uT8dC4JV6NAbIoJa36KLSKXDOHtZ2E3u3xPU7wsT8oMk9jc1ytg27+OYYKPMxEih9UW2uVb/t/eDWXzHeEDPLgbZFodJEjJ9sQ== 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=AIe4mKOyn70BXMu9ewRDR6BaGZiCjfn7IR9cPrqCt9M=; b=GTgtjxDADylS9Il+VOuY1MUuhSsy1cBPkDY4ziNNS2frPCCzeWjIgxZCIX563abPZzCFB5x/fycf81/Mg0ey98OjHyb/jUnaVz0tw5d6OoVWRHzYS+JDYlx08+60L+Y0pBRjyz2bfk/RSQU7fwpvm85UHGHBmdBZcpp7IoeAQezP2ffJJp+tyUtXav08hMfYJjOh46ex0GKEzas0XQ31buHhHaW65UeYp0Pvkzn5ZzjpucZF4ptd8G7VqKe9iH3nJ5BFks8Lahp9yNZynTuoc1tvkALMoJisP2GbnGfsKehOZhaI0UaK8FW4fBQED2M6hECMxPETEUkbB1yC8HZmKA== Received: from DM6PR07CA0080.namprd07.prod.outlook.com (2603:10b6:5:337::13) by MW4PR12MB6729.namprd12.prod.outlook.com (2603:10b6:303:1ed::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 23:29:39 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:337:cafe::f3) by DM6PR07CA0080.outlook.office365.com (2603:10b6:5:337::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:29:39 +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 DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.21 via Frontend Transport; Tue, 29 Nov 2022 23:29:39 +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.36; Tue, 29 Nov 2022 15:29:30 -0800 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.36; Tue, 29 Nov 2022 15:29:29 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 6/8] null_blk: add param to set max disacrd sectors Date: Tue, 29 Nov 2022 15:28:11 -0800 Message-ID: <20221129232813.37968-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: DM6NAM11FT010:EE_|MW4PR12MB6729:EE_ X-MS-Office365-Filtering-Correlation-Id: a2cae71b-d97c-432f-12cd-08dad26195f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LeVfjxuzxwNIPAI0hn7SyD/a45gUILPYe6+Kq+3YcrVtsrLd7EddXqAm5rB2xpzMKuwlJUE0E0xRS8Qw42vbUG5i5L+usI2yooVEHInb8wIU+XG6BSwwGKu/xKFzx/OKWNjqlp3NaQXdY6hcDfOYzHT8ONihjqV2qJybyera/YwtLCJuugtaI6XN55bDxcBD6uOMpNa75qq22vWWS0p/qyM4e+yq0skD/ftaj/0ZHwfEX7p3UUDJPCAQwonzIsGB+0ab/Dsg52AHKQqSTlsHWyo/XKAI6dUp+2Tx9NUCqH7kZFSdr9DSvacoJjG9J/fy/fIZmqOTmvqTH6Ve++K1MHxrNsmqJzY5sqfgbu3MV8K/TRLwXXnPsFM7sjwNbqoH8asoxJ5WMl04i3lw/9nOEborvwuhsWQKcOMvdi08HCR6GtavyFTHcHUDfR5J41ZrfWohlYmPOlhonyPSLIl/8HCRL6QdustVSIbkoEK8vo8N4B2QJvR76O2JglmV0lL2sGLN9SIHWjBn2We3NMToY8y9lqZj0QIO9UOcmKOPnaw10Ul7D/aexfo4IUqITK9eBpiJsq4zqhhoXEkp7TREFIiFosB8IlOkm0gavALTHZv5ZKuDFJgnidgGVKVwMoGKAXAjSxr3EUNFNH0a1TE+7DT/frk/s1PoJ7bkG/q23FV81Iza5xeOavZPuh1IQphoqpaMrvTec8DLcHr/I943Ow== 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)(39860400002)(396003)(136003)(376002)(346002)(451199015)(40470700004)(46966006)(36840700001)(26005)(107886003)(6666004)(40480700001)(110136005)(54906003)(36756003)(40460700003)(7696005)(82740400003)(316002)(47076005)(426003)(7636003)(356005)(83380400001)(36860700001)(2906002)(8676002)(70586007)(4326008)(70206006)(8936002)(5660300002)(336012)(1076003)(82310400005)(41300700001)(186003)(16526019)(478600001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:29:39.4114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2cae71b-d97c-432f-12cd-08dad26195f2 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: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6729 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of hardcoding value for the maximum discard sector to UINT_MAX >> 9, allow user to set the value with newly added module parameter max_discard_sectors. To retain the backward compatibility make set default value to UINT_MAX >> 9. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Shin'ichiro Kawasaki --- drivers/block/null_blk/main.c | 10 +++++++++- drivers/block/null_blk/null_blk.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 96b8aca5abda..2f787807cf63 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -216,6 +216,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 unsigned int g_max_discard_sectors = UINT_MAX >> 9; +module_param_named(max_discard_sectors, g_max_discard_sectors, uint, 0444); +MODULE_PARM_DESC(max_discard_sectors, "Maximum size of a REQ_OP_DISCARD command (in 512B sectors)."); + 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"); @@ -420,6 +424,7 @@ NULLB_DEVICE_ATTR(home_node, uint, NULL); NULLB_DEVICE_ATTR(queue_mode, uint, NULL); NULLB_DEVICE_ATTR(blocksize, uint, NULL); NULLB_DEVICE_ATTR(max_sectors, uint, NULL); +NULLB_DEVICE_ATTR(max_discard_sectors, uint, NULL); NULLB_DEVICE_ATTR(irqmode, uint, NULL); NULLB_DEVICE_ATTR(hw_queue_depth, uint, NULL); NULLB_DEVICE_ATTR(index, uint, NULL); @@ -544,6 +549,7 @@ static struct configfs_attribute *nullb_device_attrs[] = { &nullb_device_attr_queue_mode, &nullb_device_attr_blocksize, &nullb_device_attr_max_sectors, + &nullb_device_attr_max_discard_sectors, &nullb_device_attr_irqmode, &nullb_device_attr_hw_queue_depth, &nullb_device_attr_index, @@ -686,6 +692,7 @@ static struct nullb_device *null_alloc_dev(void) dev->queue_mode = g_queue_mode; dev->blocksize = g_bs; dev->max_sectors = g_max_sectors; + dev->max_discard_sectors = g_max_discard_sectors; dev->irqmode = g_irqmode; dev->hw_queue_depth = g_hw_queue_depth; dev->blocking = g_blocking; @@ -1850,7 +1857,8 @@ static void null_config_discard(struct nullb *nullb) } nullb->q->limits.discard_granularity = nullb->dev->blocksize; - blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9); + blk_queue_max_discard_sectors(nullb->q, + nullb->dev->max_discard_sectors); } static void null_config_write_zeroes(struct nullb *nullb) diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 2c0c9c29158f..09940211326d 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -102,6 +102,7 @@ struct nullb_device { unsigned int queue_mode; /* block interface */ unsigned int blocksize; /* block size */ unsigned int max_sectors; /* Max sectors per command */ + unsigned int max_discard_sectors; /* Max discard sectors per command */ unsigned int irqmode; /* IRQ completion handler */ unsigned int hw_queue_depth; /* queue depth */ unsigned int index; /* index of the disk, only valid with a disk */ From patchwork Tue Nov 29 23:28:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059331 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 C1274C4167B for ; Tue, 29 Nov 2022 23:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbiK2Xae (ORCPT ); Tue, 29 Nov 2022 18:30:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiK2X37 (ORCPT ); Tue, 29 Nov 2022 18:29:59 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2058.outbound.protection.outlook.com [40.107.220.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8CC6E57C; Tue, 29 Nov 2022 15:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0MKENUU+7VBJHI0InFyKjDNZIh0PUdB5L7lD9WflVJCDs/bTvvC5VAIRKnfJpnfGnCYgnPsZpSrFvYLQ5XWfoYbkrk17YulkWMpUgq8TSzfQ424l1ofJ53FP779zTGzhNqkKsKENdhX5GI0j/2jYxJoZd3o5OB799FYZfX286uasPEkk6Ba4zUUpn0qclUpyM2raDH+dtuqKdpH96E4dYsV8DWDk8T8JW4gMkKbO5vZ5XmTVfC9yQrlymmYmusLYmUHkePfcnIzjOHXtYOa9+BHemNwPZG6NOR7fbUyJtk6UAOZkszAgxXtS8Oe/XY+tnd38WAWXM2C98L1SzY+Hw== 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=nFqgZ6hkvB+UNHlLEnApNNs+eawUZVXnNm+limTbryI=; b=SW+EAkj1FJ2Mrycaxng+5scVYisjZRBgvOLl+K1GQyFwGDS8VL6pGQcRITe8HizK/DDea1x8v3Z42C5vjmQVQv4X7sdual6XwIZC2DloygqVQpofP/Dn1BL2itzLQOBax/7tjkSFqvmeccNrWuTnoKsUNDh1TahaDDJC/LX24Q1+yUVqZX9TSCGeamlsrQSqmgICZLqHP620olxrjX4aHgKnQsy/aULLLV0h1+THubKC5SucNFg4K58R/pDlx9nScF913MC3nGNZuKUqshAfOkuvioRH0AU/XjqZ8HutRrnEBB1sj24vJN4qxQnHE502y69qSEpebmgVUERjJzU4dQ== 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=nFqgZ6hkvB+UNHlLEnApNNs+eawUZVXnNm+limTbryI=; b=Y7V7L1cB5YntI4uRFgyB31ntPDInqwUV9yJq+ALmeRGlcv/fMUwAHEhow8oGy/+GTejDv+aqJt+tvet5MQrKTlLhqZtFPMID/vCUp/SCK/rQETAb5RzZeHnIhrUY0elf14FdvBDtMKEJGZVUk55jI5ka9lOghqCAX+Rp+/WUC7w1CPtrYE6K8ysVTAcybUud1GPIeN5b+T9Ud6fBkarRMnOvIvssqytdbjdsg2dssWiz3nBizHtKJGnARqjg3NGyz3Ksiep/1C4wN8MIbRlIrP/juwHFdDXUccNu5WE0Vzrl3EvhlVAG9mJ6Scuc/f/s03naaJIkmu2yc2hy5PUPZw== Received: from DS7PR05CA0086.namprd05.prod.outlook.com (2603:10b6:8:56::7) by DM4PR12MB6109.namprd12.prod.outlook.com (2603:10b6:8:ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.21; Tue, 29 Nov 2022 23:29:52 +0000 Received: from DM6NAM11FT087.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::4b) by DS7PR05CA0086.outlook.office365.com (2603:10b6:8:56::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.13 via Frontend Transport; Tue, 29 Nov 2022 23:29:52 +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 DM6NAM11FT087.mail.protection.outlook.com (10.13.172.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.8 via Frontend Transport; Tue, 29 Nov 2022 23:29:52 +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.36; Tue, 29 Nov 2022 15:29:41 -0800 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.36; Tue, 29 Nov 2022 15:29:41 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 7/8] null_blk: add param to set max write-zeroes sects Date: Tue, 29 Nov 2022 15:28:12 -0800 Message-ID: <20221129232813.37968-8-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: DM6NAM11FT087:EE_|DM4PR12MB6109:EE_ X-MS-Office365-Filtering-Correlation-Id: fe1bca24-d97e-4c79-e16e-08dad2619d7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P+2ZIYSWRSc8rAfl6sMhkVe/UkNDTuoPY9h2W3fvk2tb5udpOpzw+D2Yk2sJHmRpVgr3CSi5cv2+zs4jYG9Ysg9PvHDoMteptC6DAbbsA4PPsdZfY/VRgx6CwtfW9QjZ9X/1F8aXX4bVHPgLtnNMc8bSwcP7SRj//uQYgiVFUK1fJSPSGoGvcNl3Snf/elIos3IXJpjUq8gh2RhjtE8NaApnmlM7mUnMSxQcAspB08US9ddkKy7wgSQ9M71/Hav/WIImtc6txO8Ad2udYz0EjmDOe4JrTrZshPMYuMnWKqDHV4MiX4xi//iDvd34kKW9yRyLivv+SHJrW4wjXY7wrppKMvAeoHAEeVjYQOI953g4ptskdXe0/swfBnc4aTVqm+Bz4nTfUXM0eWd99S0NTjd57RJ7WMZjp5bvOrQJnLGQMim58OKkCgxilru6Mld/DE13Kvqd4v9lsCFrf/AgtVY7ftAR/xQ9VqMK3nBI1xp+XQLkdqtEZP9B6u3KtaWYT67UeylcTCTUglZm/NzC6Vdc2MRuxLipZaANP0+XND68XUwmz1x0SyDpSc3Iq8k3CJqvTN9Jek2IyLM//rs9dT2ZWD6FfWYu8R1HFZoEUvK8AcJZnS2Y/vegqdygOyRx0uGzjj5BtMWGu1EYIYJdpitR4MLa17g8JwT9riUyCG8yyRA7UFzKhHZKr2CPrVb31rqBpRuZiCC7AUrtFZ9GEQ== 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)(346002)(376002)(39860400002)(396003)(451199015)(36840700001)(40470700004)(46966006)(316002)(8676002)(110136005)(54906003)(26005)(426003)(16526019)(186003)(2616005)(36756003)(41300700001)(5660300002)(4326008)(70586007)(70206006)(336012)(2906002)(8936002)(82310400005)(356005)(7636003)(36860700001)(83380400001)(47076005)(82740400003)(1076003)(40460700003)(40480700001)(478600001)(7696005)(107886003)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:29:52.0848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe1bca24-d97e-4c79-e16e-08dad2619d7f 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: DM6NAM11FT087.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6109 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of hardcoding value for the maximum write-zeroes sector to UINT_MAX >> 9, allow user to set the value with newly added module parameter max_write_zeroes_sectors. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Shin'ichiro Kawasaki --- drivers/block/null_blk/main.c | 10 +++++++++- drivers/block/null_blk/null_blk.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 2f787807cf63..8b7f42024f14 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -224,6 +224,10 @@ 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 int g_max_write_zeroes_sectors = UINT_MAX >> 9; +module_param_named(max_write_zeroes_sectors, g_max_write_zeroes_sectors, uint, 0444); +MODULE_PARM_DESC(max_write_zeroes_sectors, "Maximum size of a REQ_OP_WRITE_ZEROES command (in 512B sectors)."); + 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)"); @@ -425,6 +429,7 @@ NULLB_DEVICE_ATTR(queue_mode, uint, NULL); NULLB_DEVICE_ATTR(blocksize, uint, NULL); NULLB_DEVICE_ATTR(max_sectors, uint, NULL); NULLB_DEVICE_ATTR(max_discard_sectors, uint, NULL); +NULLB_DEVICE_ATTR(max_write_zeroes_sectors, uint, NULL); NULLB_DEVICE_ATTR(irqmode, uint, NULL); NULLB_DEVICE_ATTR(hw_queue_depth, uint, NULL); NULLB_DEVICE_ATTR(index, uint, NULL); @@ -550,6 +555,7 @@ static struct configfs_attribute *nullb_device_attrs[] = { &nullb_device_attr_blocksize, &nullb_device_attr_max_sectors, &nullb_device_attr_max_discard_sectors, + &nullb_device_attr_max_write_zeroes_sectors, &nullb_device_attr_irqmode, &nullb_device_attr_hw_queue_depth, &nullb_device_attr_index, @@ -693,6 +699,7 @@ static struct nullb_device *null_alloc_dev(void) dev->blocksize = g_bs; dev->max_sectors = g_max_sectors; dev->max_discard_sectors = g_max_discard_sectors; + dev->max_write_zeroes_sectors = g_max_write_zeroes_sectors; dev->irqmode = g_irqmode; dev->hw_queue_depth = g_hw_queue_depth; dev->blocking = g_blocking; @@ -1865,7 +1872,8 @@ 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); + blk_queue_max_write_zeroes_sectors(nullb->q, + nullb->dev->max_write_zeroes_sectors); } static const struct block_device_operations null_bio_ops = { diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 09940211326d..e692c2a7369e 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -103,6 +103,7 @@ struct nullb_device { unsigned int blocksize; /* block size */ unsigned int max_sectors; /* Max sectors per command */ unsigned int max_discard_sectors; /* Max discard sectors per command */ + unsigned int max_write_zeroes_sectors; /* Max write-zeroes sectors per command */ unsigned int irqmode; /* IRQ completion handler */ unsigned int hw_queue_depth; /* queue depth */ unsigned int index; /* index of the disk, only valid with a disk */ From patchwork Tue Nov 29 23:28:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13059332 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 1DB4CC433FE for ; Tue, 29 Nov 2022 23:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbiK2Xaz (ORCPT ); Tue, 29 Nov 2022 18:30:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbiK2Xa0 (ORCPT ); Tue, 29 Nov 2022 18:30:26 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA7F711A4; Tue, 29 Nov 2022 15:30:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ty+rTS/PcEyucpnhOxECoXjw9ZRuWBOMfaqO+kWgXyySD5EtBvr25lmwuAyyLNWVPET6vAQZ8WLLUaY7txA43sJdU9ey1xwUpVXnJugpq9nZ3PIt4ZukKov1wQLLPFjqwrL6G0VyCzxWiNzyk/VqoNnxGvipkJjCu0N7u3odQyDvECJk4aNgqBMkaqWCkHd4R5iuz7bf8F9DbNbzJbhI2ed/J19EVYxf0TYtIYValQXi5cu26OhH9g49soDBMolaQFQSsW5PZieUsIWy2q+ZhDHNKwBTBGXzmOVumEKzT9npLj1JdtTFGJkU1BSSkT/36/4L2OuCc0B6qqlvU9biBg== 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=93bHBBtS0wv2XFC3NpfyeM7QV18vLpAd7mLOdv0Ca3U=; b=ABw5W/RQPRJUNKF5b1xy68uUY4B4/aPs0jquUK82/TOu9yuSh3YA4ecZBQlHkMr+pjFAEJNMXRQ646v4JqHntJvZtsoHjTQQ4pQq4dX5thEfe2LwBs01XfaQduTi18hVWkXctfGpTuzWJO2BKClzIft0wdbX8F6t2ALAXDe16RIGToQP3HCWpNFNXuEY/IV41Ge0lpWZEC0LCP3wzfaVTsaAi1LQ4n/ree2seCLlYbpG89w5AkXkLupUJMtU4r1qBrSGYy8SdjmdF+ASAea7BWj6U0EClDpge1eJtkjcW0zIYq0mTKAZMzoy5XF1eW9maWbiqveVQ9h6Ec5ZO9MikQ== 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=93bHBBtS0wv2XFC3NpfyeM7QV18vLpAd7mLOdv0Ca3U=; b=EkDtE7/4dOc9nADw7CTWcX8cnXRrMxW0tTWwqR5RicwH7OtYSme37kzOMZimjht29YxZ1J8bbLLWFoGnCgt1IzPF47aP8SmCm2h8NsG6pH2GFha271ENEbBPorwsJpBbosPaW7OiNp0MKb05VsGnCLYxDEosivkXgFg7guawRCWLenGOmBWxdMSPvZeOEhpQ+VMeeCWLzLvpW8K7ccKSlbojEbzaUsq2rJdHpi282yD7lXEq1YSZjZfIaADHh4NAIlf/rqYPgSnwwO5FP9n7rsyjis4BG39Jopcu7jXI5+XNiXwFobYw0TTpnKaVK9W+tebrlayclhlXYrHBX/lNDQ== Received: from DM6PR07CA0040.namprd07.prod.outlook.com (2603:10b6:5:74::17) by CH0PR12MB5371.namprd12.prod.outlook.com (2603:10b6:610:d6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 23:30:05 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::8c) by DM6PR07CA0040.outlook.office365.com (2603:10b6:5:74::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23 via Frontend Transport; Tue, 29 Nov 2022 23:30:05 +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 DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.18 via Frontend Transport; Tue, 29 Nov 2022 23:30:05 +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.36; Tue, 29 Nov 2022 15:29:53 -0800 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.36; Tue, 29 Nov 2022 15:29:52 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , Chaitanya Kulkarni Subject: [PATCH V4 8/8] null-blk: allow REQ_OP_ZONE_RESET_ALL to configure Date: Tue, 29 Nov 2022 15:28:13 -0800 Message-ID: <20221129232813.37968-9-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221129232813.37968-1-kch@nvidia.com> References: <20221129232813.37968-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: DM6NAM11FT025:EE_|CH0PR12MB5371:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f769a18-bbae-478d-1157-08dad261a564 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dsNU3nUqq26GInb0yTDhWKXOX3RBQEncqWf19M6FgZkgA14gWDQGdpnN2sazGpOf6oFW/Sw5YQ5FKqvolJs5jPsqzpDTPgRgYTOimVCZ/jiU9nebYkP/GCxYJColtgxpEbOJqfeqyxtmSahRI9Wtwz4QiqNGMIzo5rtRh1u6+ELSSxmlAz89mvcIhe9HI2lnBCl60da+SUhySYUcKdse2CW6QYVPqz0Y6/UyRzdnYZ8l4ZGI9uvsp67PdCx8yrZRC5zwNGTelVaEn0I1iBAjq6Z8N5eRQE1Jbjd6VDdPa8TH7hWuhPb4X6D2sE1IKnEcnCkRRunlnkgafp41eAibdOB0kDs5yIFkLk0x0WjzUC2aAtR0FviBCLDrBQjX47XmFIPInUfyC99G7i8uCL98Z0c/WBCG8dgQWulvBjxS71RHNspQ/kUKScMSGvYton2OYJ62TaPrtGhEjOSwJ3Z39op5XISE0tZUi/Nry6QJSxzt4CjbDyWMSrpRoMJOe9dfH2A2lcTu6ZYQkdw5D+ElTNhsdL6lUk0K+mcPnshEEWkUWarDzxNadU6TO8fgwLj4CZp4xuGc6pGldOna6RJFfivQJ1oyLtZn742Df/YPlDszyRY8IG+xXEe+Gz2/k4t259nj5oIdUwwC4gVf1sK6L0dby4AS60/WxdoXnMz4HkDu23H8TLDfCtbYzolBua4kyp9AqHEYn8x8oFCuBMk0xg== 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)(346002)(39860400002)(376002)(136003)(396003)(451199015)(36840700001)(46966006)(40470700004)(426003)(47076005)(2906002)(83380400001)(2616005)(41300700001)(5660300002)(8936002)(186003)(16526019)(1076003)(336012)(36756003)(40480700001)(36860700001)(40460700003)(82740400003)(82310400005)(107886003)(356005)(7636003)(7696005)(54906003)(110136005)(26005)(478600001)(316002)(6666004)(70206006)(4326008)(8676002)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 23:30:05.3399 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f769a18-bbae-478d-1157-08dad261a564 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: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5371 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org For a Zoned Block Device zone reset all is emulated if underlaying device doesn't support REQ_OP_ZONE_RESET_ALL operation. In null_blk Zoned mode there is no way to test zone reset all emulation present in the block layer since we enable it by default :- blkdev_zone_mgmt() blkdev_zone_reset_all_emulation() <--- blkdev_zone_reset_all() Add a module parameter zone_reset_all to enable or disable REQ_OP_ZONE_RESET_ALL, enable it by default to retain the existing behaviour. Signed-off-by: Chaitanya Kulkarni Reviewed-by: Damien Le Moal --- drivers/block/null_blk/main.c | 9 ++++++++- drivers/block/null_blk/null_blk.h | 1 + drivers/block/null_blk/zoned.c | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 8b7f42024f14..5dc69f42b46c 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -260,6 +260,10 @@ static unsigned int g_zone_max_active; module_param_named(zone_max_active, g_zone_max_active, uint, 0444); MODULE_PARM_DESC(zone_max_active, "Maximum number of active zones when block device is zoned. Default: 0 (no limit)"); +static bool g_zone_reset_all = true; +module_param_named(zone_reset_all, g_zone_reset_all, bool, 0444); +MODULE_PARM_DESC(zone_reset_all, "Allow REQ_OP_ZONE_RESET_ALL. Default: true"); + static struct nullb_device *null_alloc_dev(void); static void null_free_dev(struct nullb_device *dev); static void null_del_dev(struct nullb *nullb); @@ -446,6 +450,7 @@ NULLB_DEVICE_ATTR(zone_capacity, ulong, NULL); NULLB_DEVICE_ATTR(zone_nr_conv, uint, NULL); NULLB_DEVICE_ATTR(zone_max_open, uint, NULL); NULLB_DEVICE_ATTR(zone_max_active, uint, NULL); +NULLB_DEVICE_ATTR(zone_reset_all, bool, NULL); NULLB_DEVICE_ATTR(virt_boundary, bool, NULL); NULLB_DEVICE_ATTR(no_sched, bool, NULL); NULLB_DEVICE_ATTR(shared_tag_bitmap, bool, NULL); @@ -574,6 +579,7 @@ static struct configfs_attribute *nullb_device_attrs[] = { &nullb_device_attr_zone_nr_conv, &nullb_device_attr_zone_max_open, &nullb_device_attr_zone_max_active, + &nullb_device_attr_zone_reset_all, &nullb_device_attr_virt_boundary, &nullb_device_attr_no_sched, &nullb_device_attr_shared_tag_bitmap, @@ -639,7 +645,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,write_zeroes\n"); + "zone_nr_conv,zone_size,zone_reset_all,write_zeroes\n"); } CONFIGFS_ATTR_RO(memb_group_, features); @@ -715,6 +721,7 @@ static struct nullb_device *null_alloc_dev(void) dev->zone_nr_conv = g_zone_nr_conv; dev->zone_max_open = g_zone_max_open; dev->zone_max_active = g_zone_max_active; + dev->zone_reset_all = g_zone_reset_all; dev->virt_boundary = g_virt_boundary; dev->no_sched = g_no_sched; dev->shared_tag_bitmap = g_shared_tag_bitmap; diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index e692c2a7369e..e7efe8de4ebf 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -115,6 +115,7 @@ struct nullb_device { bool discard; /* if support discard */ bool write_zeroes; /* if support write_zeroes */ bool zoned; /* if device is zoned */ + bool zone_reset_all; /* if support REQ_OP_ZONE_RESET_ALL */ bool virt_boundary; /* virtual boundary on/off for the device */ bool no_sched; /* no IO scheduler for the device */ bool shared_tag_bitmap; /* use hostwide shared tags */ diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index 55a69e48ef8b..7310d1c3f9ec 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -160,7 +160,8 @@ int null_register_zoned_dev(struct nullb *nullb) struct request_queue *q = nullb->q; disk_set_zoned(nullb->disk, BLK_ZONED_HM); - blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); + if (dev->zone_reset_all) + blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE); if (queue_is_mq(q)) {