From patchwork Mon Nov 19 12:55:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/3, v2] ext4: let us fully support punching hole feature in fallocate Date: Mon, 19 Nov 2012 02:55:17 -0000 From: Zheng Liu X-Patchwork-Id: 199996 Message-Id: <1353329718-2075-3-git-send-email-wenqing.lz@taobao.com> To: linux-ext4@vger.kernel.org Cc: Zheng Liu From: Zheng Liu After adding indirect punching hole feature, we need to enable it in fallocate. For this purpose, some sanity checks need to be adjusted. Currently we need to check FALLOC_FL_PUNCH_HOLE flag before other sanity checks. Signed-off-by: Zheng Liu --- fs/ext4/extents.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 7011ac9..b43b3e9 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4420,13 +4420,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; @@ -4434,6 +4427,13 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len) if (mode & FALLOC_FL_PUNCH_HOLE) return ext4_punch_hole(file, offset, len); + /* + * 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; /*