Skip to content

Commit

Permalink
Fix zed/udev thrashing due to autoexpand=on
Browse files Browse the repository at this point in the history
Flushing the device and invaliding the page cache to ensure a
consistent view of the device is only needed when the device
was successfully expanded.  Unconditionally performing these
operations is safe but it has the side effect of triggering
another udev change event which will be handled by the ZED.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue openzfs#7366
  • Loading branch information
behlendorf committed Apr 5, 2018
1 parent ef76d2d commit 95189f0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2461,12 +2461,15 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg)
*
* Also, we don't call efi_rescan() - that would just return EBUSY.
* The module will do it for us in vdev_disk_open().
*
* On success flush the buffers to disk and invalidate the page cache
* to ensure a consistent view of the relabled device.
*/
error = efi_use_whole_disk(fd);

/* Flush the buffers to disk and invalidate the page cache. */
(void) fsync(fd);
(void) ioctl(fd, BLKFLSBUF);
if (error == 0) {
(void) fsync(fd);
(void) ioctl(fd, BLKFLSBUF);
}

(void) close(fd);
if (error && error != VT_ENOSPC) {
Expand Down

0 comments on commit 95189f0

Please sign in to comment.