Page MenuHomeFreeBSD

md(4): Add dummy support of the BIO_FLUSH command for malloc and swap backend.
ClosedPublic

Authored by afedorov on Feb 13 2022, 1:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 5:00 PM
Unknown Object (File)
Nov 13 2024, 9:17 PM
Unknown Object (File)
Nov 13 2024, 9:11 PM
Unknown Object (File)
Nov 12 2024, 3:23 AM
Unknown Object (File)
Nov 5 2024, 9:31 AM
Unknown Object (File)
Oct 24 2024, 2:09 PM
Unknown Object (File)
Oct 17 2024, 8:48 PM
Unknown Object (File)
Oct 16 2024, 8:21 AM

Details

Summary

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.

Test Plan

After the patch, the error in the guest system goes away.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

afedorov created this revision.

BTW, mdstart_vnode() does not set bio_resid after handling a BIO_FLUSH. I suspect it does not matter in practice, since by convention BIO_FLUSH commands have bio_length == 0.

This revision is now accepted and ready to land.Feb 13 2022, 3:15 PM
This revision now requires review to proceed.Feb 14 2022, 12:32 PM

BTW, mdstart_vnode() does not set bio_resid after handling a BIO_FLUSH. I suspect it does not matter in practice, since by convention BIO_FLUSH commands have bio_length == 0.

Indeed. Thanks for pointing this.

This revision is now accepted and ready to land.Feb 14 2022, 2:01 PM

This applies cleanly to 13.0R and corrects the issue. Tested with dd(1) and fio using /dev/ada0 backed by a malloc md device.

Great work!