All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ext4: fix error handling of failed migration
@ 2026-10-25 20:18 Lukas Czerner
  2026-10-25 20:18 ` [PATCH 1/2] ext4: fix failed migrate freeing extent tree blocks Lukas Czerner
  2026-10-25 20:18 ` [PATCH 2/2] ext4: don't lose the error of a failed migration Lukas Czerner
  0 siblings, 2 replies; 5+ messages in thread
From: Lukas Czerner @ 2026-10-25 20:18 UTC (permalink / raw)
  To: linux-ext4; +Cc: Theodore Ts'o, Lukas Czerner

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-25 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-25 20:18 [PATCH 0/2] ext4: fix error handling of failed migration Lukas Czerner
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.