]> git.baikalelectronics.ru Git - kernel.git/commit
ext4: update the backup superblock's at the end of the online resize
authorTheodore Ts'o <tytso@mit.edu>
Thu, 27 Oct 2022 20:04:36 +0000 (16:04 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 28 Oct 2022 03:21:40 +0000 (23:21 -0400)
commit3cecee7772d4efb01d6ccd745f0f17209346dc45
tree49228b068784ddee98e2291baa6d1039cedf4aa4
parentc9ad8ca945fbcca0bb4d1542e6418e72bd00ba07
ext4: update the backup superblock's at the end of the online resize

When expanding a file system using online resize, various fields in
the superblock (e.g., s_blocks_count, s_inodes_count, etc.) change.
To update the backup superblocks, the online resize uses the function
update_backups() in fs/ext4/resize.c.  This function was not updating
the checksum field in the backup superblocks.  This wasn't a big deal
previously, because e2fsck didn't care about the checksum field in the
backup superblock.  (And indeed, update_backups() goes all the way
back to the ext3 days, well before we had support for metadata
checksums.)

However, there is an alternate, more general way of updating
superblock fields, ext4_update_primary_sb() in fs/ext4/ioctl.c.  This
function does check the checksum of the backup superblock, and if it
doesn't match will mark the file system as corrupted.  That was
clearly not the intent, so avoid to aborting the resize when a bad
superblock is found.

In addition, teach update_backups() to properly update the checksum in
the backup superblocks.  We will eventually want to unify
updapte_backups() with the infrasture in ext4_update_primary_sb(), but
that's for another day.

Note: The problem has been around for a while; it just didn't really
matter until ext4_update_primary_sb() was added by commit 2369c46d4781
("ext4: implement support for get/set fs label").  And it became
trivially easy to reproduce after commit 965e95ebd566 ("ext4: update
the s_overhead_clusters in the backup sb's when resizing") in v6.0.

Cc: stable@kernel.org # 5.17+
Fixes: 2369c46d4781 ("ext4: implement support for get/set fs label")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ioctl.c
fs/ext4/resize.c