From patchwork Fri Aug 13 01:55:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Renquan X-Patchwork-Id: 119366 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7D1u7Pc015623 for ; Fri, 13 Aug 2010 01:56:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761116Ab0HMB4F (ORCPT ); Thu, 12 Aug 2010 21:56:05 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:51585 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754890Ab0HMB4E (ORCPT ); Thu, 12 Aug 2010 21:56:04 -0400 Received: by pvg2 with SMTP id 2so650439pvg.19 for ; Thu, 12 Aug 2010 18:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=dgm56Zdip4N2+Szt658S4kjXVEKPWbwOVtLCOmDVegQ=; b=puqXvpF92cgcNS2D47OqbE0RshYhqcfyP7fAmUeNc5oNB1ZLaAi21qAz5gjUAFYmNp zrq9sts0rj+q9dajLmwg3sMSr7tyMv9C1uCcKXqQzJgKVEMwYS3HO2ErdABiXlsoUdsS utAILRQl+ayb34x0frT9xdEUEZ/GUjwYD0PzQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=D98J8ImiOx8YmkEBIPd6o8Ba+fC84xVlYCsXsqOgv3hcO/hOMAY7HDfPZP0Hn/OoW5 UQTcWt3Jp11YmCi8FerTuYBV3nX3R4VdQiBd4kW+mERXxbY3nMNspMAZgJXRrYjqvQ7c PqzAeKxL+AArnT2sgYVdTSIVR1bW3rT1e9eH8= Received: by 10.142.204.17 with SMTP id b17mr752116wfg.142.1281664562769; Thu, 12 Aug 2010 18:56:02 -0700 (PDT) Received: from localhost.localdomain (bb121-7-138-210.singnet.com.sg [121.7.138.210]) by mx.google.com with ESMTPS id g5sm2314061wfd.19.2010.08.12.18.55.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 12 Aug 2010 18:56:01 -0700 (PDT) From: Cheng Renquan To: chris.mason@oracle.com, Josef Bacik Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: avoid duplications by moving the static int array from header to c file Date: Fri, 13 Aug 2010 09:55:48 +0800 Message-Id: <1281664548-10189-1-git-send-email-crquan@gmail.com> X-Mailer: git-send-email 1.7.0.4 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.3 (demeter.kernel.org [140.211.167.41]); Fri, 13 Aug 2010 01:56:08 +0000 (UTC) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index c3df14c..3a89207 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -24,6 +24,15 @@ #include "print-tree.h" #include "locking.h" +int btrfs_super_csum_size(struct btrfs_super_block *s) +{ + static const int btrfs_csum_sizes[] = { 4, 0 }; + + int t = btrfs_super_csum_type(s); + BUG_ON(t >= ARRAY_SIZE(btrfs_csum_sizes)); + return btrfs_csum_sizes[t]; +} + static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level); static int split_leaf(struct btrfs_trans_handle *trans, struct btrfs_root diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index e9bf864..99220ee 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -132,8 +132,6 @@ struct btrfs_ordered_sum; /* csum types */ #define BTRFS_CSUM_TYPE_CRC32 0 -static int btrfs_csum_sizes[] = { 4, 0 }; - /* four bytes for CRC32 */ #define BTRFS_EMPTY_DIR_SIZE 0 @@ -1877,12 +1875,7 @@ BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block, BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, csum_type, 16); -static inline int btrfs_super_csum_size(struct btrfs_super_block *s) -{ - int t = btrfs_super_csum_type(s); - BUG_ON(t >= ARRAY_SIZE(btrfs_csum_sizes)); - return btrfs_csum_sizes[t]; -} +int btrfs_super_csum_size(struct btrfs_super_block *s); static inline unsigned long btrfs_leaf_data(struct extent_buffer *l) {