Port OpenZFS zpool label clear improvements
zfs - Zettabyte File System
As a prerequisite for persistent L2ARC, it will help to have this OpenZFS change ported as a prerequisite:
From 066da71e7fe32f569736b53454b034937d0d3813 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf <email@example.com> Date: Thu, 21 Mar 2019 10:13:01 -0700 Subject: [PATCH] Improve `zpool labelclear` 1) As implemented the `zpool labelclear` command overwrites the calculated offsets of all four vdev labels even when only a single valid label is found. If the device as been re-purposed but still contains a valid label this can result in space no longer owned by ZFS being zeroed. Prevent this by verifying every label removed is intact before it's overwritten. 2) Address a small bug in zpool_do_labelclear() which prevented labelclear from working on file vdevs. Only block devices support BLKFLSBUF, try the ioctl() but when it's reported as unsupported this should not be fatal. 3) Fix `zpool labelclear` so it can be run on vdevs which were removed from the pool with `zpool remove`. Additionally, allow intact but partial labels to be cleared as in the case of a failed `zpool attach` or `zpool replace`. 4) Remove LABELCLEAR and LABELREAD variables for test cases. Reviewed-by: Matt Ahrens <firstname.lastname@example.org> Reviewed-by: Tim Chase <email@example.com> Reviewed-by: Tony Hutter <firstname.lastname@example.org> Signed-off-by: Brian Behlendorf <email@example.com> Closes #8500 Closes #8373 Closes #6261
This also needs the fixes in #13012 for the added zfs tests to pass.