Page MenuHomeFreeBSD

Don't deliver gmirror BIOs during provider teardown
ClosedPublic

Authored by markj on Jun 21 2016, 6:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 30, 9:05 AM
Unknown Object (File)
Fri, Mar 28, 9:16 PM
Unknown Object (File)
Feb 26 2025, 9:51 PM
Unknown Object (File)
Feb 26 2025, 4:37 PM
Unknown Object (File)
Feb 26 2025, 1:14 PM
Unknown Object (File)
Feb 20 2025, 1:13 PM
Unknown Object (File)
Jan 26 2025, 7:08 PM
Unknown Object (File)
Dec 23 2024, 3:12 AM
Subscribers

Details

Summary

This results in lock recursion if any regular or sync BIOs are on
sc_queue when the provider is destroyed, for example when the last
component of a mirror fails. g_mirror_done() and g_mirror_sync_done()
both acquire the queue lock, but we're already holding it in order to
drain the queue. Instead, just free the BIOs.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj retitled this revision from to Don't deliver gmirror BIOs during provider teardown.
markj edited the test plan for this revision. (Show Details)
markj updated this object.
imp added a reviewer: imp.
imp added inline comments.
sys/geom/mirror/g_mirror.c
2124 ↗(On Diff #17737)

This warrants a comment about what you're doing. Why does that test make sense?

This revision is now accepted and ready to land.Jun 21 2016, 6:51 PM
markj edited edge metadata.

Add a comment explaining the check.

This revision now requires review to proceed.Jun 21 2016, 8:04 PM
markj added inline comments.
sys/geom/mirror/g_mirror.c
2124 ↗(On Diff #17737)

Added, thanks.

imp edited edge metadata.

Perfect. I alway struggle between too much and too little information, and this strikes a good balance.. Thanks.

This revision is now accepted and ready to land.Jun 21 2016, 8:15 PM
ngie added a reviewer: ngie.

I don't remember gmirror good enough to properly review this, sorry. But speaking about lock recursion, it could probably be solved in different way -- grab queue content under the lock and then deliver errors after lock is dropped. I don't very like magic with SYNC flag and free() in proposed change, it looks dirty.

markj marked an inline comment as done.EditedJun 22 2016, 5:24 AM
In D6908#145071, @mav wrote:

I don't remember gmirror good enough to properly review this, sorry. But speaking about lock recursion, it could probably be solved in different way -- grab queue content under the lock and then deliver errors after lock is dropped. I don't very like magic with SYNC flag and free() in proposed change, it looks dirty.

That would fix the lock recursion but still be undesirable: the bio_done handlers for the mirror BIOs just enqueue the BIO again, so we end up inserting into the queue we're trying to drain. And at this point, the mirror worker does not run the queue again, so these requeued BIOs would be leaked. I could modify the bio_done handlers in question to check for a flag in the mirror softc, but if they are not executed directly, the GEOM up thread will race with a free of the softc.

This revision was automatically updated to reflect the committed changes.