]> Pileus Git - ~andy/linux/commit
ext4: refactor punch hole code
authorTheodore Ts'o <tytso@mit.edu>
Wed, 3 Apr 2013 16:45:17 +0000 (12:45 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 3 Apr 2013 16:45:17 +0000 (12:45 -0400)
commit26a4c0c6ccecf6814cf44f951c97222bd795bc1a
tree9b3a2fa02c61464ead1456499cad46e41644878b
parent781f143ea0fd7981ebe2e8cd96114997c8cf6c07
ext4: refactor punch hole code

Move common code in ext4_ind_punch_hole() and ext4_ext_punch_hole()
into ext4_punch_hole().  This saves over 150 lines of code.

This also fixes a potential bug when the punch_hole() code is racing
against indirect-to-extents or extents-to-indirect migation.  We are
currently using i_mutex to protect against changes to the inode flag;
specifically, the append-only, immutable, and extents inode flags.  So
we need to take i_mutex before deciding whether to use the
extents-specific or indirect-specific punch_hole code.

Also, there was a missing call to ext4_inode_block_unlocked_dio() in
the indirect punch codepath.  This was added in commit 02d262dffcf4c
to block DIO readers racing against the punch operation in the
codepath for extent-mapped inodes, but it was missing for
indirect-block mapped inodes.  One of the advantages of refactoring
the code is that it makes such oversights much less likely.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/indirect.c
fs/ext4/inode.c