diff mbox

[2/2] Btrfs: kill some BUG_ONs() in the find_parent_nodes()

Message ID 1364209747-1623-1-git-send-email-wangshilong1991@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wang Shilong March 25, 2013, 11:09 a.m. UTC
From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>

The reason that BUG_ON() happens in these places is just
because of ENOMEM. 

We try ro return ENOMEM rather than trigger BUG_ON(), the
caller will abort the transaction thus avoiding the kernel panic.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/backref.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Jan Schmidt March 25, 2013, 11:47 a.m. UTC | #1
On Mon, March 25, 2013 at 12:09 (+0100), Wang Shilong wrote:
> From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
> 
> The reason that BUG_ON() happens in these places is just
> because of ENOMEM. 
> 
> We try ro return ENOMEM rather than trigger BUG_ON(), the
> caller will abort the transaction thus avoiding the kernel panic.
> 
> Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
>  fs/btrfs/backref.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index bd605c8..a5e2beb 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -900,7 +900,8 @@ again:
>  		if (ref->count && ref->root_id && ref->parent == 0) {
>  			/* no parent == root of tree */
>  			ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
> -			BUG_ON(ret < 0);
> +			if (ret)
> +				goto out;
>  		}
>  		if (ref->count && ref->parent) {
>  			struct extent_inode_elem *eie = NULL;
> @@ -920,6 +921,8 @@ again:
>  			ret = ulist_add_merge(refs, ref->parent,
>  					      (uintptr_t)ref->inode_list,
>  					      (u64 *)&eie, GFP_NOFS);
> +			if (ret)
> +				goto out;
>  			if (!ret && extent_item_pos) {

Remove ret here, too, please.

>  				/*
>  				 * we've recorded that parent, so we must extend
> @@ -930,7 +933,6 @@ again:
>  					eie = eie->next;
>  				eie->next = ref->inode_list;
>  			}
> -			BUG_ON(ret < 0);
>  		}
>  		kfree(ref);
>  	}
> 

Otherwise,

Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>

Thanks!
-Jan
--
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
Wang Shilong March 25, 2013, 12:22 p.m. UTC | #2
Hello,

> 
> On Mon, March 25, 2013 at 12:09 (+0100), Wang Shilong wrote:
>> From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
>> 
>> The reason that BUG_ON() happens in these places is just
>> because of ENOMEM. 
>> 
>> We try ro return ENOMEM rather than trigger BUG_ON(), the
>> caller will abort the transaction thus avoiding the kernel panic.
>> 
>> Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
>> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
>> ---
>> fs/btrfs/backref.c |    6 ++++--
>> 1 files changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
>> index bd605c8..a5e2beb 100644
>> --- a/fs/btrfs/backref.c
>> +++ b/fs/btrfs/backref.c
>> @@ -900,7 +900,8 @@ again:
>> 		if (ref->count && ref->root_id && ref->parent == 0) {
>> 			/* no parent == root of tree */
>> 			ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
>> -			BUG_ON(ret < 0);
>> +			if (ret)
>> +				goto out;
>> 		}
>> 		if (ref->count && ref->parent) {
>> 			struct extent_inode_elem *eie = NULL;
>> @@ -920,6 +921,8 @@ again:
>> 			ret = ulist_add_merge(refs, ref->parent,
>> 					      (uintptr_t)ref->inode_list,
>> 					      (u64 *)&eie, GFP_NOFS);
>> +			if (ret)
>> +				goto out;
>> 			if (!ret && extent_item_pos) {
> 
> Remove ret here, too, please.

Thanks for reviewing! I've addressed your comments and
V2 has been sent out.

Thanks,
Wang

> 
>> 				/*
>> 				 * we've recorded that parent, so we must extend
>> @@ -930,7 +933,6 @@ again:
>> 					eie = eie->next;
>> 				eie->next = ref->inode_list;
>> 			}
>> -			BUG_ON(ret < 0);
>> 		}
>> 		kfree(ref);
>> 	}
>> 
> 
> Otherwise,
> 
> Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
> 
> Thanks!
> -Jan

--
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
diff mbox

Patch

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index bd605c8..a5e2beb 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -900,7 +900,8 @@  again:
 		if (ref->count && ref->root_id && ref->parent == 0) {
 			/* no parent == root of tree */
 			ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
-			BUG_ON(ret < 0);
+			if (ret)
+				goto out;
 		}
 		if (ref->count && ref->parent) {
 			struct extent_inode_elem *eie = NULL;
@@ -920,6 +921,8 @@  again:
 			ret = ulist_add_merge(refs, ref->parent,
 					      (uintptr_t)ref->inode_list,
 					      (u64 *)&eie, GFP_NOFS);
+			if (ret)
+				goto out;
 			if (!ret && extent_item_pos) {
 				/*
 				 * we've recorded that parent, so we must extend
@@ -930,7 +933,6 @@  again:
 					eie = eie->next;
 				eie->next = ref->inode_list;
 			}
-			BUG_ON(ret < 0);
 		}
 		kfree(ref);
 	}