diff options
author | Zheng Liu <wenqing.lz@taobao.com> | 2013-01-28 09:21:37 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-01-28 09:21:37 -0500 |
commit | 8bad6fc813a3a5300f51369c39d315679fd88c72 (patch) | |
tree | c455b1f18cc19627a9ab1055d57b72042aeae0a0 /fs/ext4/extents.c | |
parent | 03dafb5f59bd31b3f590329e95434203f0ca6661 (diff) |
ext4: add punching hole support for non-extent-mapped files
This patch add supports for indirect file support punching hole. It
is almost the same as ext4_ext_punch_hole. First, we invalidate all
pages between this hole, and then we try to deallocate all blocks of
this hole.
A recursive function is used to handle deallocation of blocks. In
this function, it iterates over the entries in inode's i_blocks or
indirect blocks, and try to free the block for each one of them.
After applying this patch, xfstest #255 will not pass w/o extent because
indirect-based file doesn't support unwritten extents.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 391e53a52e58..566c8f3789e1 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -4400,13 +4400,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
4400 | struct ext4_map_blocks map; | 4400 | struct ext4_map_blocks map; |
4401 | unsigned int credits, blkbits = inode->i_blkbits; | 4401 | unsigned int credits, blkbits = inode->i_blkbits; |
4402 | 4402 | ||
4403 | /* | ||
4404 | * currently supporting (pre)allocate mode for extent-based | ||
4405 | * files _only_ | ||
4406 | */ | ||
4407 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | ||
4408 | return -EOPNOTSUPP; | ||
4409 | |||
4410 | /* Return error if mode is not supported */ | 4403 | /* Return error if mode is not supported */ |
4411 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | 4404 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
4412 | return -EOPNOTSUPP; | 4405 | return -EOPNOTSUPP; |
@@ -4418,6 +4411,13 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
4418 | if (ret) | 4411 | if (ret) |
4419 | return ret; | 4412 | return ret; |
4420 | 4413 | ||
4414 | /* | ||
4415 | * currently supporting (pre)allocate mode for extent-based | ||
4416 | * files _only_ | ||
4417 | */ | ||
4418 | if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) | ||
4419 | return -EOPNOTSUPP; | ||
4420 | |||
4421 | trace_ext4_fallocate_enter(inode, offset, len, mode); | 4421 | trace_ext4_fallocate_enter(inode, offset, len, mode); |
4422 | map.m_lblk = offset >> blkbits; | 4422 | map.m_lblk = offset >> blkbits; |
4423 | /* | 4423 | /* |