Skip to content

Commit

Permalink
f2fs: fix to spread f2fs_is_checkpoint_ready()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
chaseyu authored and Jaegeuk Kim committed Aug 23, 2019
1 parent 7975f34 commit 955ebcd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fs/f2fs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
err = -EIO;
goto err;
}
err = f2fs_is_checkpoint_ready(sbi);
if (err)
goto err;

sb_start_pagefault(inode->i_sb);

Expand Down Expand Up @@ -1567,6 +1570,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))
Expand Down Expand Up @@ -3062,8 +3068,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:
Expand Down
4 changes: 4 additions & 0 deletions fs/f2fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,13 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
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 (IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) {
int err = fscrypt_get_encryption_info(dir);
Expand Down
5 changes: 5 additions & 0 deletions fs/f2fs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/posix_acl_xattr.h>
#include "f2fs.h"
#include "xattr.h"
#include "segment.h"

static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
struct dentry *unused, struct inode *inode,
Expand Down Expand Up @@ -729,6 +730,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;
Expand Down

0 comments on commit 955ebcd

Please sign in to comment.