]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
mkfs: optimize zone reset for the entire device xfs-zoned-2025-02-06
authorChristoph Hellwig <hch@lst.de>
Fri, 31 Jan 2025 04:21:15 +0000 (05:21 +0100)
committerChristoph Hellwig <hch@lst.de>
Fri, 31 Jan 2025 04:40:04 +0000 (05:40 +0100)
Include the conventional zones for the data device in the range to reset.
This allows the kernel to do a reset all when mkfs is used on the entire
device, which is a lot of faster than doing it zone by zone.

Signed-off-by: Christoph Hellwig <hch@lst.de>
mkfs/xfs_mkfs.c

index 0627af81da3763cb9acc270264506517b8221806..879b6a250ec4727d1203d807ee417662f0f4ee38 100644 (file)
@@ -3710,8 +3710,19 @@ discard_devices(
                uint64_t        nsectors = xi->data.size;
 
                if (cfg->rtstart && zt->data.nr_zones) {
-                       reset_zones(cfg, xi->data.fd, cfg->rtstart, xi->rt.size,
-                                       quiet);
+                       /*
+                        * Note that the zone reset here includes the LBA range
+                        * for the data device.
+                        *
+                        * This is because doing a single zone reset all on the
+                        * entire device (which the kernel automatically does
+                        * for us for a full device range) is a lot faster than
+                        * resetting each zone individually and resetting
+                        * the conventional zones used for the data device is a
+                        * no-op.
+                        */
+                       reset_zones(cfg, xi->data.fd, 0,
+                                       cfg->rtstart + xi->rt.size, quiet);
                        nsectors -= cfg->rtstart;
                }
                discard_blocks(xi->data.fd, nsectors, quiet);