diff mbox series

btrfs: open-code remount flag setting in btrfs_remount

Message ID 20200722090039.17402-1-johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: open-code remount flag setting in btrfs_remount | expand

Commit Message

Johannes Thumshirn July 22, 2020, 9 a.m. UTC
When we're (re)mounting a btrfs filesystem we set the
BTRFS_FS_STATE_REMOUNTING state in fs_info to serialize against async
reclaim or defrags.

This flag is set in btrfs_remount_prepare() called by btrfs_remount(). As
btrfs_remount_prepare() does nothing but setting this flag and doesn't
have a second caller, we can just open-code the flag setting in
btrfs_remount().

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/super.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

David Sterba July 22, 2020, 2:15 p.m. UTC | #1
On Wed, Jul 22, 2020 at 06:00:39PM +0900, Johannes Thumshirn wrote:
> When we're (re)mounting a btrfs filesystem we set the
> BTRFS_FS_STATE_REMOUNTING state in fs_info to serialize against async
> reclaim or defrags.
> 
> This flag is set in btrfs_remount_prepare() called by btrfs_remount(). As
> btrfs_remount_prepare() does nothing but setting this flag and doesn't
> have a second caller, we can just open-code the flag setting in
> btrfs_remount().

Agreed, that's too trivial and set_bit of state flags are commonly used.
I'd suggest to also lift the clear_bit counterpart from
btrfs_remount_cleanup and move it right after it in btrfs_remount, so we
have both set/clear in one function.

The original idea was probably to have prepare/cleanup wrapped but I
don't see much value to have the trivial wrapper.
Anand Jain July 30, 2020, 5:07 a.m. UTC | #2
> -static inline void btrfs_remount_prepare(struct btrfs_fs_info *fs_info)
> -{
> -	set_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
> -}
> -
>   static inline void btrfs_remount_begin(struct btrfs_fs_info *fs_info,
>   				       unsigned long old_opts, int flags)
>   {
> @@ -1837,7 +1832,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
>   	int ret;
>   
>   	sync_filesystem(sb);
> -	btrfs_remount_prepare(fs_info);
> +	set_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
>   

  Reviewed-by: Anand Jain <anand.jain@oracle.com>
diff mbox series

Patch

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a4f0bb29b8d6..19b1f0e8034e 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1782,11 +1782,6 @@  static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
 				new_pool_size);
 }
 
-static inline void btrfs_remount_prepare(struct btrfs_fs_info *fs_info)
-{
-	set_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
-}
-
 static inline void btrfs_remount_begin(struct btrfs_fs_info *fs_info,
 				       unsigned long old_opts, int flags)
 {
@@ -1837,7 +1832,7 @@  static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 	int ret;
 
 	sync_filesystem(sb);
-	btrfs_remount_prepare(fs_info);
+	set_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
 
 	if (data) {
 		void *new_sec_opts = NULL;