From patchwork Thu Oct 6 03:18:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999883 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 6E4B4C433FE for ; Thu, 6 Oct 2022 03:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbiJFDTL (ORCPT ); Wed, 5 Oct 2022 23:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiJFDTE (ORCPT ); Wed, 5 Oct 2022 23:19:04 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45926895EF; Wed, 5 Oct 2022 20:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AImP+QcyeM9+kmUVcVw7Hbraaq4DqimYQlPpNCw7bqdGtcgeB9jApGVetP97HFRTDd7+MRlnIYG36duPW5+UcdnQfcjeRyePYrUisQJoKjJp6gX8Nw+8ft1jRIOL3Gbm0TJVOpX0mlPprPbJp4JjI+kv+sdKFMl9kBy9ZbmncHgC1lvSMedCWgm8nOB0IIoZR11F9Mkv/yaG50EbEDktC3d7K/IXrVp1Dndi0JwYW+EmAQPuZpkXFtWB5GAMNYNEkHgGMv4tT2ku70K9fBBdx0LFylI+s/xhyNG5PqBPMJImp7ceakT88HORXo0wYK29FZhKSdiffRL/lKyw13Jo9A== 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=j2yzPXeQSKewpvExOKRm0U02gC7dZ/EpqVpDN7cWPeP0O0G3Dp5W7uNq6TjS9uH8xOf6mv3354T+mQtDKo2xAGEc4x4JE+WXHRVIH+PA7LpFFBDuRZxCvS1R1NCcQzD27pulSZ/aLhy4p4RuTbAf1/xzBzwKWn7jU9u2jc/lm4ty9bIGyv+YC4d9/n8NC0BgCzBN7Els1SBx1Lvn0+LYxq/xr2DazMxhgsyZnpDsIYYpPokS+mIgl9urYuvSBYjlFz7D9XtbiZ7D2zaSblfM12U3RcApW4FCTw0MTPFZdXDOMOU8P4UnTmaqPWGBsyU3SZJfk7QF89DqdVTVA+ynBA== 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=ShV53pzdufW90Mkoufjz3WrZZaG3bVJr07/MRL+ulptdJduC8lTn2OQ4LbulrezdIGgR2Vx9jOmtCVTHMXPn4//ROY/3M7nyoUVS4WX4UX9r07Ge2cX/GO3oEGLD61Z+F4jyPlOIx+7Fp84fwLgSErBVuBlqR9g7hCqE4z+AnS8+9VTcl4pzQVYyEDC3euUWgC/Hd2m3yY1/x6xbk/fg8NXAmikJ/zztPPNgtuqJfu3NqZDbimvLWzPpTRezxYfuhcgSWfjzXOAzgD4dNFjWRTe1/qhy4gEcF7k8aN3CQdRFgVmlwAwJv4jGnQCgiOw4pRzqKd54BXq9rMAQX8IvkA== Received: from BN9PR03CA0108.namprd03.prod.outlook.com (2603:10b6:408:fd::23) by MW4PR12MB5667.namprd12.prod.outlook.com (2603:10b6:303:18a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Thu, 6 Oct 2022 03:19:00 +0000 Received: from BN8NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fd:cafe::98) by BN9PR03CA0108.outlook.office365.com (2603:10b6:408:fd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Thu, 6 Oct 2022 03:19:00 +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 BN8NAM11FT031.mail.protection.outlook.com (10.13.177.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:18:59 +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; Wed, 5 Oct 2022 20:18:52 -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; Wed, 5 Oct 2022 20:18:51 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 1/7] null_blk: allow REQ_OP_WRITE_ZEROES Date: Wed, 5 Oct 2022 20:18:23 -0700 Message-ID: <20221006031829.37741-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: BN8NAM11FT031:EE_|MW4PR12MB5667:EE_ X-MS-Office365-Filtering-Correlation-Id: eed496fd-a38f-4095-031c-08daa7498315 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sJEMVGf7kp7xaGrOHat3cBSdPASbfZ4nbOTXG7Yy82GZo+7Uy0iC8zpfs/9yLJuhabhxfZq7rFdhXE2peowMi3HdRNwnYbM7WgGPElre6a7B4kMszHsEBLJXJOmR+Ap0qgInT9PfKrIsPUTSPDb7mU5dDkRQnhGLW6XniJ6MmNqwEP7v2Zp9e4aqe+0yc/+REI3s+TSZZRHwuXkyE6kpIGkH17CPNzz+X9vSek6dXJs3/CScbOapie1w3gU97nsMYjfuhdLqW4X3wqN+6nClaV2hyzoxSv3V0ISlzApNYk432vfGN6sBtAurWX/f26VP9tQyV3L+d4rgjIssPPfUAwA5RBPEosD5pIPIjeiYX8YO+uMwoPckf8YUmR5EFBmllhGunTgEOEhH3cwRj2O9u9yn8P+otb/8zzCZafxERTfGtUhY/U25//rE7UfngS/0pKMJ9VRXfibr+LRnivUvHU3dU0FLsQeL7Pt5KxhsJ2SKJh258DIF7XYvtARHBJZXyUr6t7q0wIy+9MKMN0YcYTI65NVmige31tknzV7GyM8GSLUG89jwOPVzt6zWo8BOLZkgf2ooACmO9n0tP6Jbe8NHoFHo3ZwXu0IL6f38XmtQLerYE7Uk0EyiLEChpDhCXOEF9l3S9WuhJm/BtO+ZyXprPhBtKEsoedwmxGMbZMvUmTIr45kz8OQl3d79W6eNEw/R7Qgujb5exrjgnEQ8llKhJFBwDNskPPzwIIPbOwjff+oneVkFEJjVKbPmz099qPxCYWjONjQJ6pveS2WWeQ== 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)(40470700004)(46966006)(36840700001)(54906003)(6666004)(82310400005)(2616005)(110136005)(478600001)(8676002)(36756003)(316002)(40480700001)(82740400003)(4326008)(7696005)(356005)(7636003)(186003)(70586007)(47076005)(40460700003)(1076003)(336012)(426003)(83380400001)(36860700001)(16526019)(26005)(70206006)(41300700001)(7416002)(5660300002)(8936002)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:18:59.7802 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eed496fd-a38f-4095-031c-08daa7498315 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: BN8NAM11FT031.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5667 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 --- 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 Thu Oct 6 03:18:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999884 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 9F291C433F5 for ; Thu, 6 Oct 2022 03:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbiJFDTd (ORCPT ); Wed, 5 Oct 2022 23:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbiJFDT3 (ORCPT ); Wed, 5 Oct 2022 23:19:29 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2040.outbound.protection.outlook.com [40.107.92.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D4B8982D; Wed, 5 Oct 2022 20:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etBXGZsJV679jCUsi+6pjDI24KPrGA9oejauZF8uqAjthwPc9ald5ZBCu37QtF/5UUjs4N0F5Nuq5LydOad8RyiMSTK013R/y6sbWebS5VcB+T0AFigwDyPW2I4ZV7S7wKel0BIZSgZITvcgyu420kISDExdcWNTD3kIhGDrHaNPygICWUgLm5k0s2il1iCaMIOu/4aOTo7Ey6AmsQu6jfmlWK1ZRWs6XABHSOTnXBbTChO0M42v4W6+YuKoFW9iGlGMVVpLfUp3dwLA/VL4+3n7qCCn8ddDRDQQRL2v6Y4Pdv8DhvVvqvo5KXMgxd5hshE637glbom8hmHzIgHxrg== 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=XVyLsk84eGTqdOdiC1UUS/H84WIRS+MqGvB2+r5zWjU2y61XjOJzej3zoUfYdUunO8r+RW9KLCcm43TVPNqX1nz4cc2HrQDS684/Cwib4344twk9+RubK9lWlBJrLodZSa9EC8z2s+dHPK3WrHlzzjBw9Jwi0ks5Gx2WWGK1/LcHbcpTVLLsjkjwNOypW3DCPZYLu76Tf92d2WdQ+1iYDzIN421aQJ7AAl2cc4SSg/Mkryju7foGbU4RjYfs6QroDrO9uJqlabrp5TbPNcS4m9B+9qi6a1Oj8C4DTJGeyRTflCSrkphZONl/6J0Rpc741Bzeq3n29PuKjqVEqANTPw== 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=noGm/MbXpfSzCynLd/Hwki/FzOMzw2tIpl5sEyuM2KLHid4GZ92Yjv5T3o/6GTxZO11fARgoDy6I509Pc1apHdF9d+dm2v3tTkkoVDSL7jHgb8XrIGFrtuFWjtYGps6D6NeAAidF9OmR45IfH5mqhNJU3cnkvnyzAM96ZoXj9e3NipT9bTiDQSh2SI+eMK/Qu+t6SgBMribELKqRq7uKZt3902tpeMJxreih4dlsS9d7GOhC3lNuzwsrrccnv/YWxro5ChICgvcPcYTa+bDcOBsrcSbIR5jbv9zLC5TYXhineGSFnVncTSPj2GapMqN3uIFFATDM3lfX5Lvb5fPVUA== Received: from DS7PR03CA0321.namprd03.prod.outlook.com (2603:10b6:8:2b::6) by BL3PR12MB6569.namprd12.prod.outlook.com (2603:10b6:208:38c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20; Thu, 6 Oct 2022 03:19:06 +0000 Received: from DM6NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::15) by DS7PR03CA0321.outlook.office365.com (2603:10b6:8:2b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.30 via Frontend Transport; Thu, 6 Oct 2022 03:19:06 +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 DM6NAM11FT038.mail.protection.outlook.com (10.13.173.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:19:06 +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; Wed, 5 Oct 2022 20:19:03 -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; Wed, 5 Oct 2022 20:19:02 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 2/7] null_blk: code cleaup Date: Wed, 5 Oct 2022 20:18:24 -0700 Message-ID: <20221006031829.37741-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: DM6NAM11FT038:EE_|BL3PR12MB6569:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bf70fff-fef2-435a-0212-08daa74986c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MynncS2b+uM4c4QhVvfzADl0qgsC2EJ2oksyKaUcWoPf3B6kGqNt8N4DPoxTqgC7gy+P84Ew7mV4hAKJM2O49M8F57IiH8XX4Ny3NEvPCiLGE0KwL5dKQ6rk+kdPsgkPNQW5nJF9xBBBA8LpT9f+0SKSUWvIaUyRKX5hwmne5rllfRq45v3RIeYjTXpb0d78JsS0YEh1vesL+ad3G1v81hgJnDQ91cdpDAMwy8li1TJJQGIiAjyg5CRTw7WewKo6A5v2RC2fQvEtUGzA0FG6juP8G/4x1YyTwLmcYb2a9Rr7eRpeFP1wWxbdmJEsMdEB1Bs0kiqzdWKRn6DDymMD0oR+awkWZVN0oOIoeqQx/gbUNu5sKgjz8T5nFCnp9qJ6lRV8T88EwONilI/YZ5Na3wFS+iGgMKfl4PjbwTZ0wKifTw9mHW4j8hlHazhBfDcNdmpdBM9b7Rb+V7QSP/kJpHn2yFV2Bne+kJDkfbBbGkgqY9H1y5+bhBGW+Mpsr7Y4m8fh/a3Evus/UAxNZU24ohtV3JbuO7TCijfFMaD81INWRbVim1K21askOt2bubVJB3z47/X2T7HAU9zXYXq6n+5pQuKp7BkqDwRKtDnO3rRVg9sfvrkmrr5n/5oqL7JiOh5MSyaCe7mw8MFzQuTlvgPUD+5lh+PlgRCv3UqN3gP+B6OT90WTxKybuSDjFCL2ehKhRdGqyxttnWEKKa0gQ0mR++R53ZNaC6P6r+pIXnfMqZRQ1PkSCSb8OJRRuYt0DemDJ2taqUMXixvGutIZuw== 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)(396003)(39860400002)(136003)(376002)(346002)(451199015)(40470700004)(36840700001)(46966006)(26005)(82740400003)(8676002)(40480700001)(7416002)(7696005)(5660300002)(41300700001)(4326008)(7636003)(40460700003)(36756003)(70586007)(70206006)(54906003)(1076003)(110136005)(83380400001)(2906002)(8936002)(478600001)(316002)(2616005)(6666004)(186003)(47076005)(82310400005)(16526019)(36860700001)(356005)(336012)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:19:06.0227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bf70fff-fef2-435a-0212-08daa74986c4 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: DM6NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6569 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..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 Thu Oct 6 03:18:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999885 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 D7E88C433F5 for ; Thu, 6 Oct 2022 03:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230097AbiJFDUW (ORCPT ); Wed, 5 Oct 2022 23:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbiJFDTs (ORCPT ); Wed, 5 Oct 2022 23:19:48 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CBFE8995E; Wed, 5 Oct 2022 20:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dMVs2c/zZmOvwMwgwhXOsCepVwrfAnDtVxMdFfu3xdZRVDZMxr4OBCSbp0Qy8c/t5iEvokrl7YKhWVXEJUjRs8PZtrxJaZ7GtCL67hwx/+7+xqsxPs9gOE4EaWCGApJgQjIovidWq3+fSQ9IOxCLf33ZDM0fy5xt1iIaYAnCpMubk58rsr+1RQnTV+0RWqtVS2bi83zA5oCTBUEg7i2vqzEziMAqRhIHnT7M2DK5Onv8FhR/JQVRemOuWZELZc+R7pjSANGipkmUg7wNbOotswZWKWRWV+8dCjkz3dlM9LB3VGfyrTw5WWqy+Dd781sAAxMGqe5uSJDFVile8u60pA== 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=SLKSZcYWePeC5l62ZFoA00vICU10ByB9PN30SLGHvvs=; b=lVSj/niy/oARg6gzXZChUmFZFExn+oVF8d0nAVUep2BVNpi8X4MS0fWKdp69qqz4uL05CEn+pBjKK6uJ4gDpYpGf5ZHoZTIKB+GhgKWuYZ2ptka4yAsWgNbGfspg1Uky0gznA5G8JpsXorbbxriLs5jOQb2jlnNdnZx4aoYufRhaW458rEGJudOwnjx6tLGAmKsNOhms/hsyp5PtMro2wHEzG8WqBtqtWoXfX3Ntxee8q3JoUlqngoVfECehE2xjRR+Ka5EgrR/RlZBCjF5QWOjXqnMgLpFoesUnFxq4Lsxs329XrkIGMxFcL7lRWuBYncLMV2bqdd2mz2yaPwiWMw== 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=SLKSZcYWePeC5l62ZFoA00vICU10ByB9PN30SLGHvvs=; b=bvlNyNuXsIoJXQy+lxQ/A9lXnIEjePce69eoktovNBhJrDgP4aN1Hm4Qp5XmpAde7QfjG5SC31fSVRiaPfErQH8+ALSZXQftl/VEDxNg29VRbRyRY0irwqP+lmpj7mqqKVQUxywlAUy25sJueKy2O/dRdCndm6GQ2NPVhno49GhddGEYI5Dyq1ZqMzlgCQs7h2QTDXZjKxm0GHXC4f94KhwOVS0bguLsgkVYHUNOsLJ5GniO3keY+FkvaQWYzBWeTq0qjeVYnKiGASnl5xaOxdzjJ9/54ckjiCAmUSg9Nbilp8h/j3+t0HTlQdxXsbOzmhEyQ+xi83pZk9m+/63FKg== Received: from DS7PR05CA0040.namprd05.prod.outlook.com (2603:10b6:8:2f::33) by CY5PR12MB6131.namprd12.prod.outlook.com (2603:10b6:930:25::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Thu, 6 Oct 2022 03:19:26 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::d2) by DS7PR05CA0040.outlook.office365.com (2603:10b6:8:2f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.9 via Frontend Transport; Thu, 6 Oct 2022 03:19:26 +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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:19:26 +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; Wed, 5 Oct 2022 20:19:15 -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; Wed, 5 Oct 2022 20:19:14 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 3/7] null_blk: initialize cmd->bio in __alloc_cmd() Date: Wed, 5 Oct 2022 20:18:25 -0700 Message-ID: <20221006031829.37741-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: DM6NAM11FT012:EE_|CY5PR12MB6131:EE_ X-MS-Office365-Filtering-Correlation-Id: 01d23d48-7123-4885-8104-08daa74992e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JIg3U34fujrnq0IM13T0OM4ulOV9ODNmqQXzIJfjWmuXpVZl1th9mhfxfhEDech0tLccnpGvCade+jSKPMxRu7oDruCw4a6U86TrXl09Q2RZS4F3V9PrLhcwe98vaXu67IqkeGn15cxlQK1883DN02+dYbe7lbEUWj3X5PlhGz6ZlUrCpTEH+HLLqWrXzj6TosvOsKdnGhsoCD2h9/MFBM94eLx+eoenAYacmBwzuVF0OcshLTKPAR6QvXqmgnPPmxPNuR4ccblAP7SjPyxIgRfZGAtZbMlBTynLXvmq+ZO9+60j3ZqanWaiNlmrDskk2rt/IS0tkFCuWcLzz5/7LgJgaNDa3Px8zQv+p8uEZ+dqQ3FWeGNXCPZsJQ44Xi4fRkeMdkHTTomw10+Q2Ka7OYcrmQqGBCrW31d1p2hye4wXWlGwGt0eLmyXnzUgjS/3PNfLJmdKiTwOaNyDEX7bB6Jzs+cZP+FCguAqwPdw/Dne3xQxs1nrieKGrF204hd0T3eRSzwqeGXnyHontn0T3LD/BVjBrmi+TEeMOH09PZVyRsiR7jZAD6uxrxNb3MGM5MbECy4EvJ58ZaNGFOj+x7wJv0CTpTe8A0935Z4kMR9ngXVrLirB7w09bk1W2lccAsWdG07q2hVQMjSP/sCwDC+JqkkdmqMlqhId2lmeK+DKAJniOPnocDv0AGuuY9P+/vuBn2TFoChqDBqQ3g+6UrXZyGtsy0onrSa2CisgTumOx5H2UeYrTLoRPC0bBHrki2uZ2kQ8G98hI7Rq2uljFQ== 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)(346002)(396003)(376002)(451199015)(46966006)(40470700004)(36840700001)(41300700001)(70206006)(1076003)(6666004)(8676002)(186003)(4326008)(2616005)(336012)(2906002)(7416002)(426003)(83380400001)(47076005)(36860700001)(16526019)(7696005)(40480700001)(5660300002)(8936002)(40460700003)(36756003)(26005)(70586007)(316002)(82740400003)(82310400005)(110136005)(7636003)(54906003)(356005)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:19:26.3578 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01d23d48-7123-4885-8104-08daa74992e0 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6131 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 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 Thu Oct 6 03:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999886 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 AF01BC433FE for ; Thu, 6 Oct 2022 03:20:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbiJFDU3 (ORCPT ); Wed, 5 Oct 2022 23:20:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbiJFDTt (ORCPT ); Wed, 5 Oct 2022 23:19:49 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2057.outbound.protection.outlook.com [40.107.102.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505F0D96; Wed, 5 Oct 2022 20:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i9xZc56r1VdSAuALoy0FDHoboQriszuVrK2rXe0fHCyGViLOXw53/E2ntWhlEcwPk6+CX98AMpL9qMpzB3UUymz3W+wKqA7oFygKXAXXw8igUcrGaU5/Hb+PESHH2VjHh4YgHuCDHSFbFopIezBWTBFjOSnMBskkb7gwXOVDrRLgqeCRZ0JQEPTjyl1v4cfXAVPO9FeZoNo8IisKrk1hHiwnR4VdK/NVxW+I66ObTyWQ70RpMIQfs6XjwIUszj8R1xgtS15ZwxAxYtASHFIO9oSxdlH90VFnH5vA8n3g9KklZ2BTYqHKGm7A8DA5tMpl/hCO6Fj4FpUjSvWGTYGo+w== 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=Q8yRQ0Dvn2WSh+NQSHOCa6FnoS/37bVJD2T3lt91ap8=; b=kaeY0ToL+su5aYp2EdCwVCzVXW581dEpsF0L3FRrxT7v9O3w2JPdNhRIdaAu5jyS+o1SmWNFRtUY/VZcuQi9yTbcrcDpmoowpY7fVahBGeNhjWvpwTrYqOkQ4DRn2tkNsLveB0iwf1UJlv4M3i3K+2AUdzspmwSzI+PAT3UKMZzcUwBPEouvR2Nd3Dd+svd73uS4sWbdj/v5dMras3LsiOPSjRz+Yk8oZ46ZQ9wdZ/SD4oTNdRzclvIWNA0lzYBi5dq68U5IWS2elTqwxDL6QrDfrDfDzcmdxjsOb9ZjeBxiDQGx2fhstgliwRr7ogbAVq3DcKR3NEQIzkXKusnUuQ== 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=Q8yRQ0Dvn2WSh+NQSHOCa6FnoS/37bVJD2T3lt91ap8=; b=bOvBLvcND2ZOSIw+wlqTGQgGq5GgbhGR8Wc+XtgrjdZ4+CU4HZlWuvY3TD3ssl3DT24gsdDqLUVR6hXVTQyVP6hntE/0Sm+c6cPp+PFIbZ6UCpes1RNGMilNDJ68IPWL7mDrLF+ciPvzC65taY8bXYtq52V9gB233IxNMHfMerIAFhfCjcNo+0F3mLgxF7uXeW2ne1cpJ5a45E7g2sDxQRjRCs0RzTJBPGSnQY8/MNJEXU6wnJ4HIiQrHkwWAuDiYAsK2NGdxROEgdpOCyW8Ce27/LfXKRSTUuGCsY2baJirRHfno0S+kxG/8+nFmsMAeTDJbr0TgF66LsIkeRh2qg== Received: from DS7PR03CA0208.namprd03.prod.outlook.com (2603:10b6:5:3b6::33) by SA1PR12MB7270.namprd12.prod.outlook.com (2603:10b6:806:2b9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Thu, 6 Oct 2022 03:19:33 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b6:cafe::2b) by DS7PR03CA0208.outlook.office365.com (2603:10b6:5:3b6::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24 via Frontend Transport; Thu, 6 Oct 2022 03:19:33 +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 DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:19:33 +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; Wed, 5 Oct 2022 20:19:26 -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; Wed, 5 Oct 2022 20:19:25 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 4/7] null_blk: don't use magic numbers in the code Date: Wed, 5 Oct 2022 20:18:26 -0700 Message-ID: <20221006031829.37741-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: DM6NAM11FT059:EE_|SA1PR12MB7270:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ae254e0-0ad4-4c15-3390-08daa7499724 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Pp/R7p7z1hiT4NHWtK1vB/knaoHRl9MZyC01XQcsLccdw77TT66BzsCuZflYtsZytT6idUBwdAJz1nJT7y3InABcySm5KKanMsgBHL1CVzy1hf5nCueUEQRsMmV34jwNsYlwQQ6hq9X1+ajqyajBP2iA2n748lyPLSCTC8GDjeyZUf1PgEfrSK+mz5ZWX2I8E7/+BfdvgyDM2eREJW3bwkmM4BSFDLOHl7KYgZ68FNskDxrgWEkN5B3IC/qCI4wSskfYrs2h1drWqge29AefflOpZJp0ZAo1SHDx1vfqeN+3I1YWidXa2pIt4ooEB+/VxsjXCnIfHztUx13fJo0Re43kNx+oiSFKlUwS1Ac/Ig48B5gDgIA51PCD7oSpoGIMGiJ1wbJ0mkHV3UnoaJD2ZfPPJ1doa/NxUIGSZecf+HOdr0wpEdZSmwBK1tSsbCg+lG2AhynoZVGmmFPjEuFQv7WefYoPvH/om9DG2vM+YQ3PZlrmJevE9ZLQFHpHLrt4s+JOYNKz1Jxs17oeHEu3HkGv4df90xxS6lI1y0NN4mxL+T8g4m0JfP8+w6lcotnOEgdHhrld+bK2X2mRNQNGfFz4bI7IQAihr7HRjWT1R1ehyuSVT2yp3Bc0O5AWQZWwrdXHHZm0bQMvOX03oNoBXsG46sY+gZ9ZzvALJFSYe5EHCdvOtX7D3jI1CAlC7i4DI69GNCP9rqf2hiDjxAldzAbYj6AO/nqeU8MDlOit5w/fJR3MA/JX1t6AgpTLLHo4VpJe7vBWmnEWu5NPhZIuA== 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)(346002)(39860400002)(396003)(376002)(451199015)(40470700004)(36840700001)(46966006)(82310400005)(478600001)(26005)(7696005)(82740400003)(7636003)(356005)(36756003)(83380400001)(1076003)(36860700001)(2616005)(426003)(186003)(47076005)(336012)(16526019)(41300700001)(8676002)(7416002)(8936002)(2906002)(4326008)(70206006)(40480700001)(40460700003)(110136005)(70586007)(54906003)(316002)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:19:33.4967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ae254e0-0ad4-4c15-3390-08daa7499724 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: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7270 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 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 Thu Oct 6 03:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999887 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 20976C43217 for ; Thu, 6 Oct 2022 03:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbiJFDVI (ORCPT ); Wed, 5 Oct 2022 23:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbiJFDUS (ORCPT ); Wed, 5 Oct 2022 23:20:18 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2089.outbound.protection.outlook.com [40.107.243.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9348EFD1B; Wed, 5 Oct 2022 20:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJ2bFlS6cMTVKE+RQWzVM0DrRr4pfycGqhj68o4mSNOQLlIczdlj13i3WDIynGuJWx8kl2DQfgSd1XK45+iQalQ4qcgaU20scN25Wa/ljV970bpfjuOBSxhCnc8gbBZwR8y+jCssazZceRiOti5o7UeboJVPdQhEU4R0J0c9UN3nQ5yQh4EePRigp/iSQPOZ0JstEgRPoGc7exHSOBjYuSOHsP4GeC7CqCr+0TkFsSsKloxyk6acYGGqjYXRqjapWP5GUCvXP5Zyqof6CDBotwNKagRIAHt4tfYYoCNu7/6frApA73UqBrfkZq0VCt5uYJwGUQTR97f8nEKA4WGlJg== 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=IX+xbbfntfGp6qSLeWi/TiLE6ByMSFVgHyXWTgWKkJRUiwwZ9DihHvsFLOCbXe7osKY4lyVJzEdU89DxrU0QqzZ0NZH1HJZY29RjuAGj0jycykzCId3x7Mxzb9T4wCSrWHM3wV2iAgkTSqVlDWbywVQqyetnsYYn7pkyVQB2FGjp0hHrMZBxRifeUFrdpS4w2ovs9RcRhaqch9u4mpV9stC3uzUb00p/oogM+F3mf1RvR5r9kJR584Q+BjpZbOx/RX1WlTgifhpz/Xr5W1QsbxNvIPrDlKgugkJpZMS0POzL0Ppo4MrxkB1Qm22wazRigu3zPxwys+8vlNjyP2ALPQ== 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=GPQ4xow/n0jFeWYi3z9AMftw/F08w1TGKqHZHuwtgPhVTwyIrv6PbGMCkEUL/FxMqHn8eq8r4llQxJ4QTnmvygTXBQlEWwzy3A4R5uW+OkmwnlOpUEBTEUMuguaMMqdaQQEmuvUAvC5+wxYG9rufExOXJlWwuKI/rwdvZHqoToGa5fZxWzax/fzTCQAkineT11H82U3r5+W2lw8J3pr1pZEMSL1jaaTtGYUKjKS7d0BuV9R2htYQ6OMuk3OU9Iw9AYZGNH+VlKgg3mggyyieTjWV8EWgiykt1yzeo3y3O3tCDp16IPyrwwP3h3GiZ7j6QUVT4WhjVRUw1bJyD2HJJw== Received: from DM6PR18CA0029.namprd18.prod.outlook.com (2603:10b6:5:15b::42) by CY8PR12MB7313.namprd12.prod.outlook.com (2603:10b6:930:53::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.24; Thu, 6 Oct 2022 03:19:49 +0000 Received: from DM6NAM11FT055.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::61) by DM6PR18CA0029.outlook.office365.com (2603:10b6:5:15b::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31 via Frontend Transport; Thu, 6 Oct 2022 03:19:48 +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 DM6NAM11FT055.mail.protection.outlook.com (10.13.173.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:19:48 +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; Wed, 5 Oct 2022 20:19:37 -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; Wed, 5 Oct 2022 20:19:37 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 5/7] null_blk: remove extra space in switch condition Date: Wed, 5 Oct 2022 20:18:27 -0700 Message-ID: <20221006031829.37741-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: DM6NAM11FT055:EE_|CY8PR12MB7313:EE_ X-MS-Office365-Filtering-Correlation-Id: cc393655-875b-4ef7-87c9-08daa749a03f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EJxP0IR9FKm2rj8DPrOhVWrO7JaHBhxnVfPSCTf4ZMaR3n4mbqI+r4nUUSv4LI8KWk8eMT+bxQnld3jW7gJoOxu4WgUNvrSdP8UM96olSqk/YpSlSMwNRDScjxduVx8a5lLjGFbs8og6ksrZJh0d4LuXo8Fxlce8q0BN1v9U0MKa83DRWVM9IAm0cvJZZ/6XA3hlFmX6+nk3Eg6HmdfN7l6tYmSj6Sh7zy58MmLcnxT/F+Yopb+njgj5BSALFotYHKn/uUgRsPIsxr0UnMcFJcrHhci248T2CzSdXv3fzqCaq+uckjbtRwFrSIP00AFpw0kPzUx8hDT3uKKzQbFCQfasAfZABU9psTZ5Hku5zShIGmhmFmUxt6RLcECoxDivS7zzYbI2oBza/J2DX9y41y1m0WD5acbE+TFrXeTsiSImFfdLJlCvS+6s2D/Rx82LVonDAuuE7+H1lkOt3mdTJk2qBahIc78KO/+qOrDKvpi6PmFJh5GLMBplt6G794dD0yiSS+kjRMBZDWRYDJ+VNeEZqvOrcGOi413mzQbvTz9s0k23CyFo7N/C+QRc6lYlWcMIyEbKb1AgR6FauwOoBmXJboanUVfPbTh8OyUtScagzRtfqNf//YfvHs7V65GmJq3MnPAnL1DdEUbXWyeavThJ5MARjhg0Kt3tCoaZdGF4PFZFnx68zuiTn4YnLiBoAS0pxjXQx22odp3M+mM1+agqIEq6IFp8ol5ZfXegITKKCAOFVruPqSshPVa0gGNnAAvc9X0GfrDJtYLL0Rjhvw== 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)(376002)(396003)(39860400002)(136003)(451199015)(40470700004)(36840700001)(46966006)(7636003)(356005)(2906002)(4326008)(54906003)(316002)(70206006)(8676002)(7416002)(110136005)(70586007)(8936002)(4744005)(41300700001)(2616005)(40460700003)(186003)(336012)(16526019)(426003)(47076005)(40480700001)(7696005)(26005)(6666004)(1076003)(36860700001)(478600001)(5660300002)(82740400003)(83380400001)(36756003)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:19:48.7753 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc393655-875b-4ef7-87c9-08daa749a03f 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: DM6NAM11FT055.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7313 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 Thu Oct 6 03:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999888 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 086A6C433F5 for ; Thu, 6 Oct 2022 03:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbiJFDV0 (ORCPT ); Wed, 5 Oct 2022 23:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbiJFDUY (ORCPT ); Wed, 5 Oct 2022 23:20:24 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2048.outbound.protection.outlook.com [40.107.237.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B302AE23; Wed, 5 Oct 2022 20:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lBjz67kQWIHllXfgfdCybLerehTkGbwr/PrqXPRpGaTxFzkCUnqfd/St0iWt1UViLG/vUQp55le2u4Exk2S51hYRUwJA0eWlkhpSJb+BqbhIMMijRt7bpyeRq7HIa2slOH0GfFERTsjrKRMbqlNhc3WH2XmKpk+HGd8jEDQnkDObce0IrtQn6yIt8QW0/znipDKAVbyS1phCg3rXToqHb9wEjeBP1/XEEodKQM9r+RqvN1rFLgVs/7/AlMLv2z51hf2MwNmcgysKAhsF8TDCRlpUrY19kWvH89EkiSY5xCiqPtnLj3JSY3FPz0EBICIMGxEVn5ZAwPplaIhTW8sFWA== 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=aFVy1/ld0MXgw+oE1K9nLlfO29EK9HG7qOWDWSGBJHxX/bfJNPIqCZhSPcRcYu9CeIxko7F1INbShIYdYitFOPbNKKrn3iSvC38STJKiTwQ5fb7NkpcORj7Ol3Fu/DRHaAkbHn62Nl/7xYecCPXQp+wupixO743jfJgULxB11BB7YfunhpFPQ79E4XeCzfYaMap1uSpJ3UbbHXAdlAOeSoxs4pxtGy9e5fsA1nlcTpgppG68rlOgSgvj01CScCtPVNvh8FAroN/yJ7MeyuYKHZhNUjswsXJ88R2jO8o5tuq2MhUduAX2MLZbq3PSiPK86dr3suQ8fTfvQ9Wxo643Gw== 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=lmDEtdU2bvNHkP+gGSrh8jAAvMAZaOfAmfE47NS0VAIOrRaSETdA1NUviuBTFS0YRBkKWF8gyDLpeCpjRE6KtrNkNYIiEjlkMNIsYBqNAzHecaHokdbDhOo11DhnDqCQe+WB6RkP3uCw3tJlCx1ciDBbOiBcDfKcfVP9qWHveej2I5+c7Ckw2NAEIL1Iw9RIIoiPVsOzfR60+mYJdgrhLkmIQVYWEzt+4kk0PotVPcVr8hAW7+uZKqHQtcpcfC+K6LCskPvfVxlxg54QvMJ8ueM+54tFcxYgJPoKMSeeIZdlDrugq9dj2be9dYtqO64Pa0N6tC2B5JcKzDeV5BImFQ== Received: from BN8PR15CA0048.namprd15.prod.outlook.com (2603:10b6:408:80::25) by PH7PR12MB6609.namprd12.prod.outlook.com (2603:10b6:510:213::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31; Thu, 6 Oct 2022 03:19:59 +0000 Received: from BN8NAM11FT092.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::4c) by BN8PR15CA0048.outlook.office365.com (2603:10b6:408:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31 via Frontend Transport; Thu, 6 Oct 2022 03:19:58 +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 BN8NAM11FT092.mail.protection.outlook.com (10.13.176.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:19:58 +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; Wed, 5 Oct 2022 20:19:49 -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; Wed, 5 Oct 2022 20:19:48 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 6/7] null_blk: add param to set max disacrd sectors Date: Wed, 5 Oct 2022 20:18:28 -0700 Message-ID: <20221006031829.37741-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: BN8NAM11FT092:EE_|PH7PR12MB6609:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e4c1c3a-cb2c-46ff-2477-08daa749a634 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jlh+nN4bNYy4zJ27/mK9iu/QoqElfMPj2xkye2EdHa6yifHVIWjbsQtKfZCWy2FNlmt4FTo8J+RM2BaIX6NrxITNFWr+iTpITuDRvlG8MFEYebtDeK/tIuXMp/z6ndp5znQVZLZSi2j5bAcvvOoXt4qvfnD5bvD2X8/HRV5Pu3he/LxiGuBsflpx+/cp+LkwdAORm5AggndaTgGWcw/SwmBtZbh12cG5N7jg66eMIDGZ8B/FkzXsCg3VfNPKhIlSt5LArOXeW4UfssecYQjMC5iSjhPk5PXOh7ZlbA6vPHmISvnaypmZyidMEwHpyhzC6etOWer3mx7jo9RC1QjmYSQI2tdNewFMBz7/ZlkrE8+IF8swNsKT0BD8Gp5SaawXcHr7hh16SbFwngWrJIjMvxOCj2FiE6AGR+4Cgf9GPMG08TpRZRB0Q2n/2YgBJeVrpUDdzJ60/obQomcg6SRLTwl4adM5ZlWqH7eJqnSaKRS/JNrh0gVlyABIA3bI9CAE7qrwRwXiEvTI8t0DHMy4tnMRLG33kBPVnnyoEXbR8j8VJkfdJkY/uqHyixKeuFSDU3LU8ObO+xDgQKXgpteaAQdqpB/87tJBn3rDIRSPdZ04v3aH3sjjXGyhB2ZfOkc5PVoX86EhnDYFF7y3pZAxOJ2J428TBlJ8BZeSbh1m0E478QYCilHfpK0G85jFqeYi4ZqXIzfqbqE9oT35ZZlFJrlH7Rx/Tz6hzzrHBHV1uaE0z4xphcrgkAaf8h+WOHxs3zyGWnq7JhQOirnJaaUoOg== 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)(396003)(376002)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(7636003)(5660300002)(356005)(82740400003)(478600001)(2906002)(7416002)(16526019)(1076003)(186003)(47076005)(426003)(83380400001)(70586007)(6666004)(54906003)(41300700001)(7696005)(8676002)(4326008)(26005)(70206006)(336012)(36860700001)(40460700003)(110136005)(36756003)(316002)(8936002)(40480700001)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:19:58.6889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e4c1c3a-cb2c-46ff-2477-08daa749a634 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: BN8NAM11FT092.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6609 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 --- 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 Thu Oct 6 03:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 12999889 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 ADD46C433FE for ; Thu, 6 Oct 2022 03:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbiJFDVv (ORCPT ); Wed, 5 Oct 2022 23:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbiJFDUi (ORCPT ); Wed, 5 Oct 2022 23:20:38 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2046.outbound.protection.outlook.com [40.107.92.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D4588DC1; Wed, 5 Oct 2022 20:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JWF7UdtvIrhwSBl3z8epaQiafXqM0Rt8eU2GjZrY5MzJStjROVI2hIOai00NQfJWuhjzJRczbcXapeh0jwb8tu+ABtlwMbH5CvhzTUuQNgY3l13ZXulTdi/VPQkVoCuFznCXxspaKvjlHGxIgdNP0lkqhwq7sE0Xn8QNNlLA0LhOhGOFnLgMmD1/UBOpFvmZZGaMFiIC0rKKbbW2JEpo9OmBDHp5NnJprr9MnYXCJ0gSBTWT2hnTrNAA63te3I964Ladb2Du2pjtNP1+KxWdFscNgtYeL8ZpvdyCBETOcq4k7uFWI6fM/eSsZU+i4DE5DIog5QKOugcXOHyBqJ2BzQ== 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=aPz4hniV9+7w6Q8zy9JCkPcJr0nXtOIDqUxt0MiIssFAoao4PEdjJAz2raiaYamCx4B3yuAhiSOG+QUWC1l3S6SKj/Q5P+IEdoo14uFolFseafQ0tlV8nb3S69W2dB/78l8yA7w766JZN2BdKcUBhHLtu8/RPvFxtT78aFYhqLJviu5BQ3V4wpnUu2PzUmPc34XUuJQqLB/kLnW9EUkWf08FJ+nRiFgoBaf5KaHVFS1Ztf+eGPaCxbmY9WSWU+O0qX8CVTVjACHwwAjgkfCCEzuclbz7gjFjfCxEvg8bBY+ibnG6ELmxJtwnvqra+ngMUd/tOMhbf3r/YFo9pzip4A== 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=nFqgZ6hkvB+UNHlLEnApNNs+eawUZVXnNm+limTbryI=; b=NtJoBb5iBFifQEhCjGiXBlop1y3YmUvBadilEnoqPKwqr9nVr6k5QDtVOdJp8TS4mcdDuhSb4gTSkPkNvRpTQBWa/WRFzjWFIZWX6jpTAG/Y2d3yKI6dc5EvF7u9/8eE5PsR3cSwzhUbX6/5UMNXAnSv2Jv8KjNJBDx0XYNAvOAZ7R+e3xb6viOFFs5YODs5hJXX7rFNyhOq5yKRHCf8BdL5N8FeopPitIAhsUyStgfWR6PTePul6XSKubL2CAkRT9nOQ1ZVYTO1s+PIWxjoJn+HLfStKcDAVWgp9imP6YbYfiAZALsnMJUKZSGNsU2pZalO7ZzTtUGx+4pkW7oxCQ== Received: from DM6PR18CA0005.namprd18.prod.outlook.com (2603:10b6:5:15b::18) by BL1PR12MB5732.namprd12.prod.outlook.com (2603:10b6:208:387::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Thu, 6 Oct 2022 03:20:06 +0000 Received: from DM6NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:5:15b:cafe::10) by DM6PR18CA0005.outlook.office365.com (2603:10b6:5:15b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.31 via Frontend Transport; Thu, 6 Oct 2022 03:20:06 +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 DM6NAM11FT066.mail.protection.outlook.com (10.13.173.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.10 via Frontend Transport; Thu, 6 Oct 2022 03:20:06 +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; Wed, 5 Oct 2022 20:20:01 -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; Wed, 5 Oct 2022 20:20:00 -0700 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V2 7/7] null_blk: add param to set max write-zeroes sects Date: Wed, 5 Oct 2022 20:18:29 -0700 Message-ID: <20221006031829.37741-8-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221006031829.37741-1-kch@nvidia.com> References: <20221006031829.37741-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: DM6NAM11FT066:EE_|BL1PR12MB5732:EE_ X-MS-Office365-Filtering-Correlation-Id: a732949e-ade9-4721-ec95-08daa749aabb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FEEdvXolkIKyG17UMTtvrzOAhEoDox2pNPVChpmJcv3HMfQKDXKVDl+Fnlxcuc3cXOwKx76Ze0WxmnmstYQSCWxzciwctZB8zbLZRyCzYdst/lm86+zjVHDuOhozvtSorTUnkHCiFy1GHgmzY04UYQM5dIQiWMpqv9wCJFlLXU7/QEkH9fIOLMulzPc1AZ5EQPH9plztNLtIA6VSBju1PkUEZ0BWRE+M46m/drizdfqOsvMZY2PoAz82zsBIRSlOXA2a/9ejE2Q4pf/2OOGUcVC7OhZD2+cMfnH7BucFWEwVBy0Be1DG16EpyeLs0gYDiwvw19tYENqHneREYZTmbGUkXjmyuMjnJMldO/+mY3ZiOhlUztGQx2RNuJQeTS1iFUiNjzpXSUakDIMf5aerOp5YFtU5yR5VIoGVcGxaAhgC++cjJcqDwEGJn2mzq4hqrfyuxtCa3Rt97W+3Q+rrkb3WdTSAe47Y0YQ5DoLLWctNB+hHiFot5rfhmNUUPyvv6dJipjpjpYRVm7dmzU+I7yx/iJqxim9FnlgZ7SqYEF76QD5UrooBtYiCG9WY+9hg7NzKhqJVsavO73ADIZg9M5t2yfEEXzT5LCwpogV9+dYOyGsAJT4fbEs8NsNm2I1UHrxcGds4JdqYES9YdQlClV9hitnySDpsZdHV+qryDyRCHrz8Zr0mM/2ieLYbCmkp6pXu+/YGvX9JEQJu9uc7fYD4TArVGWmj5xRGbJQO7yi/Hvi28iyOWBSPpVhu+5ZIMggkWAYCYWjge0RapNySBQ== 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)(376002)(136003)(396003)(39860400002)(346002)(451199015)(40470700004)(46966006)(36840700001)(8936002)(36756003)(54906003)(356005)(5660300002)(7416002)(478600001)(82310400005)(110136005)(40460700003)(6666004)(36860700001)(186003)(426003)(336012)(82740400003)(1076003)(47076005)(2616005)(26005)(7636003)(16526019)(83380400001)(40480700001)(2906002)(316002)(8676002)(4326008)(70206006)(70586007)(41300700001)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 03:20:06.3677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a732949e-ade9-4721-ec95-08daa749aabb 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: DM6NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5732 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 --- 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 */