A block layer introduction part 1: the bio layer
A block layer introduction part 1: the bio layer
Posted Oct 25, 2017 19:12 UTC (Wed) by edos (guest, #116377)Parent article: A block layer introduction part 1: the bio layer
How is that possible when we have stacked block devices to produce a deadlock based on interdependency? It is not clear for me still
Posted Oct 25, 2017 21:34 UTC (Wed)
by neilbrown (subscriber, #359)
[Link] (7 responses)
Now, suppose there is no free memory, suppose the private mempool has 16 preallocated entries, and suppose 16 threads all perform exactly this 8K write submission (to different addresses in the RAID1) at the same time.
There are other scenarios that are more complex, but are likely enough to actually happen in practice.
Posted Oct 25, 2017 22:03 UTC (Wed)
by Cyberax (✭ supporter ✭, #52523)
[Link] (5 responses)
Posted Oct 26, 2017 4:03 UTC (Thu)
by neilbrown (subscriber, #359)
[Link] (4 responses)
Posted Oct 26, 2017 4:06 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
Posted Oct 26, 2017 5:57 UTC (Thu)
by neilbrown (subscriber, #359)
[Link] (2 responses)
Surely it is better to design the code to be dead-lock free. It isn't that hard once the problem is understood. (and if the problem isn't understood, then a workaround like that might not be a complete solution).
Posted Oct 26, 2017 6:04 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link] (1 responses)
Posted Oct 27, 2017 2:01 UTC (Fri)
by neilbrown (subscriber, #359)
[Link]
No, hence the parenthetical comment (newer code will have sorted this to the end of the list, to help avoid the deadlock).
Posted Oct 26, 2017 8:49 UTC (Thu)
by edos (guest, #116377)
[Link]
A block layer introduction part 1: the bio layer
- Suppose I have a RAID1 array where each of the member devices is a RAID0 array with a 4K chunk size.
- An 8K write BIO arrives for the RAID1 array. raid1 code allocates two bios from a private pool and sends an 8K bio to each of the RAID0 devices. These two bios gets queued by generic_make_request.
- Then generic_make_request starts processing the first RAID0 bio. raid0 code needs to split it into 2 4K bios and so allocates a bio from a private pool and submits the new bio and the old bio (now reduced in size) to the underlying devices. These two bios get queued by generic_make_request.
- Then generic_make_request starts processing the second RAID0 bio (newer code will have sorted this to the end of the list, to help avoid the deadlock). Again raid0 code needs to split the bio.
We will end up with 16 threads all trying to allocate a second bio from the same private pool, while the 16 preallocated entries are each trapped, one per thread, in the generic_make_request queue. The allocations will wait for a previously allocated bio to complete, and those previous bios won't be processed by generic_make_request() until after the allocation completes.
A block layer introduction part 1: the bio layer
A block layer introduction part 1: the bio layer
A block layer introduction part 1: the bio layer
A block layer introduction part 1: the bio layer
A block layer introduction part 1: the bio layer
A block layer introduction part 1: the bio layer
Providing drivers which split bios only process one of them and submit the other directly to generic_make_request(), there should be no deadlock (of this sort).
A block layer introduction part 1: the bio layer