OSDN Git Service

f2fs: fix to spread f2fs_is_checkpoint_ready()
authorChao Yu <yuchao0@huawei.com>
Mon, 22 Jul 2019 09:57:05 +0000 (17:57 +0800)
committer0ranko0P <ranko0p@outlook.com>
Tue, 24 Dec 2019 20:42:23 +0000 (04:42 +0800)
We missed to call f2fs_is_checkpoint_ready() in several places, it may
allow space allocation even when free space was exhausted during
checkpoint is disabled, fix to add them.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c
fs/f2fs/namei.c
fs/f2fs/xattr.c

index c51d0c5..83611bc 100644 (file)
@@ -59,6 +59,9 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
                err = -EIO;
                goto err;
        }
+       err = f2fs_is_checkpoint_ready(sbi);
+       if (err)
+               goto err;
 
        sb_start_pagefault(inode->i_sb);
 
@@ -1576,6 +1579,9 @@ static long f2fs_fallocate(struct file *file, int mode,
 
        if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
                return -EIO;
+       ret = f2fs_is_checkpoint_ready(F2FS_I_SB(inode));
+       if (ret)
+               return ret;
 
        /* f2fs only support ->fallocate for regular file */
        if (!S_ISREG(inode->i_mode))
@@ -2862,8 +2868,13 @@ static int f2fs_ioc_resize_fs(struct file *filp, unsigned long arg)
 
 long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+       int ret;
+
        if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp)))))
                return -EIO;
+       ret = f2fs_is_checkpoint_ready(F2FS_I_SB(file_inode(filp)));
+       if (ret)
+               return ret;
 
        switch (cmd) {
        case F2FS_IOC_GETFLAGS:
index a1a78ff..467f9fe 100644 (file)
@@ -799,9 +799,13 @@ out:
 static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
+       int ret;
 
        if (unlikely(f2fs_cp_error(sbi)))
                return -EIO;
+       ret = f2fs_is_checkpoint_ready(sbi);
+       if (ret)
+               return ret;
 
        if (f2fs_encrypted_inode(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) {
                int err = fscrypt_get_encryption_info(dir);
index d48af3b..7445142 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/posix_acl_xattr.h>
 #include "f2fs.h"
 #include "xattr.h"
+#include "segment.h"
 
 static size_t f2fs_xattr_generic_list(const struct xattr_handler *handler,
                struct dentry *dentry, char *list, size_t list_size,
@@ -768,6 +769,10 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        int err;
 
+       err = f2fs_is_checkpoint_ready(sbi);
+       if (err)
+               return err;
+
        err = dquot_initialize(inode);
        if (err)
                return err;