Re: [PATCH v9] loop: defer the queue limits clear to a workqueue
From: Tao Cui
Date: Tue Dec 01 2026 - 08:15:02 EST
Hello, Bart
在 2026/12/1 00:34, Bart Van Assche 写道:
> On 11/30/26 6:57 AM, Tao Cui wrote:
>> 于 2026年11月30日 GMT+08:00 22:04:09,Bart Van Assche <bvanassche@xxxxxxx> 写道:
>>> On 11/30/26 2:20 AM, Tao Cui wrote:
>>>> I'm planning to send this as v10 unless you see a problem with the
>>>> design.
>>> Are there any lo_fallocate() callers that expect that
>>> loop_clear_limits() has completed by the time lo_fallocate() returns?
>>>
>> I think no, nothing depends on that. lo_fallocate() is only called from
>> do_req_filebacked(): both call sites return the fallocate result
>> directly to request completion, so the failing request completes with
>> EOPNOTSUPP regardless of when the limits update commits, and nothing
>> reads the queue limits expecting the cleared state right after
>> lo_fallocate() returns. Requests dispatched before the work item runs
>> also fail with EOPNOTSUPP, the first one reports, repeats are quiet, and the work items serialize on lo->workqueue, so the update
>> converges.
>>
>> Tested with PROVE_LOCKING enabled: loop/011, the concurrency sweep and
>> the mkfs/unbind stress run clean.
>>
>> Please correct me if I have misunderstood anything here
> Please queue the dynamically allocated work on another workqueue than
> lo->workqueue. I'm concerned that using lo->workqueue might trigger a
> deadlock.
>
Done: the work item is now queued on a dedicated unbounded workqueue
(loopc%d) instead of lo->workqueue, and lo_free_disk() drains that
workqueue before the loop_device is freed, so outstanding clear work
items cannot outlive it.
On the deadlock concern: I could not trigger it on either queue
placement, despite trying fairly hard with an adversarial mix of
LOOP_SET_BLOCK_SIZE, LOOP_SET_DIRECT_IO, write-zeroes and rebind churn
(600 rebinds, 10,000 queue-limits updates, up to 56 concurrent failing
requests, stacked loop devices) under PROVE_LOCKING. The backing
files in these tests are memory-backed, so the drain times are short.
The failure reporting stays at exactly one per binding throughout, and
no report, hang or deadlock was observed with either the shared or the
dedicated workqueue.
The full suite (loop/011, the concurrency sweep and the mkfs/unbind
stress) also runs clean on both kernels.
Thanks,
Tao.
> Thanks,
>
> Bart.