ext4: fix xfstests 75, 112, 127 punch hole failure
commitba06208a1315ab2d2217e09c79582b886c9f629e
authorAllison Henderson <achender@linux.vnet.ibm.com>
Sat, 3 Sep 2011 15:55:59 +0000 (3 11:55 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 3 Sep 2011 15:55:59 +0000 (3 11:55 -0400)
tree08410f6be28c6811aa17b1cde65cc31e79e01e83
parent4e96b2dbbf1d7e81f22047a50f862555a6cb87cb
ext4: fix xfstests 75, 112, 127 punch hole failure

This patch addresses a bug found by xfstests 75, 112, 127
when blocksize = 1k

This bug happens because the punch hole code only zeros
out non block aligned regions of the page.  This means that if the
blocks are smaller than a page, then the block aligned regions of
the page inside the hole are left un-zeroed, and their buffer heads
are still mapped.  This bug is corrected by using
ext4_discard_partial_page_buffers to properly zero the partial page
at the head and tail of the hole, and unmap the corresponding buffer
heads

This patch also addresses a bug reported by Lukas while working on a
new patch to add discard support for loop devices using punch hole.
The bug happened because of the first and last block number
needed to be cast to a larger data type before calculating the
byte offset, but since now we only need the byte offsets of the
pages, we no longer even need to be calculating the byte offsets
of the blocks.  The code to do the block offset calculations is
removed in this patch.

Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
fs/ext4/extents.c