From: Giuseppe Di Natale Date: Wed, 12 Apr 2017 22:49:31 +0000 (-0700) Subject: Invalidate cache during a zpool labelclear X-Git-Tag: zfs-0.7.0-rc4~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a167aa7cd45b045047a75c07e06f3697bed8440c;p=zfs 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 Signed-off-by: Giuseppe Di Natale Closes #6009 --- diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index ebadccf19..cc6c18eed 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -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);