Skip to content

Commit a721800

Browse files
Long Ligregkh
authored andcommitted
xfs: fix mount hang during primary superblock recovery failure
commit efebe42 upstream. When mounting an image containing a log with sb modifications that require log replay, the mount process hang all the time and stack as follows: [root@localhost ~]# cat /proc/557/stack [<0>] xfs_buftarg_wait+0x31/0x70 [<0>] xfs_buftarg_drain+0x54/0x350 [<0>] xfs_mountfs+0x66e/0xe80 [<0>] xfs_fs_fill_super+0x7f1/0xec0 [<0>] get_tree_bdev_flags+0x186/0x280 [<0>] get_tree_bdev+0x18/0x30 [<0>] xfs_fs_get_tree+0x1d/0x30 [<0>] vfs_get_tree+0x2d/0x110 [<0>] path_mount+0xb59/0xfc0 [<0>] do_mount+0x92/0xc0 [<0>] __x64_sys_mount+0xc2/0x160 [<0>] x64_sys_call+0x2de4/0x45c0 [<0>] do_syscall_64+0xa7/0x240 [<0>] entry_SYSCALL_64_after_hwframe+0x76/0x7e During log recovery, while updating the in-memory superblock from the primary SB buffer, if an error is encountered, such as superblock corruption occurs or some other reasons, we will proceed to out_release and release the xfs_buf. However, this is insufficient because the xfs_buf's log item has already been initialized and the xfs_buf is held by the buffer log item as follows, the xfs_buf will not be released, causing the mount thread to hang. xlog_recover_do_primary_sb_buffer xlog_recover_do_reg_buffer xlog_recover_validate_buf_type xfs_buf_item_init(bp, mp) The solution is straightforward, we simply need to allow it to be handled by the normal buffer write process. The filesystem will be shutdown before the submission of buffer_list in xlog_do_recovery_pass(), ensuring the correct release of the xfs_buf as follows: xlog_do_recovery_pass error = xlog_recover_process xlog_recover_process_data xlog_recover_process_ophdr xlog_recovery_process_trans ... xlog_recover_buf_commit_pass2 error = xlog_recover_do_primary_sb_buffer //Encounter error and return if (error) goto out_writebuf ... out_writebuf: xfs_buf_delwri_queue(bp, buffer_list) //add bp to list return error ... if (!list_empty(&buffer_list)) if (error) xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); //shutdown first xfs_buf_delwri_submit(&buffer_list); //submit buffers in list __xfs_buf_submit if (bp->b_mount->m_log && xlog_is_shutdown(bp->b_mount->m_log)) xfs_buf_ioend_fail(bp) //release bp correctly Fixes: 6a18765 ("xfs: update the file system geometry after recoverying superblock buffers") Cc: [email protected] # v6.12 Signed-off-by: Long Li <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ab55feb commit a721800

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/xfs/xfs_buf_item_recover.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ xlog_recover_buf_commit_pass2(
10791079
error = xlog_recover_do_primary_sb_buffer(mp, item, bp, buf_f,
10801080
current_lsn);
10811081
if (error)
1082-
goto out_release;
1082+
goto out_writebuf;
10831083

10841084
/* Update the rt superblock if we have one. */
10851085
if (xfs_has_rtsb(mp) && mp->m_rtsb_bp) {
@@ -1096,6 +1096,15 @@ xlog_recover_buf_commit_pass2(
10961096
xlog_recover_do_reg_buffer(mp, item, bp, buf_f, current_lsn);
10971097
}
10981098

1099+
/*
1100+
* Buffer held by buf log item during 'normal' buffer recovery must
1101+
* be committed through buffer I/O submission path to ensure proper
1102+
* release. When error occurs during sb buffer recovery, log shutdown
1103+
* will be done before submitting buffer list so that buffers can be
1104+
* released correctly through ioend failure path.
1105+
*/
1106+
out_writebuf:
1107+
10991108
/*
11001109
* Perform delayed write on the buffer. Asynchronous writes will be
11011110
* slower when taking into account all the buffers to be flushed.

0 commit comments

Comments
 (0)