]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
f2fs: skip punching hole in special condition
authorChao Yu <chao2.yu@samsung.com>
Mon, 15 Sep 2014 10:03:32 +0000 (18:03 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 23 Sep 2014 18:10:21 +0000 (11:10 -0700)
Now punching hole in directory is not supported in f2fs, so let's limit file
type in punch_hole().

In addition, in punch_hole if offset is exceed file size, we should skip
punching hole.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index a95ba23e3bd3d4f688db741e8165ac033e0ff691..ac8c6804097fe95006f59af2ca56de22575035ff 100644 (file)
@@ -658,6 +658,13 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
        loff_t off_start, off_end;
        int ret = 0;
 
+       if (!S_ISREG(inode->i_mode))
+               return -EOPNOTSUPP;
+
+       /* skip punching hole beyond i_size */
+       if (offset >= inode->i_size)
+               return ret;
+
        ret = f2fs_convert_inline_data(inode, MAX_INLINE_DATA + 1, NULL);
        if (ret)
                return ret;