Skip to content

Commit

Permalink
ext4: mark fc as ineligible using an handle in ext4_xattr_set()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Luis Henriques (SUSE) <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
Cc: [email protected]
  • Loading branch information
Luis Henriques (SUSE) authored and tytso committed Oct 4, 2024
1 parent faab35a commit 04e6ce8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ext4/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2559,14 +2559,15 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,

error = ext4_xattr_set_handle(handle, inode, name_index, name,
value, value_len, flags);
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR,
handle);
error2 = ext4_journal_stop(handle);
if (error == -ENOSPC &&
ext4_should_retry_alloc(sb, &retries))
goto retry;
if (error == 0)
error = error2;
}
ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, NULL);

return error;
}
Expand Down

0 comments on commit 04e6ce8

Please sign in to comment.