btrfs: adjust order of unlocks in do_trimming()
diff mbox series

Message ID 20181128032112.1152-1-suy.fnst@cn.fujitsu.com
State New
Headers show
Series
  • btrfs: adjust order of unlocks in do_trimming()
Related show

Commit Message

Su Yue Nov. 28, 2018, 3:21 a.m. UTC
In function do_trimming(), block_group->lock should be unlocked first.

Fixes: 7fe1e6415026 ("Btrfs: rewrite btrfs_trim_block_group()")
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
 fs/btrfs/free-space-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nikolay Borisov Nov. 28, 2018, 7:14 a.m. UTC | #1
On 28.11.18 г. 5:21 ч., Su Yue wrote:
> In function do_trimming(), block_group->lock should be unlocked first.
> 
> Fixes: 7fe1e6415026 ("Btrfs: rewrite btrfs_trim_block_group()")
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/free-space-cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 4ba0aedc878b..3731fa92df56 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -3149,8 +3149,8 @@ static int do_trimming(struct btrfs_block_group_cache *block_group,
>  			space_info->bytes_readonly += reserved_bytes;
>  		block_group->reserved -= reserved_bytes;
>  		space_info->bytes_reserved -= reserved_bytes;
> -		spin_unlock(&space_info->lock);
>  		spin_unlock(&block_group->lock);
> +		spin_unlock(&space_info->lock);
>  	}
>  
>  	return ret;
>
David Sterba Nov. 28, 2018, 2:10 p.m. UTC | #2
On Wed, Nov 28, 2018 at 11:21:12AM +0800, Su Yue wrote:
> In function do_trimming(), block_group->lock should be unlocked first.

Please also write why this is correct and if there are any bad
consequences of the current behaviour. Thanks.
David Sterba May 30, 2019, 1:52 p.m. UTC | #3
On Wed, Nov 28, 2018 at 03:10:12PM +0100, David Sterba wrote:
> On Wed, Nov 28, 2018 at 11:21:12AM +0800, Su Yue wrote:
> > In function do_trimming(), block_group->lock should be unlocked first.
> 
> Please also write why this is correct and if there are any bad
> consequences of the current behaviour. Thanks.

I've updated the changelog and added the patch to misc-next.

Patch
diff mbox series

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 4ba0aedc878b..3731fa92df56 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -3149,8 +3149,8 @@  static int do_trimming(struct btrfs_block_group_cache *block_group,
 			space_info->bytes_readonly += reserved_bytes;
 		block_group->reserved -= reserved_bytes;
 		space_info->bytes_reserved -= reserved_bytes;
-		spin_unlock(&space_info->lock);
 		spin_unlock(&block_group->lock);
+		spin_unlock(&space_info->lock);
 	}
 
 	return ret;