libzfs: import: zpool_clear_label: actually fail if clearing l2arc header fails
Found with -Wunused-but-set-variable on Clang trunk
Upstream-commit: a4e0cee178
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13304
This commit is contained in:
parent
1f4c79b1ce
commit
ff23ef0c99
|
@ -146,10 +146,10 @@ zpool_clear_label(int fd)
|
||||||
struct stat64 statbuf;
|
struct stat64 statbuf;
|
||||||
int l;
|
int l;
|
||||||
vdev_label_t *label;
|
vdev_label_t *label;
|
||||||
l2arc_dev_hdr_phys_t *l2dhdr;
|
l2arc_dev_hdr_phys_t *l2dhdr = NULL;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
int labels_cleared = 0, header_cleared = 0;
|
int labels_cleared = 0;
|
||||||
boolean_t clear_l2arc_header = B_FALSE;
|
boolean_t clear_l2arc_header = B_FALSE, header_cleared = B_FALSE;
|
||||||
|
|
||||||
if (fstat64_blk(fd, &statbuf) == -1)
|
if (fstat64_blk(fd, &statbuf) == -1)
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -219,13 +219,10 @@ zpool_clear_label(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the L2ARC header. */
|
/* Clear the L2ARC header. */
|
||||||
if (clear_l2arc_header) {
|
if (clear_l2arc_header &&
|
||||||
memset(l2dhdr, 0, sizeof (l2arc_dev_hdr_phys_t));
|
pwrite64(fd, l2dhdr, 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))
|
||||||
VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) {
|
header_cleared = B_TRUE;
|
||||||
header_cleared++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(label);
|
free(label);
|
||||||
free(l2dhdr);
|
free(l2dhdr);
|
||||||
|
@ -233,6 +230,9 @@ zpool_clear_label(int fd)
|
||||||
if (labels_cleared == 0)
|
if (labels_cleared == 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
|
if (clear_l2arc_header && !header_cleared)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue