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) | |
download | linux-8bad6fc813a3a5300f51369c39d315679fd88c72.tar.gz linux-8bad6fc813a3a5300f51369c39d315679fd88c72.tar.bz2 linux-8bad6fc813a3a5300f51369c39d315679fd88c72.zip |
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) struct ext4_map_blocks map; unsigned int credits, blkbits = inode->i_blkbits; - /* - * currently supporting (pre)allocate mode for extent-based - * files _only_ - */ - if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) - return -EOPNOTSUPP; - /* Return error if mode is not supported */ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) return -EOPNOTSUPP; @@ -4418,6 +4411,13 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) if (ret) return ret; + /* + * currently supporting (pre)allocate mode for extent-based + * files _only_ + */ + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) + return -EOPNOTSUPP; + trace_ext4_fallocate_enter(inode, offset, len, mode); map.m_lblk = offset >> blkbits; /* |