All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: do not decrease bytes_may_use when replaying extents
@ 2016-08-26  3:33 Wang Xiaoguang
  2016-09-01 15:36 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Xiaoguang @ 2016-08-26  3:33 UTC (permalink / raw)
  To: linux-btrfs; +Cc: clm, dsterba

When replaying extents, there is no need to update bytes_may_use
in btrfs_alloc_logged_file_extent(), otherwise it'll trigger a
WARN_ON about bytes_may_use.

Fixes: ("btrfs: update btrfs_space_info's bytes_may_use timely")
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index ae8f9aa..7a15990 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8242,6 +8242,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
 {
 	int ret;
 	struct btrfs_block_group_cache *block_group;
+	struct btrfs_space_info *space_info;
 
 	/*
 	 * Mixed block groups will exclude before processing the log so we only
@@ -8257,9 +8258,14 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
 	if (!block_group)
 		return -EINVAL;
 
-	ret = btrfs_add_reserved_bytes(block_group, ins->offset,
-				       ins->offset, 0);
-	BUG_ON(ret); /* logic error */
+	space_info = block_group->space_info;
+	spin_lock(&space_info->lock);
+	spin_lock(&block_group->lock);
+	space_info->bytes_reserved += ins->offset;
+	block_group->reserved += ins->offset;
+	spin_unlock(&block_group->lock);
+	spin_unlock(&space_info->lock);
+
 	ret = alloc_reserved_file_extent(trans, root, 0, root_objectid,
 					 0, owner, offset, ins, 1);
 	btrfs_put_block_group(block_group);
-- 
2.9.0




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

* Re: [PATCH] btrfs: do not decrease bytes_may_use when replaying extents
  2016-08-26  3:33 [PATCH] btrfs: do not decrease bytes_may_use when replaying extents Wang Xiaoguang
@ 2016-09-01 15:36 ` David Sterba
  2016-09-01 17:30   ` Josef Bacik
  0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2016-09-01 15:36 UTC (permalink / raw)
  To: Wang Xiaoguang; +Cc: jbacik, linux-btrfs, clm, dsterba

CC Josef. It's a followup of patch that went to 4.8-rc4 so we'd better
get it to 4.8.

On Fri, Aug 26, 2016 at 11:33:14AM +0800, Wang Xiaoguang wrote:
> When replaying extents, there is no need to update bytes_may_use
> in btrfs_alloc_logged_file_extent(), otherwise it'll trigger a
> WARN_ON about bytes_may_use.
> 
> Fixes: ("btrfs: update btrfs_space_info's bytes_may_use timely")
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index ae8f9aa..7a15990 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -8242,6 +8242,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
>  {
>  	int ret;
>  	struct btrfs_block_group_cache *block_group;
> +	struct btrfs_space_info *space_info;
>  
>  	/*
>  	 * Mixed block groups will exclude before processing the log so we only
> @@ -8257,9 +8258,14 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
>  	if (!block_group)
>  		return -EINVAL;
>  
> -	ret = btrfs_add_reserved_bytes(block_group, ins->offset,
> -				       ins->offset, 0);
> -	BUG_ON(ret); /* logic error */
> +	space_info = block_group->space_info;
> +	spin_lock(&space_info->lock);
> +	spin_lock(&block_group->lock);
> +	space_info->bytes_reserved += ins->offset;
> +	block_group->reserved += ins->offset;
> +	spin_unlock(&block_group->lock);
> +	spin_unlock(&space_info->lock);
> +
>  	ret = alloc_reserved_file_extent(trans, root, 0, root_objectid,
>  					 0, owner, offset, ins, 1);
>  	btrfs_put_block_group(block_group);
> -- 
> 2.9.0
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] btrfs: do not decrease bytes_may_use when replaying extents
  2016-09-01 15:36 ` David Sterba
@ 2016-09-01 17:30   ` Josef Bacik
  0 siblings, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2016-09-01 17:30 UTC (permalink / raw)
  To: dsterba, Wang Xiaoguang, linux-btrfs, clm, dsterba

On 09/01/2016 11:36 AM, David Sterba wrote:
> CC Josef. It's a followup of patch that went to 4.8-rc4 so we'd better
> get it to 4.8.
>
> On Fri, Aug 26, 2016 at 11:33:14AM +0800, Wang Xiaoguang wrote:
>> When replaying extents, there is no need to update bytes_may_use
>> in btrfs_alloc_logged_file_extent(), otherwise it'll trigger a
>> WARN_ON about bytes_may_use.
>>
>> Fixes: ("btrfs: update btrfs_space_info's bytes_may_use timely")
>> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>

Reviewed-by: Josef Bacik <jbacik@fb.com>

Thanks,

Josef


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

end of thread, other threads:[~2016-09-01 21:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26  3:33 [PATCH] btrfs: do not decrease bytes_may_use when replaying extents Wang Xiaoguang
2016-09-01 15:36 ` David Sterba
2016-09-01 17:30   ` Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.