Commit c3688d21 authored by Zhang Yi's avatar Zhang Yi Committed by Theodore Ts'o
Browse files

ext4: unify SYNC mode checks in fallocate paths



In the ext4 fallocate call chain, SYNC mode handling is inconsistent:
some places check the inode state, while others check the open file
descriptor state. Unify these checks by evaluating both conditions
to ensure consistent behavior across all fallocate operations.

Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260327102939.1095257-11-yi.zhang@huaweicloud.com


Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 7d81ec02
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -4782,7 +4782,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
		goto out_handle;

	ext4_update_inode_fsync_trans(handle, inode, 1);
	if (file->f_flags & O_SYNC)
	if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
		ext4_handle_sync(handle);

out_handle:
@@ -4820,7 +4820,8 @@ static long ext4_do_fallocate(struct file *file, loff_t offset,
	if (ret)
		goto out;

	if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
	if (((file->f_flags & O_SYNC) || IS_SYNC(inode)) &&
	    EXT4_SB(inode->i_sb)->s_journal) {
		ret = ext4_fc_commit(EXT4_SB(inode->i_sb)->s_journal,
					EXT4_I(inode)->i_sync_tid);
	}
@@ -5593,7 +5594,7 @@ static int ext4_collapse_range(struct file *file, loff_t offset, loff_t len)
		goto out_handle;

	ext4_update_inode_fsync_trans(handle, inode, 1);
	if (IS_SYNC(inode))
	if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
		ext4_handle_sync(handle);

out_handle:
@@ -5717,7 +5718,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len)
		goto out_handle;

	ext4_update_inode_fsync_trans(handle, inode, 1);
	if (IS_SYNC(inode))
	if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
		ext4_handle_sync(handle);

out_handle:
+1 −1
Original line number Diff line number Diff line
@@ -4531,7 +4531,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
		goto out_handle;

	ext4_update_inode_fsync_trans(handle, inode, 1);
	if (IS_SYNC(inode))
	if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
		ext4_handle_sync(handle);
out_handle:
	ext4_journal_stop(handle);