On Sun, Jan 12, 2025 at 09:49:39PM -0800, Christoph Hellwig wrote: > On Mon, Jan 13, 2025 at 10:24:26AM +0800, Ming Lei wrote: > > If vfs_flush() is called with queue frozen, the queue freeze lock may be > > connected with FS internal lock > > What "FS internal lock" ? Please see the report: https://lore.kernel.org/linux-block/359BC288-B0B1-4815-9F01-3A349B12E816@xxxxxxxxxxxxxx/T/#u > > > , and potential deadlock could be > > triggered. > > > > Fix it by moving vfs_flush() out of queue freezing. > > That doesn't work. The pagecache will be dirties by any command > processed using buffered I/O, so we need to freeze first to ensure > that there are no outstanding commands. vfs_flush() is called in case of previous buffered IO for flushing dirty pages. The call from loop_change_fd() has been broken, because ->lo_backing_file is updated to new one when calling loop_update_dio(), and I will cover this case in V2. For others in which backing file isn't changed, the patch is just fine in case of new buffered IO mode, isn't it? Thanks, Ming