Skip to content

Commit

Permalink
Invalidate cache during a zpool labelclear
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Giuseppe Di Natale <[email protected]>
Closes openzfs#6009
  • Loading branch information
dinatale2 authored and behlendorf committed Apr 13, 2017
1 parent 00481e7 commit a167aa7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a167aa7

Please sign in to comment.