ext4: use ext4_zero_partial_blocks in punch_hole
authorLukas Czerner <lczerner@redhat.com>
Tue, 28 May 2013 03:32:35 +0000 (23:32 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 28 May 2013 03:32:35 +0000 (23:32 -0400)
commita87dd18ce24dee5da1e9eb44bf8d8d48e0957efd
treef05a1b28fc0ee8a26007a7da20805b3f643f4923
parent55f252c9f50e998f6bc3aadc7806f049f7443d21
ext4: use ext4_zero_partial_blocks in punch_hole

We're doing to get rid of ext4_discard_partial_page_buffers() since it is
duplicating some code and also partially duplicating work of
truncate_pagecache_range(), moreover the old implementation was much
clearer.

Now when the truncate_inode_pages_range() can handle truncating non page
aligned regions we can use this to invalidate and zero out block aligned
region of the punched out range and then use ext4_block_truncate_page()
to zero the unaligned blocks on the start and end of the range. This
will greatly simplify the punch hole code. Moreover after this commit we
can get rid of the ext4_discard_partial_page_buffers() completely.

We also introduce function ext4_prepare_punch_hole() to do come common
operations before we attempt to do the actual punch hole on
indirect or extent file which saves us some code duplication.

This has been tested on ppc64 with 1k block size with fsx and xfstests
without any problems.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/inode.c