]> git.dujemihanovic.xyz Git - linux.git/commitdiff
ext4: mark fc as ineligible using an handle in ext4_xattr_set()
authorLuis Henriques (SUSE) <luis.henriques@linux.dev>
Mon, 23 Sep 2024 10:49:09 +0000 (11:49 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 4 Oct 2024 21:36:09 +0000 (17:36 -0400)
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
fs/ext4/xattr.c

index e0e1956dcdd397d61b2c0700b130afcc61fa883e..7647e9f6e1903add24cfe83bad2beaf657aacd6e 100644 (file)
@@ -2559,6 +2559,8 @@ retry:
 
                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))
@@ -2566,7 +2568,6 @@ retry:
                if (error == 0)
                        error = error2;
        }
-       ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_XATTR, NULL);
 
        return error;
 }