From: Christian Brauner <brauner@kernel.org>
To: Theodore Ts'o <tytso@mit.edu>, Jan Kara <jack@suse.cz>,
linux-ext4@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org,
"Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH 1/4] ext4: don't lose the result of ext4_ext_migrate()
Date: Mon, 30 Nov 2026 14:22:13 +0100 [thread overview]
Message-ID: <20261130-work-ext4-setflags_migrate-v1-1-80f1875cfadc@kernel.org> (raw)
In-Reply-To: <20261130-work-ext4-setflags_migrate-v1-0-80f1875cfadc@kernel.org>
Since commit a413036791d0 ("ext4: Provide function to handle transaction
restarts") ext4_ext_migrate() overwrites its result with the return
value of the final ext4_journal_ensure_credits(). So if building the
extent tree fails, e.g., with ENOSPC, or ext4_ext_swap_inode_data()
returns EAGAIN because a block got allocated in the meantime, we report
success and the inode stays block mapped. And if the handle had to be
restarted we return 1 to FS_IOC_SETFLAGS and EXT4_IOC_MIGRATE.
Keep the result of the migration and only return the error of the
credit check if nothing else failed.
Fixes: a413036791d0 ("ext4: Provide function to handle transaction restarts")
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/ext4/migrate.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 09931d3ba2c6a..be48456fa76f3 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -410,7 +410,7 @@ static int free_ext_block(handle_t *handle, struct inode *inode)
int ext4_ext_migrate(struct inode *inode)
{
handle_t *handle;
- int retval = 0, i;
+ int retval = 0, err, i;
__le32 *i_data;
struct ext4_inode_info *ei;
struct inode *tmp_inode = NULL;
@@ -567,9 +567,12 @@ int ext4_ext_migrate(struct inode *inode)
}
/* We mark the tmp_inode dirty via ext4_ext_tree_init. */
- retval = ext4_journal_ensure_credits(handle, 1, 0);
- if (retval < 0)
+ err = ext4_journal_ensure_credits(handle, 1, 0);
+ if (err < 0) {
+ if (!retval)
+ retval = err;
goto out_stop;
+ }
/*
* Mark the tmp_inode as of size zero
*/
--
2.53.0
next prev parent reply other threads:[~2026-11-30 13:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 13:22 [PATCH 0/4] ext4: don't fail FS_IOC_{SETFLAGS,FSSETXATTR} after applying them aka things that fell out of my uapi16 library work Christian Brauner
2026-11-30 13:22 ` Christian Brauner [this message]
2026-11-30 13:22 ` [PATCH 2/4] ext4: don't fail FS_IOC_SETFLAGS after applying it Christian Brauner
2026-11-30 13:22 ` [PATCH 3/4] ext4: split the flag checks out of ext4_ioctl_setflags() Christian Brauner
2026-11-30 13:22 ` [PATCH 4/4] ext4: don't fail FS_IOC_FSSETXATTR after applying it Christian Brauner
2026-11-30 13:39 ` [PATCH 0/4] ext4: don't fail FS_IOC_{SETFLAGS,FSSETXATTR} after applying them aka things that fell out of my uapi16 library work sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130-work-ext4-setflags_migrate-v1-1-80f1875cfadc@kernel.org \
--to=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox