Commit 7beb01f7 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: clean up f2fs_sb_has_##feature_name

In F2FS_HAS_FEATURE(), we will use F2FS_SB(sb) to get sbi pointer to
access .raw_super field, to avoid unneeded pointer conversion, this
patch changes to F2FS_HAS_FEATURE() accept sbi parameter directly.

Just do cleanup, no logic change.
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 089842de
...@@ -1465,7 +1465,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1465,7 +1465,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
* invalidate intermediate page cache borrowed from meta inode * invalidate intermediate page cache borrowed from meta inode
* which are used for migration of encrypted inode's blocks. * which are used for migration of encrypted inode's blocks.
*/ */
if (f2fs_sb_has_encrypt(sbi->sb)) if (f2fs_sb_has_encrypt(sbi))
invalidate_mapping_pages(META_MAPPING(sbi), invalidate_mapping_pages(META_MAPPING(sbi),
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1); MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
......
...@@ -152,12 +152,13 @@ struct f2fs_mount_info { ...@@ -152,12 +152,13 @@ struct f2fs_mount_info {
#define F2FS_FEATURE_VERITY 0x0400 /* reserved */ #define F2FS_FEATURE_VERITY 0x0400 /* reserved */
#define F2FS_FEATURE_SB_CHKSUM 0x0800 #define F2FS_FEATURE_SB_CHKSUM 0x0800
#define F2FS_HAS_FEATURE(sb, mask) \ #define __F2FS_HAS_FEATURE(raw_super, mask) \
((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0) ((raw_super->feature & cpu_to_le32(mask)) != 0)
#define F2FS_SET_FEATURE(sb, mask) \ #define F2FS_HAS_FEATURE(sbi, mask) __F2FS_HAS_FEATURE(sbi->raw_super, mask)
(F2FS_SB(sb)->raw_super->feature |= cpu_to_le32(mask)) #define F2FS_SET_FEATURE(sbi, mask) \
#define F2FS_CLEAR_FEATURE(sb, mask) \ (sbi->raw_super->feature |= cpu_to_le32(mask))
(F2FS_SB(sb)->raw_super->feature &= ~cpu_to_le32(mask)) #define F2FS_CLEAR_FEATURE(sbi, mask) \
(sbi->raw_super->feature &= ~cpu_to_le32(mask))
/* /*
* Default values for user and/or group using reserved blocks * Default values for user and/or group using reserved blocks
...@@ -3458,9 +3459,9 @@ static inline bool f2fs_post_read_required(struct inode *inode) ...@@ -3458,9 +3459,9 @@ static inline bool f2fs_post_read_required(struct inode *inode)
} }
#define F2FS_FEATURE_FUNCS(name, flagname) \ #define F2FS_FEATURE_FUNCS(name, flagname) \
static inline int f2fs_sb_has_##name(struct super_block *sb) \ static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
{ \ { \
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_##flagname); \ return F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_##flagname); \
} }
F2FS_FEATURE_FUNCS(encrypt, ENCRYPT); F2FS_FEATURE_FUNCS(encrypt, ENCRYPT);
...@@ -3490,7 +3491,7 @@ static inline int get_blkz_type(struct f2fs_sb_info *sbi, ...@@ -3490,7 +3491,7 @@ static inline int get_blkz_type(struct f2fs_sb_info *sbi,
static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi) static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi)
{ {
return f2fs_sb_has_blkzoned(sbi->sb); return f2fs_sb_has_blkzoned(sbi);
} }
static inline bool f2fs_hw_support_discard(struct f2fs_sb_info *sbi) static inline bool f2fs_hw_support_discard(struct f2fs_sb_info *sbi)
...@@ -3565,7 +3566,7 @@ static inline bool f2fs_force_buffered_io(struct inode *inode, ...@@ -3565,7 +3566,7 @@ static inline bool f2fs_force_buffered_io(struct inode *inode,
* for blkzoned device, fallback direct IO to buffered IO, so * for blkzoned device, fallback direct IO to buffered IO, so
* all IOs can be serialized by log-structured write. * all IOs can be serialized by log-structured write.
*/ */
if (f2fs_sb_has_blkzoned(sbi->sb)) if (f2fs_sb_has_blkzoned(sbi))
return true; return true;
if (test_opt(sbi, LFS) && (rw == WRITE) && if (test_opt(sbi, LFS) && (rw == WRITE) &&
block_unaligned_IO(inode, iocb, iter)) block_unaligned_IO(inode, iocb, iter))
...@@ -3588,7 +3589,7 @@ extern void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate, ...@@ -3588,7 +3589,7 @@ extern void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
static inline bool is_journalled_quota(struct f2fs_sb_info *sbi) static inline bool is_journalled_quota(struct f2fs_sb_info *sbi)
{ {
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
if (f2fs_sb_has_quota_ino(sbi->sb)) if (f2fs_sb_has_quota_ino(sbi))
return true; return true;
if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] || if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] ||
F2FS_OPTION(sbi).s_qf_names[GRPQUOTA] || F2FS_OPTION(sbi).s_qf_names[GRPQUOTA] ||
......
...@@ -696,7 +696,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat, ...@@ -696,7 +696,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat,
unsigned int flags; unsigned int flags;
if (f2fs_has_extra_attr(inode) && if (f2fs_has_extra_attr(inode) &&
f2fs_sb_has_inode_crtime(inode->i_sb) && f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) { F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
stat->result_mask |= STATX_BTIME; stat->result_mask |= STATX_BTIME;
stat->btime.tv_sec = fi->i_crtime.tv_sec; stat->btime.tv_sec = fi->i_crtime.tv_sec;
...@@ -2030,7 +2030,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) ...@@ -2030,7 +2030,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
if (!f2fs_sb_has_encrypt(inode->i_sb)) if (!f2fs_sb_has_encrypt(F2FS_I_SB(inode)))
return -EOPNOTSUPP; return -EOPNOTSUPP;
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
...@@ -2040,7 +2040,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) ...@@ -2040,7 +2040,7 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg)
{ {
if (!f2fs_sb_has_encrypt(file_inode(filp)->i_sb)) if (!f2fs_sb_has_encrypt(F2FS_I_SB(file_inode(filp))))
return -EOPNOTSUPP; return -EOPNOTSUPP;
return fscrypt_ioctl_get_policy(filp, (void __user *)arg); return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
} }
...@@ -2051,7 +2051,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg) ...@@ -2051,7 +2051,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
int err; int err;
if (!f2fs_sb_has_encrypt(inode->i_sb)) if (!f2fs_sb_has_encrypt(sbi))
return -EOPNOTSUPP; return -EOPNOTSUPP;
err = mnt_want_write_file(filp); err = mnt_want_write_file(filp);
...@@ -2635,12 +2635,11 @@ static int f2fs_ioc_setproject(struct file *filp, __u32 projid) ...@@ -2635,12 +2635,11 @@ static int f2fs_ioc_setproject(struct file *filp, __u32 projid)
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct super_block *sb = sbi->sb;
struct page *ipage; struct page *ipage;
kprojid_t kprojid; kprojid_t kprojid;
int err; int err;
if (!f2fs_sb_has_project_quota(sb)) { if (!f2fs_sb_has_project_quota(sbi)) {
if (projid != F2FS_DEF_PROJID) if (projid != F2FS_DEF_PROJID)
return -EOPNOTSUPP; return -EOPNOTSUPP;
else else
...@@ -2757,7 +2756,7 @@ static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg) ...@@ -2757,7 +2756,7 @@ static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg)
fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags & fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags &
F2FS_FL_USER_VISIBLE); F2FS_FL_USER_VISIBLE);
if (f2fs_sb_has_project_quota(inode->i_sb)) if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)))
fa.fsx_projid = (__u32)from_kprojid(&init_user_ns, fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
fi->i_projid); fi->i_projid);
......
...@@ -118,7 +118,7 @@ static bool f2fs_enable_inode_chksum(struct f2fs_sb_info *sbi, struct page *page ...@@ -118,7 +118,7 @@ static bool f2fs_enable_inode_chksum(struct f2fs_sb_info *sbi, struct page *page
{ {
struct f2fs_inode *ri = &F2FS_NODE(page)->i; struct f2fs_inode *ri = &F2FS_NODE(page)->i;
if (!f2fs_sb_has_inode_chksum(sbi->sb)) if (!f2fs_sb_has_inode_chksum(sbi))
return false; return false;
if (!IS_INODE(page) || !(ri->i_inline & F2FS_EXTRA_ATTR)) if (!IS_INODE(page) || !(ri->i_inline & F2FS_EXTRA_ATTR))
...@@ -218,7 +218,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) ...@@ -218,7 +218,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
return false; return false;
} }
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb) if (f2fs_sb_has_flexible_inline_xattr(sbi)
&& !f2fs_has_extra_attr(inode)) { && !f2fs_has_extra_attr(inode)) {
set_sbi_flag(sbi, SBI_NEED_FSCK); set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_msg(sbi->sb, KERN_WARNING, f2fs_msg(sbi->sb, KERN_WARNING,
...@@ -228,7 +228,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) ...@@ -228,7 +228,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
} }
if (f2fs_has_extra_attr(inode) && if (f2fs_has_extra_attr(inode) &&
!f2fs_sb_has_extra_attr(sbi->sb)) { !f2fs_sb_has_extra_attr(sbi)) {
set_sbi_flag(sbi, SBI_NEED_FSCK); set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_msg(sbi->sb, KERN_WARNING, f2fs_msg(sbi->sb, KERN_WARNING,
"%s: inode (ino=%lx) is with extra_attr, " "%s: inode (ino=%lx) is with extra_attr, "
...@@ -340,7 +340,7 @@ static int do_read_inode(struct inode *inode) ...@@ -340,7 +340,7 @@ static int do_read_inode(struct inode *inode)
fi->i_extra_isize = f2fs_has_extra_attr(inode) ? fi->i_extra_isize = f2fs_has_extra_attr(inode) ?
le16_to_cpu(ri->i_extra_isize) : 0; le16_to_cpu(ri->i_extra_isize) : 0;
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)) { if (f2fs_sb_has_flexible_inline_xattr(sbi)) {
fi->i_inline_xattr_size = le16_to_cpu(ri->i_inline_xattr_size); fi->i_inline_xattr_size = le16_to_cpu(ri->i_inline_xattr_size);
} else if (f2fs_has_inline_xattr(inode) || } else if (f2fs_has_inline_xattr(inode) ||
f2fs_has_inline_dentry(inode)) { f2fs_has_inline_dentry(inode)) {
...@@ -390,14 +390,14 @@ static int do_read_inode(struct inode *inode) ...@@ -390,14 +390,14 @@ static int do_read_inode(struct inode *inode)
if (fi->i_flags & F2FS_PROJINHERIT_FL) if (fi->i_flags & F2FS_PROJINHERIT_FL)
set_inode_flag(inode, FI_PROJ_INHERIT); set_inode_flag(inode, FI_PROJ_INHERIT);
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi->sb) && if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi) &&
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_projid)) F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_projid))
i_projid = (projid_t)le32_to_cpu(ri->i_projid); i_projid = (projid_t)le32_to_cpu(ri->i_projid);
else else
i_projid = F2FS_DEF_PROJID; i_projid = F2FS_DEF_PROJID;
fi->i_projid = make_kprojid(&init_user_ns, i_projid); fi->i_projid = make_kprojid(&init_user_ns, i_projid);
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_inode_crtime(sbi->sb) && if (f2fs_has_extra_attr(inode) && f2fs_sb_has_inode_crtime(sbi) &&
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) { F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
fi->i_crtime.tv_sec = le64_to_cpu(ri->i_crtime); fi->i_crtime.tv_sec = le64_to_cpu(ri->i_crtime);
fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec); fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec);
...@@ -542,11 +542,11 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) ...@@ -542,11 +542,11 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
if (f2fs_has_extra_attr(inode)) { if (f2fs_has_extra_attr(inode)) {
ri->i_extra_isize = cpu_to_le16(F2FS_I(inode)->i_extra_isize); ri->i_extra_isize = cpu_to_le16(F2FS_I(inode)->i_extra_isize);
if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode)->sb)) if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode)))
ri->i_inline_xattr_size = ri->i_inline_xattr_size =
cpu_to_le16(F2FS_I(inode)->i_inline_xattr_size); cpu_to_le16(F2FS_I(inode)->i_inline_xattr_size);
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)->sb) && if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
i_projid)) { i_projid)) {
projid_t i_projid; projid_t i_projid;
...@@ -556,7 +556,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) ...@@ -556,7 +556,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
ri->i_projid = cpu_to_le32(i_projid); ri->i_projid = cpu_to_le32(i_projid);
} }
if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)->sb) && if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
i_crtime)) { i_crtime)) {
ri->i_crtime = ri->i_crtime =
......
...@@ -61,7 +61,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -61,7 +61,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
goto fail; goto fail;
} }
if (f2fs_sb_has_project_quota(sbi->sb) && if (f2fs_sb_has_project_quota(sbi) &&
(F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL)) (F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL))
F2FS_I(inode)->i_projid = F2FS_I(dir)->i_projid; F2FS_I(inode)->i_projid = F2FS_I(dir)->i_projid;
else else
...@@ -79,7 +79,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -79,7 +79,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
f2fs_may_encrypt(inode)) f2fs_may_encrypt(inode))
f2fs_set_encrypted_inode(inode); f2fs_set_encrypted_inode(inode);
if (f2fs_sb_has_extra_attr(sbi->sb)) { if (f2fs_sb_has_extra_attr(sbi)) {
set_inode_flag(inode, FI_EXTRA_ATTR); set_inode_flag(inode, FI_EXTRA_ATTR);
F2FS_I(inode)->i_extra_isize = F2FS_TOTAL_EXTRA_ATTR_SIZE; F2FS_I(inode)->i_extra_isize = F2FS_TOTAL_EXTRA_ATTR_SIZE;
} }
...@@ -92,7 +92,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -92,7 +92,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
if (f2fs_may_inline_dentry(inode)) if (f2fs_may_inline_dentry(inode))
set_inode_flag(inode, FI_INLINE_DENTRY); set_inode_flag(inode, FI_INLINE_DENTRY);
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)) { if (f2fs_sb_has_flexible_inline_xattr(sbi)) {
f2fs_bug_on(sbi, !f2fs_has_extra_attr(inode)); f2fs_bug_on(sbi, !f2fs_has_extra_attr(inode));
if (f2fs_has_inline_xattr(inode)) if (f2fs_has_inline_xattr(inode))
xattr_size = F2FS_OPTION(sbi).inline_xattr_size; xattr_size = F2FS_OPTION(sbi).inline_xattr_size;
......
...@@ -2561,17 +2561,17 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) ...@@ -2561,17 +2561,17 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
if (dst->i_inline & F2FS_EXTRA_ATTR) { if (dst->i_inline & F2FS_EXTRA_ATTR) {
dst->i_extra_isize = src->i_extra_isize; dst->i_extra_isize = src->i_extra_isize;
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb) && if (f2fs_sb_has_flexible_inline_xattr(sbi) &&
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize), F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
i_inline_xattr_size)) i_inline_xattr_size))
dst->i_inline_xattr_size = src->i_inline_xattr_size; dst->i_inline_xattr_size = src->i_inline_xattr_size;
if (f2fs_sb_has_project_quota(sbi->sb) && if (f2fs_sb_has_project_quota(sbi) &&
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize), F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
i_projid)) i_projid))
dst->i_projid = src->i_projid; dst->i_projid = src->i_projid;
if (f2fs_sb_has_inode_crtime(sbi->sb) && if (f2fs_sb_has_inode_crtime(sbi) &&
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize), F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
i_crtime_nsec)) { i_crtime_nsec)) {
dst->i_crtime = src->i_crtime; dst->i_crtime = src->i_crtime;
......
...@@ -250,7 +250,7 @@ static int recover_inode(struct inode *inode, struct page *page) ...@@ -250,7 +250,7 @@ static int recover_inode(struct inode *inode, struct page *page)
i_gid_write(inode, le32_to_cpu(raw->i_gid)); i_gid_write(inode, le32_to_cpu(raw->i_gid));
if (raw->i_inline & F2FS_EXTRA_ATTR) { if (raw->i_inline & F2FS_EXTRA_ATTR) {
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)->sb) && if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(raw, le16_to_cpu(raw->i_extra_isize), F2FS_FITS_IN_INODE(raw, le16_to_cpu(raw->i_extra_isize),
i_projid)) { i_projid)) {
projid_t i_projid; projid_t i_projid;
......
...@@ -1736,7 +1736,7 @@ static int __issue_discard_async(struct f2fs_sb_info *sbi, ...@@ -1736,7 +1736,7 @@ static int __issue_discard_async(struct f2fs_sb_info *sbi,
struct block_device *bdev, block_t blkstart, block_t blklen) struct block_device *bdev, block_t blkstart, block_t blklen)
{ {
#ifdef CONFIG_BLK_DEV_ZONED #ifdef CONFIG_BLK_DEV_ZONED
if (f2fs_sb_has_blkzoned(sbi->sb) && if (f2fs_sb_has_blkzoned(sbi) &&
bdev_zoned_model(bdev) != BLK_ZONED_NONE) bdev_zoned_model(bdev) != BLK_ZONED_NONE)
return __f2fs_issue_discard_zone(sbi, bdev, blkstart, blklen); return __f2fs_issue_discard_zone(sbi, bdev, blkstart, blklen);
#endif #endif
...@@ -1948,7 +1948,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, ...@@ -1948,7 +1948,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
sbi->blocks_per_seg, cur_pos); sbi->blocks_per_seg, cur_pos);
len = next_pos - cur_pos; len = next_pos - cur_pos;
if (f2fs_sb_has_blkzoned(sbi->sb) || if (f2fs_sb_has_blkzoned(sbi) ||
(force && len < cpc->trim_minlen)) (force && len < cpc->trim_minlen))
goto skip; goto skip;
......
...@@ -259,7 +259,7 @@ static int f2fs_set_qf_name(struct super_block *sb, int qtype, ...@@ -259,7 +259,7 @@ static int f2fs_set_qf_name(struct super_block *sb, int qtype,
"quota options when quota turned on"); "quota options when quota turned on");
return -EINVAL; return -EINVAL;
} }
if (f2fs_sb_has_quota_ino(sb)) { if (f2fs_sb_has_quota_ino(sbi)) {
f2fs_msg(sb, KERN_INFO, f2fs_msg(sb, KERN_INFO,
"QUOTA feature is enabled, so ignore qf_name"); "QUOTA feature is enabled, so ignore qf_name");
return 0; return 0;
...@@ -314,7 +314,7 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi) ...@@ -314,7 +314,7 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi)
* 'grpquota' mount options are allowed even without quota feature * 'grpquota' mount options are allowed even without quota feature
* to support legacy quotas in quota files. * to support legacy quotas in quota files.
*/ */
if (test_opt(sbi, PRJQUOTA) && !f2fs_sb_has_project_quota(sbi->sb)) { if (test_opt(sbi, PRJQUOTA) && !f2fs_sb_has_project_quota(sbi)) {
f2fs_msg(sbi->sb, KERN_ERR, "Project quota feature not enabled. " f2fs_msg(sbi->sb, KERN_ERR, "Project quota feature not enabled. "
"Cannot enable project quota enforcement."); "Cannot enable project quota enforcement.");
return -1; return -1;
...@@ -348,7 +348,7 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi) ...@@ -348,7 +348,7 @@ static int f2fs_check_quota_options(struct f2fs_sb_info *sbi)
} }
} }
if (f2fs_sb_has_quota_ino(sbi->sb) && F2FS_OPTION(sbi).s_jquota_fmt) { if (f2fs_sb_has_quota_ino(sbi) && F2FS_OPTION(sbi).s_jquota_fmt) {
f2fs_msg(sbi->sb, KERN_INFO, f2fs_msg(sbi->sb, KERN_INFO,
"QUOTA feature is enabled, so ignore jquota_fmt"); "QUOTA feature is enabled, so ignore jquota_fmt");
F2FS_OPTION(sbi).s_jquota_fmt = 0; F2FS_OPTION(sbi).s_jquota_fmt = 0;
...@@ -417,7 +417,7 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -417,7 +417,7 @@ static int parse_options(struct super_block *sb, char *options)
set_opt(sbi, DISCARD); set_opt(sbi, DISCARD);
break; break;
case Opt_nodiscard: case Opt_nodiscard:
if (f2fs_sb_has_blkzoned(sb)) { if (f2fs_sb_has_blkzoned(sbi)) {
f2fs_msg(sb, KERN_WARNING, f2fs_msg(sb, KERN_WARNING,
"discard is required for zoned block devices"); "discard is required for zoned block devices");
return -EINVAL; return -EINVAL;
...@@ -566,7 +566,7 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -566,7 +566,7 @@ static int parse_options(struct super_block *sb, char *options)
return -ENOMEM; return -ENOMEM;
if (strlen(name) == 8 && if (strlen(name) == 8 &&
!strncmp(name, "adaptive", 8)) { !strncmp(name, "adaptive", 8)) {
if (f2fs_sb_has_blkzoned(sb)) { if (f2fs_sb_has_blkzoned(sbi)) {
f2fs_msg(sb, KERN_WARNING, f2fs_msg(sb, KERN_WARNING,
"adaptive mode is not allowed with " "adaptive mode is not allowed with "
"zoned block device feature"); "zoned block device feature");
...@@ -758,7 +758,7 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -758,7 +758,7 @@ static int parse_options(struct super_block *sb, char *options)
break; break;
case Opt_test_dummy_encryption: case Opt_test_dummy_encryption:
#ifdef CONFIG_F2FS_FS_ENCRYPTION #ifdef CONFIG_F2FS_FS_ENCRYPTION
if (!f2fs_sb_has_encrypt(sb)) { if (!f2fs_sb_has_encrypt(sbi)) {
f2fs_msg(sb, KERN_ERR, "Encrypt feature is off"); f2fs_msg(sb, KERN_ERR, "Encrypt feature is off");
return -EINVAL; return -EINVAL;
} }
...@@ -799,13 +799,13 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -799,13 +799,13 @@ static int parse_options(struct super_block *sb, char *options)
if (f2fs_check_quota_options(sbi)) if (f2fs_check_quota_options(sbi))
return -EINVAL; return -EINVAL;
#else #else
if (f2fs_sb_has_quota_ino(sbi->sb) && !f2fs_readonly(sbi->sb)) { if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sbi->sb)) {
f2fs_msg(sbi->sb, KERN_INFO, f2fs_msg(sbi->sb, KERN_INFO,
"Filesystem with quota feature cannot be mounted RDWR " "Filesystem with quota feature cannot be mounted RDWR "
"without CONFIG_QUOTA"); "without CONFIG_QUOTA");
return -EINVAL; return -EINVAL;
} }
if (f2fs_sb_has_project_quota(sbi->sb) && !f2fs_readonly(sbi->sb)) { if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) {
f2fs_msg(sb, KERN_ERR, f2fs_msg(sb, KERN_ERR,
"Filesystem with project quota feature cannot be " "Filesystem with project quota feature cannot be "
"mounted RDWR without CONFIG_QUOTA"); "mounted RDWR without CONFIG_QUOTA");
...@@ -821,8 +821,8 @@ static int parse_options(struct super_block *sb, char *options) ...@@ -821,8 +821,8 @@ static int parse_options(struct super_block *sb, char *options)
} }
if (test_opt(sbi, INLINE_XATTR_SIZE)) { if (test_opt(sbi, INLINE_XATTR_SIZE)) {
if (!f2fs_sb_has_extra_attr(sb) || if (!f2fs_sb_has_extra_attr(sbi) ||
!f2fs_sb_has_flexible_inline_xattr(sb)) { !f2fs_sb_has_flexible_inline_xattr(sbi)) {
f2fs_msg(sb, KERN_ERR, f2fs_msg(sb, KERN_ERR,
"extra_attr or flexible_inline_xattr " "extra_attr or flexible_inline_xattr "
"feature is off"); "feature is off");
...@@ -1431,7 +1431,7 @@ static void default_options(struct f2fs_sb_info *sbi) ...@@ -1431,7 +1431,7 @@ static void default_options(struct f2fs_sb_info *sbi)
sbi->sb->s_flags |= SB_LAZYTIME; sbi->sb->s_flags |= SB_LAZYTIME;
set_opt(sbi, FLUSH_MERGE); set_opt(sbi, FLUSH_MERGE);
set_opt(sbi, DISCARD); set_opt(sbi, DISCARD);
if (f2fs_sb_has_blkzoned(sbi->sb)) if (f2fs_sb_has_blkzoned(sbi))
set_opt_mode(sbi, F2FS_MOUNT_LFS); set_opt_mode(sbi, F2FS_MOUNT_LFS);
else else
set_opt_mode(sbi, F2FS_MOUNT_ADAPTIVE); set_opt_mode(sbi, F2FS_MOUNT_ADAPTIVE);
...@@ -1575,7 +1575,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) ...@@ -1575,7 +1575,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
sb->s_flags &= ~SB_RDONLY; sb->s_flags &= ~SB_RDONLY;
if (sb_any_quota_suspended(sb)) { if (sb_any_quota_suspended(sb)) {
dquot_resume(sb, -1); dquot_resume(sb, -1);
} else if (f2fs_sb_has_quota_ino(sb)) { } else if (f2fs_sb_has_quota_ino(sbi)) {
err = f2fs_enable_quotas(sb); err = f2fs_enable_quotas(sb);
if (err) if (err)
goto restore_opts; goto restore_opts;
...@@ -1817,7 +1817,7 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly) ...@@ -1817,7 +1817,7 @@ int f2fs_enable_quota_files(struct f2fs_sb_info *sbi, bool rdonly)
int enabled = 0; int enabled = 0;
int i, err; int i, err;
if (f2fs_sb_has_quota_ino(sbi->sb) && rdonly) { if (f2fs_sb_has_quota_ino(sbi) && rdonly) {
err = f2fs_enable_quotas(sbi->sb); err = f2fs_enable_quotas(sbi->sb);
if (err) { if (err) {
f2fs_msg(sbi->sb, KERN_ERR, f2fs_msg(sbi->sb, KERN_ERR,
...@@ -1848,7 +1848,7 @@ static int f2fs_quota_enable(struct super_block *sb, int type, int format_id, ...@@ -1848,7 +1848,7 @@ static int f2fs_quota_enable(struct super_block *sb, int type, int format_id,
unsigned long qf_inum; unsigned long qf_inum;
int err; int err;
BUG_ON(!f2fs_sb_has_quota_ino(sb)); BUG_ON(!f2fs_sb_has_quota_ino(F2FS_SB(sb)));
qf_inum = f2fs_qf_ino(sb, type); qf_inum = f2fs_qf_ino(sb, type);
if (!qf_inum) if (!qf_inum)
...@@ -1993,7 +1993,7 @@ static int f2fs_quota_off(struct super_block *sb, int type) ...@@ -1993,7 +1993,7 @@ static int f2fs_quota_off(struct super_block *sb, int type)
goto out_put; goto out_put;
err = dquot_quota_off(sb, type); err = dquot_quota_off(sb, type);
if (err || f2fs_sb_has_quota_ino(sb)) if (err || f2fs_sb_has_quota_ino(F2FS_SB(sb)))
goto out_put; goto out_put;
inode_lock(inode); inode_lock(inode);
...@@ -2173,7 +2173,7 @@ static int f2fs_set_context(struct inode *inode, const void *ctx, size_t len, ...@@ -2173,7 +2173,7 @@ static int f2fs_set_context(struct inode *inode, const void *ctx, size_t len,
* if LOST_FOUND feature is enabled. * if LOST_FOUND feature is enabled.
* *
*/ */
if (f2fs_sb_has_lost_found(sbi->sb) && if (f2fs_sb_has_lost_found(sbi) &&
inode->i_ino == F2FS_ROOT_INO(sbi)) inode->i_ino == F2FS_ROOT_INO(sbi))
return -EPERM; return -EPERM;
...@@ -2396,7 +2396,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, ...@@ -2396,7 +2396,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
__u32 crc = 0; __u32 crc = 0;
/* Check checksum_offset and crc in superblock */ /* Check checksum_offset and crc in superblock */
if (le32_to_cpu(raw_super->feature) & F2FS_FEATURE_SB_CHKSUM) { if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) {
crc_offset = le32_to_cpu(raw_super->checksum_offset); crc_offset = le32_to_cpu(raw_super->checksum_offset);
if (crc_offset != if (crc_offset !=
offsetof(struct f2fs_super_block, crc)) { offsetof(struct f2fs_super_block, crc)) {
...@@ -2746,7 +2746,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) ...@@ -2746,7 +2746,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
unsigned int n = 0; unsigned int n = 0;
int err = -EIO; int err = -EIO;
if (!f2fs_sb_has_blkzoned(sbi->sb)) if (!f2fs_sb_has_blkzoned(sbi))
return 0; return 0;
if (sbi->blocks_per_blkz && sbi->blocks_per_blkz != if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
...@@ -2877,7 +2877,7 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) ...@@ -2877,7 +2877,7 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
} }
/* we should update superblock crc here */ /* we should update superblock crc here */
if (!recover && f2fs_sb_has_sb_chksum(sbi->sb)) { if (!recover && f2fs_sb_has_sb_chksum(sbi)) {
crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi), crc = f2fs_crc32(sbi, F2FS_RAW_SUPER(sbi),
offsetof(struct f2fs_super_block, crc)); offsetof(struct f2fs_super_block, crc));
F2FS_RAW_SUPER(sbi)->crc = cpu_to_le32(crc); F2FS_RAW_SUPER(sbi)->crc = cpu_to_le32(crc);
...@@ -2965,7 +2965,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) ...@@ -2965,7 +2965,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
#ifdef CONFIG_BLK_DEV_ZONED #ifdef CONFIG_BLK_DEV_ZONED
if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM && if (bdev_zoned_model(FDEV(i).bdev) == BLK_ZONED_HM &&
!f2fs_sb_has_blkzoned(sbi->sb)) { !f2fs_sb_has_blkzoned(sbi)) {
f2fs_msg(sbi->sb, KERN_ERR, f2fs_msg(sbi->sb, KERN_ERR,
"Zoned block device feature not enabled\n"); "Zoned block device feature not enabled\n");
return -EINVAL; return -EINVAL;
...@@ -3061,7 +3061,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3061,7 +3061,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
sbi->raw_super = raw_super; sbi->raw_super = raw_super;
/* precompute checksum seed for metadata */ /* precompute checksum seed for metadata */
if (f2fs_sb_has_inode_chksum(sb)) if (f2fs_sb_has_inode_chksum(sbi))
sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid, sbi->s_chksum_seed = f2fs_chksum(sbi, ~0, raw_super->uuid,
sizeof(raw_super->uuid)); sizeof(raw_super->uuid));
...@@ -3071,7 +3071,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3071,7 +3071,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
* devices, but mandatory for host-managed zoned block devices. * devices, but mandatory for host-managed zoned block devices.
*/ */
#ifndef CONFIG_BLK_DEV_ZONED #ifndef CONFIG_BLK_DEV_ZONED
if (f2fs_sb_has_blkzoned(sb)) { if (f2fs_sb_has_blkzoned(sbi)) {
f2fs_msg(sb, KERN_ERR, f2fs_msg(sb, KERN_ERR,
"Zoned block device support is not enabled\n"); "Zoned block device support is not enabled\n");
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
...@@ -3098,13 +3098,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3098,13 +3098,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
sb->dq_op = &f2fs_quota_operations; sb->dq_op = &f2fs_quota_operations;
if (f2fs_sb_has_quota_ino(sb)) if (f2fs_sb_has_quota_ino(sbi))
sb->s_qcop = &dquot_quotactl_sysfile_ops; sb->s_qcop = &dquot_quotactl_sysfile_ops;
else else
sb->s_qcop = &f2fs_quotactl_ops; sb->s_qcop = &f2fs_quotactl_ops;
sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ; sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
if (f2fs_sb_has_quota_ino(sbi->sb)) { if (f2fs_sb_has_quota_ino(sbi)) {
for (i = 0; i < MAXQUOTAS; i++) { for (i = 0; i < MAXQUOTAS; i++) {
if (f2fs_qf_ino(sbi->sb, i)) if (f2fs_qf_ino(sbi->sb, i))
sbi->nquota_files++; sbi->nquota_files++;
...@@ -3294,7 +3294,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3294,7 +3294,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
/* Enable quota usage during mount */ /* Enable quota usage during mount */
if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) { if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb)) {
err = f2fs_enable_quotas(sb); err = f2fs_enable_quotas(sb);
if (err) if (err)
f2fs_msg(sb, KERN_ERR, f2fs_msg(sb, KERN_ERR,
...@@ -3389,7 +3389,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -3389,7 +3389,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
free_meta: free_meta:
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
f2fs_truncate_quota_inode_pages(sb); f2fs_truncate_quota_inode_pages(sb);
if (f2fs_sb_has_quota_ino(sb) && !f2fs_readonly(sb)) if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sb))
f2fs_quota_off_umount(sbi->sb); f2fs_quota_off_umount(sbi->sb);
#endif #endif
/* /*
......
...@@ -90,34 +90,34 @@ static ssize_t features_show(struct f2fs_attr *a, ...@@ -90,34 +90,34 @@ static ssize_t features_show(struct f2fs_attr *a,
if (!sb->s_bdev->bd_part) if (!sb->s_bdev->bd_part)
return snprintf(buf, PAGE_SIZE, "0\n"); return snprintf(buf, PAGE_SIZE, "0\n");
if (f2fs_sb_has_encrypt(sb)) if (f2fs_sb_has_encrypt(sbi))
len += snprintf(buf, PAGE_SIZE - len, "%s", len += snprintf(buf, PAGE_SIZE - len, "%s",
"encryption"); "encryption");
if (f2fs_sb_has_blkzoned(sb)) if (f2fs_sb_has_blkzoned(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "blkzoned"); len ? ", " : "", "blkzoned");
if (f2fs_sb_has_extra_attr(sb)) if (f2fs_sb_has_extra_attr(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "extra_attr"); len ? ", " : "", "extra_attr");
if (f2fs_sb_has_project_quota(sb)) if (f2fs_sb_has_project_quota(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "projquota"); len ? ", " : "", "projquota");
if (f2fs_sb_has_inode_chksum(sb)) if (f2fs_sb_has_inode_chksum(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "inode_checksum"); len ? ", " : "", "inode_checksum");
if (f2fs_sb_has_flexible_inline_xattr(sb)) if (f2fs_sb_has_flexible_inline_xattr(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "flexible_inline_xattr"); len ? ", " : "", "flexible_inline_xattr");
if (f2fs_sb_has_quota_ino(sb)) if (f2fs_sb_has_quota_ino(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "quota_ino"); len ? ", " : "", "quota_ino");
if (f2fs_sb_has_inode_crtime(sb)) if (f2fs_sb_has_inode_crtime(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "inode_crtime"); len ? ", " : "", "inode_crtime");
if (f2fs_sb_has_lost_found(sb)) if (f2fs_sb_has_lost_found(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "lost_found"); len ? ", " : "", "lost_found");
if (f2fs_sb_has_sb_chksum(sb)) if (f2fs_sb_has_sb_chksum(sbi))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "sb_checksum"); len ? ", " : "", "sb_checksum");
len += snprintf(buf + len, PAGE_SIZE - len, "\n"); len += snprintf(buf + len, PAGE_SIZE - len, "\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment