libext2fs: read and write full size inodes

Change libext2fs to read and write full-size inodes in preparation for
the metadata checksumming patchset, which will require this.  Due to
ABI compatibility requirements, this change must be hidden from client
programs.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: change ext4 on-disk layout to support metadata checksumming

Define flags and extend ext4 structure definitions to support metadata
checksumming.  Ted Ts'o covered many of these fields in an earlier
patch, but there are more required changes to the disk layout.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs: optionally ignore bad checksums

If someone is debugging a badly damaged filesystem, it might be useful
to disable the checksum verifications that will otherwise prevent the
filesystem from loading.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: precompute FS UUID checksum seed

Precompute the FS UUID checksum seed that is used for all metadata
checksumming operations and store it in ext2_filsys.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: add inode checksum support

This patch adds the ability for the libext2fs functions to read and
write the inode checksum.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs: dump inode checksum when appropriate

Dump inode checksum when displaying inode info.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs: add inode checksum support

This patch adds to tune2fs the ability to toggle the metadata checksum
rocompat feature flag, which will rewrite the inode table with
checksums.  Disallow changing the UUID while the fs is mounted,
because rewriting the metadata objects is racy.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: verify and correct inode checksums

Detect mismatches of the inode and checksum, and prompt the user to
fix the situation.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
mke2fs: allow metadata checksums to be turned on at mkfs time

Write out reserved inodes with full checksums when writing out a
zeroed table.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: create the inode bitmap checksum

Provide a field in the block group descriptor to store inode bitmap
checksum, and some helper functions to calculate and verify it.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs: rewrite inode bitmap checksums

When toggling metadata_csum, mark the inode bitmap dirty so that they
are written out with new checksums.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
dumpe2fs: display inode bitmap checksum

Display the inode bitmap checksum for each block group.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: verify inode bitmap checksum

Rewrite the block bitmap when the checksum doesn't match.  This is ok
since e2fsck will have already computed the correct inode bitmap.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: create the block bitmap checksum

Calculate and verify the block bitmap checksum.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
dumpe2fs: display block bitmap checksum

Display the block bitmap checksum when displaying block groups.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: verify block bitmap checksum

Check block bitmap checksum and write a new checksum if the
verification fails.  This is ok because e2fsck has already computed
the correct block bitmap.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: don't verify bitmap checksums

Since the correct inode and block bitmaps are calculated in pass 5,
don't fail the bitmap read operation in prior passes since (a)
incorrect results won't kill us and (b) if we fail early, we'll never
_get_ to pass 5.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs: rewrite block bitmap checksums

When toggling metadata_csum, mark the block bitmap dirty so that it
gets written with new checksums.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: verify and calculate extent tree block checksums

Verify and calculate extent tree block checksums when processing
filesystems.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs: enable extent tree checksums

Add to tune2fs the ability to recalculate extent tree checksums when
altering the metadata checksum feature flag.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>