btrfs: Don't BUG_ON errors from update_ref_for_cow()
authorMark Fasheh <mfasheh@suse.com>
Mon, 29 Aug 2011 21:30:39 +0000 (14:30 -0700)
committerDavid Sterba <dsterba@suse.cz>
Thu, 22 Mar 2012 00:45:38 +0000 (01:45 +0100)
__btrfs_cow_block(), the only caller of update_ref_for_cow() will BUG_ON()
any error return.  Instead, we can go read-only fs as update_ref_for_cow()
manipulates disk data in a way which doesn't look like it's easily rolled
back.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
fs/btrfs/ctree.c

index 3b767d2b68e833275030627341695d911b6960ac..36e16bd507984df09b335d97a6b898ddd458bf91 100644 (file)
@@ -474,7 +474,10 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
                            BTRFS_FSID_SIZE);
 
        ret = update_ref_for_cow(trans, root, buf, cow, &last_ref);
-       BUG_ON(ret);
+       if (ret) {
+               btrfs_std_error(root->fs_info, ret);
+               return ret;
+       }
 
        if (root->ref_cows)
                btrfs_reloc_cow_block(trans, root, buf, cow);