Commit 68075ea8 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba
Browse files

btrfs: handle btrfs_record_root_in_trans failure in start_transaction



btrfs_record_root_in_trans will return errors in the future, so handle
the error properly in start_transaction.

Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ add comment ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent d18c7bd9
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -746,7 +746,16 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
	 * Thus it need to be called after current->journal_info initialized,
	 * or we can deadlock.
	 */
	btrfs_record_root_in_trans(h, root);
	ret = btrfs_record_root_in_trans(h, root);
	if (ret) {
		/*
		 * The transaction handle is fully initialized and linked with
		 * other structures so it needs to be ended in case of errors,
		 * not just freed.
		 */
		btrfs_end_transaction(h);
		return ERR_PTR(ret);
	}

	return h;