From 5da89caa81e7e7068cf4c0a7b09b329598e4bc2c Mon Sep 17 00:00:00 2001 From: Gui Hecheng Date: Thu, 26 Jun 2014 10:53:06 +0800 Subject: [PATCH] btrfs-progs: use BTRFS_SUPER_INFO_SIZE to replace raw 4096 in btrfs-image Signed-off-by: Gui Hecheng Signed-off-by: David Sterba --- btrfs-image.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/btrfs-image.c b/btrfs-image.c index b8e8c4d6..2bf634bf 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);