Re: [PATCH v10] loop: defer the queue limits clear to a workqueue
From: Tao Cui
Date: Fri Dec 04 2026 - 04:59:08 EST
Hello, Bart,
在 2026/12/4 1:18, Bart Van Assche 写道:
>
> On 12/3/26 12:16 AM, Tao Cui wrote:
>> + lo->clear_wq = alloc_workqueue("loopc%d",
>> + WQ_UNBOUND | WQ_MEM_RECLAIM,
>> + 0, lo->lo_number);
>
> WQ_MEM_RECLAIM creates a rescuer thread per loop device. Is that flag
> really needed? Additionally, has it been considered to use a single
> workqueue for all loop devices?
Agreed on the flag: v11 drops it, loop%d, which runs the request path
itself, does not use WQ_MEM_RECLAIM either.
On a single workqueue for all devices: I'd rather not, if you're OK
with that. The work function reads the loop_device, and the
per-device queue is what keeps that safe, since lo_free_disk() destroys
it before the loop_device is freed. A shared queue cannot be destroyed
at teardown, so the work item would have to carry a new reference on
the loop device. loop%d is per device already, so I'd keep this shape
unless you prefer the shared queue.
>
>> + if (!file)
>> + return false;
>
> lo_fallocate() has already dereferenced 'file', so this can't happen.
>
Agreed, will remove.
>> + if (!queue_work(lo->clear_wq, &w->clear_limits_work)) {
>
> queue_work() cannot fail for a work item that has just been
> initialized. Please remove this error path.
>
Agreed, will remove.
>> + if (loop_clear_limits(lo, file, mode) &&
>> + test_and_set_bit(0, &lo->clear_limits_reported))
>> + rq->rq_flags |= RQF_QUIET;
>
> Please move the RQF_QUIET changes into a separate patch since these are
> not needed to fix the race.
Sure, I'll post it as 2/2 of a two-patch series. The marking is what
keeps loop/011 at exactly one dmesg error per binding: without it,
concurrent failures can all report before the first clear commits
(this is how blktests CI failed loop/011 back on v6).
>
>> + if (lo->clear_wq)
>> + destroy_workqueue(lo->clear_wq);
>> if (lo->workqueue)
>> destroy_workqueue(lo->workqueue);
>
> Work queued on lo->workqueue queues work on clear_wq, so please destroy
> lo->workqueue first.
>
Agreed, will swap the order.
Thanks,
Tao.
> Thanks,
>
> Bart.