diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 7aed626b21bf..ed3cfea56fa0 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -137,10 +137,9 @@ zpool_clear_label(int fd) struct stat64 statbuf; int l; vdev_label_t *label; - l2arc_dev_hdr_phys_t *l2dhdr; uint64_t size; - int labels_cleared = 0, header_cleared = 0; - boolean_t clear_l2arc_header = 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); @@ -150,11 +149,6 @@ zpool_clear_label(int fd) if ((label = calloc(1, sizeof (vdev_label_t))) == NULL) return (-1); - if ((l2dhdr = calloc(1, sizeof (l2arc_dev_hdr_phys_t))) == NULL) { - free(label); - return (-1); - } - for (l = 0; l < VDEV_LABELS; l++) { uint64_t state, guid, l2cache; nvlist_t *config; @@ -204,24 +198,22 @@ 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; } - /* 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++; - } + _Static_assert(sizeof (*label) >= sizeof (l2arc_dev_hdr_phys_t), + "label < l2arc_dev_hdr_phys_t"); + memset(label, 0, sizeof (l2arc_dev_hdr_phys_t)); + if (pwrite64(fd, label, sizeof (l2arc_dev_hdr_phys_t), + VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) + header_cleared = B_TRUE; } free(label); - free(l2dhdr); - if (labels_cleared == 0) + if (!labels_cleared || (clear_l2arc_header && !header_cleared)) return (-1); return (0); diff --git a/module/zfs/vdev_removal.c b/module/zfs/vdev_removal.c index 17f9d6c90804..f988ca22fa4a 100644 --- a/module/zfs/vdev_removal.c +++ b/module/zfs/vdev_removal.c @@ -2251,7 +2251,6 @@ spa_vdev_remove_top_check(vdev_t *vd) * and not be raidz or draid. */ vdev_t *rvd = spa->spa_root_vdev; - int num_indirect = 0; for (uint64_t id = 0; id < rvd->vdev_children; id++) { vdev_t *cvd = rvd->vdev_child[id]; @@ -2267,8 +2266,6 @@ spa_vdev_remove_top_check(vdev_t *vd) if (cvd->vdev_ashift != 0 && cvd->vdev_alloc_bias == VDEV_BIAS_NONE) ASSERT3U(cvd->vdev_ashift, ==, spa->spa_max_ashift); - if (cvd->vdev_ops == &vdev_indirect_ops) - num_indirect++; if (!vdev_is_concrete(cvd)) continue; if (vdev_get_nparity(cvd) != 0) diff --git a/tests/zfs-tests/cmd/draid.c b/tests/zfs-tests/cmd/draid.c index 6f4ecd5ef4c5..618cb9c4df52 100644 --- a/tests/zfs-tests/cmd/draid.c +++ b/tests/zfs-tests/cmd/draid.c @@ -1312,14 +1312,11 @@ static int draid_merge(int argc, char *argv[]) { char filename[MAXPATHLEN] = {0}; - int c, error, total_merged = 0, verbose = 0; + int c, error, total_merged = 0; nvlist_t *allcfgs; - while ((c = getopt(argc, argv, ":v")) != -1) { + while ((c = getopt(argc, argv, ":")) != -1) { switch (c) { - case 'v': - verbose++; - break; case ':': (void) fprintf(stderr, "missing argument for '%c' option\n", optopt);