All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
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	[thread overview]
Message-ID: <1403751186-31559-6-git-send-email-guihc.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1403751186-31559-1-git-send-email-guihc.fnst@cn.fujitsu.com>

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
 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);
-- 
1.8.1.4


      parent reply	other threads:[~2014-06-26  2:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26  2:53 [PATCH 1/6] btrfs-progs: fix btrfs-image old_restore fsck failure Gui Hecheng
2014-06-26  2:53 ` [PATCH 2/6] btrfs-progs: deal with malloc failure in btrfs-image Gui Hecheng
2014-06-26  2:53 ` [PATCH 3/6] btrfs-progs: cleanup unnecessary free if malloc fails " Gui Hecheng
2014-06-26  2:53 ` [PATCH 4/6] btrfs-progs: cleanup possible silent failure " Gui Hecheng
2014-06-26  2:53 ` [PATCH 5/6] btrfs-progs: limit minimal num of args for btrfs-image Gui Hecheng
2014-06-27 12:35   ` David Sterba
2014-06-30  1:47     ` Gui Hecheng
2014-06-30  3:54     ` [PATCH 1/2] btrfs-progs: move the check_argc_* functions into utils.c Gui Hecheng
2014-06-30  3:54       ` [PATCH v2 2/2] btrfs-progs: limit minimal num of args for btrfs-image Gui Hecheng
2014-07-01 23:11       ` [PATCH 1/2] btrfs-progs: move the check_argc_* functions into utils.c David Sterba
2014-07-02  0:20         ` WorMzy Tykashi
2014-07-02  9:34           ` David Sterba
2014-07-02 10:50             ` WorMzy Tykashi
2014-07-02  1:13         ` Gui Hecheng
2014-07-10  1:06         ` [PATCH] btrfs-progs: use check_argc_* to check arg number for all tools Gui Hecheng
2014-07-16  3:44           ` [PATCH v2] " Gui Hecheng
2014-07-16  3:58             ` Gui Hecheng
2014-07-16  3:59           ` Gui Hecheng
2014-06-26  2:53 ` Gui Hecheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403751186-31559-6-git-send-email-guihc.fnst@cn.fujitsu.com \
    --to=guihc.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.