Re: [PATCH v10] loop: defer the queue limits clear to a workqueue
From: Bart Van Assche
Date: Thu Dec 03 2026 - 12:18:32 EST
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?
> + if (!file)
> + return false;
lo_fallocate() has already dereferenced 'file', so this can't happen.
> + 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.
> + 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.
> + 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.
Thanks,
Bart.