Invalidate cache during a zpool labelclear

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
This commit is contained in:
Giuseppe Di Natale 2017-04-12 15:49:31 -07:00 committed by Brian Behlendorf
parent 00481e7dad
commit a167aa7cd4

View File

@ -865,6 +865,10 @@ zpool_do_labelclear(int argc, char **argv)
return (1); 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) { if (zpool_read_label(fd, &config, NULL) != 0 || config == NULL) {
(void) fprintf(stderr, (void) fprintf(stderr,
gettext("failed to check state for %s\n"), vdev); gettext("failed to check state for %s\n"), vdev);