bhyve EVF_VNODE mevent on plain file fires on every data change
#14081 introduced support for EVF_VNODE mevents in bhyve, which are events that trigger when a file's metadata changes in some way. This is used to trigger resize events in various block device emulation pieces.
The FreeBSD implementation used kqueue with
EVFILT_VNODE Takes a file descriptor as the identifier and the events to watch for in fflags, and returns when one or more of the requested events occurs on the de- scriptor. The events to monitor are: NOTE_ATTRIB The file referenced by the de- scriptor had its attributes changed.
My illumos implementation used event ports with
It has since become apparent that this fires for all writes to the backing file (since it watches for ctime changes)
, which is not ideal. However, most illumos bhyve VMs will be using ZFS volumes as backing storage for block
devices and, since those do not support event ports, they will be using the fallback polling method introduced in
There are tests, introduced with #14374, which check for proper operation with plain files, plain files unlinked from
the filesystem and ZFS volumes, but they failed to catch this problematic behaviour most of the time; run the plain
file test in a loop and it will eventually fail.
We should stop using event ports for this and use the polling mechanism in all cases, and also adjust the test
to properly check this.
Updated by Andy Fiddaman over 1 year ago
I've tested the associated change on gerrit through the mevent vnode tests:
% ./vnode_file PASS vnode_file - temporary file PASS vnode_file - anon file PASS vnode_file % pfexec ./vnode_zvol PASS vnode_zvol
and also checking that a guest still receives an event when an NVMe disk is resized, whether that disk is backed by a zvol or a file.
Updated by Electric Monk over 1 year ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
commit e8d712970f7ec76e09d5013b0b9aa5f0e0cf3e62 Author: Andy Fiddaman <email@example.com> Date: 2022-03-16T00:03:11.000Z 14517 bhyve EVF_VNODE mevent on plain file fires on every data change Reviewed by: Jason King <firstname.lastname@example.org> Reviewed by: Patrick Mooney <email@example.com> Approved by: Dan McDonald <firstname.lastname@example.org>