From patchwork Tue Jun 28 22:07:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Fasheh X-Patchwork-Id: 926372 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5SM9Ivh011007 for ; Tue, 28 Jun 2011 22:09:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752983Ab1F1WHr (ORCPT ); Tue, 28 Jun 2011 18:07:47 -0400 Received: from cantor2.suse.de ([195.135.220.15]:46723 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752746Ab1F1WHn (ORCPT ); Tue, 28 Jun 2011 18:07:43 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id E2B558F0A5; Wed, 29 Jun 2011 00:07:41 +0200 (CEST) Date: Tue, 28 Jun 2011 15:07:41 -0700 From: Mark Fasheh To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH] btrfs: Remove BUG_ON's from btrfs_update_root Message-ID: <20110628220741.GE20816@wotan.suse.de> Reply-To: Mark Fasheh Mime-Version: 1.0 Content-Disposition: inline Organization: SUSE Labs, Novell, Inc User-Agent: Mutt/1.5.9i Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 28 Jun 2011 22:09:18 +0000 (UTC) Instead, have it pass those errors back to the callers. Most callers right now actually BUG_ON the return code anyway so behavior hasn't really changed in those cases. Others (such as btrfs_sync_log()) try to handle the error returned. btrfs_ioctl_subvol_setflags() ignores the error today. In order to maintain behavior I placed a BUG_ON clause there - at least though it's now at a higher level in the code. Signed-off-by: Mark Fasheh --- fs/btrfs/ioctl.c | 1 + fs/btrfs/root-tree.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a3c4751..6ebd282 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1437,6 +1437,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file, ret = btrfs_update_root(trans, root->fs_info->tree_root, &root->root_key, &root->root_item); + BUG_ON(ret); btrfs_commit_transaction(trans, root); out_reset: diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index ebe4544..ea96ab8 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -94,7 +94,9 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root unsigned long ptr; path = btrfs_alloc_path(); - BUG_ON(!path); + if (!path) + return -ENOMEM; + ret = btrfs_search_slot(trans, root, key, path, 0, 1); if (ret < 0) goto out; @@ -104,7 +106,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root printk(KERN_CRIT "unable to update root key %llu %u %llu\n", (unsigned long long)key->objectid, key->type, (unsigned long long)key->offset); - BUG_ON(1); + goto out; } l = path->nodes[0];