ext4: fast commit may miss file actions
authorXin Yin <yinxin.x@bytedance.com>
Mon, 17 Jan 2022 09:36:55 +0000 (17:36 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Mar 2022 18:12:32 +0000 (19:12 +0100)
commit6f6ffc717b852b6aad4dd3618b0ee16f7be0829a
treef86a7b2b8a747c97495c72ff3e0219e2fd5cf748
parent97abcfedc87cb501071e8947184ee0c5acca6874
ext4: fast commit may miss file actions

[ Upstream commit bdc8a53a6f2f0b1cb5f991440f2100732299eb93 ]

in the follow scenario:
1. jbd start transaction n
2. task A get new handle for transaction n+1
3. task A do some actions and add inode to FC_Q_MAIN fc_q
4. jbd complete transaction n and clear FC_Q_MAIN fc_q
5. task A call fsync

Fast commit will lost the file actions during a full commit.

we should also add updates to staging queue during a full commit.
and in ext4_fc_cleanup(), when reset a inode's fc track range, check
it's i_sync_tid, if it bigger than current transaction tid, do not
rest it, or we will lost the track range.

And EXT4_MF_FC_COMMITTING is not needed anymore, so drop it.

Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
Link: https://lore.kernel.org/r/20220117093655.35160-3-yinxin.x@bytedance.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext4/ext4.h
fs/ext4/fast_commit.c
fs/ext4/super.c