diff options
author | наб <[email protected]> | 2022-04-07 04:32:27 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-04-15 14:16:59 -0700 |
commit | ff23ef0c99a71e8697b4a39886b0f62b4ecf935d (patch) | |
tree | 9f03d1a473aa1e6bb9d8a9c7ae8414b38958b8ac /lib | |
parent | 1f4c79b1ce0b27b747149b2820fa5f6f051b7d4b (diff) |
libzfs: import: zpool_clear_label: actually fail if clearing l2arc header fails
Found with -Wunused-but-set-variable on Clang trunk
Upstream-commit: a4e0cee1780cbd8f2cb9a263a0ed8d91dbe68b4a
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #13304
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_import.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 64fa31c67..ddaa5de5d 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -146,10 +146,10 @@ zpool_clear_label(int fd) struct stat64 statbuf; int l; vdev_label_t *label; - l2arc_dev_hdr_phys_t *l2dhdr; + l2arc_dev_hdr_phys_t *l2dhdr = NULL; uint64_t size; - int labels_cleared = 0, header_cleared = 0; - boolean_t clear_l2arc_header = B_FALSE; + int labels_cleared = 0; + boolean_t clear_l2arc_header = B_FALSE, header_cleared = B_FALSE; if (fstat64_blk(fd, &statbuf) == -1) return (0); @@ -219,13 +219,10 @@ zpool_clear_label(int fd) } /* Clear the L2ARC header. */ - if (clear_l2arc_header) { - memset(l2dhdr, 0, sizeof (l2arc_dev_hdr_phys_t)); - if (pwrite64(fd, l2dhdr, sizeof (l2arc_dev_hdr_phys_t), - VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) { - header_cleared++; - } - } + if (clear_l2arc_header && + pwrite64(fd, l2dhdr, sizeof (l2arc_dev_hdr_phys_t), + VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) + header_cleared = B_TRUE; free(label); free(l2dhdr); @@ -233,6 +230,9 @@ zpool_clear_label(int fd) if (labels_cleared == 0) return (-1); + if (clear_l2arc_header && !header_cleared) + return (-1); + return (0); } |