linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext2: code cleanup by using test_opt() and clear_opt()
@ 2019-05-20  5:45 Chengguang Xu
  2019-05-20  8:49 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Chengguang Xu @ 2019-05-20  5:45 UTC (permalink / raw)
  To: jack; +Cc: linux-ext4, Chengguang Xu

Using test_opt() and clear_opt() instead of directly
comparing flag bit of mount option.

Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
---
 fs/ext2/super.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 3988633789cb..ca7229c38fce 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -302,16 +302,16 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
 	if (test_opt(sb, NOBH))
 		seq_puts(seq, ",nobh");
 
-	if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA)
+	if (test_opt(sb, USRQUOTA))
 		seq_puts(seq, ",usrquota");
 
-	if (sbi->s_mount_opt & EXT2_MOUNT_GRPQUOTA)
+	if (test_opt(sb, GRPQUOTA))
 		seq_puts(seq, ",grpquota");
 
-	if (sbi->s_mount_opt & EXT2_MOUNT_XIP)
+	if (test_opt(sb, XIP))
 		seq_puts(seq, ",xip");
 
-	if (sbi->s_mount_opt & EXT2_MOUNT_DAX)
+	if (test_opt(sb, DAX))
 		seq_puts(seq, ",dax");
 
 	if (!test_opt(sb, RESERVATION))
@@ -934,8 +934,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
 	sbi->s_resgid = opts.s_resgid;
 
 	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
-		((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
-		 SB_POSIXACL : 0);
+		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
 	sb->s_iflags |= SB_I_CGROUPWB;
 
 	if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
@@ -966,11 +965,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
 
 	blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
 
-	if (sbi->s_mount_opt & EXT2_MOUNT_DAX) {
+	if (test_opt(sb, DAX)) {
 		if (!bdev_dax_supported(sb->s_bdev, blocksize)) {
 			ext2_msg(sb, KERN_ERR,
 				"DAX unsupported by block device. Turning off DAX.");
-			sbi->s_mount_opt &= ~EXT2_MOUNT_DAX;
+			clear_opt(sbi->s_mount_opt, DAX);
 		}
 	}
 
@@ -1403,7 +1402,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
 	sbi->s_resuid = new_opts.s_resuid;
 	sbi->s_resgid = new_opts.s_resgid;
 	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
-		((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? SB_POSIXACL : 0);
+		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
 	spin_unlock(&sbi->s_lock);
 
 	return 0;
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext2: code cleanup by using test_opt() and clear_opt()
  2019-05-20  5:45 [PATCH] ext2: code cleanup by using test_opt() and clear_opt() Chengguang Xu
@ 2019-05-20  8:49 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-05-20  8:49 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: jack, linux-ext4

On Mon 20-05-19 13:45:03, Chengguang Xu wrote:
> Using test_opt() and clear_opt() instead of directly
> comparing flag bit of mount option.
> 
> Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>

Thanks! Applied.

								Honza

> ---
>  fs/ext2/super.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 3988633789cb..ca7229c38fce 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -302,16 +302,16 @@ static int ext2_show_options(struct seq_file *seq, struct dentry *root)
>  	if (test_opt(sb, NOBH))
>  		seq_puts(seq, ",nobh");
>  
> -	if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA)
> +	if (test_opt(sb, USRQUOTA))
>  		seq_puts(seq, ",usrquota");
>  
> -	if (sbi->s_mount_opt & EXT2_MOUNT_GRPQUOTA)
> +	if (test_opt(sb, GRPQUOTA))
>  		seq_puts(seq, ",grpquota");
>  
> -	if (sbi->s_mount_opt & EXT2_MOUNT_XIP)
> +	if (test_opt(sb, XIP))
>  		seq_puts(seq, ",xip");
>  
> -	if (sbi->s_mount_opt & EXT2_MOUNT_DAX)
> +	if (test_opt(sb, DAX))
>  		seq_puts(seq, ",dax");
>  
>  	if (!test_opt(sb, RESERVATION))
> @@ -934,8 +934,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>  	sbi->s_resgid = opts.s_resgid;
>  
>  	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
> -		((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
> -		 SB_POSIXACL : 0);
> +		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
>  	sb->s_iflags |= SB_I_CGROUPWB;
>  
>  	if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
> @@ -966,11 +965,11 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>  
>  	blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
>  
> -	if (sbi->s_mount_opt & EXT2_MOUNT_DAX) {
> +	if (test_opt(sb, DAX)) {
>  		if (!bdev_dax_supported(sb->s_bdev, blocksize)) {
>  			ext2_msg(sb, KERN_ERR,
>  				"DAX unsupported by block device. Turning off DAX.");
> -			sbi->s_mount_opt &= ~EXT2_MOUNT_DAX;
> +			clear_opt(sbi->s_mount_opt, DAX);
>  		}
>  	}
>  
> @@ -1403,7 +1402,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
>  	sbi->s_resuid = new_opts.s_resuid;
>  	sbi->s_resgid = new_opts.s_resgid;
>  	sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
> -		((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? SB_POSIXACL : 0);
> +		(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
>  	spin_unlock(&sbi->s_lock);
>  
>  	return 0;
> -- 
> 2.20.1
> 
> 
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-20  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20  5:45 [PATCH] ext2: code cleanup by using test_opt() and clear_opt() Chengguang Xu
2019-05-20  8:49 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).