Whamcloud - gitweb
libext2fs: use ZERO_RANGE before PUNCH_HOLE in unix_zeroout
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 28 Aug 2018 23:38:00 +0000 (16:38 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 6 Sep 2018 15:54:41 +0000 (11:54 -0400)
commit3f6a9786d749e40952c233e6d1d324045d67416c
tree721c9c98762137152165e098150e81d737b7ce30
parentf56db533fc5be9a1398ae9ff67fc03837cc667ea
libext2fs: use ZERO_RANGE before PUNCH_HOLE in unix_zeroout

In unix_zeroout() for files, we should try a ZERO_RANGE before we try
PUNCH_HOLE because the former will not cause us to lose preallocated
blocks.  Since block devices have supported fallocate for a few years
now, refactor the fallocate calls into a helper and call it from either
case.

Reported-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/unix_io.c