Re: [PATCH] f2fs: Prevent s_writer rw_sem count mismatch in f2fs_evict_inode

From: Chao Yu
Date: Fri Mar 22 2024 - 22:11:42 EST


On 2024/3/22 12:16, Yeongjin Gil wrote:
If f2fs_evict_inode is called between freeze_super and thaw_super, the
s_writer rwsem count may become negative, resulting in hang.

CPU1 CPU2

f2fs_resize_fs() f2fs_evict_inode()
f2fs_freeze
set SBI_IS_FREEZING
skip sb_start_intwrite
f2fs_unfreeze
clear SBI_IS_FREEZING
sb_end_intwrite

To solve this problem, the call to sb_end_write is determined by whether
sb_start_intwrite is called, rather than the current freezing status.

Reviewed-by: Sungjong Seo <sj1557.seo@xxxxxxxxxxx>
Reviewed-by: Sunmin Jeong <s_min.jeong@xxxxxxxxxxx>
Signed-off-by: Yeongjin Gil <youngjin.gil@xxxxxxxxxxx>

Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,