btrfs-progs: transaction: do proper error handling in transaction commit
There are cases that btrfs_commit_transaction() itself can fail, mostly due to ENOSPC when allocating space. Don't panic out in this case. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a8985f549c
commit
9f45658fd2
|
@ -74,7 +74,8 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
|
|||
ret = btrfs_update_root(trans, tree_root,
|
||||
&root->root_key,
|
||||
&root->root_item);
|
||||
BUG_ON(ret);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
btrfs_write_dirty_block_groups(trans, root);
|
||||
}
|
||||
return 0;
|
||||
|
@ -102,9 +103,11 @@ int commit_tree_roots(struct btrfs_trans_handle *trans,
|
|||
next = fs_info->dirty_cowonly_roots.next;
|
||||
list_del_init(next);
|
||||
root = list_entry(next, struct btrfs_root, dirty_list);
|
||||
update_cowonly_root(trans, root);
|
||||
ret = update_cowonly_root(trans, root);
|
||||
free_extent_buffer(root->commit_root);
|
||||
root->commit_root = NULL;
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -168,7 +171,8 @@ commit_tree:
|
|||
ret = commit_tree_roots(trans, fs_info);
|
||||
BUG_ON(ret);
|
||||
ret = __commit_transaction(trans, root);
|
||||
BUG_ON(ret);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
write_ctree_super(trans);
|
||||
btrfs_finish_extent_commit(trans, fs_info->extent_root,
|
||||
&fs_info->pinned_extents);
|
||||
|
@ -177,7 +181,8 @@ commit_tree:
|
|||
root->commit_root = NULL;
|
||||
fs_info->running_transaction = NULL;
|
||||
fs_info->last_trans_committed = transid;
|
||||
return 0;
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void btrfs_abort_transaction(struct btrfs_trans_handle *trans, int error)
|
||||
|
|
Loading…
Reference in a new issue