Some userspace applications may call ioctl(fd, DIOCGFLUSH) for an md(4) device with a memory or swap backend.
An example of such an application is bhyve. achi-hd controller emulation calls blockif_flush(), which fails if md(4) (malloc or swap) is used as the disk image.
The guest system in this case displays an error message:
(ada0:ahcich0:0:0:0): FLUSHCACHE48. ACB: ea 00 00 00 00 40 00 00 00 00 00 00 (ada0:ahcich0:0:0:0): CAM status: ATA Status Error (ada0:ahcich0:0:0:0): ATA status: 41 (DRDY ERR), error: 04 (ABRT ) (ada0:ahcich0:0:0:0): RES: 41 04 00 00 00 40 00 00 00 00 00 (ada0:ahcich0:0:0:0): Retrying command, 0 more tries remain (ada0:ahcich0:0:0:0): FLUSHCACHE48. ACB: ea 00 00 00 00 40 00 00 00 00 00 00 (ada0:ahcich0:0:0:0): CAM status: ATA Status Error (ada0:ahcich0:0:0:0): ATA status: 41 (DRDY ERR), error: 04 (ABRT ) (ada0:ahcich0:0:0:0): RES: 41 04 00 00 00 40 00 00 00 00 00 (ada0:ahcich0:0:0:0): Error 5, Retries exhausted (ada0:ahcich0:0:0:0): Synchronize cache failed
See detailed description in PR: 260200
Since BIO_FLUSH is useless in the case of memory or swap, just add dummy support for it.