summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve/block_if.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-03-19 09:56:38 +0000
committermav <mav@FreeBSD.org>2015-03-19 09:56:38 +0000
commit6a65b273d8774477c629ed5f9b50d7946a7c43ff (patch)
tree226e85fec8848b8012185d08213f0ad4ab1c6eed /usr.sbin/bhyve/block_if.c
parent207f5e4d982a38a26b05f47f9af3d5bea8778fc9 (diff)
downloadFreeBSD-src-6a65b273d8774477c629ed5f9b50d7946a7c43ff.zip
FreeBSD-src-6a65b273d8774477c629ed5f9b50d7946a7c43ff.tar.gz
MFC r279658, r279673, r279675:
Implement cache flush for ahci-hd and for virtio-blk over device.
Diffstat (limited to 'usr.sbin/bhyve/block_if.c')
-rw-r--r--usr.sbin/bhyve/block_if.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c
index 5934006..e765987 100644
--- a/usr.sbin/bhyve/block_if.c
+++ b/usr.sbin/bhyve/block_if.c
@@ -80,6 +80,7 @@ struct blockif_elem {
struct blockif_ctxt {
int bc_magic;
int bc_fd;
+ int bc_ischr;
int bc_rdonly;
off_t bc_size;
int bc_sectsz;
@@ -190,6 +191,11 @@ blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be)
err = errno;
break;
case BOP_FLUSH:
+ if (bc->bc_ischr) {
+ if (ioctl(bc->bc_fd, DIOCGFLUSH))
+ err = errno;
+ } else if (fsync(bc->bc_fd))
+ err = errno;
break;
default:
err = EINVAL;
@@ -348,6 +354,7 @@ blockif_open(const char *optstr, const char *ident)
bc->bc_magic = BLOCKIF_SIG;
bc->bc_fd = fd;
+ bc->bc_ischr = S_ISCHR(sbuf.st_mode);
bc->bc_rdonly = ro;
bc->bc_size = size;
bc->bc_sectsz = sectsz;
OpenPOWER on IntegriCloud