From patchwork Mon Jun 27 07:50:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9199997 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 80D9160757 for ; Mon, 27 Jun 2016 07:52:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 717C128324 for ; Mon, 27 Jun 2016 07:52:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6630C2807B; Mon, 27 Jun 2016 07:52:46 +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 BC6502807B for ; Mon, 27 Jun 2016 07:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751905AbcF0Hwk (ORCPT ); Mon, 27 Jun 2016 03:52:40 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:18089 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751830AbcF0Hwj (ORCPT ); Mon, 27 Jun 2016 03:52:39 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="646268" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 27 Jun 2016 15:52:19 +0800 Received: from localhost.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id 768D24056404 for ; Mon, 27 Jun 2016 15:52:15 +0800 (CST) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents Date: Mon, 27 Jun 2016 15:50:10 +0800 Message-Id: <20160627075011.24330-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 768D24056404.AA1BC 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 Btrfs_record_file_extent() will split extents using max extent size(128M). It works well for real file extents, but not that well for large hole extent, as hole doesn't have extent size limit. In that case, it will only insert one 128M hole, and skip the rest, leading to discontinuous extent error for converted btrfs. Fix it by not splitting hole extents. Signed-off-by: Qu Wenruo --- extent-tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extent-tree.c b/extent-tree.c index 5ca53fa..a58da23 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -3985,10 +3985,11 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, u64 extent_offset; u64 num_bytes = *ret_num_bytes; - num_bytes = min_t(u64, num_bytes, BTRFS_MAX_EXTENT_SIZE); /* * All supported file system should not use its 0 extent. * As it's for hole + * + * And hole extent has no size limit, no need to loop. */ if (disk_bytenr == 0) { ret = btrfs_insert_file_extent(trans, root, objectid, @@ -3996,6 +3997,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, num_bytes, num_bytes); return ret; } + num_bytes = min_t(u64, num_bytes, BTRFS_MAX_EXTENT_SIZE); path = btrfs_alloc_path(); if (!path)