From patchwork Tue Jan 24 03:03:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9533993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CFAF06042F for ; Tue, 24 Jan 2017 03:03:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4B3E21F61 for ; Tue, 24 Jan 2017 03:03:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9828122638; Tue, 24 Jan 2017 03:03:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FEF021F61 for ; Tue, 24 Jan 2017 03:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750729AbdAXDDa (ORCPT ); Mon, 23 Jan 2017 22:03:30 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:23871 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750721AbdAXDD3 (ORCPT ); Mon, 23 Jan 2017 22:03:29 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15035204" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 24 Jan 2017 11:03:13 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id A38BF47B1517 for ; Tue, 24 Jan 2017 11:03:08 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Jan 2017 11:03:13 +0800 From: Qu Wenruo To: Subject: [PATCH 2/2] btrfs-progs: Introduce macro to calculate backup superblock offset Date: Tue, 24 Jan 2017 11:03:06 +0800 Message-ID: <20170124030306.3452-2-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124030306.3452-1-quwenruo@cn.fujitsu.com> References: <20170124030306.3452-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: A38BF47B1517.AFCF3 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new macro, BTRFS_SB_OFFSET() to calculate backup superblock offset, this is handy if one wants to initialize static array at declaration time. Suggested-by: David Sterba Signed-off-by: Qu Wenruo --- disk-io.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/disk-io.h b/disk-io.h index c4afea3f..08ee5cee 100644 --- a/disk-io.h +++ b/disk-io.h @@ -98,11 +98,17 @@ enum btrfs_read_sb_flags { SBREAD_PARTIAL = (1 << 1), }; +/* + * Use macro to define mirror super block position, + * so we can use it in static array initialization + */ +#define BTRFS_SB_MIRROR_OFFSET(mirror) ((u64)(SZ_16K) << \ + (BTRFS_SUPER_MIRROR_SHIFT * (mirror))) + static inline u64 btrfs_sb_offset(int mirror) { - u64 start = SZ_16K; if (mirror) - return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror); + return BTRFS_SB_MIRROR_OFFSET(mirror); return BTRFS_SUPER_INFO_OFFSET; }