Btrfs-progs: let btrfs-image actually work on a balanced fs
PATCH 1/1 Btrfs-progs: let btrfs-image actually work on a balanced fs
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,
--- btrfs-image.c | 5 ++++- disk-io.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-)
btrfs-image.c +4 -1
@@ -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;
disk-io.c +2 -1
@@ -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 );
Signature · 1 line
1.9.3
btrfs-image.c static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb, · line 1028
Quoted 12 lines
btrfs-image.c +3
-0@@ -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" );
Did you mean to leave that in? The raw super offset sure makes it look like debugging output.
- z
Quoted 6 lines · Zach Brown
Quoted 6 lines
btrfs-image.c +0
-0@@ -1020,6 +1020,9 @@ static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb,int i =0 ;int ret;
Quoted 10 lines
btrfs-image.c static int copy_tree_blocks(struct btrfs_root *root, struct extent_buffer *eb, · line 1028
Quoted 6 lines
btrfs-image.c +3
-0+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" );Did you mean to leave that in? The raw super offset sure makes it look like debugging output.
Sigh sorry, thought I culled everything. Thanks,
Josef