From patchwork Fri Feb 24 05:52:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9589417 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 EB1036042B for ; Fri, 24 Feb 2017 05:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCFC0287A2 for ; Fri, 24 Feb 2017 05:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8B76287AB; Fri, 24 Feb 2017 05:55:24 +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 1AA102879C for ; Fri, 24 Feb 2017 05:55:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751154AbdBXFyc (ORCPT ); Fri, 24 Feb 2017 00:54:32 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:60453 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750997AbdBXFya (ORCPT ); Fri, 24 Feb 2017 00:54:30 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15915860" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 24 Feb 2017 13:52:51 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 2B24747C4EA9; Fri, 24 Feb 2017 13:52:50 +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; Fri, 24 Feb 2017 13:52:49 +0800 From: Qu Wenruo To: , Subject: [PATCH v2 4/9] btrfs-progs: convert: Introduce simple range structure for convert reserved ranges Date: Fri, 24 Feb 2017 13:52:27 +0800 Message-ID: <20170224055232.4140-5-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170224055232.4140-1-quwenruo@cn.fujitsu.com> References: <20170224055232.4140-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 2B24747C4EA9.AF7B8 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/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/convert/main.c b/convert/main.c index 26356e8a..ba088cc3 100644 --- a/convert/main.c +++ b/convert/main.c @@ -86,6 +86,7 @@ #include #include #include +#include #include "ctree.h" #include "disk-io.h" @@ -118,6 +119,33 @@ #define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID +/* + * 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; +}; + +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(struct simple_range *range) +{ + return (range->start + range->len); +} + struct task_ctx { uint32_t max_copy_inodes; uint32_t cur_copy_inodes;