From patchwork Tue Mar 14 08:05:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9622669 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 7124260244 for ; Tue, 14 Mar 2017 08:05:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60D052808F for ; Tue, 14 Mar 2017 08:05:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 557E328420; Tue, 14 Mar 2017 08:05:21 +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 D09682808F for ; Tue, 14 Mar 2017 08:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750891AbdCNIFU (ORCPT ); Tue, 14 Mar 2017 04:05:20 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:33948 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750847AbdCNIFT (ORCPT ); Tue, 14 Mar 2017 04:05:19 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="16546218" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 Mar 2017 16:05:14 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 7A8D948A2967; Tue, 14 Mar 2017 16:05:14 +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, 14 Mar 2017 16:05:12 +0800 From: Qu Wenruo To: CC: Subject: [PATCH v3 2/7] btrfs-progs: convert: Introduce simple range structure for convert reserved ranges Date: Tue, 14 Mar 2017 16:05:04 +0800 Message-ID: <20170314080509.31163-3-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170314080509.31163-1-quwenruo@cn.fujitsu.com> References: <20170314080509.31163-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 7A8D948A2967.AFAD1 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 strucutre, simple_range, to present one continuous range. Also, use such structure to define btrfs_reserved_ranges(), which convert and rollback will use. Suggested-by: David Sterba Signed-off-by: Qu Wenruo --- convert/common.h | 27 +++++++++++++++++++++++++++ convert/main.c | 1 + 2 files changed, 28 insertions(+) diff --git a/convert/common.h b/convert/common.h index 0d3adeaa..28ca1461 100644 --- a/convert/common.h +++ b/convert/common.h @@ -26,6 +26,33 @@ #include "common-defs.h" #include "extent-cache.h" +/* + * Presents one simple continuous range. + * + * For multiple or non-continuous ranges, use extent_cache_tree from + * extent-cache.c + */ +struct simple_range { + u64 start; + u64 len; +}; + +const static struct simple_range btrfs_reserved_ranges[] = { + {0, SZ_1M}, + {BTRFS_SB_MIRROR_OFFSET(1), SZ_64K}, + {BTRFS_SB_MIRROR_OFFSET(2), SZ_64K} +}; + +/* + * Simple range functions + * + * Get range end (exclusive) + */ +static inline u64 range_end(const struct simple_range *range) +{ + return (range->start + range->len); +} + struct btrfs_mkfs_config; struct btrfs_convert_context { diff --git a/convert/main.c b/convert/main.c index 079c1ebd..41309645 100644 --- a/convert/main.c +++ b/convert/main.c @@ -81,6 +81,7 @@ #include #include #include +#include #include "ctree.h" #include "disk-io.h"