Re: [PATCH v2 02/12] loop: Remove the "bool global" function argument

Bart Van Assche <[email protected]> Mon, 3 Aug 2026 10:41:59 -0700
Newsgroups org.kernel.vger.linux-block
Message-ID <[email protected]>
On 8/3/26 6:05 AM, Nilay Shroff wrote:
> Overall this change looks good to me. But I see, lo->lo_lock
> is used to protect lo->lo_backing_file. so shall we annotate
> the lo->lo_backing_file using __guarded_by(&lo_lock)?

I don't think so. It seems to me that the strategy in the loop driver
for serializing accesses to lo->lo_backing_file is too complicated for
lock context annotations. My understanding is as follows:
* lo->lo_mutex serializes configuration and state changes on an
   individual loop device.
* loop_validate_mutex serializes concurrent loop_configure(),
   loop_change_fd(), and loop_clr_fd() calls across all loop devices to
   safely execute loop_validate_file() when loop devices are stacked
   or nested.
* The blk_mq_freeze_queue() call in __loop_change_fd() serializes I/O
   request processing and the code in __loop_change_fd() that is executed
   while the queue is frozen.

Thanks,

Bart.