linux/fs/jbd2
Zhang Yi aac45075f6 jbd2: add a missing data flush during file and fs synchronization
When the filesystem performs file or filesystem synchronization (e.g.,
ext4_sync_file()), it queries the journal to determine whether to flush
the file device through jbd2_trans_will_send_data_barrier(). If the
target transaction has not started committing, it assumes that the
journal will submit the flush command, allowing the filesystem to bypass
a redundant flush command. However, this assumption is not always valid.
If the journal is not located on the filesystem device, the journal
commit thread will not submit the flush command unless the variable
->t_need_data_flush is set to 1. Consequently, the flush may be missed,
and data may be lost following a power failure or system crash, even if
the synchronization appears to succeed.

Unfortunately, we cannot determine with certainty whether the target
transaction will flush to the filesystem device before it commits.
However, if it has not started committing, it must be the running
transaction. Therefore, fix it by always set its t_need_data_flush to 1,
ensuring that the committing thread will flush the filesystem device.

Fixes: bbd2be3691 ("jbd2: Add function jbd2_trans_will_send_data_barrier()")
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20241206111327.4171337-1-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2025-03-21 00:59:28 -04:00
..
checkpoint.c ext4: fix incorrect tid assumption in jbd2_journal_shrink_checkpoint_list() 2024-08-26 23:39:48 -04:00
commit.c jbd2: Correct stale comment of release_buffer_page 2025-03-13 10:41:21 -04:00
journal.c jbd2: add a missing data flush during file and fs synchronization 2025-03-21 00:59:28 -04:00
Kconfig jbd2: switch to using the crc32c library 2024-12-01 17:23:02 -08:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
recovery.c jbd2: do not try to recover wiped journal 2025-03-17 11:19:41 -04:00
revoke.c jbd2: correct stale function name in comment 2025-03-13 10:41:21 -04:00
transaction.c jbd2: remove jbd2_journal_unfile_buffer() 2025-03-18 00:15:25 -04:00