Re: [syzbot] [jfs?] INFO: task hung in txBegin

Edward Adam Davis
2024-07-20T02:36:58Z

with sb rwsem lock to order syncfs and wb worker

#syz test: upstream 50736169ecc8

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 92a5b8283528..660a1ac8912f 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2123,8 +2123,12 @@ static long wb_writeback(struct bdi_writeback *wb,
queue_io(wb, work, dirtied_before);
queued = true;
}
- if (work->sb)
+ if (work->sb) {
+ printk("sb: %p, %s\n", work->sb, __func__);
+ down_write(&work->sb->s_umount);
progress = writeback_sb_inodes(work->sb, wb, work);
+ up_write(&work->sb->s_umount);
+ }
else
progress = __writeback_inodes_wb(wb, work);
trace_writeback_written(wb, work);
diff --git a/fs/sync.c b/fs/sync.c
index dc725914e1ed..111c3c29b139 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -51,6 +51,7 @@ int sync_filesystem(struct super_block *sb)
* methods call sync_dirty_buffer() and thus effectively write one block
* at a time.
*/
+ printk("sb: %p, %s\n", sb, __func__);
writeback_inodes_sb(sb, WB_REASON_SYNC);
if (sb->s_op->sync_fs) {
ret = sb->s_op->sync_fs(sb, 0);