]> git.proxmox.com Git - mirror_zfs.git/commit
Improve `zpool labelclear`
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 21 Mar 2019 17:13:01 +0000 (10:13 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Mar 2019 17:13:01 +0000 (10:13 -0700)
commit066da71e7fe32f569736b53454b034937d0d3813
tree2b4723e49c2e4720cb600da78cc5b60f618742ba
parent304d469dcdcb47a6c4e993a62007a8b7c81a212a
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 <mahrens@delphix.com>
Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8500
Closes #8373
Closes #6261
12 files changed:
cmd/zpool/zpool_main.c
lib/libzfs/libzfs_import.c
tests/runfiles/linux.run
tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am
tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg
tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_removed.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh [new file with mode: 0755]
tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh
tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh