Skip to content

Commit e81c930

Browse files
Luís Henriquestytso
authored andcommitted
ext4: set csum seed in tmp inode while migrating to extents
When migrating to extents, the temporary inode will have it's own checksum seed. This means that, when swapping the inodes data, the inode checksums will be incorrect. This can be fixed by recalculating the extents checksums again. Or simply by copying the seed into the temporary inode. Link: https://bugzilla.kernel.org/show_bug.cgi?id=213357 Reported-by: Jeroen van Wolffelaar <[email protected]> Signed-off-by: Luís Henriques <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent ae6ec19 commit e81c930

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

fs/ext4/migrate.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,17 @@ int ext4_ext_migrate(struct inode *inode)
459459
ext4_journal_stop(handle);
460460
goto out_unlock;
461461
}
462+
/*
463+
* Use the correct seed for checksum (i.e. the seed from 'inode'). This
464+
* is so that the metadata blocks will have the correct checksum after
465+
* the migration.
466+
*
467+
* Note however that, if a crash occurs during the migration process,
468+
* the recovery process is broken because the tmp_inode checksums will
469+
* be wrong and the orphans cleanup will fail.
470+
*/
471+
ei = EXT4_I(inode);
472+
EXT4_I(tmp_inode)->i_csum_seed = ei->i_csum_seed;
462473
i_size_write(tmp_inode, i_size_read(inode));
463474
/*
464475
* Set the i_nlink to zero so it will be deleted later
@@ -502,7 +513,6 @@ int ext4_ext_migrate(struct inode *inode)
502513
goto out_tmp_inode;
503514
}
504515

505-
ei = EXT4_I(inode);
506516
i_data = ei->i_data;
507517
memset(&lb, 0, sizeof(lb));
508518

0 commit comments

Comments
 (0)