]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
libxfs: skip verification on initial "guess" superblock read
authorDave Chinner <dchinner@redhat.com>
Thu, 6 Mar 2014 23:25:04 +0000 (10:25 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 6 Mar 2014 23:25:04 +0000 (10:25 +1100)
commitc13fe77eac2f91c4b06a327594003b32e4e12f7e
tree61ca7adee3b0af2a8fc304335b84f940a8e61622
parentf3cddd915ab7a68b91d4969218932e6abae08f89
libxfs: skip verification on initial "guess" superblock read

[userspace port]

When xfs_readsb() does the very first read of the superblock,
it makes a guess at the length of the buffer, based on the
sector size of the underlying storage.  This may or may
not match the filesystem sector size in sb_sectsize, so
we can't i.e. do a CRC check on it; it might be too short.

In fact, mounting a filesystem with sb_sectsize larger
than the device sector size will cause a mount failure
if CRCs are enabled, because we are checksumming a length
which exceeds the buffer passed to it.

So always read twice; the first time we read with NULL
buffer ops to skip verification; then set the proper
read length, hook up the proper verifier, and give it
another go.

Once we are sure that we've got the right buffer length,
we can also use bp->b_length in the xfs_sb_read_verify,
rather than the less-trusted on-disk sectorsize for
secondary superblocks.  Before this we ran the risk of
passing junk to the crc32c routines, which didn't always
handle extreme values.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/xfs_sb.c