From patchwork Fri May 27 01:26:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 9137553 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 39A7F6075C for ; Fri, 27 May 2016 01:25:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D5D827CEC for ; Fri, 27 May 2016 01:25:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22425282F7; Fri, 27 May 2016 01:25:26 +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, UNPARSEABLE_RELAY 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 C86E727CEC for ; Fri, 27 May 2016 01:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755891AbcE0BZP (ORCPT ); Thu, 26 May 2016 21:25:15 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:42491 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755769AbcE0BZP (ORCPT ); Thu, 26 May 2016 21:25:15 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u4R1PAjC032162 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 May 2016 01:25:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u4R1PARk009089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 May 2016 01:25:10 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u4R1P9f3010451; Fri, 27 May 2016 01:25:10 GMT Received: from localhost.us.oracle.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 26 May 2016 18:25:09 -0700 From: Liu Bo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 2/2] Btrfs-progs: convert: add hint bytenr when allocating free space Date: Thu, 26 May 2016 18:26:50 -0700 Message-Id: <1464312410-10999-2-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464312410-10999-1-git-send-email-bo.li.liu@oracle.com> References: <1464312410-10999-1-git-send-email-bo.li.liu@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 Without proper hint, btrfs-convert always starts searching from the very first available block which usually belongs to SYSTEM block group, but we're not allowed to use any block in SYSTEM block group for metadata/data. This adds hint to make convert smarter. Signed-off-by: Liu Bo --- btrfs-convert.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/btrfs-convert.c b/btrfs-convert.c index 550aa8f..fd807ef 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -1399,6 +1399,7 @@ static int create_image(struct btrfs_convert_context *cctx, u64 total_bytes; u64 flags = BTRFS_INODE_READONLY; u32 sectorsize = root->sectorsize; + u64 hint = 0; total_bytes = btrfs_super_total_bytes(fs_info->super_copy); first_free = BTRFS_SUPER_INFO_OFFSET + sectorsize * 2 - 1; @@ -1427,9 +1428,11 @@ static int create_image(struct btrfs_convert_context *cctx, * special, we can't rely on relocate_extents_range to relocate it. */ for (last_byte = 0; last_byte < first_free; last_byte += sectorsize) { - ret = custom_alloc_extent(root, sectorsize, 0, &key, 0); + ret = custom_alloc_extent(root, sectorsize, hint, &key, 0); if (ret) goto fail; + + hint = key.objectid; ret = copy_disk_extent(root, key.objectid, last_byte, sectorsize); if (ret) @@ -2085,7 +2088,7 @@ static int relocate_one_reference(struct btrfs_trans_handle *trans, ret = get_state_private(reloc_tree, bytenr, &new_pos); BUG_ON(ret); } else { - ret = custom_alloc_extent(root, sectorsize, 0, &key, 0); + ret = custom_alloc_extent(root, sectorsize, new_pos, &key, 0); if (ret) goto fail; new_pos = key.objectid;