Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: enhance f2fs_is_checkpoint_ready()'s readability

This patch changes sematics of f2fs_is_checkpoint_ready()'s return
value as: return true when checkpoint is ready, other return false,
it can improve readability of below conditions.

f2fs_submit_page_write()
...
if (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN) ||
!f2fs_is_checkpoint_ready(sbi))
__submit_merged_bio(io);

f2fs_balance_fs()
...
if (!f2fs_is_checkpoint_ready(sbi))
return;

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
00e09c0b b757f6ed

+34 -44
+4 -3
fs/f2fs/data.c
··· 634 634 goto next; 635 635 out: 636 636 if (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN) || 637 - f2fs_is_checkpoint_ready(sbi)) 637 + !f2fs_is_checkpoint_ready(sbi)) 638 638 __submit_merged_bio(io); 639 639 up_write(&io->io_rwsem); 640 640 } ··· 2570 2570 2571 2571 trace_f2fs_write_begin(inode, pos, len, flags); 2572 2572 2573 - err = f2fs_is_checkpoint_ready(sbi); 2574 - if (err) 2573 + if (!f2fs_is_checkpoint_ready(sbi)) { 2574 + err = -ENOSPC; 2575 2575 goto fail; 2576 + } 2576 2577 2577 2578 if ((f2fs_is_atomic_file(inode) && 2578 2579 !f2fs_available_free_memory(sbi, INMEM_PAGES)) ||
+8 -10
fs/f2fs/file.c
··· 57 57 err = -EIO; 58 58 goto err; 59 59 } 60 - err = f2fs_is_checkpoint_ready(sbi); 61 - if (err) 60 + 61 + if (!f2fs_is_checkpoint_ready(sbi)) { 62 + err = -ENOSPC; 62 63 goto err; 64 + } 63 65 64 66 sb_start_pagefault(inode->i_sb); 65 67 ··· 1573 1571 1574 1572 if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) 1575 1573 return -EIO; 1576 - ret = f2fs_is_checkpoint_ready(F2FS_I_SB(inode)); 1577 - if (ret) 1578 - return ret; 1574 + if (!f2fs_is_checkpoint_ready(F2FS_I_SB(inode))) 1575 + return -ENOSPC; 1579 1576 1580 1577 /* f2fs only support ->fallocate for regular file */ 1581 1578 if (!S_ISREG(inode->i_mode)) ··· 3147 3146 3148 3147 long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 3149 3148 { 3150 - int ret; 3151 - 3152 3149 if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp))))) 3153 3150 return -EIO; 3154 - ret = f2fs_is_checkpoint_ready(F2FS_I_SB(file_inode(filp))); 3155 - if (ret) 3156 - return ret; 3151 + if (!f2fs_is_checkpoint_ready(F2FS_I_SB(file_inode(filp)))) 3152 + return -ENOSPC; 3157 3153 3158 3154 switch (cmd) { 3159 3155 case F2FS_IOC_GETFLAGS:
+1 -1
fs/f2fs/inode.c
··· 616 616 if (!is_inode_flag_set(inode, FI_DIRTY_INODE)) 617 617 return 0; 618 618 619 - if (f2fs_is_checkpoint_ready(sbi)) 619 + if (!f2fs_is_checkpoint_ready(sbi)) 620 620 return -ENOSPC; 621 621 622 622 /*
+14 -22
fs/f2fs/namei.c
··· 272 272 273 273 if (unlikely(f2fs_cp_error(sbi))) 274 274 return -EIO; 275 - err = f2fs_is_checkpoint_ready(sbi); 276 - if (err) 277 - return err; 275 + if (!f2fs_is_checkpoint_ready(sbi)) 276 + return -ENOSPC; 278 277 279 278 err = dquot_initialize(dir); 280 279 if (err) ··· 320 321 321 322 if (unlikely(f2fs_cp_error(sbi))) 322 323 return -EIO; 323 - err = f2fs_is_checkpoint_ready(sbi); 324 - if (err) 325 - return err; 324 + if (!f2fs_is_checkpoint_ready(sbi)) 325 + return -ENOSPC; 326 326 327 327 err = fscrypt_prepare_link(old_dentry, dir, dentry); 328 328 if (err) ··· 590 592 591 593 if (unlikely(f2fs_cp_error(sbi))) 592 594 return -EIO; 593 - err = f2fs_is_checkpoint_ready(sbi); 594 - if (err) 595 - return err; 595 + if (!f2fs_is_checkpoint_ready(sbi)) 596 + return -ENOSPC; 596 597 597 598 err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, 598 599 &disk_link); ··· 721 724 722 725 if (unlikely(f2fs_cp_error(sbi))) 723 726 return -EIO; 724 - err = f2fs_is_checkpoint_ready(sbi); 725 - if (err) 726 - return err; 727 + if (!f2fs_is_checkpoint_ready(sbi)) 728 + return -ENOSPC; 727 729 728 730 err = dquot_initialize(dir); 729 731 if (err) ··· 818 822 static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) 819 823 { 820 824 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 821 - int ret; 822 825 823 826 if (unlikely(f2fs_cp_error(sbi))) 824 827 return -EIO; 825 - ret = f2fs_is_checkpoint_ready(sbi); 826 - if (ret) 827 - return ret; 828 + if (!f2fs_is_checkpoint_ready(sbi)) 829 + return -ENOSPC; 828 830 829 831 if (IS_ENCRYPTED(dir) || DUMMY_ENCRYPTION_ENABLED(sbi)) { 830 832 int err = fscrypt_get_encryption_info(dir); ··· 859 865 860 866 if (unlikely(f2fs_cp_error(sbi))) 861 867 return -EIO; 862 - err = f2fs_is_checkpoint_ready(sbi); 863 - if (err) 864 - return err; 868 + if (!f2fs_is_checkpoint_ready(sbi)) 869 + return -ENOSPC; 865 870 866 871 if (is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && 867 872 (!projid_eq(F2FS_I(new_dir)->i_projid, ··· 1053 1060 1054 1061 if (unlikely(f2fs_cp_error(sbi))) 1055 1062 return -EIO; 1056 - err = f2fs_is_checkpoint_ready(sbi); 1057 - if (err) 1058 - return err; 1063 + if (!f2fs_is_checkpoint_ready(sbi)) 1064 + return -ENOSPC; 1059 1065 1060 1066 if ((is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && 1061 1067 !projid_eq(F2FS_I(new_dir)->i_projid,
+1 -1
fs/f2fs/segment.c
··· 501 501 if (need && excess_cached_nats(sbi)) 502 502 f2fs_balance_fs_bg(sbi); 503 503 504 - if (f2fs_is_checkpoint_ready(sbi)) 504 + if (!f2fs_is_checkpoint_ready(sbi)) 505 505 return; 506 506 507 507 /*
+4 -4
fs/f2fs/segment.h
··· 586 586 reserved_sections(sbi) + needed); 587 587 } 588 588 589 - static inline int f2fs_is_checkpoint_ready(struct f2fs_sb_info *sbi) 589 + static inline bool f2fs_is_checkpoint_ready(struct f2fs_sb_info *sbi) 590 590 { 591 591 if (likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED))) 592 - return 0; 592 + return true; 593 593 if (likely(!has_not_enough_free_secs(sbi, 0, 0))) 594 - return 0; 595 - return -ENOSPC; 594 + return true; 595 + return false; 596 596 } 597 597 598 598 static inline bool excess_prefree_segs(struct f2fs_sb_info *sbi)
+2 -3
fs/f2fs/xattr.c
··· 732 732 733 733 if (unlikely(f2fs_cp_error(sbi))) 734 734 return -EIO; 735 - err = f2fs_is_checkpoint_ready(sbi); 736 - if (err) 737 - return err; 735 + if (!f2fs_is_checkpoint_ready(sbi)) 736 + return -ENOSPC; 738 737 739 738 err = dquot_initialize(inode); 740 739 if (err)