From patchwork Thu Sep 6 06:40:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Sheng-Hui X-Patchwork-Id: 1412221 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C7C023FC71 for ; Thu, 6 Sep 2012 06:41:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752158Ab2IFGkx (ORCPT ); Thu, 6 Sep 2012 02:40:53 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:42730 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999Ab2IFGkw (ORCPT ); Thu, 6 Sep 2012 02:40:52 -0400 Received: by ieje11 with SMTP id e11so2493083iej.19 for ; Wed, 05 Sep 2012 23:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=RrJnq+PLO94jp6XTq34KqfKFaecUc/Ok4/xK4ovxfog=; b=NgO+N4udR7irkKAO4zlPKeya2JMitvoJHy+VPd4gJdATXbIWKjbDbcvl5gXrb1cOwc iYn2BG13aQgMfjxNy/b7Bb53OQ1f20E7vJAPOKv4e7TC5V8I7rKLAVz8z10dwXdVeJJl 2w1bDHchf48VRMp0+5enUWPP96XLP8qIAXQ3ouJl+D4Di5HWPX5GuySanzEQkmey10EU iGJN2FfgkJkzgOx+PBJMXTX1Ey69pp8kbJUbxuMFTCGvjOFD5Vd4q5/Xu1atLUy+J36r xZsFetSR8fj+2CKmELVD3WGI76KuXb/Lp78Q+fPMDWNK57BaUC0FydNuLAt4Z3Rlbng3 NUng== Received: by 10.50.7.164 with SMTP id k4mr1053705iga.38.1346913652121; Wed, 05 Sep 2012 23:40:52 -0700 (PDT) Received: from [192.168.1.102] ([122.70.1.251]) by mx.google.com with ESMTPS id ng5sm2368268igc.0.2012.09.05.23.40.48 (version=SSLv3 cipher=OTHER); Wed, 05 Sep 2012 23:40:50 -0700 (PDT) Message-ID: <50484569.8080709@gmail.com> Date: Thu, 06 Sep 2012 14:40:41 +0800 From: Wang Sheng-Hui User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 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 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 --- 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 *