aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libzfs/libzfs_import.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c
index 806ab4e23..ed3cfea56 100644
--- a/lib/libzfs/libzfs_import.c
+++ b/lib/libzfs/libzfs_import.c
@@ -138,8 +138,8 @@ zpool_clear_label(int fd)
int l;
vdev_label_t *label;
uint64_t size;
- int labels_cleared = 0;
- boolean_t clear_l2arc_header = B_FALSE, header_cleared = B_FALSE;
+ boolean_t labels_cleared = B_FALSE, clear_l2arc_header = B_FALSE,
+ header_cleared = B_FALSE;
if (fstat64_blk(fd, &statbuf) == -1)
return (0);
@@ -198,9 +198,8 @@ zpool_clear_label(int fd)
size_t label_size = sizeof (vdev_label_t) - (2 * VDEV_PAD_SIZE);
if (pwrite64(fd, label, label_size, label_offset(size, l) +
- (2 * VDEV_PAD_SIZE)) == label_size) {
- labels_cleared++;
- }
+ (2 * VDEV_PAD_SIZE)) == label_size)
+ labels_cleared = B_TRUE;
}
if (clear_l2arc_header) {
@@ -214,10 +213,7 @@ zpool_clear_label(int fd)
free(label);
- if (labels_cleared == 0)
- return (-1);
-
- if (clear_l2arc_header && !header_cleared)
+ if (!labels_cleared || (clear_l2arc_header && !header_cleared))
return (-1);
return (0);