Skip to content

Commit

Permalink
libzfs: import: zpool_clear_label: bool for boolean status
Browse files Browse the repository at this point in the history
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13304
  • Loading branch information
nabijaczleweli authored and behlendorf committed Apr 13, 2022
1 parent 74e4bfb commit 0dd34a1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/libzfs/libzfs_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 0dd34a1

Please sign in to comment.