linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs-progs: let btrfs-image actually work on a balanced fs
Date: Thu, 25 Sep 2014 16:46:55 -0400	[thread overview]
Message-ID: <1411678015-5928-1-git-send-email-jbacik@fb.com> (raw)

We use the read extent buffer infrastructure to read the super block when we are
creating a btrfs-image.  This works out fine most of the time except when the fs
has been balanced, then it fails to map the super block.  So we could fix
btrfs-image to read in the super in a special way, but thats more code.  So
instead just check in the eb reading code if we are reading the super and then
don't bother mapping the block, just read the actual offset.  This fixed some
poor guy who was trying to btrfs-image his fs that had been balanced.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 btrfs-image.c | 5 ++++-
 disk-io.c     | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/btrfs-image.c b/btrfs-image.c
index cb17f16..6643ad1 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -1020,6 +1020,9 @@ static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb,
 	int i = 0;
 	int ret;
 
+	if (btrfs_header_bytenr(eb) == 65536)
+		printf("We have bytenr 65536, belongs to %llu, level %d\n",
+		       btrfs_header_owner(eb), btrfs_header_level(eb));
 	ret = add_extent(btrfs_header_bytenr(eb), root->leafsize, metadump, 0);
 	if (ret) {
 		fprintf(stderr, "Error adding metadata block\n");
@@ -1279,7 +1282,7 @@ static int create_metadump(const char *input, FILE *out, int num_threads,
 	}
 
 	ret = add_extent(BTRFS_SUPER_INFO_OFFSET, BTRFS_SUPER_INFO_SIZE,
-			&metadump, 0);
+			&metadump, 1);
 	if (ret) {
 		fprintf(stderr, "Error adding metadata %d\n", ret);
 		err = ret;
diff --git a/disk-io.c b/disk-io.c
index 26a532e..34c0a97 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -201,7 +201,8 @@ int read_whole_eb(struct btrfs_fs_info *info, struct extent_buffer *eb, int mirr
 		read_len = bytes_left;
 		device = NULL;
 
-		if (!info->on_restoring) {
+		if (!info->on_restoring &&
+		    eb->start != BTRFS_SUPER_INFO_OFFSET) {
 			ret = btrfs_map_block(&info->mapping_tree, READ,
 					      eb->start + offset, &read_len, &multi,
 					      mirror, NULL);
-- 
1.9.3


             reply	other threads:[~2014-09-25 20:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25 20:46 Josef Bacik [this message]
2014-09-25 21:44 ` [PATCH] Btrfs-progs: let btrfs-image actually work on a balanced fs Zach Brown
2014-09-26 13:00   ` Josef Bacik

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=1411678015-5928-1-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).