[Bug 260200] AHCI emulation throws CAM errors when backed by -t malloc memory disk devices
Date: Sat, 12 Feb 2022 11:40:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260200 Aleksandr Fedorov <afedorov@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |afedorov@FreeBSD.org, | |markj@FreeBSD.org --- Comment #2 from Aleksandr Fedorov <afedorov@FreeBSD.org> --- This is because md(4) + memory backend doesn't support the DIOCGFLUSH ioctl (BIO_FLUSH command): https://github.com/freebsd/freebsd-src/blob/main/sys/dev/md/md.c#L650 pci_ahci.c: https://github.com/freebsd/freebsd-src/blob/main/usr.sbin/bhyve/pci_ahci.c#L783 So I see two ways to solve this issue. First, fix bhyve with patch like this: diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c index 98c0f9f5f38b..3fb81bb86ae2 100644 --- a/usr.sbin/bhyve/block_if.c +++ b/usr.sbin/bhyve/block_if.c @@ -102,6 +102,7 @@ struct blockif_ctxt { int bc_ischr; int bc_isgeom; int bc_candelete; + int bc_canflush; int bc_rdonly; off_t bc_size; int bc_sectsz; @@ -224,6 +225,8 @@ static int blockif_flush_bc(struct blockif_ctxt *bc) { if (bc->bc_ischr) { + if (bc->bc_canflush == 0) + return (0); if (ioctl(bc->bc_fd, DIOCGFLUSH)) return (errno); } else if (fsync(bc->bc_fd)) @@ -463,7 +466,7 @@ blockif_open(nvlist_t *nvl, const char *ident) struct diocgattr_arg arg; off_t size, psectsz, psectoff; int extra, fd, i, sectsz; - int ro, candelete, geom, ssopt, pssopt; + int ro, candelete, canflush, geom, ssopt, pssopt; int nodelete; #ifndef WITHOUT_CAPSICUM @@ -566,6 +569,12 @@ blockif_open(nvlist_t *nvl, const char *ident) candelete = arg.value.i; if (ioctl(fd, DIOCGPROVIDERNAME, name) == 0) geom = 1; + if (ioctl(fd, DIOCGFLUSH) == 0) + canflush = 1; + else if (errno == ENOTSUP) { + canflush = 0; + errno = 0; + } } else psectsz = sbuf.st_blksize; @@ -614,6 +623,7 @@ blockif_open(nvlist_t *nvl, const char *ident) bc->bc_ischr = S_ISCHR(sbuf.st_mode); bc->bc_isgeom = geom; bc->bc_candelete = candelete; + bc->bc_canflush = canflush; bc->bc_rdonly = ro; bc->bc_size = size; bc->bc_sectsz = sectsz; Second, add a NOP support of the BIO_FLUSH cmd to md(4) (mdstart_malloc()). -- You are receiving this mail because: You are the assignee for the bug.