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, May 12, 4:16 PM
Unknown Object (File)
Thu, May 9, 8:33 PM
Unknown Object (File)
Thu, May 2, 12:55 PM
Unknown Object (File)
Apr 12 2024, 11:03 AM
Unknown Object (File)
Apr 11 2024, 11:54 PM
Unknown Object (File)
Apr 10 2024, 4:18 PM
Unknown Object (File)
Apr 7 2024, 10:06 AM
Unknown Object (File)
Jan 30 2024, 2:11 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!