On 2021/12/23 23:13, Jens Axboe wrote: > Race is the wrong word, I mean ordering issues. If the fput happens > before you queue your task_work, then it'll be run before that. There are two fput() related to this patch. fput(file_of_loop_device) or fput(file_of_backing_file), which one? loop_schedule_rundown() is called from lo_release() from blkdev_put() from blkdev_close() from __fput() from task_work_run(), after fput(file_of_loop_device) called task_work_add(TWA_RESUME) for scheduling __fput(). __loop_clr_fd() is called from loop_rundown_callbackfn() from task_work_run(), after loop_schedule_rundown() called task_work_add(TWA_RESUME) for scheduling loop_rundown_callbackfn(). fput(file_of_backing_file) is called from __loop_clr_fd(), and fput(file_of_backing_file) calls task_work_add(TWA_RESUME) for scheduling __fput(). And __fput() from task_work_run() calls release callback for file_of_backing_file. fput(file_of_loop_device) happens before loop_schedule_rundown() calls task_work_add(TWA_RESUME). fput(file_of_backing_file) happens after loop_schedule_rundown() called task_work_add(TWA_RESUME). The release callback for file_of_backing_file will be completed before close() syscall which triggered fput(file_of_loop_device) returns to userspace, for these are chain of add_task_work(). As a total sequence, I think there is no ordering issues. Or, am I missing limitation of task work usage?