libext2fs: correctly subtract xattr blocks on bigalloc filesystems
commit6eae35c0a8f18877988bc963e920cf715aa3347f
authorEric Biggers <ebiggers@google.com>
Thu, 25 May 2017 01:48:41 +0000 (24 21:48 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 25 May 2017 01:48:41 +0000 (24 21:48 -0400)
tree5f84240d1344de1b9e7000c7bd8e2e8569d90969
parentb0f5fa880c36bf25bb5beebd0b43102fffec99b0
libext2fs: correctly subtract xattr blocks on bigalloc filesystems

ext2fs_inode_data_blocks2() calculates an inode's data block count by
subtracting the external xattr block, if any, from the total blocks.
But on bigalloc filesystems, the xattr "block" is actually a whole
cluster, so ext2fs_inode_data_blocks2() would return a too-large value.

It seems this could have caused several different problems, but the one
I encountered was that xfstest generic/399 failed in the "bigalloc"
config because e2fsck incorrectly considered a symlink on the filesystem
to be corrupted at the end of the test.  This happened because e2fsck
incorrectly calculated a nonzero data block count for a "fast" symlink
with an external xattr block and therefore treated it as a "slow"
symlink, which failed validation.

Fix this by updating ext2fs_inode_data_blocks2() to subtract the cluster
size rather than the block size.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/blknum.c
tests/f_bigalloc_symlink_with_xattr/expect.1 [new file with mode: 0644]
tests/f_bigalloc_symlink_with_xattr/image.gz [new file with mode: 0644]
tests/f_bigalloc_symlink_with_xattr/name [new file with mode: 0644]
tests/f_bigalloc_symlink_with_xattr/script [new file with mode: 0644]