Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4591867iob; Sun, 8 May 2022 18:30:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY8YZ5Mu4S3K4e71hzRpc3El58q02q/sjBlclTNFXwghB77jyXPWL7uBjgX0fAmU0HmMAa X-Received: by 2002:a17:90b:1811:b0:1dc:8d37:b4cb with SMTP id lw17-20020a17090b181100b001dc8d37b4cbmr24104041pjb.101.1652059833672; Sun, 08 May 2022 18:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652059833; cv=none; d=google.com; s=arc-20160816; b=C8znW9lBzWG2M2GNAtWdKvGH+uFlJg3s5hYCglja5AZ70ETXT8LCo4oxOJh3G0fexi At0aWcVmLt3wWyKzFmbVO18xSH9iKypsG6Oi5NE0yM87HsE4r9Y9nr3xH9eYIym6boK4 1sdXsm4u3NBKdP2AlNrMJ+xQIaAK3p1HD5IJbt8BlYe18dunB8eHv1nmjTIDb9BqXSji 8dn2t/n57GEA/G7KVeJ2FSkAVXFPGlFQGz2fvooZyQSeo3W6pwgzo9z+jnze1FpJoheo 9fWgNNILv0AjA87ck7HVVW6104mafu+bDuTWYdUanLivMHxENne7ylWnQHG5zkZXS2QW 9RVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=yQwxoWmCgZDFVxVUZLRRvHQET55296Ujxw9EzV0ZF4E=; b=dKTDDLvsfRmHTdk+W6KdBWNcXFv3WKh7jux3+oYTzeslbRX20VjQJS4Lgz0eqYSxQw yUxorjCg5aI2h/GYJwuJeZQp9Ig6XeaveAEutTmLqWtmGP+IzEk56OzCpp8NBUWhk2Su DBvcjDEbxCAOc71x35XjLc2n/Av4jAkvyhcEZ2wtVhFsdXc9x0lvP4iDnbKFBsaee7V/ 1u74mj+0jeE1q7mHESxlUSm5owSZZ36BkK7JXzOAwWCsaKbj3D4dNMGPFUkI3REGzKnv 8+6QT5hdtHsCiYcUJW2gEG8QMQW4RCTyvYTa0uT/NNidgUrAudZeTRW4pYJ/sUgR7Zwv xnhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=GQBvyGTF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m12-20020a170902f64c00b00153b2d16659si9292506plg.609.2022.05.08.18.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 18:30:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=GQBvyGTF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B2FADDE85; Sun, 8 May 2022 18:29:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389850AbiEFIPB (ORCPT + 99 others); Fri, 6 May 2022 04:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389833AbiEFIO6 (ORCPT ); Fri, 6 May 2022 04:14:58 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A700167D27 for ; Fri, 6 May 2022 01:11:13 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220506081108euoutp01f3a199c74330cef650d462b3cf279d6d~sdcjOD1js2375323753euoutp01u for ; Fri, 6 May 2022 08:11:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220506081108euoutp01f3a199c74330cef650d462b3cf279d6d~sdcjOD1js2375323753euoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651824668; bh=yQwxoWmCgZDFVxVUZLRRvHQET55296Ujxw9EzV0ZF4E=; h=From:To:Cc:Subject:Date:References:From; b=GQBvyGTFqs0dQRbvX174z4zc8Lp1xv8OtwVfAdIYsdYJToC541xMg0M/mm//V3Z0H YEPQqAuaMcc3vtDRbm4U0XA3ga/64sIq9DC6q7RripIATXfbhYozwv5lJq+nN5a8dL kkM/BbgVJ1lis+GBqq8rZwdeu1nraTSESXmzB7Nk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220506081106eucas1p207e8015092f0e2deadd151705729da43~sdchgzEs-0616806168eucas1p2e; Fri, 6 May 2022 08:11:06 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 70.05.09887.A18D4726; Fri, 6 May 2022 09:11:06 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220506081106eucas1p181e83ef352eb8bfb1752bee0cf84020f~sdcg5V4RU1756417564eucas1p1w; Fri, 6 May 2022 08:11:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220506081106eusmtrp1ffe7e1fcd389b80a44485d3379169b1f~sdcg3wtYO3089330893eusmtrp1K; Fri, 6 May 2022 08:11:06 +0000 (GMT) X-AuditID: cbfec7f4-471ff7000000269f-23-6274d81aaf58 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A7.E9.09404.918D4726; Fri, 6 May 2022 09:11:06 +0100 (BST) Received: from localhost (unknown [106.210.248.174]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220506081105eusmtip2b916ca212802379169a16b9e436b7f61~sdcghBJ0K2136621366eusmtip2T; Fri, 6 May 2022 08:11:05 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, snitzer@kernel.org Cc: Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Pankaj Raghav Subject: [PATCH v3 00/11] support non power of 2 zoned devices Date: Fri, 6 May 2022 10:10:54 +0200 Message-Id: <20220506081105.29134-1-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUxTZxjd23t7e20AL6XRd2DC0sUpOkBwS965RSTbzN32Y2qWGJYtWvCu kJUqbRFUMvkan8UCYyCVqVM3sKJY2hHBttMqBUeVjwoCThpCAWWswEq3MSuscOvmv3POe87z nCd5SUzQSISSKTIlI5eJpSKCj7dYF+5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F57v5TZbrDyXX+L2ZtMOHhTv8 b4vNAbtDtcUX3lcoVZ66EX0xqalo46aY7PrjdU8Dw/edztbZ5nD+/+yQLxFTdmY6bso+GDxN 2jbt/Ocuy+u5T1K/SxjyzeMUY6l7vPf/vgU5Ogov3jcWHFI9YvCD+bpDjsbJNY9jAt/Wfda+ 6LK2JfWGZUoICwfnY9ej+7/MtFu/tXv38s0T9szL8XxfXFK0mztNiaU4I9FQi7moOBEALbx7 YawDAAA= X-CMS-MailID: 20220506081106eucas1p181e83ef352eb8bfb1752bee0cf84020f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220506081106eucas1p181e83ef352eb8bfb1752bee0cf84020f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220506081106eucas1p181e83ef352eb8bfb1752bee0cf84020f References: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - Background and Motivation: The zone storage implementation in Linux, introduced since v4.10, first targetted SMR drives which have a power of 2 (po2) zone size alignment requirement. The po2 zone size was further imposed implicitly by the block layer's blk_queue_chunk_sectors(), used to prevent IO merging across chunks beyond the specified size, since v3.16 through commit 762380ad9322 ("block: add notion of a chunk size for request merging"). But this same general block layer po2 requirement for blk_queue_chunk_sectors() was removed on v5.10 through commit 07d098e6bbad ("block: allow 'chunk_sectors' to be non-power-of-2"). NAND, which is the media used in newer zoned storage devices, does not naturally align to po2. In these devices, zone cap is not the same as the po2 zone size. When the zone cap != zone size, then unmapped LBAs are introduced to cover the space between the zone cap and zone size. po2 requirement does not make sense for these type of zone storage devices. This patch series aims to remove these unmapped LBAs for zoned devices when zone cap is npo2. This is done by relaxing the po2 zone size constraint in the kernel and allowing zoned device with npo2 zone sizes if zone cap == zone size. Removing the po2 requirement from zone storage should be possible now provided that no userspace regression and no performance regressions are introduced. Stop-gap patches have been already merged into f2fs-tools to proactively not allow npo2 zone sizes until proper support is added [0]. Additional kernel stop-gap patches are provided in this series for dm-zoned. Support for npo2 zonefs and btrfs support is addressed in this series. There was an effort previously [1] to add support to non po2 devices via device level emulation but that was rejected with a final conclusion to add support for non po2 zoned device in the complete stack[2]. - Patchset description: This patchset aims at adding support to non power of 2 zoned devices in the block layer, nvme layer, null blk and adds support to btrfs and zonefs. This round of patches **will not** support DM layer for non power of 2 zoned devices. More about this in the future work section. Patches 1-2 deals with removing the po2 constraint from the block layer. Patches 3-4 deals with removing the constraint from nvme zns. Patches 5-8 adds support to btrfs for non po2 zoned devices. Patch 9 removes the po2 constraint in ZoneFS Patch 10 removes the po2 contraint in null blk Patches 11 adds conditions to not allow non power of 2 devices in DM. The patch series is based on linux-next tag: next-20220502 - Performance: PO2 zone sizes utilizes log and shifts instead of division when determing alignment, zone number, etc. The same math cannot be used when using a zoned device with non po2 zone size. Hence, to avoid any performance regression on zoned devices with po2 zone sizes, the optimized math in the hot paths has been retained with branching. The performance was measured using null blk for regression and the results have been posted in the appropriate commit log. No performance regression was noticed. - Testing With respect to testing we need to tackle two things: one for regression on po2 zoned device and progression on non po2 zoned devices. kdevops (https://github.com/mcgrof/kdevops) was extensively used to automate the testing for blktests and (x)fstests for btrfs changes. The known failures were excluded during the test based on the baseline v5.17.0-rc7 -- regression Emulated zoned device with zone size =128M , nr_zones = 10000 Block and nvme zns: blktests were run with no new failures Btrfs: Changes were tested with the following profile in QEMU: [btrfs_simple_zns] TEST_DIR= SCRATCH_MNT= FSTYP=btrfs MKFS_OPTIONS="-f -d single -m single" TEST_DEV= SCRATCH_DEV_POOL= No new failures were observed in btrfs, generic and shared test suite ZoneFS: zonefs-tests-nullblk.sh and zonefs-tests.sh from zonefs-tools were run with no failures. nullblk: t/zbd/run-tests-against-nullb from fio was run with no failures. DM: It was verified if dm-zoned successfully mounts without any error. -- progression Emulated zoned device with zone size = 96M , nr_zones = 10000 Block and nvme zns: blktests were run with no new failures Btrfs: Same profile as po2 zone size was used. Many tests in xfstests for btrfs included dm-flakey and some tests required dm-linear. As they are not supported at the moment for non po2 devices, those **tests were excluded for non po2 devices**. No new failures were observed in btrfs, generic and shared test suite ZoneFS: zonefs-tests.sh from zonefs-tools were run with no failures. nullblk: A new section was added to cover non po2 devices: section14() { conv_pcnt=10 zone_size=3 zone_capacity=3 max_open=${set_max_open} zbd_test_opts+=("-o ${max_open}") } t/zbd/run-tests-against-nullb from fio was run with no failures. DM: It was verified that dm-zoned does not mount. - Open issue: * btrfs superblock location for zoned devices is expected to be in 0, 512GB(mirror) and 4TB(mirror) in the device. Zoned devices with po2 zone size will naturally align with these superblock location but non po2 devices will not align with 512GB and 4TB offset. The current approach for npo2 devices is to place the superblock mirror zones near 512GB and 4TB that is **aligned to the zone size**. This is of no issue for normal operation as we keep track where the superblock mirror are placed but this can cause an issue with recovery tools for zoned devices as they expect mirror superblock to be in 512GB and 4TB. Note that ATM, recovery tools such as `btrfs check` does not work for image dumps for zoned devices even for po2 zone sizes. - Tools: Some tools had to be updated to support non po2 devices. Once these patches are accepted in the kernel, these tool updates will also be upstreamed. * btrfs-prog: https://github.com/Panky-codes/btrfs-progs/tree/remove-po2-btrfs * blkzone: https://github.com/Panky-codes/util-linux/tree/remove-po2 * zonefs-tools: https://github.com/Panky-codes/zonefs-tools/tree/remove-po2 - Future work To reduce the amount of changes and testing, support for DM was excluded in this round of patches. The plan is to add support to F2FS and DM in the forthcoming future. [0] https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/commit/?h=dev-test&id=6afcf6493578e77528abe65ab8b12f3e1c16749f [1] https://lore.kernel.org/all/20220310094725.GA28499@lst.de/T/ [2] https://lore.kernel.org/all/20220315135245.eqf4tqngxxb7ymqa@unifi/ Changes since v1: - Put the function declaration and its usage in the same commit (Bart) - Remove bdev_zone_aligned function (Bart) - Change the name from blk_queue_zone_aligned to blk_queue_is_zone_start (Damien) - q is never null in from bdev_get_queue (Damien) - Add condition during bringup and check for zsze == zcap for npo2 drives (Damien) - Rounddown operation should be made generic to work in 32 bits arch (bart) - Add comments where generic calculation is directly used instead having special handling for po2 zone sizes (Hannes) - Make the minimum zone size alignment requirement for btrfs to be 1M instead of BTRFS_STRIPE_LEN(David) Changes since v2: - Minor formatting changes Luis Chamberlain (1): dm-zoned: ensure only power of 2 zone sizes are allowed Pankaj Raghav (10): block: make blkdev_nr_zones and blk_queue_zone_no generic for npo2 zsze block: allow blk-zoned devices to have non-power-of-2 zone size nvme: zns: Allow ZNS drives that have non-power_of_2 zone size nvmet: Allow ZNS target to support non-power_of_2 zone sizes btrfs: zoned: Cache superblock location in btrfs_zoned_device_info btrfs: zoned: Make sb_zone_number function non power of 2 compatible btrfs: zoned: use generic btrfs zone helpers to support npo2 zoned devices btrfs: zoned: relax the alignment constraint for zoned devices zonefs: allow non power of 2 zoned devices null_blk: allow non power of 2 zoned devices block/blk-core.c | 3 +- block/blk-zoned.c | 40 ++++++++--- drivers/block/null_blk/main.c | 5 +- drivers/block/null_blk/zoned.c | 14 ++-- drivers/md/dm-zone.c | 12 ++++ drivers/nvme/host/zns.c | 24 ++++--- drivers/nvme/target/zns.c | 2 +- fs/btrfs/volumes.c | 24 ++++--- fs/btrfs/zoned.c | 123 ++++++++++++++++++--------------- fs/btrfs/zoned.h | 44 ++++++++++-- fs/zonefs/super.c | 6 +- fs/zonefs/zonefs.h | 1 - include/linux/blkdev.h | 37 +++++++++- 13 files changed, 228 insertions(+), 107 deletions(-) -- 2.25.1