From patchwork Wed Jun 22 05:19:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 903502 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 p5M5KaQk028728 for ; Wed, 22 Jun 2011 05:20:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751255Ab1FVFUZ (ORCPT ); Wed, 22 Jun 2011 01:20:25 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:44849 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751154Ab1FVFUY (ORCPT ); Wed, 22 Jun 2011 01:20:24 -0400 Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id E7B343EE0BD for ; Wed, 22 Jun 2011 14:20:22 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id CA16D45DE95 for ; Wed, 22 Jun 2011 14:20:22 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id AF6D045DE61 for ; Wed, 22 Jun 2011 14:20:22 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 9FE811DB8042 for ; Wed, 22 Jun 2011 14:20:22 +0900 (JST) Received: from m105.s.css.fujitsu.com (m105.s.css.fujitsu.com [10.240.81.145]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 5AC531DB8037 for ; Wed, 22 Jun 2011 14:20:22 +0900 (JST) Received: from m105.css.fujitsu.com (m105 [127.0.0.1]) by m105.s.css.fujitsu.com (Postfix) with ESMTP id 227317C8045; Wed, 22 Jun 2011 14:20:22 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.84]) by m105.s.css.fujitsu.com (Postfix) with SMTP id B1E2C6C8001; Wed, 22 Jun 2011 14:20:21 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.4.0 Received: from T-ITOH1[10.124.101.84] by T-ITOH1 (FujitsuOutboundMailChecker v1.4.0/9992[10.124.101.84]); Wed, 22 Jun 2011 14:19:42 +0900 (JST) Message-Id: <201106220519.AA00026@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Wed, 22 Jun 2011 14:19:15 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH] Btrfs: remove unneeded BUG_ON() MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 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]); Wed, 22 Jun 2011 05:20:36 +0000 (UTC) The following functions always return 0. - add_delayed_ref_head() - add_delayed_tree_ref() - add_delayed_data_ref() - add_excluded_extent() Therefore, check by BUG_ON() is unnecessary at the caller of these functions. Signed-off-by: Tsutomu Itoh --- fs/btrfs/delayed-ref.c | 32 +++++++++++++------------------- fs/btrfs/extent-tree.c | 14 ++++---------- 2 files changed, 17 insertions(+), 29 deletions(-) -- 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 --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 125cf76..ce0c728 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -588,7 +588,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_tree_ref *ref; struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - int ret; BUG_ON(extent_op && extent_op->is_data); ref = kmalloc(sizeof(*ref), GFP_NOFS); @@ -610,13 +609,12 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, * insert both the head node and the new ref without dropping * the spin lock */ - ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, - action, 0); - BUG_ON(ret); + add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, + action, 0); + + add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, + parent, ref_root, level, action); - ret = add_delayed_tree_ref(trans, &ref->node, bytenr, num_bytes, - parent, ref_root, level, action); - BUG_ON(ret); spin_unlock(&delayed_refs->lock); return 0; } @@ -633,7 +631,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_data_ref *ref; struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - int ret; BUG_ON(extent_op && !extent_op->is_data); ref = kmalloc(sizeof(*ref), GFP_NOFS); @@ -655,13 +652,12 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, * insert both the head node and the new ref without dropping * the spin lock */ - ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, - action, 1); - BUG_ON(ret); + add_delayed_ref_head(trans, &head_ref->node, bytenr, num_bytes, + action, 1); + + add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, + parent, ref_root, owner, offset, action); - ret = add_delayed_data_ref(trans, &ref->node, bytenr, num_bytes, - parent, ref_root, owner, offset, action); - BUG_ON(ret); spin_unlock(&delayed_refs->lock); return 0; } @@ -672,7 +668,6 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, { struct btrfs_delayed_ref_head *head_ref; struct btrfs_delayed_ref_root *delayed_refs; - int ret; head_ref = kmalloc(sizeof(*head_ref), GFP_NOFS); if (!head_ref) @@ -683,10 +678,9 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans, delayed_refs = &trans->transaction->delayed_refs; spin_lock(&delayed_refs->lock); - ret = add_delayed_ref_head(trans, &head_ref->node, bytenr, - num_bytes, BTRFS_UPDATE_DELAYED_HEAD, - extent_op->is_data); - BUG_ON(ret); + add_delayed_ref_head(trans, &head_ref->node, bytenr, + num_bytes, BTRFS_UPDATE_DELAYED_HEAD, + extent_op->is_data); spin_unlock(&delayed_refs->lock); return 0; diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 1f61bf5..15286d1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -225,9 +225,7 @@ static int exclude_super_stripes(struct btrfs_root *root, if (cache->key.objectid < BTRFS_SUPER_INFO_OFFSET) { stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->key.objectid; cache->bytes_super += stripe_len; - ret = add_excluded_extent(root, cache->key.objectid, - stripe_len); - BUG_ON(ret); + add_excluded_extent(root, cache->key.objectid, stripe_len); } for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { @@ -239,9 +237,7 @@ static int exclude_super_stripes(struct btrfs_root *root, while (nr--) { cache->bytes_super += stripe_len; - ret = add_excluded_extent(root, logical[nr], - stripe_len); - BUG_ON(ret); + add_excluded_extent(root, logical[nr], stripe_len); } kfree(logical); @@ -5581,8 +5577,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, mutex_lock(&caching_ctl->mutex); if (start >= caching_ctl->progress) { - ret = add_excluded_extent(root, start, num_bytes); - BUG_ON(ret); + add_excluded_extent(root, start, num_bytes); } else if (start + num_bytes <= caching_ctl->progress) { ret = btrfs_remove_free_space(block_group, start, num_bytes); @@ -5596,8 +5591,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, start = caching_ctl->progress; num_bytes = ins->objectid + ins->offset - caching_ctl->progress; - ret = add_excluded_extent(root, start, num_bytes); - BUG_ON(ret); + add_excluded_extent(root, start, num_bytes); } mutex_unlock(&caching_ctl->mutex);