Skip to content

Commit 7beb01f

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 089842d commit 7beb01f

File tree

10 files changed

+73
-73
lines changed

10 files changed

+73
-73
lines changed

fs/f2fs/checkpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
14651465
* invalidate intermediate page cache borrowed from meta inode
14661466
* which are used for migration of encrypted inode's blocks.
14671467
*/
1468-
if (f2fs_sb_has_encrypt(sbi->sb))
1468+
if (f2fs_sb_has_encrypt(sbi))
14691469
invalidate_mapping_pages(META_MAPPING(sbi),
14701470
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
14711471

fs/f2fs/f2fs.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ struct f2fs_mount_info {
152152
#define F2FS_FEATURE_VERITY 0x0400 /* reserved */
153153
#define F2FS_FEATURE_SB_CHKSUM 0x0800
154154

155-
#define F2FS_HAS_FEATURE(sb, mask) \
156-
((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
157-
#define F2FS_SET_FEATURE(sb, mask) \
158-
(F2FS_SB(sb)->raw_super->feature |= cpu_to_le32(mask))
159-
#define F2FS_CLEAR_FEATURE(sb, mask) \
160-
(F2FS_SB(sb)->raw_super->feature &= ~cpu_to_le32(mask))
155+
#define __F2FS_HAS_FEATURE(raw_super, mask) \
156+
((raw_super->feature & cpu_to_le32(mask)) != 0)
157+
#define F2FS_HAS_FEATURE(sbi, mask) __F2FS_HAS_FEATURE(sbi->raw_super, mask)
158+
#define F2FS_SET_FEATURE(sbi, mask) \
159+
(sbi->raw_super->feature |= cpu_to_le32(mask))
160+
#define F2FS_CLEAR_FEATURE(sbi, mask) \
161+
(sbi->raw_super->feature &= ~cpu_to_le32(mask))
161162

162163
/*
163164
* Default values for user and/or group using reserved blocks
@@ -3458,9 +3459,9 @@ static inline bool f2fs_post_read_required(struct inode *inode)
34583459
}
34593460

34603461
#define F2FS_FEATURE_FUNCS(name, flagname) \
3461-
static inline int f2fs_sb_has_##name(struct super_block *sb) \
3462+
static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
34623463
{ \
3463-
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_##flagname); \
3464+
return F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_##flagname); \
34643465
}
34653466

34663467
F2FS_FEATURE_FUNCS(encrypt, ENCRYPT);
@@ -3490,7 +3491,7 @@ static inline int get_blkz_type(struct f2fs_sb_info *sbi,
34903491

34913492
static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi)
34923493
{
3493-
return f2fs_sb_has_blkzoned(sbi->sb);
3494+
return f2fs_sb_has_blkzoned(sbi);
34943495
}
34953496

34963497
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,
35653566
* for blkzoned device, fallback direct IO to buffered IO, so
35663567
* all IOs can be serialized by log-structured write.
35673568
*/
3568-
if (f2fs_sb_has_blkzoned(sbi->sb))
3569+
if (f2fs_sb_has_blkzoned(sbi))
35693570
return true;
35703571
if (test_opt(sbi, LFS) && (rw == WRITE) &&
35713572
block_unaligned_IO(inode, iocb, iter))
@@ -3588,7 +3589,7 @@ extern void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
35883589
static inline bool is_journalled_quota(struct f2fs_sb_info *sbi)
35893590
{
35903591
#ifdef CONFIG_QUOTA
3591-
if (f2fs_sb_has_quota_ino(sbi->sb))
3592+
if (f2fs_sb_has_quota_ino(sbi))
35923593
return true;
35933594
if (F2FS_OPTION(sbi).s_qf_names[USRQUOTA] ||
35943595
F2FS_OPTION(sbi).s_qf_names[GRPQUOTA] ||

fs/f2fs/file.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ int f2fs_getattr(const struct path *path, struct kstat *stat,
696696
unsigned int flags;
697697

698698
if (f2fs_has_extra_attr(inode) &&
699-
f2fs_sb_has_inode_crtime(inode->i_sb) &&
699+
f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) &&
700700
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
701701
stat->result_mask |= STATX_BTIME;
702702
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)
20302030
{
20312031
struct inode *inode = file_inode(filp);
20322032

2033-
if (!f2fs_sb_has_encrypt(inode->i_sb))
2033+
if (!f2fs_sb_has_encrypt(F2FS_I_SB(inode)))
20342034
return -EOPNOTSUPP;
20352035

20362036
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)
20402040

20412041
static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg)
20422042
{
2043-
if (!f2fs_sb_has_encrypt(file_inode(filp)->i_sb))
2043+
if (!f2fs_sb_has_encrypt(F2FS_I_SB(file_inode(filp))))
20442044
return -EOPNOTSUPP;
20452045
return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
20462046
}
@@ -2051,7 +2051,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
20512051
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
20522052
int err;
20532053

2054-
if (!f2fs_sb_has_encrypt(inode->i_sb))
2054+
if (!f2fs_sb_has_encrypt(sbi))
20552055
return -EOPNOTSUPP;
20562056

20572057
err = mnt_want_write_file(filp);
@@ -2635,12 +2635,11 @@ static int f2fs_ioc_setproject(struct file *filp, __u32 projid)
26352635
struct inode *inode = file_inode(filp);
26362636
struct f2fs_inode_info *fi = F2FS_I(inode);
26372637
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
2638-
struct super_block *sb = sbi->sb;
26392638
struct page *ipage;
26402639
kprojid_t kprojid;
26412640
int err;
26422641

2643-
if (!f2fs_sb_has_project_quota(sb)) {
2642+
if (!f2fs_sb_has_project_quota(sbi)) {
26442643
if (projid != F2FS_DEF_PROJID)
26452644
return -EOPNOTSUPP;
26462645
else
@@ -2757,7 +2756,7 @@ static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg)
27572756
fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags &
27582757
F2FS_FL_USER_VISIBLE);
27592758

2760-
if (f2fs_sb_has_project_quota(inode->i_sb))
2759+
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)))
27612760
fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
27622761
fi->i_projid);
27632762

fs/f2fs/inode.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static bool f2fs_enable_inode_chksum(struct f2fs_sb_info *sbi, struct page *page
118118
{
119119
struct f2fs_inode *ri = &F2FS_NODE(page)->i;
120120

121-
if (!f2fs_sb_has_inode_chksum(sbi->sb))
121+
if (!f2fs_sb_has_inode_chksum(sbi))
122122
return false;
123123

124124
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)
218218
return false;
219219
}
220220

221-
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)
221+
if (f2fs_sb_has_flexible_inline_xattr(sbi)
222222
&& !f2fs_has_extra_attr(inode)) {
223223
set_sbi_flag(sbi, SBI_NEED_FSCK);
224224
f2fs_msg(sbi->sb, KERN_WARNING,
@@ -228,7 +228,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
228228
}
229229

230230
if (f2fs_has_extra_attr(inode) &&
231-
!f2fs_sb_has_extra_attr(sbi->sb)) {
231+
!f2fs_sb_has_extra_attr(sbi)) {
232232
set_sbi_flag(sbi, SBI_NEED_FSCK);
233233
f2fs_msg(sbi->sb, KERN_WARNING,
234234
"%s: inode (ino=%lx) is with extra_attr, "
@@ -340,7 +340,7 @@ static int do_read_inode(struct inode *inode)
340340
fi->i_extra_isize = f2fs_has_extra_attr(inode) ?
341341
le16_to_cpu(ri->i_extra_isize) : 0;
342342

343-
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)) {
343+
if (f2fs_sb_has_flexible_inline_xattr(sbi)) {
344344
fi->i_inline_xattr_size = le16_to_cpu(ri->i_inline_xattr_size);
345345
} else if (f2fs_has_inline_xattr(inode) ||
346346
f2fs_has_inline_dentry(inode)) {
@@ -390,14 +390,14 @@ static int do_read_inode(struct inode *inode)
390390
if (fi->i_flags & F2FS_PROJINHERIT_FL)
391391
set_inode_flag(inode, FI_PROJ_INHERIT);
392392

393-
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi->sb) &&
393+
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi) &&
394394
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_projid))
395395
i_projid = (projid_t)le32_to_cpu(ri->i_projid);
396396
else
397397
i_projid = F2FS_DEF_PROJID;
398398
fi->i_projid = make_kprojid(&init_user_ns, i_projid);
399399

400-
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_inode_crtime(sbi->sb) &&
400+
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_inode_crtime(sbi) &&
401401
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
402402
fi->i_crtime.tv_sec = le64_to_cpu(ri->i_crtime);
403403
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)
542542
if (f2fs_has_extra_attr(inode)) {
543543
ri->i_extra_isize = cpu_to_le16(F2FS_I(inode)->i_extra_isize);
544544

545-
if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode)->sb))
545+
if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode)))
546546
ri->i_inline_xattr_size =
547547
cpu_to_le16(F2FS_I(inode)->i_inline_xattr_size);
548548

549-
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)->sb) &&
549+
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) &&
550550
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
551551
i_projid)) {
552552
projid_t i_projid;
@@ -556,7 +556,7 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
556556
ri->i_projid = cpu_to_le32(i_projid);
557557
}
558558

559-
if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)->sb) &&
559+
if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) &&
560560
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
561561
i_crtime)) {
562562
ri->i_crtime =

fs/f2fs/namei.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
6161
goto fail;
6262
}
6363

64-
if (f2fs_sb_has_project_quota(sbi->sb) &&
64+
if (f2fs_sb_has_project_quota(sbi) &&
6565
(F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL))
6666
F2FS_I(inode)->i_projid = F2FS_I(dir)->i_projid;
6767
else
@@ -79,7 +79,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
7979
f2fs_may_encrypt(inode))
8080
f2fs_set_encrypted_inode(inode);
8181

82-
if (f2fs_sb_has_extra_attr(sbi->sb)) {
82+
if (f2fs_sb_has_extra_attr(sbi)) {
8383
set_inode_flag(inode, FI_EXTRA_ATTR);
8484
F2FS_I(inode)->i_extra_isize = F2FS_TOTAL_EXTRA_ATTR_SIZE;
8585
}
@@ -92,7 +92,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
9292
if (f2fs_may_inline_dentry(inode))
9393
set_inode_flag(inode, FI_INLINE_DENTRY);
9494

95-
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)) {
95+
if (f2fs_sb_has_flexible_inline_xattr(sbi)) {
9696
f2fs_bug_on(sbi, !f2fs_has_extra_attr(inode));
9797
if (f2fs_has_inline_xattr(inode))
9898
xattr_size = F2FS_OPTION(sbi).inline_xattr_size;

fs/f2fs/node.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,17 +2561,17 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
25612561
if (dst->i_inline & F2FS_EXTRA_ATTR) {
25622562
dst->i_extra_isize = src->i_extra_isize;
25632563

2564-
if (f2fs_sb_has_flexible_inline_xattr(sbi->sb) &&
2564+
if (f2fs_sb_has_flexible_inline_xattr(sbi) &&
25652565
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
25662566
i_inline_xattr_size))
25672567
dst->i_inline_xattr_size = src->i_inline_xattr_size;
25682568

2569-
if (f2fs_sb_has_project_quota(sbi->sb) &&
2569+
if (f2fs_sb_has_project_quota(sbi) &&
25702570
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
25712571
i_projid))
25722572
dst->i_projid = src->i_projid;
25732573

2574-
if (f2fs_sb_has_inode_crtime(sbi->sb) &&
2574+
if (f2fs_sb_has_inode_crtime(sbi) &&
25752575
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
25762576
i_crtime_nsec)) {
25772577
dst->i_crtime = src->i_crtime;

fs/f2fs/recovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int recover_inode(struct inode *inode, struct page *page)
250250
i_gid_write(inode, le32_to_cpu(raw->i_gid));
251251

252252
if (raw->i_inline & F2FS_EXTRA_ATTR) {
253-
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)->sb) &&
253+
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)) &&
254254
F2FS_FITS_IN_INODE(raw, le16_to_cpu(raw->i_extra_isize),
255255
i_projid)) {
256256
projid_t i_projid;

fs/f2fs/segment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@ static int __issue_discard_async(struct f2fs_sb_info *sbi,
17361736
struct block_device *bdev, block_t blkstart, block_t blklen)
17371737
{
17381738
#ifdef CONFIG_BLK_DEV_ZONED
1739-
if (f2fs_sb_has_blkzoned(sbi->sb) &&
1739+
if (f2fs_sb_has_blkzoned(sbi) &&
17401740
bdev_zoned_model(bdev) != BLK_ZONED_NONE)
17411741
return __f2fs_issue_discard_zone(sbi, bdev, blkstart, blklen);
17421742
#endif
@@ -1948,7 +1948,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
19481948
sbi->blocks_per_seg, cur_pos);
19491949
len = next_pos - cur_pos;
19501950

1951-
if (f2fs_sb_has_blkzoned(sbi->sb) ||
1951+
if (f2fs_sb_has_blkzoned(sbi) ||
19521952
(force && len < cpc->trim_minlen))
19531953
goto skip;
19541954

0 commit comments

Comments
 (0)