summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2015-06-05 23:41:09 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-05 23:41:25 +0200
commit1f93b9d4ced64b51b0ac3a410e76ab0a36ea989c (patch)
treecb32d41e725bf71289659c8d62c0e616be3f9f7f
parent76c38116b338e57930aa25d76940b9b32b618db6 (diff)
btrfs-progs: convert: factor out block iteration callback
block_iterate_proc uses the libext2fs error return codes when it doesn't need them to return the error. We can push this out to __block_iterate_proc and allow the reiserfs converter to share the code. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--btrfs-convert.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 2a3fb292..a452c2ba 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -507,7 +507,7 @@ static int record_file_blocks(struct blk_iterate_data *data,
static int block_iterate_proc(u64 disk_block, u64 file_block,
struct blk_iterate_data *idata)
{
- int ret;
+ int ret = 0;
int sb_region;
int do_barrier;
struct btrfs_root *root = idata->root;
@@ -549,19 +549,23 @@ static int block_iterate_proc(u64 disk_block, u64 file_block,
idata->boundary = bytenr / root->sectorsize;
}
idata->num_blocks++;
- return 0;
fail:
- idata->errcode = ret;
- return BLOCK_ABORT;
+ return ret;
}
static int __block_iterate_proc(ext2_filsys fs, blk_t *blocknr,
e2_blkcnt_t blockcnt, blk_t ref_block,
int ref_offset, void *priv_data)
{
+ int ret;
struct blk_iterate_data *idata;
idata = (struct blk_iterate_data *)priv_data;
- return block_iterate_proc(*blocknr, blockcnt, idata);
+ ret = block_iterate_proc(*blocknr, blockcnt, idata);
+ if (ret) {
+ idata->errcode = ret;
+ return BLOCK_ABORT;
+ }
+ return 0;
}
/*
@@ -1202,10 +1206,8 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
if (!ext2fs_fast_test_block_bitmap(ext2_fs->block_map, block))
continue;
ret = block_iterate_proc(block, block, &data);
- if (ret & BLOCK_ABORT) {
- ret = data.errcode;
+ if (ret < 0)
goto fail;
- }
}
if (data.num_blocks > 0) {
ret = record_file_blocks(&data, data.first_block,
@@ -1958,10 +1960,8 @@ static int relocate_one_reference(struct btrfs_trans_handle *trans,
ret = block_iterate_proc(new_pos / sectorsize,
cur_offset / sectorsize, &data);
- if (ret & BLOCK_ABORT) {
- ret = data.errcode;
+ if (ret < 0)
goto fail;
- }
cur_offset += sectorsize;
bytenr += sectorsize;