summaryrefslogtreecommitdiff
path: root/btrfs-image.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@fusionio.com>2013-05-03 16:18:46 -0400
committerChris Mason <chris.mason@fusionio.com>2013-05-03 16:18:46 -0400
commit9c821327408803229e93a788e032e8e9caf11686 (patch)
treed8bd6cba4e6abc2bbfed25b6c52143eba35d16f8 /btrfs-image.c
parent617efb6bb8cd3afbfd36411925469537be218229 (diff)
btrfs-image: fix reading the super block on big metadata blocks
btrfs-image is assuming that every metadata block is the same size. The super is a special snowflake though. It's 4K even on 64K filesystems. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'btrfs-image.c')
-rw-r--r--btrfs-image.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/btrfs-image.c b/btrfs-image.c
index 188291ca..739ae357 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -506,7 +506,8 @@ static int flush_pending(struct metadump_struct *md, int done)
}
while (!md->data && size > 0) {
- eb = read_tree_block(md->root, start, blocksize, 0);
+ u64 this_read = min(blocksize, size);
+ eb = read_tree_block(md->root, start, this_read, 0);
if (!eb) {
free(async->buffer);
free(async);
@@ -516,9 +517,9 @@ static int flush_pending(struct metadump_struct *md, int done)
}
copy_buffer(async->buffer + offset, eb);
free_extent_buffer(eb);
- start += blocksize;
- offset += blocksize;
- size -= blocksize;
+ start += this_read;
+ offset += this_read;
+ size -= this_read;
}
md->pending_start = (u64)-1;