]> www.infradead.org Git - users/hch/misc.git/commit
loop: move vfs_fsync() out of loop_update_dio()
authorMing Lei <ming.lei@redhat.com>
Tue, 18 Mar 2025 07:29:55 +0000 (15:29 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 18 Mar 2025 14:03:30 +0000 (08:03 -0600)
commit86947bdc28894520ed5aab0cf21b99ff0b659e07
treecf4587e035c3127c0f3f26095f95feaea4d2bc89
parentffa1e7ada456087c2402b37cd6b2863ced29aff0
loop: move vfs_fsync() out of loop_update_dio()

If vfs_flush() is called with queue frozen, the queue freeze lock may be
connected with FS internal lock, and lockdep warning can be triggered
because the queue freeze lock is connected with too many global or
sub-system locks.

Fix the warning by moving vfs_fsync() out of loop_update_dio():

- vfs_fsync() is only needed when switching to dio

- only loop_change_fd() and loop_configure() may switch from buffered
IO to direct IO, so call vfs_fsync() directly here. This way is safe
because either loop is in unbound, or new file isn't attached

- for the other two cases of set_status and set_block_size, direct IO
can only become off, so no need to call vfs_fsync()

Cc: Christoph Hellwig <hch@infradead.org>
Reported-by: Kun Hu <huk23@m.fudan.edu.cn>
Reported-by: Jiaji Qin <jjtan24@m.fudan.edu.cn>
Closes: https://lore.kernel.org/linux-block/359BC288-B0B1-4815-9F01-3A349B12E816@m.fudan.edu.cn/T/#u
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250318072955.3893805-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c