From: Ye Bin yebin10@huawei.com
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I76JSK
--------------------------------
When do IO fault injection, mount maybe hung: blk_update_request: I/O error, dev dm-4, sector 2128216 op 0x0:(READ) flags 0x1000 phys_seg 1 prio class 0 XFS (dm-4): metadata I/O error in "xfs_btree_read_buf_block.constprop.0+0x190/0x200 [xfs]" at daddr 0x207958 len 8 error 5 blk_update_request: I/O error, dev dm-4, sector 2108042 op 0x1:(WRITE) flags 0x29800 phys_seg 1 prio class 0 XFS (dm-4): log I/O error -5 XFS (dm-4): Metadata I/O Error (0x1) detected at xfs_trans_read_buf_map+0x2b6/0x510 [xfs] (fs/xfs/xfs_trans_buf.c:296). Shutting down filesystem. sd 6:0:0:3: [sdh] Synchronizing SCSI cache XFS (dm-4): Please unmount the filesystem and rectify the problem(s) XFS (dm-4): Failed to recover intents XFS (dm-4): Ending recovery (logdev: internal)
PID: 2489297 TASK: ffff8880355c1b00 CPU: 0 COMMAND: "mount" __schedule at ffffffff93aa03c1 schedule at ffffffff93aa0c6f schedule_timeout at ffffffff93aa63c0 xfs_wait_buftarg at ffffffffc1170ff0 [xfs] xfs_log_mount_finish at ffffffffc11bddc4 [xfs] xfs_mountfs at ffffffffc11a4492 [xfs] xfs_fc_fill_super at ffffffffc11ae01c [xfs] get_tree_bdev at ffffffff92c62a79 vfs_get_tree at ffffffff92c60fe0 do_new_mount at ffffffff92caaca0 path_mount at ffffffff92cabf83 __se_sys_mount at ffffffff92cac352 do_syscall_64 at ffffffff93a8b153 entry_SYSCALL_64_after_hwframe at ffffffff93c00099
Ftrace log: mount-2489297 [002] .... 337330.575879: xfs_buf_wait_buftarg: dev 253:4 bno 0x3220 nblks 0x8 hold 2 pincount 0 lock 1 flags DONE|PAGES caller __list_l0
Above issue hapnens as xfs_buf log item is in AIL list, but xlog is already shutdown, so xfs_log_worker() will not wakeup xfsaild to submit AIL list. Then the last 'b_hold' will no chance to be decreased. Then xfs_wait_buftarg() will dead loop to free xfs_buf. To solve above issue there is need to push AIL list before call xfs_wait_buftarg(). As xfs_log_mount_finish() return error, xfs_mountfs() will call xfs_log_mount_cancel() to clean AIL list, and call xfs_wait_buftarg() to make sure all xfs_buf has been reclaimed. So what we need to do is call xfs_wait_buftarg() when 'error == 0' in xfs_log_mount_finish().
Signed-off-by: Ye Bin yebin@huawei.com Signed-off-by: Long Li leo.lilong@huawei.com --- fs/xfs/xfs_log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 506bb43b1eda..7220945cf816 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -821,7 +821,9 @@ xfs_log_mount_finish( } else { xfs_info(mp, "Ending clean mount"); } - xfs_wait_buftarg(mp->m_ddev_targp); + + if (!error) + xfs_wait_buftarg(mp->m_ddev_targp);
clear_bit(XLOG_RECOVERY_NEEDED, &log->l_opstate); if (readonly)