Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Lukas Czerner <lukas@czerner.cz>
To: linux-ext4@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>, Lukas Czerner <lukas@czerner.cz>
Subject: [PATCH 0/2] ext4: fix error handling of failed migration
Date: Sun, 25 Oct 2026 21:18:01 +0100	[thread overview]
Message-ID: <20261025201803.3043712-1-lukas@czerner.cz> (raw)

When converting an inode from indirect blocks to extents (the
EXT4_IOC_MIGRATE ioctl) fails, two problems can show up.

ext4_ext_swap_inode_data() can fail after the temporary inode's extent
tree has already been copied into the original inode. The error path
then frees the extent tree blocks via the temporary inode, leaving the
filesystem with multiply claimed blocks. Fix it by resetting the
temporary inode's extent tree and i_blocks right after the copy, so the
cleanup can neither free the original inode's extent tree blocks nor
truncate its data.

Also, ext4_journal_ensure_credits() overwrites whatever error the
migration ran into previously, so the ioctl reports success even though
the migration failed. Use a separate variable for its return value.

Tested with xfstests quick with defaults, home-brewed EXT4_IOC_MIGRATE
stress test and a reproducer written by AI.

Lukas Czerner (2):
  ext4: fix failed migrate freeing extent tree blocks
  ext4: don't lose the error of a failed migration

 fs/ext4/ext4.h    |  1 +
 fs/ext4/extents.c | 11 ++++++++++-
 fs/ext4/migrate.c | 22 ++++++++++++++++++----
 3 files changed, 29 insertions(+), 5 deletions(-)


base-commit: 5b0764a53235d3c77e1ed674e836e1b3fe1a4b1f
-- 
2.56.0


             reply	other threads:[~2026-10-25 20:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 20:18 Lukas Czerner [this message]
2026-10-25 20:18 ` [PATCH 1/2] ext4: fix failed migrate freeing extent tree blocks Lukas Czerner
2026-10-25 20:45   ` sashiko-bot
2026-10-25 20:18 ` [PATCH 2/2] ext4: don't lose the error of a failed migration Lukas Czerner
2026-10-25 20:34   ` 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=20261025201803.3043712-1-lukas@czerner.cz \
    --to=lukas@czerner.cz \
    --cc=linux-ext4@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