f2fs: clean up f2fs_sb_has_xxx functions
This patch introduces F2FS_FEATURE_FUNCS to clean up the definitions of different f2fs_sb_has_xxx functions. Signed-off-by: Sheng Yong <shengyong1@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
3bb09a0e7e
commit
ccd31cb28f
|
@ -206,7 +206,7 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi,
|
||||||
if (type != DATA && type != NODE)
|
if (type != DATA && type != NODE)
|
||||||
goto submit_io;
|
goto submit_io;
|
||||||
|
|
||||||
if (f2fs_sb_mounted_blkzoned(sbi->sb) && current->plug)
|
if (f2fs_sb_has_blkzoned(sbi->sb) && current->plug)
|
||||||
blk_finish_plug(current->plug);
|
blk_finish_plug(current->plug);
|
||||||
|
|
||||||
start = bio->bi_iter.bi_size >> F2FS_BLKSIZE_BITS;
|
start = bio->bi_iter.bi_size >> F2FS_BLKSIZE_BITS;
|
||||||
|
|
|
@ -3182,45 +3182,20 @@ static inline bool f2fs_bio_encrypted(struct bio *bio)
|
||||||
return bio->bi_private != NULL;
|
return bio->bi_private != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int f2fs_sb_has_crypto(struct super_block *sb)
|
#define F2FS_FEATURE_FUNCS(name, flagname) \
|
||||||
{
|
static inline int f2fs_sb_has_##name(struct super_block *sb) \
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_ENCRYPT);
|
{ \
|
||||||
|
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_##flagname); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb)
|
F2FS_FEATURE_FUNCS(encrypt, ENCRYPT);
|
||||||
{
|
F2FS_FEATURE_FUNCS(blkzoned, BLKZONED);
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED);
|
F2FS_FEATURE_FUNCS(extra_attr, EXTRA_ATTR);
|
||||||
}
|
F2FS_FEATURE_FUNCS(project_quota, PRJQUOTA);
|
||||||
|
F2FS_FEATURE_FUNCS(inode_chksum, INODE_CHKSUM);
|
||||||
static inline int f2fs_sb_has_extra_attr(struct super_block *sb)
|
F2FS_FEATURE_FUNCS(flexible_inline_xattr, FLEXIBLE_INLINE_XATTR);
|
||||||
{
|
F2FS_FEATURE_FUNCS(quota_ino, QUOTA_INO);
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_EXTRA_ATTR);
|
F2FS_FEATURE_FUNCS(inode_crtime, INODE_CRTIME);
|
||||||
}
|
|
||||||
|
|
||||||
static inline int f2fs_sb_has_project_quota(struct super_block *sb)
|
|
||||||
{
|
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_PRJQUOTA);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int f2fs_sb_has_inode_chksum(struct super_block *sb)
|
|
||||||
{
|
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_INODE_CHKSUM);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int f2fs_sb_has_flexible_inline_xattr(struct super_block *sb)
|
|
||||||
{
|
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_FLEXIBLE_INLINE_XATTR);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int f2fs_sb_has_quota_ino(struct super_block *sb)
|
|
||||||
{
|
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_QUOTA_INO);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int f2fs_sb_has_inode_crtime(struct super_block *sb)
|
|
||||||
{
|
|
||||||
return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_INODE_CRTIME);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_BLK_DEV_ZONED
|
#ifdef CONFIG_BLK_DEV_ZONED
|
||||||
static inline int get_blkz_type(struct f2fs_sb_info *sbi,
|
static inline int get_blkz_type(struct f2fs_sb_info *sbi,
|
||||||
|
@ -3240,7 +3215,7 @@ static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi)
|
||||||
{
|
{
|
||||||
struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
|
struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev);
|
||||||
|
|
||||||
return blk_queue_discard(q) || f2fs_sb_mounted_blkzoned(sbi->sb);
|
return blk_queue_discard(q) || f2fs_sb_has_blkzoned(sbi->sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
|
static inline void set_opt_mode(struct f2fs_sb_info *sbi, unsigned int mt)
|
||||||
|
|
|
@ -1938,7 +1938,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_crypto(inode->i_sb))
|
if (!f2fs_sb_has_encrypt(inode->i_sb))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
|
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
|
||||||
|
@ -1948,7 +1948,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_crypto(file_inode(filp)->i_sb))
|
if (!f2fs_sb_has_encrypt(file_inode(filp)->i_sb))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
|
return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
|
||||||
}
|
}
|
||||||
|
@ -1959,7 +1959,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_crypto(inode->i_sb))
|
if (!f2fs_sb_has_encrypt(inode->i_sb))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (uuid_is_nonzero(sbi->raw_super->encrypt_pw_salt))
|
if (uuid_is_nonzero(sbi->raw_super->encrypt_pw_salt))
|
||||||
|
|
|
@ -1485,7 +1485,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_mounted_blkzoned(sbi->sb) &&
|
if (f2fs_sb_has_blkzoned(sbi->sb) &&
|
||||||
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
|
||||||
|
@ -1683,7 +1683,7 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
|
||||||
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_mounted_blkzoned(sbi->sb) ||
|
if (f2fs_sb_has_blkzoned(sbi->sb) ||
|
||||||
(force && len < cpc->trim_minlen))
|
(force && len < cpc->trim_minlen))
|
||||||
goto skip;
|
goto skip;
|
||||||
|
|
||||||
|
|
|
@ -405,14 +405,14 @@ static int parse_options(struct super_block *sb, char *options)
|
||||||
q = bdev_get_queue(sb->s_bdev);
|
q = bdev_get_queue(sb->s_bdev);
|
||||||
if (blk_queue_discard(q)) {
|
if (blk_queue_discard(q)) {
|
||||||
set_opt(sbi, DISCARD);
|
set_opt(sbi, DISCARD);
|
||||||
} else if (!f2fs_sb_mounted_blkzoned(sb)) {
|
} else if (!f2fs_sb_has_blkzoned(sb)) {
|
||||||
f2fs_msg(sb, KERN_WARNING,
|
f2fs_msg(sb, KERN_WARNING,
|
||||||
"mounting with \"discard\" option, but "
|
"mounting with \"discard\" option, but "
|
||||||
"the device does not support discard");
|
"the device does not support discard");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Opt_nodiscard:
|
case Opt_nodiscard:
|
||||||
if (f2fs_sb_mounted_blkzoned(sb)) {
|
if (f2fs_sb_has_blkzoned(sb)) {
|
||||||
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;
|
||||||
|
@ -561,7 +561,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_mounted_blkzoned(sb)) {
|
if (f2fs_sb_has_blkzoned(sb)) {
|
||||||
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");
|
||||||
|
@ -1282,7 +1282,7 @@ static void default_options(struct f2fs_sb_info *sbi)
|
||||||
set_opt(sbi, NOHEAP);
|
set_opt(sbi, NOHEAP);
|
||||||
sbi->sb->s_flags |= SB_LAZYTIME;
|
sbi->sb->s_flags |= SB_LAZYTIME;
|
||||||
set_opt(sbi, FLUSH_MERGE);
|
set_opt(sbi, FLUSH_MERGE);
|
||||||
if (f2fs_sb_mounted_blkzoned(sbi->sb)) {
|
if (f2fs_sb_has_blkzoned(sbi->sb)) {
|
||||||
set_opt_mode(sbi, F2FS_MOUNT_LFS);
|
set_opt_mode(sbi, F2FS_MOUNT_LFS);
|
||||||
set_opt(sbi, DISCARD);
|
set_opt(sbi, DISCARD);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2246,7 +2246,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_mounted_blkzoned(sbi->sb))
|
if (!f2fs_sb_has_blkzoned(sbi->sb))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
|
if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
|
||||||
|
@ -2453,7 +2453,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_mounted_blkzoned(sbi->sb)) {
|
!f2fs_sb_has_blkzoned(sbi->sb)) {
|
||||||
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;
|
||||||
|
@ -2548,7 +2548,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_mounted_blkzoned(sb)) {
|
if (f2fs_sb_has_blkzoned(sb)) {
|
||||||
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;
|
||||||
|
|
|
@ -92,10 +92,10 @@ 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_crypto(sb))
|
if (f2fs_sb_has_encrypt(sb))
|
||||||
len += snprintf(buf, PAGE_SIZE - len, "%s",
|
len += snprintf(buf, PAGE_SIZE - len, "%s",
|
||||||
"encryption");
|
"encryption");
|
||||||
if (f2fs_sb_mounted_blkzoned(sb))
|
if (f2fs_sb_has_blkzoned(sb))
|
||||||
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(sb))
|
||||||
|
|
Loading…
Reference in New Issue