From patchwork Tue Nov 15 19:52:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044099 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 50F84C4332F for ; Tue, 15 Nov 2022 19:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbiKOTxh (ORCPT ); Tue, 15 Nov 2022 14:53:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231415AbiKOTx1 (ORCPT ); Tue, 15 Nov 2022 14:53:27 -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 EF0C6118; Tue, 15 Nov 2022 11:53:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ULwPpRrtnxgYgth8+YnSuTYh1CeyHhGJ0U+nyqbC0bYMSkKAgZEuIxAQ8Dlk3L4GZ5V/RGWiKARQkE+sucIsPmZV4IcDgyJFUFEiKzuiEoDXusO2/DZl4MVr4zlK1G7+NZIfDMkRDK5qYjA4p4kwZm5GJf5IHHXmVlNH/nndw+g2vNHEPFKm4m3gwg0R/PM8vyUN1dckXZnK9nu+sNbwB0cXMWJtLeCJiPtt/aEhUsA/GwlQ2c6rmtiyTY6HkuKG8f8NfnMKqUbn5G6vGHFXUz4wIB1CjiuDMiEiZCDCyvIzzbbfJnh5QfhxqAPXwudUzAr2gZJJ0ytE47qzcJ5uDQ== 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=VjEe3lcVGK81CyGBNgfvgtbDjjzy78KeG9gnpMLBPefwbTbmeoFPyXt9j+Q39ww24yEnWqM2TY12PChNhRxzkxFI2Q2295+6slhKKyOvGf9gUKR+DdFJnnsxfdx6+RBvTZ6NWgWcN9X5b0c1sOg4GYwmnzlCLrS3y0tsgdnVGLw1Nst61ALDnh8HUtjku3CZ8hgAm/1BlNN/FLz40W2hoW/+WpInEqdSxAdj7ig64HBFDuxxSfL9Z1J2mqSpBI8Z0dE9kuKzUhltiSiW5KJQR79ayFRKPW+7xc/xwRJfPyc1+d4TR3h2So5q59hVH4PeA/8lneunwwzCs23Tg5ElAg== 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=F3SIho4yV5KPGzqUEM/Mrn2nriZKJBAWUbDaZKyFUoBoyTwwvG657Q505g6+UapzII6uVTjahmcG7P7vtGvYp7fI4mSKgCziklYvCRakr6NQrHRXivPwaUjygZ9K8HPQk+QCXHR3+pxDo38PwoZjgwjbRjINk/jNLSXohH9gcDOz0hIKOwBO2QnUGyv6md0fy5NeZElSIZIsHKOv6jXgz6RjvgbK2kzyTnVLOMgeBWlXxlhFDV58A2qPVsixEV377A6Kd35PpH02ME1AG9VCjqoAJHQsZQ1p4QpuXK82lEHVxUpTuD5hTniVxnFyuP3Yli8VN8UPLZlmyMiIeRpotw== Received: from MW4PR03CA0157.namprd03.prod.outlook.com (2603:10b6:303:8d::12) by SA1PR12MB6895.namprd12.prod.outlook.com (2603:10b6:806:24e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.22; Tue, 15 Nov 2022 19:53:23 +0000 Received: from CO1NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::db) by MW4PR03CA0157.outlook.office365.com (2603:10b6:303:8d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:53:23 +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 CO1NAM11FT050.mail.protection.outlook.com (10.13.174.79) 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, 15 Nov 2022 19:53:23 +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, 15 Nov 2022 11:53:12 -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, 15 Nov 2022 11:53:11 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 1/7] null_blk: allow REQ_OP_WRITE_ZEROES Date: Tue, 15 Nov 2022 11:52:47 -0800 Message-ID: <20221115195253.182484-2-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT050:EE_|SA1PR12MB6895:EE_ X-MS-Office365-Filtering-Correlation-Id: f5a26703-545f-4a07-8428-08dac7430dad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U/1Chon+73OplTSQ+BPS+BJG4Qb2lZFbaHOPk51B5EkZwQoLdcntknzdabbYWMkOhDpbnTiXY+1FMAcYilJ7BlreTzRX4MxbgXMmP30A5ZIETcYa8MnAWqHMq+SSeoSdFW5MbIpU/Nt1bkpD79GvVvdNgTmyZgPkYC6ZDziPxwE4iB8TvwZxc6AaMr9k1sGv0wxMbkFUPZ2luPmalCaFdB2/hBOYBwPsIgZXzlf0cJ7WCGXOxHYxsUZXYt1ua4CqVPRynh6qliZBuIJeYco/5wsiKQ5D64z5XKJYMYL/TCvT+6FEiUz0oOyxtv10z4DrO57HSkA+iCbGg1uqqYnEyr7zSSWmI1KTHL/Y53wKyaodeUBpCXWUCDjs/9C/ZBWvLBbRseI0L6cLbrxJTSqNN1RbHS6aNe7Kownxpt+pUdFJMJ4tyPH2kOFI4UfN275YJFC941FOcpMp0zWR6h4JzYAGY6Q2zBx2s4MTQin4KbZW0fgh4TnT89oE80PYVaMK83xkzInVu09ozK13TtisKgnv+0N0PjY2+owlqi8WIbQZJhDDcY4Or1D6YwhMyNhXrgN/iU+QpJ9iPpBEQ2jHHBRpU4yhp9ATzpHoGFEa3WiMDYfw8Yuyu0cPO8mk2nDgpVDAolNcY1VvXDYNpXBWrUorodvqEfCIV/jt7XTbHNoRPKsrG1lslVGmhQxs2qlTl/k6Rnw2TfrrIWFDgkZihRn2cVDT3IUSUeifW7zUh9ef+NBPJLBs8NKVo3rHL4BYxlpl/CuscfgCVUzVg3fLAw== 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)(346002)(136003)(451199015)(36840700001)(40470700004)(46966006)(110136005)(47076005)(83380400001)(426003)(2906002)(26005)(4326008)(356005)(41300700001)(70206006)(8676002)(40460700003)(36756003)(82310400005)(7636003)(7416002)(6666004)(8936002)(186003)(478600001)(16526019)(82740400003)(54906003)(36860700001)(2616005)(40480700001)(1076003)(336012)(7696005)(316002)(5660300002)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:53:23.0995 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5a26703-545f-4a07-8428-08dac7430dad 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: CO1NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6895 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 Tue Nov 15 19:52:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044100 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 A4954C4332F for ; Tue, 15 Nov 2022 19:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229973AbiKOTxw (ORCPT ); Tue, 15 Nov 2022 14:53:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231409AbiKOTxt (ORCPT ); Tue, 15 Nov 2022 14:53:49 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2051.outbound.protection.outlook.com [40.107.96.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19DDC16584; Tue, 15 Nov 2022 11:53:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NOwBIQM4t0rxEn9dguIhsgbbQpJqgXqe5JvvVd10p0V4sKDzevXTKxgrt9OnpwnVyDl6olDl2aubTfNQuv/H9B353YC8+OHQ002GW2fn/38z3AylUPOFTykDT8oDBIizFlv1ALPGjDTn5vAYAOftRODuINBAzyCXBF/SOkBB1ZjQCIYBze+1Nu7ndmbVI8U9uKoSnw7YRTeJRDQZhzsmmCp1W1HJoO09dfYL2riiu8keXxK/q53av3poVS8Fy+Qxj6VrsvdyHcABxgsf+rmyFID6xKO4SdzxIWlQ4lQOnG5gKEB+J1EXCgFBgRxbq9DH5y8T1VnNag8PfwftLIZ3wg== 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=dS37lmTSgvM6IRaI/QtncR09MCjiZjpeD33VZgRRZBZy/x4t+W2rUf4Gc5003ezNPp0y458MEuXVAIrqC5XEQtwcaBrxBm8+iZ7uA1eCKcltS5+uoLk/qQywcANqY9+CIhtG+uX67Hr5QACfscNEHd8QRdpJE7r44/C516LjRaLUOddHIDdLfSfXnFc1/EWudsO0zrvvvTjhhSCWXjzkX+lIIN2bbAZxxRelGvEDhFpJdBNkRRZssSrgmkXd+unSuJCNY65sKp+isxj0kUW/ldDR+79v/BPKGU4JKJ+eTQyFkfGjvx5fg7CR4/OUtfbTOsUAH8rrhzqd2/+VhJIu3g== 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=e11AYUnWIO4AX5Cfxa7Oob/PndRG79OvGGQMCbBVEgg=; b=eEIuYbZGLuURw1VFQil5yx0Is50ULLS7XmSVyLdCe75YxAsc+jr5/DhQ18NdN9ITeGzlD5Q/bl3tjY/kMFFhw3pUbfHzIKEZJFtMfSvT0aBvM/DF9Nj5FGuK5jmCTgcB+PPmJhDXK2uA1PmziHw+ZvuZ6BKehNzh5sVmHiRqQN5mQSy9BRrn3ap2u0vCsStPuaQOAYbyL35q63Bxlano2aqMS5qShPUHidhzmjRyIRkxNY8f4fgZc3Mti+nSieBMbw7HRwmcp7TiAOJPKA330x/VavHlJDpE69YIDLnu5LDoJkl0Xm+k/0s7P8HC9qdvzlr8hPT2IkN30p/JKxM1mQ== Received: from MW4PR03CA0276.namprd03.prod.outlook.com (2603:10b6:303:b5::11) by BL1PR12MB5318.namprd12.prod.outlook.com (2603:10b6:208:31d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 19:53:35 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b5:cafe::ff) by MW4PR03CA0276.outlook.office365.com (2603:10b6:303:b5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:53:35 +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 CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) 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, 15 Nov 2022 19:53:35 +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, 15 Nov 2022 11:53:23 -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, 15 Nov 2022 11:53:22 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 2/7] null_blk: code cleaup Date: Tue, 15 Nov 2022 11:52:48 -0800 Message-ID: <20221115195253.182484-3-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT024:EE_|BL1PR12MB5318:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b16eb19-ea5f-4131-8e1c-08dac7431508 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5LBOvw6EYvFXVHLz3yKV4LnycvIDVJ5y9W5/gUDkimGq7jcxwzI1AgtEJi7IVzLre2kf5aJ+xw9DXgXQ29K7tm6s21RCGWXHhEFs8PNUElwhZpE3ZD5/wB3yHkY5CQ7vka6Z9VbXk9uLkgR0acV1nR5Qq+AzgffnCxYSoZlEyLoFQwHHcBscfqM2qAtxIg8dtFxRo0ODmfh3tkYvDfG3AQRg25o9q+i5TMcvDR7CwEUUBkiSEGPNLnc3Bk4Bx9aGuXp0Gz5xSbSAeq/gqBtMNRxAS9vE58f5BUwMF3FSpVq5aarBTfpcJ/yaFQj/WZmgUR5eLPTF6IaGjMU1F+A0YHHoOGHGxZc+KGoK8mV/vVqINff0575WFsixMIYjddcwjqbXA9ftK4igIImYBfjJ/zbkKlIr5pfwxFtmtOwuqaP1Tg2I2ePApQJrkzkYX3z/z62A4dq3ft5JqpR253tNS9/0SNhbENjs9W5UWuX40+FpIAlLhyKsra8JDxTkbVPxuMTlFs+i1lqhSMvb7PfqTQ71J9o6i4v/IBYdSHRbAXTX2lE3kbv/Qy+57sSckVSAmgCQSsOL9zYlpnY+e1lHF5se7c59MkFfq6MsRNUDH2phOFEYMf3J8hGNsAZxj1w77MYdh945XE0SjB3kP6G7/nJzGa9kO8PPqpKXw6txX/dJ63o0JZh+BzH6JIFb0SBjaS5A9UntNiOWWoTRQvOmOH2+Xnmtk6nIiDREKkygfiVNeQ5xUpQKQP/RyPr5q4M/Zvd5ARVy+onxBk/IbLRFgfLt28BVtSGS3MfHy7n5zLjgxEh5R7zWprh59hoYe5gi 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)(39860400002)(376002)(396003)(451199015)(40470700004)(46966006)(36840700001)(54906003)(7416002)(8936002)(5660300002)(70206006)(8676002)(41300700001)(70586007)(4326008)(316002)(40480700001)(110136005)(36860700001)(478600001)(36756003)(6666004)(7696005)(26005)(356005)(16526019)(2616005)(2906002)(426003)(1076003)(7636003)(186003)(336012)(82310400005)(83380400001)(82740400003)(47076005)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:53:35.4402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b16eb19-ea5f-4131-8e1c-08dac7431508 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: CO1NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5318 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 Tue Nov 15 19:52:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044101 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 EEE76C4332F for ; Tue, 15 Nov 2022 19:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230492AbiKOTx4 (ORCPT ); Tue, 15 Nov 2022 14:53:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231540AbiKOTxw (ORCPT ); Tue, 15 Nov 2022 14:53:52 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A32C27930; Tue, 15 Nov 2022 11:53:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IUyvStYS9PCX7CaHeagTNyvEoOS3jE3w4NBDEtqw9SIeR4DbccnZJTTZDCSmh48v2WsfSiqMeEaR7+3l2i/AQeE6DbFNZEG+f5I9MByXa39lIwPecJgK2wEieFF0USbqZH/LtCGTFU3uX0TGpy36yKBaXW1dJziqMzW6BNBgTOEkXiLa/pZunAojuNc9YUPp7CN6VoRViqmsiM98mpjyW2f+HVUuOHjH1xmDUYorFjriQKEwENUUwabjCuGaywRfZDTuKzEmUrlFJ1siP7NcQZQnjY5c/BMKlXoHq48uLCLYUqeAnsr0GQdKWRV+KELD+CZ44ByiyXTWtTY9f3+GXg== 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=mmZd34vElReKDyPmuNCocxVvJitSsG66imh1clSRBVvMspekMYpnPZJloSqJ6+WEYhLIIGWirwvP0/DXiS5X1j4cy2yQzQ6ne5JpG/wFbc56nI7IJHSD+rqB1GdOP0lz0XAzXQpIAfdGVBpuiSlIi9fOCSc7ihUaztN6VXF7X71rdq/eLUOIuHtMVo3yJzmb4v9BA3ljkrdT1+uPrJKyxYJzG9fy6d8h2SH/W9AVKuwu6xPAoorzLwPRTIcC2J996Enke2sQStpIDyDH4airbaPev2kJQD70O/YNn6g9QadHtWgnIQOpGK+GM5pI+m+fgQaPzPa56TWbd6MGalfqYw== 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=PZZJAecIDxYJNi/PEEW6yXAKM5a+NxESkCX2vkJOAAw=; b=X/2dhxtsVnaZV7Vyqf+KVqs2rZuCsQDUnY88cR2l7J/sVSsPimpbWon/noaqiBPcL9IJXOTj9ohK7yg09JL22VQYgPIet3AqARMZeKMitEIrHQhSCFKh9sCHAxGGO4SsE3cgGp8tzfNaUpLX7fsxhv0Gtt3/MWbTjWEZYjCpBJoM5Op0LfrAURNtdYoI9VUdBY1ZKVI6ywDWV9UVinXRxyz8Ye8BK3wOgrxiwMYg2393/XSsLiJ4EOghQOz7akLupboP6MpqNqTcd63eNqxNUrCeFRc5KDZYCnky4UskpW0Ydz+DGWhucrcB5q1XXdcNK0teo//IjgjkWiTNugNCGg== Received: from DM6PR07CA0054.namprd07.prod.outlook.com (2603:10b6:5:74::31) by BL1PR12MB5269.namprd12.prod.outlook.com (2603:10b6:208:30b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 19:53:42 +0000 Received: from DM6NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::df) by DM6PR07CA0054.outlook.office365.com (2603:10b6:5:74::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:53:42 +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 DM6NAM11FT014.mail.protection.outlook.com (10.13.173.132) 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, 15 Nov 2022 19:53:42 +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, 15 Nov 2022 11:53:34 -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, 15 Nov 2022 11:53:34 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 3/7] null_blk: initialize cmd->bio in __alloc_cmd() Date: Tue, 15 Nov 2022 11:52:49 -0800 Message-ID: <20221115195253.182484-4-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT014:EE_|BL1PR12MB5269:EE_ X-MS-Office365-Filtering-Correlation-Id: 265b3a67-05df-4f52-5e40-08dac7431929 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nQhnbmOx31aHci/B62eWcr7CIoggotB2ytlAyFslyKaJB0Tkdxtw8ydoA/r0IWGxPMB79uK5Yb+vAA0HRHmuDdAWCxd1h5lIlKTQl1XaLfHiftWgpk/dH+8BdVB1Mx8J4hI6tCxHnhk+N1bmSNoBlk0Etnn1L9vviaGvFkJW6eIohZkVJP4lyF4ghKk9ggrFk/gNKb5nu2pHq7fPdxuD2taj0C8nzazdCgqWDFHyAAUEJsqrh15bbg7lNNCy8WWOvpKX2KPikGBTz6LB8Fm2wBLquATjn3qINCEB0R0C7SThJYe8vRZ5ScS+Uf1/6qtNrdNL+LmKKLx5k8liHuPpzEfkmqRs26l5Mhpkx4MRvTFn/2I9UoLtE4AvXu2Mi8gu6FHEcnPA4hKG4VLCloqR6kS99JjIxy4l89G9Lm0ai+KmFC5d4QFz8XX1/EDkBg3ANySSb/gWfhNkwBoZ2YrAtGMwO/O2fGqSGw14K9pClJrOVbEtNm8dFJ85RMZPgqqKXAkn5nCvrh9BTN6JDvMZ74qxLI0oU8W9rzcOAI/tPej5ay4PuSzfIJu+SO9fuAbmesJ1n8rh8UrEpvwDBISYIh3AmplPicNk/45euMra8ZkCiKhxvaQekH+MaBnqFnl1aAaPb4joCy0h/Q3WA5NhNAgykOjjkTNLPyOv6O47CY7MRcxDHzdpk2+mREesiAlFZtSgQYGEj0pcpwRziEHpESYlvhj2eBS17SnCffarbtQli7BbiNljd1MZCyMb4M4LvBYlDBcWMGhBTIBNM2rNpA== 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)(396003)(346002)(376002)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(7696005)(2906002)(2616005)(4326008)(316002)(54906003)(8676002)(83380400001)(41300700001)(70206006)(40460700003)(36756003)(336012)(5660300002)(70586007)(26005)(7416002)(16526019)(8936002)(186003)(47076005)(426003)(82310400005)(356005)(1076003)(110136005)(82740400003)(478600001)(36860700001)(6666004)(40480700001)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:53:42.3661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 265b3a67-05df-4f52-5e40-08dac7431929 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: DM6NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5269 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 --- 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 15 19:52:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044102 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 E8B3AC4332F for ; Tue, 15 Nov 2022 19:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbiKOTyQ (ORCPT ); Tue, 15 Nov 2022 14:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbiKOTyK (ORCPT ); Tue, 15 Nov 2022 14:54:10 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2064.outbound.protection.outlook.com [40.107.101.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5443D2CC94; Tue, 15 Nov 2022 11:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e593txaV9FnGS1/u7+R4yIlkRtMGCsQvef1OkYlv9fsqW+QgvNTfYNHwtCEj+yJmBdK+J8WAONkgyCch7YMQkTz/UzLALfQhWHUBb2VlqXb38n5izIuS0jSheVOjwT7Z18MapbSddZcDE9m7u8v1YLsKU3aT4rMKP+FYpEwg3UeBMViOBGAL0LViGY/kAH/pkkNT73DQAJgRoIxEGLBx04a/iO5vjNxj82ICmxAXTdI4QVtd3zhDPb1meBvYryF+0GERNtj8F6dtCfzbENixIIMS/+wVC2chGV73cyzDHITkOpLLyVRUVZIxhOFeLkkWKXDEXWxG2Z/rQq8sIfsD9A== 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=IbeujpJzDRE62F+WmITaQymnVJXgSWRWdandKWMcHMbBCah1kr6ibAljHhqZcO+68cM3i1asmiAY4rPKnN+UgoXC7zcF1TVW6Q+EhmXQ/gGOALjVAzwt2txfo2v1J/biLqWg7i9nqLjuEjmO/cvMDXr3ZgYw9wkJ9uGTnBlIA8BgwsED9/lchAHjKAJs9q3yhUmOfbXQco3Pe1cXEx7ZDTwbguHnXRUBaSTKmm1Us+PndhUrLAI4GXK+CftRVIChUgZAmgMtvHTI/Uf0XasuUnYgFGIQrmj/viYNZzWp5YubPcim7FesGiHVKdYHrnFVsEuUhLDGmBYkJ9dMKaUJbg== 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=QcZaBxzCrlxwQRocyAtbTyXcp7ABZjxJB5o4lLmW3q3lGDLODMv9qeGoaCg4ujjW/vvVG12oqZ8AKs9o/c4aanIpBnykgtstnBrpbzVbJ9Xmp3Ws47sZ2n6leznsOShzAp6CfgRHv86JsnHO7oU3Yb1Ypw5pVVy1egFyBw1fiDxDGG2Y/o1f1KG9C0IbdwRkLbYSl45uDUvHFUeMiOKrOF8hhL1di5NEDIssxChJgOAcpF076J6zY2dF+LwrsA6cDjNpof2YoVuTo35POqwwifW4kyL6kAQV2X0TmlmbKLdPN/2d9W7C0D9em2YPqWnAQg4gpJF8LUCI7iYf5B4nmg== Received: from MW4PR03CA0249.namprd03.prod.outlook.com (2603:10b6:303:b4::14) by IA1PR12MB6388.namprd12.prod.outlook.com (2603:10b6:208:388::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 19:54:01 +0000 Received: from CO1NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::dc) by MW4PR03CA0249.outlook.office365.com (2603:10b6:303:b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:54:01 +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 CO1NAM11FT096.mail.protection.outlook.com (10.13.175.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Tue, 15 Nov 2022 19:54:00 +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, 15 Nov 2022 11:53:47 -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, 15 Nov 2022 11:53:45 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 4/7] null_blk: don't use magic numbers in the code Date: Tue, 15 Nov 2022 11:52:50 -0800 Message-ID: <20221115195253.182484-5-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT096:EE_|IA1PR12MB6388:EE_ X-MS-Office365-Filtering-Correlation-Id: a9e35941-62e0-42ad-e5a3-08dac743242b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RU+0jrKku2OjmOG4jgnfQnEh9m0ZNUNpxWewfQx125JNaBCya8yrBquaFFhqK8JggkY8/aUwKJjHkW8RbmBeU984GNl9yut9lhYyNkLqboS7FY9NVG8oFloysYlYeVv8CWU1tExQr3OC2+IybOZXuw6CVgYDlngdp8AEBYrmp4heuIflAw5/HTh2U+x7h9KfLzyLsBTrGdDpn+DNtImjCUNz7Rx6MZHZmS0zHBWUOHetUBWqhWwkKTPZQRXEFXLMhnxkkIOJQL4JpE32OmScoj5BJbG8KGV7tbCLpjD3/cJpVKxQ9HNPCCE31TLb8M4+bm3FfPj/tnF1yNWGmUFPBsVCTwZEhUkWUCJt7e1LTJ/XDmJiP44WrgQPy7cjeqabUGWtPjbCeXofV/es6svXjcujVwlHTUKaH8xlNqBOjYHAy1Go+vyUYHLo4HuW8a7TXfyfiNdGVScXsTB4ACNOgm7IhffGsL4Jezj4nn3J20ZPr3MIN5ASaI7uyfUZiMVencFHgn5z9CxZnzbh9Q0pPsI3lxi7nsbcj+2mqwoCHFyX8PUPt2UqCDtTJurKsnZUW4HogS8bD9YSJ9yk20O3XEMpBHOEcEgsU45fV1/+fypRu+WZGeJIDZJIEGwSms2OMnUUIWocqFqemvNJ4sieoa52k4/iNWGPFo4LVCyXb3NyETyOqYbqI6E8A7yW3J4iWUortFps8IyAOGZyWcUsaAl4V6pgSZJQZfzwse4dDNJpe9/Eif5EV4doyX8Zh2ojXPu082nUJkS73NzxZesEqg== 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)(376002)(39860400002)(136003)(346002)(396003)(451199015)(46966006)(36840700001)(40470700004)(36756003)(2906002)(478600001)(36860700001)(7416002)(8936002)(356005)(83380400001)(40460700003)(1076003)(47076005)(336012)(2616005)(426003)(16526019)(54906003)(7636003)(316002)(110136005)(186003)(82310400005)(40480700001)(5660300002)(70586007)(82740400003)(4326008)(41300700001)(70206006)(8676002)(6666004)(7696005)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:54:00.8376 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9e35941-62e0-42ad-e5a3-08dac743242b 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: CO1NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6388 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 15 19:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044103 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 43E12C433FE for ; Tue, 15 Nov 2022 19:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbiKOTyk (ORCPT ); Tue, 15 Nov 2022 14:54:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbiKOTyY (ORCPT ); Tue, 15 Nov 2022 14:54:24 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2066.outbound.protection.outlook.com [40.107.220.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A1E6250; Tue, 15 Nov 2022 11:54:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2aHAXxmKfdty0S/wWFv2yUce1uoZdfZ+wVvKkNJ3rfiiL/1vOzlpWrAAnoEWjCduBwBm4F2bB6x61SOFkppsAD0K61v7oz5N8NUU2TuXaKMsps7jcsy8vYld6tQyUe6fyViiLlfhTY2gXOGWVb5YaV/2msKrgWZOP57KfxwA2Prax6IQWyfF46/bvFYK3pfzSMFrk2xO8EjgUc9qFHZu1XFIa44YMQ5wGPmfIBBOSf7a3G+RTlYLRmJx2YJgz+h6RXNkhxL+IHzNESaEoXKHlcdCD3cFwLGhfFHNNDm1JeafWQvzm+V+o9qC1+YAsd8B6IM7et7spF1+45YZ9Kquw== 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=HgIwnDdbxUV/T/AFdywXy4IkLzDHbyTLCYXhkHH8cUkU3kYvdD4eunj+pOKuoNGtdYVWJ6ARxyQJhRO3pLwh3294dCs/Pa7ZHh+tiATNJZ71Lh5aZVcHyBuCgXRfuQAxkaLNXJiTc7e1XZ03AhX7/moQ8yfjT8lt9a4MHolJ6oZDzk/LowFKFmjqc7vbcS1n9c5Aaqr0Hvc1XrbLRizRbuNw+rUL7Wz9LJvnO4AnCq4dNdjUj77lMi3JlPGGDDnx255CWEG3yv/oldS/k/UYvDtBEtu1mR3VeKGFBrF+GeQ2JcItCWNlslwnwA34zAqIgv3c5jfabh0fbSAC0OmYSw== 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=KiLAjJ+YWiKO/cZsJFmLCEH8r2kiulS+akAiHUDdbmA=; b=skyEmr/vTBoxoKs5EMsgKmGys6a2wNSOWI40rhonA7OW8Pk/ZyGsI3DilYzHLJiBbQY7A+cRwFHKEzHWlP7m3xqwZmVP1/lt6p2Rvmkm15OXfuaYTWM2o+Mis8Was9Az2Hx6Nt5KZgqVYNfqiW2AWvBfNXpZ0g5IUtscktXhThtG33kqPMfU9L0b/JwTRgtmbqgMXvDYkcg3MTvk1CvKCIzK/ieyQshpZNOrSKF7Yze397TqoVt4dFjC7dDxOFn53OvAAm3KPKrWYiJIhuPdu83JNdmHFB8qSpWPc7p7KCMZ7F/ntQxDsVkt+1CIQHKB8uEqOzB1xL4kFEXdHg/+5g== Received: from MW4PR04CA0205.namprd04.prod.outlook.com (2603:10b6:303:86::30) by PH7PR12MB5758.namprd12.prod.outlook.com (2603:10b6:510:1d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 19:54:13 +0000 Received: from CO1NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:303:86:cafe::7a) by MW4PR04CA0205.outlook.office365.com (2603:10b6:303:86::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:54:13 +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 CO1NAM11FT021.mail.protection.outlook.com (10.13.175.51) 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, 15 Nov 2022 19:54:13 +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, 15 Nov 2022 11:53:59 -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, 15 Nov 2022 11:53:58 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 5/7] null_blk: remove extra space in switch condition Date: Tue, 15 Nov 2022 11:52:51 -0800 Message-ID: <20221115195253.182484-6-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT021:EE_|PH7PR12MB5758:EE_ X-MS-Office365-Filtering-Correlation-Id: 45edf247-74bb-4cf3-559d-08dac7432b6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5/IVLoERFua759+t5Y+OUd2aeNdPfMbItdzI7jlokf2uw3G/owtGtW2z/MNdeWxj+uJMhpkn/To7VRweK8sKOI5uJE2yDe7+PmqssHzgKYNcxMkoTbgfufG7gDSg3GJKMpW0AmnzDWzSe3B++xMHZ3tjArFV2bdqIdgK7xQY+yLzuSpmk9BlpquYhNkJ0JaYH339jOZgHY/uLN+rDD5qlewFvGNQCshPXT52w8uNvjtIiqhWVd9UfqZWNiBECUnIXHJCGXPduaXt8t6N62pukdCM3SOaIJ8s+drUvwYIjVyOWic6RRuutZfHFbe/zyLp3aE+pj7NAQgVYfsuNRsR3IjlmtLajSH8u+yIPWcK7iUV4tbCI1ucOudTIzKjjXRUxlV9vGCxoGQFK/nSkob2lz3ZAvIRy4FibqhzEd13RifbJhPn0K+rWxGAWEdWfku8J8FALI6nydi3YilAbtFiVcSXi27xOCfx4dr4vmH6BPXVzg7yfsY/XShe2TQJJpCdcNXY4whb7xQ6bCRpgtL1LpRmzW3PuHveqsAafKz0nmTL6Mxq5OpAksE8xHjLWXknxOhWiGnA0fn/0rvatd6Uw4dHtp4HGBgDKnYnd0GEuKCvB/2EyE50YV9GvrmhVeQ0SjuAAqHRWuL1AU/iCOgz3DmY/6c5wjarQ073LnMwaTjt+80Hd5v8WAuh5FUEYv1O2ybEEJRqzBkCEWQW8aW581KBqmEskCHq5U+OzKmZnQNsGLjDE1cty+52gewno1SJ69gW5eBTHMIr1weTK0QyA== 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)(376002)(136003)(451199015)(36840700001)(40470700004)(46966006)(316002)(110136005)(54906003)(70586007)(478600001)(8676002)(4326008)(5660300002)(41300700001)(2906002)(70206006)(40460700003)(40480700001)(36756003)(82310400005)(36860700001)(356005)(7636003)(8936002)(4744005)(7416002)(83380400001)(186003)(336012)(16526019)(1076003)(82740400003)(47076005)(426003)(6666004)(7696005)(26005)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:54:13.0171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45edf247-74bb-4cf3-559d-08dac7432b6e 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: CO1NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5758 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 15 19:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044104 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 D68C8C433FE for ; Tue, 15 Nov 2022 19:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbiKOTyo (ORCPT ); Tue, 15 Nov 2022 14:54:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbiKOTya (ORCPT ); Tue, 15 Nov 2022 14:54:30 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2059.outbound.protection.outlook.com [40.107.220.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C19E22EF5B; Tue, 15 Nov 2022 11:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iysyIkb2qe+ZRjpP5tOEVfR+zxh+EnNRv//T6R3d6FJApLHGNd6arBiZrQGWQaaljZSGpYrG33Gh03BIzVds2GNPTjdU3rbZIehDqUinneOVXfm2PWj1uIVA94RoRgn4LpPtDVjWkdesApLFSfVSkvZw8xwPRvAyv5Ud5KYqgTYzSLl6oFKZqgJ2/YhnUFhIdkrmLyl5UQFJ5O0E7pP+bNtDYu5u8cvDarc3YoI6R02kXGbkFu7RS4efIZQcU0gxyU2lE2rHpW3NcyWP+kQp5OOcOiGDWDOlA1tDwlvfNgTxY4T8oQ8cVBMTdQwO41i5O4rYy0SsOtmE0+qcWsl1sg== 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=OoEyqfoDvqukhS5V31Qn5F6N3uk3Vlgk0bRG0H5c1wtW9DJ5xyrwc9zDpljGC0fe5z1A4w7ZgpYaCv6blA/kYsfG4V89TGmylBlAf+imqTtCvjL1NWasOWodQET2kvc2BsAWC3+ouGEEYd5GkVZbT0Fh5rwnb9qchS7Th8acq9xrgUA3UhYxgWjtwWs8FxsuENHw7r7THEUCerqdA0IJgkDZvuFYz8eWaDn/wy5iCzanTHvyyjvYro24y46z6kooEBbBBPksR2Z3bI58e23CJTdiPjoEM/Tb5bHaR15NbCroFwIXe31YV0gL/i82lKxEd9+If8EJgTG8SV3OrN0V3g== 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=AIe4mKOyn70BXMu9ewRDR6BaGZiCjfn7IR9cPrqCt9M=; b=JFSoxaegqJ3HA3Bv7/FbiSsofDuso7pZ1NoxtEB16S22Ls7Absj+/n2RYG+cwKKmyJLAjLXhbg5Lb1mYV04ATJhkj5nxrJZyo35Lsp5WVvT7Zqw6jRTexPZ/7QpQUV4vPFDhkT8HcyG6zx+E/puG4Df/ARhdKk/9cRxQzBj+0r9nx2jNs9TdzmaNDsdtKkivIMAWhk93I5hOO6PTm8vs3cuQ3XJgIlMG55uI3P95xt7mLhSumZih/uBhSdVW6FLKjyGe7BAiKLdyFqAEYCj8nx/xwUjroKrAS/rM3scNwBNjUGGIvEiE5AEC7fJ2aeyC7F6yeJq336UCihpKJ0sRKw== Received: from DS7PR03CA0302.namprd03.prod.outlook.com (2603:10b6:8:2b::11) by DS0PR12MB7678.namprd12.prod.outlook.com (2603:10b6:8:135::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 19:54:20 +0000 Received: from DM6NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::17) by DS7PR03CA0302.outlook.office365.com (2603:10b6:8:2b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:54:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT034.mail.protection.outlook.com (10.13.173.47) 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, 15 Nov 2022 19:54:20 +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, 15 Nov 2022 11:54:10 -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, 15 Nov 2022 11:54:09 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 6/7] null_blk: add param to set max disacrd sectors Date: Tue, 15 Nov 2022 11:52:52 -0800 Message-ID: <20221115195253.182484-7-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT034:EE_|DS0PR12MB7678:EE_ X-MS-Office365-Filtering-Correlation-Id: ad003b49-0383-49cf-b811-08dac7432faf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TtL/gI3VI4vIMG4K5klqNxvmYDSRoLs2cPau0DRjTEG87Y9jbnCE0byoy+TWhSecqve7gDM74DfdUaTS3chalArv1++XByk9Y3yaSdjxFBlBdP+Ox46Q22msejjBdaDJ+vUasTe0hwnvdMrrNAfDYqEuwBw8skZ84C1bB8OJEpd9dNTc/302JwNnl56o/cxdQXPR/lH4V7FUbn9pYcQ6/tMWhLadOqo6dmQDPrHd5ry3hhQ4vRuW+tUX+P4Pi4esMtBxf9iDrf1RLmaiNYShQPWfoeEMrgbBpW8aYZx8KplH3iImrNj/1eKwBtBYm5pKFPycYmCE0WW2X9lgRlfZtvIhArSUOGWK0L9IQc9o8qm4t8+u3ZVMOffACVTqaavLld4M8naQsEZgEKYZ2PS92QYITZM6L06SqgGqruo6Az2sLSXJ1ZtK9eiUT2zcfetGjTojKDCUWxkNT7ykk1JQZnhc/wF2PIMZSnUy7Xns0b8ZHWNjFmUrIysmVebVp8jUFUUqBL5j++YQDDeufhPwpkIwZMdskeCpxJApHGqOlbsa5Rcih7yvHxwgJS3UsBdL4PvrJ5znl8dLrbGRrCSWCxKjgzilouZ2p61AgeIVdAOW1xaYtWdN7lB2Gn7rVuxXSNNG5Fn84L6h6BLncEeitWhR9s70Yzsd0+XfBeUma9wU46f0ZBQxt0hpmu5PWk8ZhBKUshYeXeVJUxiKEs4qkevu53pnjnxH5QIhJkrGE6E1tBFv6dItTTAHu4adNm+15cYZUnBNTHILEgas7kkeWg== 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)(346002)(136003)(376002)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(2616005)(47076005)(83380400001)(82740400003)(1076003)(426003)(356005)(7636003)(16526019)(36860700001)(186003)(7416002)(336012)(8936002)(2906002)(478600001)(8676002)(40480700001)(82310400005)(7696005)(5660300002)(4326008)(70586007)(70206006)(6666004)(26005)(41300700001)(54906003)(110136005)(316002)(40460700003)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:54:20.1565 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad003b49-0383-49cf-b811-08dac7432faf 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: DM6NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7678 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 Tue Nov 15 19:52:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 13044105 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 EBC3FC4332F for ; Tue, 15 Nov 2022 19:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbiKOTy7 (ORCPT ); Tue, 15 Nov 2022 14:54:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbiKOTyh (ORCPT ); Tue, 15 Nov 2022 14:54:37 -0500 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 6336E275EA; Tue, 15 Nov 2022 11:54:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jOG0VlSJf/PIbhD0UGV3ega4ruCv1Kc+gtrkGHBNAhmNX1y4xuTfIbz3gamWOaqDFrHRX1dFmN6idZomItLdUCyH5VH5jIVMV0Yl6dRbsYvRM8rs5skZpaJN2uUi4dRdTHHGHvFAdZUWJnnaHRgA96PEt7LKS2C0V2JTU2/CmoedmPJBuB6pvCK/J6AAUK8ZgMuwUMJPXCl2jIrrei/OP20plwdQvqqLCeflkdpauBlj3BDLzQio7rKxtTygCM72JqAQ4A4OBLepViyc5PkAE8/Z60lKxW3GN8YTKlE48nTnX38rIU9ay6Ps3m86nKUJ8dToH+30HE5Go3nFY7OR6g== 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=DbNfWzJHOdyOEBkKDQahHFuycq8yi4+zkGROgvB+iN/JfEGfyFS87GVI81Y8VxkomMazHoGQeIEqLtsGMziGLGiQoef9FSshdj1i4Xsgp7haPLuhHqt0QJ3jY/Y/AbOFKK42kYl0KMP0+QFd1RBFjWoHFsnnqNY1I50NtcSfjfbltw5zxyAlcEFcc1EbLhDVP8QXULfDt5PZ5shhWH64UMfQGx2t53+G41fnkVRTqs3cGvQA3Zl2gjD1C4G5uUIK+uvIJStmdOsxoNu0PoyqCuF1H1F+979HXgxyXNaE2+60V7VnqtdsQu6YqL8XlTyFLpsG7wnxNE3ICjzChhiS/w== 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=SRf6Z2BKdQhsuU33647aSajLJfjUcK6ybXKiekPU/pH3IUQZ7FvKPCXqjBtY9Eseky4z2wyAl0qHDKqUMpEjrdhyDqe/CiSUhTvYHA5D3oF13lQMcR4So41pfxuJuhxsNdM8QEbj3SqJHu59P0BIHBTluVYhqjBcEwwoFeQwAvKTjSmfP9iBE52LU0T25Q+A93vHYqtg0MvowUOORHLMAhcvCkOhTqyV9MjRO+LkEqSpGJk+W2rZfqnSEa7d4utOmexJwFhTxGt468Ovj0duycU2JBejG0G+7ZJDE3v+Krowq6eM2yg1aTJnatKgC8rbRE5TX50oSNlz2zgWO/G0nw== Received: from MW4PR03CA0171.namprd03.prod.outlook.com (2603:10b6:303:8d::26) by CH2PR12MB4101.namprd12.prod.outlook.com (2603:10b6:610:a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 19:54:34 +0000 Received: from CO1NAM11FT080.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::55) by MW4PR03CA0171.outlook.office365.com (2603:10b6:303:8d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 19:54:33 +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 CO1NAM11FT080.mail.protection.outlook.com (10.13.174.99) 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, 15 Nov 2022 19:54:33 +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, 15 Nov 2022 11:54:21 -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, 15 Nov 2022 11:54:21 -0800 From: Chaitanya Kulkarni To: , CC: , , , , , , , , Subject: [PATCH V3 7/7] null_blk: add param to set max write-zeroes sects Date: Tue, 15 Nov 2022 11:52:53 -0800 Message-ID: <20221115195253.182484-8-kch@nvidia.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20221115195253.182484-1-kch@nvidia.com> References: <20221115195253.182484-1-kch@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT080:EE_|CH2PR12MB4101:EE_ X-MS-Office365-Filtering-Correlation-Id: 6baf2f32-42e4-4f89-6d23-08dac74337cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o5cU8cZD0U6dJeJN3vW/vRnGe4XvmYF7+UHk51li3YiEtR9/d8zYQhXu/958YH9U4xynD+PlWqDjlJCkT6hXDhxFnmr8WssTfoafV1S7+EptNsTDYCN2Yh7pGNdm5J70D73m4pl+IckpTr2lHbR0iGmbFgSRzoSchoYueD2VqiozoZUI+1EmQElXO69Y0ceS/STgtEkpIlnBx6WsTTkIF35aDqSP9IimpgxI3h34g7lBgwP73gFlcphS6k65ybSJgYnl9zJYZqxpI0nQPEatvF4kufUWD8jVmvpP8eLEnQUtBLUNGVwFyiFNGeTyIJcgQEc1/kqKS10khQ/7cUgsukJQK8Zf/iroJf1LIFFbYJ7my9Wbu0dkouj06YJLM+SKY3vntahK7Ll3Nuw8ALdcl7nVmp0BYY4h/SQ65BevMcHtpdwxMq+cQZhj0RSvim7QbqHJ6FmIjI1i34zMDJMPRQGKIzo58HJ6ays77bXWhKIXkRF+dILjojkQ/3tPIVOR4kkoVByUtPaKdNscfB8zx2PrOvvR8AI2UI/C4s+FPNjzmOT9+kEbLMCC1C7AdXEjehEqsOfRPjDGm+MbaF5UVzgBYHFGSCmXOvoUhoNX3bM4k1QDyKzJ84yAA9hBbEVdrFQck8r7HeSSz9ba7eVQDO9I3rhc0dWR+GsuIo8SQiUmmb38Pqkk8Sp/blYXs+xb52C/tP9sxxAvp+OJhQmU7UgGgROAcva9XecD9o3qkr2e7Go18hTKzPyKc4p/iJ69h2CMp3cmRHmnYPxuWxUMeA== 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)(376002)(346002)(396003)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(41300700001)(36860700001)(40480700001)(478600001)(2616005)(4326008)(70586007)(8676002)(36756003)(70206006)(110136005)(2906002)(54906003)(40460700003)(1076003)(16526019)(6666004)(336012)(186003)(47076005)(426003)(83380400001)(5660300002)(82740400003)(316002)(7696005)(356005)(7416002)(8936002)(26005)(7636003)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 19:54:33.7598 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6baf2f32-42e4-4f89-6d23-08dac74337cb 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: CO1NAM11FT080.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4101 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 */