From patchwork Thu Jun 1 16:24:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lakshmipathi.G" X-Patchwork-Id: 9760273 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 D962A602BC for ; Thu, 1 Jun 2017 16:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD6BC284BF for ; Thu, 1 Jun 2017 16:27:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1677284FC; Thu, 1 Jun 2017 16:27: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=-5.4 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB 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 717B4284BF for ; Thu, 1 Jun 2017 16:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751721AbdFAQ1J (ORCPT ); Thu, 1 Jun 2017 12:27:09 -0400 Received: from p3nlsmtpcp01-03.prod.phx3.secureserver.net ([184.168.200.142]:59670 "EHLO p3nlsmtpcp01-03.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751750AbdFAQ0P (ORCPT ); Thu, 1 Jun 2017 12:26:15 -0400 Received: from p3plcpnl0639.prod.phx3.secureserver.net ([50.62.176.166]) by : HOSTING RELAY : with SMTP id GSu1dzUrq7z1JGSu1dRtb1; Thu, 01 Jun 2017 09:24:49 -0700 Received: from [59.93.15.78] (port=60766 helo=giis.co.in) by p3plcpnl0639.prod.phx3.secureserver.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.88) (envelope-from ) id 1dGSu0-0004tX-7u; Thu, 01 Jun 2017 09:24:49 -0700 Date: Thu, 1 Jun 2017 21:54:29 +0530 From: "Lakshmipathi.G@giis.co.in" To: Qu Wenruo , dsterba , btrfs Subject: [PATCH v3] btrfs-progs: btrfs-convert: Add larger device support Message-ID: <20170601162429.GA19537@giis.co.in> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - p3plcpnl0639.prod.phx3.secureserver.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gmail.com X-Get-Message-Sender-Via: p3plcpnl0639.prod.phx3.secureserver.net: authenticated_id: lakshmipathi.g@giis.co.in X-Authenticated-Sender: p3plcpnl0639.prod.phx3.secureserver.net: lakshmipathi.g@giis.co.in X-Source: X-Source-Args: X-Source-Dir: X-CMAE-Envelope: MS4wfK9xkTrOdnbyZmNSzzkNQP/4/HBQpYAZos2XE/lAIr3eKRwc/0QwyNvwO1jlt3BffIED3fUaU4koNYp/OpTeWCQWQsZ4BUHfgfbxHr7hHBktP7JkaSXU 4jj/vEsSVlk+My0lQb3UnvIRIxsIrkBHoajXTmRM/eGZyPyYxOADJwdxtfPmRaTAZtyBN0kGt2dH0+X5JjV8FtFf2sL+mZMve6kjS275KLPAnP+zwRB5jlBE 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 With larger file system (in this case its 22TB), ext2fs_open() returns EXT2_ET_CANT_USE_LEGACY_BITMAPS error message with ext2fs_read_block_bitmap(). To overcome this issue, (a) we need pass EXT2_FLAG_64BITS flag with ext2fs_open. (b) use 64-bit functions like ext2fs_get_block_bitmap_range2, ext2fs_inode_data_blocks2,ext2fs_read_ext_attr2. (c) use 64bit types with btrfs_convert_context fields. bug: https://bugzilla.kernel.org/show_bug.cgi?id=194795 Signed-off-by: Lakshmipathi.G@giis.co.in --- convert/common.h | 8 ++++---- convert/source-ext2.c | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/convert/common.h b/convert/common.h index 0d3adea..2f4ea48 100644 --- a/convert/common.h +++ b/convert/common.h @@ -30,10 +30,10 @@ struct btrfs_mkfs_config; struct btrfs_convert_context { u32 blocksize; - u32 first_data_block; - u32 block_count; - u32 inodes_count; - u32 free_inodes_count; + u64 first_data_block; + u64 block_count; + u64 inodes_count; + u64 free_inodes_count; u64 total_bytes; char *volume_name; const struct btrfs_convert_operations *convert_ops; diff --git a/convert/source-ext2.c b/convert/source-ext2.c index 1b0576b..275cb89 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -34,8 +34,9 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name) ext2_filsys ext2_fs; ext2_ino_t ino; u32 ro_feature; + int open_flag = EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS; - ret = ext2fs_open(name, 0, 0, 0, unix_io_manager, &ext2_fs); + ret = ext2fs_open(name, open_flag, 0, 0, unix_io_manager, &ext2_fs); if (ret) { fprintf(stderr, "ext2fs_open: %s\n", error_message(ret)); return -1; @@ -148,7 +149,7 @@ static int ext2_read_used_space(struct btrfs_convert_context *cctx) return -ENOMEM; for (i = 0; i < fs->group_desc_count; i++) { - ret = ext2fs_get_block_bitmap_range(fs->block_map, blk_itr, + ret = ext2fs_get_block_bitmap_range2(fs->block_map, blk_itr, block_nbytes * 8, block_bitmap); if (ret) { error("fail to get bitmap from ext2, %s", @@ -353,7 +354,7 @@ static int ext2_create_symlink(struct btrfs_trans_handle *trans, int ret; char *pathname; u64 inode_size = btrfs_stack_inode_size(btrfs_inode); - if (ext2fs_inode_data_blocks(ext2_fs, ext2_inode)) { + if (ext2fs_inode_data_blocks2(ext2_fs, ext2_inode)) { btrfs_set_stack_inode_size(btrfs_inode, inode_size + 1); ret = ext2_create_file_extents(trans, root, objectid, btrfs_inode, ext2_fs, ext2_ino, @@ -627,9 +628,9 @@ static int ext2_copy_extended_attrs(struct btrfs_trans_handle *trans, ret = -ENOMEM; goto out; } - err = ext2fs_read_ext_attr(ext2_fs, ext2_inode->i_file_acl, buffer); + err = ext2fs_read_ext_attr2(ext2_fs, ext2_inode->i_file_acl, buffer); if (err) { - fprintf(stderr, "ext2fs_read_ext_attr: %s\n", + fprintf(stderr, "ext2fs_read_ext_attr2: %s\n", error_message(err)); ret = -1; goto out;