]> granicus.if.org Git - zfs/commitdiff
Invalidate cache during a zpool labelclear
authorGiuseppe Di Natale <dinatale2@llnl.gov>
Wed, 12 Apr 2017 22:49:31 +0000 (15:49 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 13 Apr 2017 16:13:51 +0000 (09:13 -0700)
Be sure to invalidate a vdev's cache before performing
a zpool labelclear. There are cases where the cache is
stale because we did some operation that bypassed it,
and since we are doing an open with only O_RDWR, we
should invalidate it to be safe.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Closes #6009

cmd/zpool/zpool_main.c

index ebadccf19e09d681e4667cae45c0d412a364495b..cc6c18eed897dd78fd76839b9d19d44aa9899442 100644 (file)
@@ -865,6 +865,10 @@ zpool_do_labelclear(int argc, char **argv)
                return (1);
        }
 
+       if (ioctl(fd, BLKFLSBUF) != 0)
+               (void) fprintf(stderr, gettext("failed to invalidate "
+                   "cache for %s: %s\n"), vdev, strerror(errno));
+
        if (zpool_read_label(fd, &config, NULL) != 0 || config == NULL) {
                (void) fprintf(stderr,
                    gettext("failed to check state for %s\n"), vdev);