summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-08-28 16:48:16 +0200
committerDavid Sterba <dsterba@suse.com>2017-09-08 16:15:05 +0200
commit448999d84ddc2eaf36938176fb5091d2c2029e2f (patch)
tree4e90505605420f6d3467639d2899e93c893596dd /mkfs
parent4ef5a112c9d2fe9d6f03ac2ea3aa5b1af0f37254 (diff)
btrfs-progs: add crude error handling when transaction start fails
Currently transaction bugs out insided btrfs_start_transaction in case of error, we want to lift the error handling to the callers. This patch adds the BUG_ON anywhere it's been missing so far. This is not the best way of course. Transforming BUG_ON to a proper error handling highly depends on the caller and should be dealt with case by case. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/mkfs/main.c b/mkfs/main.c
index dfa7a031..f4952581 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -75,6 +75,7 @@ static int create_metadata_block_groups(struct btrfs_root *root, int mixed,
int ret;
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
bytes_used = btrfs_super_bytes_used(fs_info->super_copy);
root->fs_info->system_allocs = 1;
@@ -1047,6 +1048,7 @@ static int make_image(const char *source_dir, struct btrfs_root *root)
INIT_LIST_HEAD(&dir_head.list);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
ret = traverse_directory(trans, root, source_dir, &dir_head);
if (ret) {
error("unable to traverse directory %s: %d", source_dir, ret);
@@ -1325,6 +1327,7 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info,
btrfs_init_path(&path);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
key.objectid = 0;
key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
@@ -1758,7 +1761,7 @@ int main(int argc, char **argv)
}
trans = btrfs_start_transaction(root, 1);
- if (!trans) {
+ if (IS_ERR(trans)) {
error("failed to start transaction");
goto error;
}
@@ -1782,7 +1785,7 @@ int main(int argc, char **argv)
}
trans = btrfs_start_transaction(root, 1);
- if (!trans) {
+ if (IS_ERR(trans)) {
error("failed to start transaction");
goto error;
}
@@ -1860,6 +1863,7 @@ raid_groups:
if (source_dir_set) {
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
ret = create_chunks(trans, root,
num_of_meta_chunks, size_of_data,
&allocation);