Re: [PATCH] loop: block loop reconfiguration of offset/sizelimit on mounted device

Theodore Tso
2026-03-30T19:01:13Z

On Mon, Mar 30, 2026 at 08:03:55PM +0530, Deepanshu Kartikey wrote:
>
> The check would be:
>
> #ifndef CONFIG_BLK_DEV_WRITE_MOUNTED
> if ((lo->lo_offset != info->lo_offset ||
> lo->lo_sizelimit != info->lo_sizelimit) &&
> lo->lo_device->bd_writers < 0) {
> err = -EBUSY;
> goto out_unlock;
> }
> #endif

Can you please move bdev_writes_blocked() into
include/linux/blk_types.h as an inline function as Christoph
suggested?

The reason for that is that "bdev_writers < 0" is an implementation
detail and it might change in the future, and then loop driver might
break unexpectedly. Using bdev_writes_blocked() is also much clearer
from a code readability perspective.

> Regarding Christoph's point about increasing lo_sizelimit being
> safe - should I narrow the check to only block shrinking and
> offset changes?

Yes, I think we should allow the loop device to grow, since that's
harmless and there are some legitimate use cases when people might
want to do this and then trigger an online resize so the file system
grows to use the added space.

- Ted