From patchwork Thu Jun 26 02:53:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Hecheng X-Patchwork-Id: 4425541 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AF3629F387 for ; Thu, 26 Jun 2014 02:58:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0B5420379 for ; Thu, 26 Jun 2014 02:58:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8AA320384 for ; Thu, 26 Jun 2014 02:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757440AbaFZC6h (ORCPT ); Wed, 25 Jun 2014 22:58:37 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:26146 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1757303AbaFZC6f (ORCPT ); Wed, 25 Jun 2014 22:58:35 -0400 X-IronPort-AV: E=Sophos;i="5.00,779,1396972800"; d="scan'208";a="32451603" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jun 2014 10:55:53 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s5Q2wWkv027102 for ; Thu, 26 Jun 2014 10:58:32 +0800 Received: from localhost.localdomain (10.167.226.111) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 26 Jun 2014 10:58:42 +0800 From: Gui Hecheng To: CC: Gui Hecheng Subject: [PATCH 6/6] btrfs-progs: use BTRFS_SUPER_INFO_SIZE to replace raw 4096 in btrfs-image Date: Thu, 26 Jun 2014 10:53:06 +0800 Message-ID: <1403751186-31559-6-git-send-email-guihc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1403751186-31559-1-git-send-email-guihc.fnst@cn.fujitsu.com> References: <1403751186-31559-1-git-send-email-guihc.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.111] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gui Hecheng --- btrfs-image.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/btrfs-image.c b/btrfs-image.c index b13f236..ed0b6ec 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -1163,7 +1163,7 @@ static int copy_from_extent_tree(struct metadump_struct *metadump, int ret; extent_root = metadump->root->fs_info->extent_root; - bytenr = BTRFS_SUPER_INFO_OFFSET + 4096; + bytenr = BTRFS_SUPER_INFO_OFFSET + BTRFS_SUPER_INFO_SIZE; key.objectid = bytenr; key.type = BTRFS_EXTENT_ITEM_KEY; key.offset = 0; @@ -1278,7 +1278,8 @@ static int create_metadump(const char *input, FILE *out, int num_threads, return ret; } - ret = add_extent(BTRFS_SUPER_INFO_OFFSET, 4096, &metadump, 0); + ret = add_extent(BTRFS_SUPER_INFO_OFFSET, BTRFS_SUPER_INFO_SIZE, + &metadump, 0); if (ret) { fprintf(stderr, "Error adding metadata %d\n", ret); err = ret; @@ -1368,7 +1369,7 @@ static void update_super_old(u8 *buffer) btrfs_set_stack_stripe_offset(&chunk->stripe, 0); memcpy(chunk->stripe.dev_uuid, super->dev_item.uuid, BTRFS_UUID_SIZE); btrfs_set_super_sys_array_size(super, sizeof(*key) + sizeof(*chunk)); - csum_block(buffer, 4096); + csum_block(buffer, BTRFS_SUPER_INFO_SIZE); } static int update_super(u8 *buffer) @@ -1422,7 +1423,7 @@ static int update_super(u8 *buffer) } btrfs_set_super_sys_array_size(super, new_array_size); - csum_block(buffer, 4096); + csum_block(buffer, BTRFS_SUPER_INFO_SIZE); return 0; } @@ -1569,12 +1570,12 @@ static void write_backup_supers(int fd, u8 *buf) for (i = 1; i < BTRFS_SUPER_MIRROR_MAX; i++) { bytenr = btrfs_sb_offset(i); - if (bytenr + 4096 > size) + if (bytenr + BTRFS_SUPER_INFO_SIZE > size) break; btrfs_set_super_bytenr(super, bytenr); - csum_block(buf, 4096); - ret = pwrite64(fd, buf, 4096, bytenr); - if (ret < 4096) { + csum_block(buf, BTRFS_SUPER_INFO_SIZE); + ret = pwrite64(fd, buf, BTRFS_SUPER_INFO_SIZE, bytenr); + if (ret < BTRFS_SUPER_INFO_SIZE) { if (ret < 0) fprintf(stderr, "Problem writing out backup " "super block %d, err %d\n", i, errno);