Skip to content

Commit 89bbc55

Browse files
Luis Henriques (SUSE)gregkh
authored andcommitted
ext4: mark fc as ineligible using an handle in ext4_xattr_set()
commit 04e6ce8 upstream. Calling ext4_fc_mark_ineligible() with a NULL handle is racy and may result in a fast-commit being done before the filesystem is effectively marked as ineligible. This patch moves the call to this function so that an handle can be used. If a transaction fails to start, then there's not point in trying to mark the filesystem as ineligible, and an error will eventually be returned to user-space. Suggested-by: Jan Kara <jack@suse.cz> Signed-off-by: Luis Henriques (SUSE) <luis.henriques@linux.dev> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20240923104909.18342-3-luis.henriques@linux.dev Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c5771f1 commit 89bbc55

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ext4/xattr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2554,14 +2554,15 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,
25542554

25552555
error = ext4_xattr_set_handle(handle, inode, name_index, name,
25562556
value, value_len, flags);
2557+
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR,
2558+
handle);
25572559
error2 = ext4_journal_stop(handle);
25582560
if (error == -ENOSPC &&
25592561
ext4_should_retry_alloc(sb, &retries))
25602562
goto retry;
25612563
if (error == 0)
25622564
error = error2;
25632565
}
2564-
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, NULL);
25652566

25662567
return error;
25672568
}

0 commit comments

Comments
 (0)