jbd2: fix descriptor block size handling errors with journal_csum
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 27 Aug 2014 22:40:07 +0000 (18:40 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 29 Aug 2014 02:22:29 +0000 (22:22 -0400)
commitdb9ee220361de03ee86388f9ea5e529eaad5323c
tree1f5047f2f588e814901be723a989adde97ae5093
parent022eaa7517017efe4f6538750c2b59a804dc7df7
jbd2: fix descriptor block size handling errors with journal_csum

It turns out that there are some serious problems with the on-disk
format of journal checksum v2.  The foremost is that the function to
calculate descriptor tag size returns sizes that are too big.  This
causes alignment issues on some architectures and is compounded by the
fact that some parts of jbd2 use the structure size (incorrectly) to
determine the presence of a 64bit journal instead of checking the
feature flags.

Therefore, introduce journal checksum v3, which enlarges the
descriptor block tag format to allow for full 32-bit checksums of
journal blocks, fix the journal tag function to return the correct
sizes, and fix the jbd2 recovery code to use feature flags to
determine 64bitness.

Add a few function helpers so we don't have to open-code quite so
many pieces.

Switching to a 16-byte block size was found to increase journal size
overhead by a maximum of 0.1%, to convert a 32-bit journal with no
checksumming to a 32-bit journal with checksum v3 enabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
fs/ext4/super.c
fs/jbd2/commit.c
fs/jbd2/journal.c
fs/jbd2/recovery.c
fs/jbd2/revoke.c
include/linux/jbd2.h