ext4: fix error handling of failed migration
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | ext4: fix failed migrate freeing extent tree blocksfs/ fs/ fs/ | +23 | 0 replies | |
| 2/2 | ext4: don't lose the error of a failed migrationfs/ | +6 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] ext4: fix error handling of failed migration
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
Signature · 1 line
2.56.0