linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Sheng-Hui <shhuiw@gmail.com>
To: chris.mason@fusionio.com, linux-btrfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] btrfs: remove unnecessary -ENOMEM BUG_ON check in extent-tree.c/exclude_super_stripes
Date: Thu, 06 Sep 2012 14:40:41 +0800	[thread overview]
Message-ID: <50484569.8080709@gmail.com> (raw)

The memory allocation failure is BUG_ON in add_excluded_extent (following
the code path) and btrfs_rmap_block. No need to BUG_ON -ENOMEM inside
exclude_super_stripes itself.

Its return value is always 0, and useless for its callers. Set it as void
instead 0-returned.

Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
---
 fs/btrfs/extent-tree.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index ba58024..95492cc 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -234,39 +234,33 @@ static void free_excluded_extents(struct btrfs_root *root,
 			  start, end, EXTENT_UPTODATE, GFP_NOFS);
 }
 
-static int exclude_super_stripes(struct btrfs_root *root,
+static void exclude_super_stripes(struct btrfs_root *root,
 				 struct btrfs_block_group_cache *cache)
 {
 	u64 bytenr;
 	u64 *logical;
 	int stripe_len;
-	int i, nr, ret;
+	int i, nr;
 
 	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); /* -ENOMEM */
+		add_excluded_extent(root, cache->key.objectid, stripe_len);
 	}
 
 	for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
 		bytenr = btrfs_sb_offset(i);
-		ret = btrfs_rmap_block(&root->fs_info->mapping_tree,
-				       cache->key.objectid, bytenr,
-				       0, &logical, &nr, &stripe_len);
-		BUG_ON(ret); /* -ENOMEM */
+		btrfs_rmap_block(&root->fs_info->mapping_tree,
+				 cache->key.objectid, bytenr,
+				 0, &logical, &nr, &stripe_len);
 
 		while (nr--) {
 			cache->bytes_super += stripe_len;
-			ret = add_excluded_extent(root, logical[nr],
-						  stripe_len);
-			BUG_ON(ret); /* -ENOMEM */
+			add_excluded_extent(root, logical[nr], stripe_len);
 		}
 
 		kfree(logical);
 	}
-	return 0;
 }
 
 static struct btrfs_caching_control *
-- 
1.7.1

             reply	other threads:[~2012-09-06  6:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-06  6:40 Wang Sheng-Hui [this message]
2012-09-06 10:09 ` [PATCH 1/3] btrfs: remove unnecessary -ENOMEM BUG_ON check in extent-tree.c/exclude_super_stripes David Sterba
2012-09-06 14:12   ` Wang Sheng-Hui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50484569.8080709@gmail.com \
    --to=shhuiw@gmail.com \
    --cc=chris.mason@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).