Skip to content

Allow concurrent BlockBackend context changes

Merge Request Required Information

Jira: https://issues.redhat.com/browse/RHEL-24593

Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=58831635

Summary of Changes

Without the AioContext lock, a BB's context may kind of change at any time (unless it has a root node, and I/O requests are pending). That also means that its own context (BlockBackend.ctx) and that of its root node can differ sometimes (while the context is being changed).

blk_get_aio_context() doesn't know this yet and asserts that both are always equal (if there is a root node). Because it's no longer true, and because callers don't seem to really care about the root node's context, we can and should remove the assertion and just return the BB's context.

This issue became apparent from a call in scsi_device_for_each_req_async_bh(), which tries to follow the BB should it have changed contexts between the BH being scheduled and it running. Because contexts can now change at any time, not just between the BH being scheduled and it running, we must also consider it changing while the BH is running. To prevent such a context change, we can consider that BH an in-flight request on the BB; changing the BB’s context would drain it, which blocks on all in-flight requests. This has the added advantage of scsi_device_purge_requests() actually blocking until all requests are purged (it contains a blk_drain(), too).

Approved Development Ticket

https://issues.redhat.com/browse/RHEL-24593

Merge request reports

Loading