linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix WARNING in btrfs_select_ref_head()
@ 2016-06-20  1:18 Wang Xiaoguang
  2016-07-08 15:27 ` David Sterba
  2016-09-06 17:34 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Wang Xiaoguang @ 2016-06-20  1:18 UTC (permalink / raw)
  To: linux-btrfs; +Cc: fdmanana

This issue was found when testing in-band dedupe enospc behaviour,
sometimes run_one_delayed_ref() may fail for enospc reason, then
__btrfs_run_delayed_refs()will return, but forget to add num_heads_read
back, which will trigger "WARN_ON(delayed_refs->num_heads_ready == 0)" in
btrfs_select_ref_head().

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6146729..eeedff3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2665,7 +2665,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
 
 		btrfs_free_delayed_extent_op(extent_op);
 		if (ret) {
+			spin_lock(&delayed_refs->lock);
 			locked_ref->processing = 0;
+			delayed_refs->num_heads_ready++;
+			spin_unlock(&delayed_refs->lock);
 			btrfs_delayed_ref_unlock(locked_ref);
 			btrfs_put_delayed_ref(ref);
 			btrfs_debug(fs_info, "run_one_delayed_ref returned %d", ret);
-- 
1.8.3.1




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

* Re: [PATCH] btrfs: fix WARNING in btrfs_select_ref_head()
  2016-06-20  1:18 [PATCH] btrfs: fix WARNING in btrfs_select_ref_head() Wang Xiaoguang
@ 2016-07-08 15:27 ` David Sterba
  2016-09-06 17:34 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-07-08 15:27 UTC (permalink / raw)
  To: Wang Xiaoguang; +Cc: linux-btrfs, fdmanana

On Mon, Jun 20, 2016 at 09:18:52AM +0800, Wang Xiaoguang wrote:
> @@ -2665,7 +2665,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
>  
>  		btrfs_free_delayed_extent_op(extent_op);
>  		if (ret) {
> +			spin_lock(&delayed_refs->lock);
>  			locked_ref->processing = 0;
> +			delayed_refs->num_heads_ready++;
> +			spin_unlock(&delayed_refs->lock);
>  			btrfs_delayed_ref_unlock(locked_ref);
>  			btrfs_put_delayed_ref(ref);
>  			btrfs_debug(fs_info, "run_one_delayed_ref returned %d", ret);

I don't feel qualified to review this and add it to the 4.8 first pull.
The patch will be in for-next though.

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

* Re: [PATCH] btrfs: fix WARNING in btrfs_select_ref_head()
  2016-06-20  1:18 [PATCH] btrfs: fix WARNING in btrfs_select_ref_head() Wang Xiaoguang
  2016-07-08 15:27 ` David Sterba
@ 2016-09-06 17:34 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-09-06 17:34 UTC (permalink / raw)
  To: jbacik; +Cc: linux-btrfs, fdmanana, Wang Xiaoguang

Josef, can you please review this?

On Mon, Jun 20, 2016 at 09:18:52AM +0800, Wang Xiaoguang wrote:
> This issue was found when testing in-band dedupe enospc behaviour,
> sometimes run_one_delayed_ref() may fail for enospc reason, then
> __btrfs_run_delayed_refs()will return, but forget to add num_heads_read
> back, which will trigger "WARN_ON(delayed_refs->num_heads_ready == 0)" in
> btrfs_select_ref_head().
> 
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 6146729..eeedff3 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2665,7 +2665,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
>  
>  		btrfs_free_delayed_extent_op(extent_op);
>  		if (ret) {
> +			spin_lock(&delayed_refs->lock);
>  			locked_ref->processing = 0;
> +			delayed_refs->num_heads_ready++;
> +			spin_unlock(&delayed_refs->lock);
>  			btrfs_delayed_ref_unlock(locked_ref);
>  			btrfs_put_delayed_ref(ref);
>  			btrfs_debug(fs_info, "run_one_delayed_ref returned %d", ret);
> -- 
> 1.8.3.1
> 
> 
> 
> --
> 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

end of thread, other threads:[~2016-09-06 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20  1:18 [PATCH] btrfs: fix WARNING in btrfs_select_ref_head() Wang Xiaoguang
2016-07-08 15:27 ` David Sterba
2016-09-06 17:34 ` David Sterba

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).