]> Pileus Git - ~andy/linux/commitdiff
Btrfs: kill some BUG_ONs() in the find_parent_nodes()
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>
Fri, 29 Mar 2013 23:03:21 +0000 (23:03 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Mon, 6 May 2013 19:54:30 +0000 (15:54 -0400)
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>
Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/backref.c

index bd605c87adfd58b3363861b00af8c646487fab56..3dd0693bad78e00eef0810e61ef422a86f635591 100644 (file)
@@ -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 < 0)
+                               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 < 0)
+                               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);
        }