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
F102427671: D34260.diff
Tue, Nov 12, 3:23 AM
Unknown Object (File)
Tue, Nov 5, 9:31 AM
Unknown Object (File)
Thu, Oct 24, 2:09 PM
Unknown Object (File)
Thu, Oct 17, 8:48 PM
Unknown Object (File)
Wed, Oct 16, 8:21 AM
Unknown Object (File)
Sep 27 2024, 12:08 AM
Unknown Object (File)
Sep 25 2024, 12:30 PM
Unknown Object (File)
Sep 25 2024, 12:30 PM

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

Lint
Lint Skipped
Unit
Tests Skipped

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!