From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/4] btrfs-progs: transaction: Error out other than panic when committing transaction
Date: Thu, 5 Jul 2018 15:37:29 +0800 [thread overview]
Message-ID: <20180705073731.18459-3-wqu@suse.com> (raw)
In-Reply-To: <20180705073731.18459-1-wqu@suse.com>
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>
---
transaction.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/transaction.c b/transaction.c
index 9619265ef6e8..b82d346b52c8 100644
--- a/transaction.c
+++ b/transaction.c
@@ -73,7 +73,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;
@@ -101,9 +102,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;
@@ -162,12 +165,15 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
root->root_item.level = btrfs_header_level(root->node);
ret = btrfs_update_root(trans, root->fs_info->tree_root,
&root->root_key, &root->root_item);
- BUG_ON(ret);
+ if (ret < 0)
+ goto out;
commit_tree:
ret = commit_tree_roots(trans, fs_info);
- BUG_ON(ret);
+ if (ret < 0)
+ goto out;
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);
@@ -176,7 +182,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)
--
2.18.0
next prev parent reply other threads:[~2018-07-05 7:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 7:37 [PATCH 0/4] Some random fuzz test fixes Qu Wenruo
2018-07-05 7:37 ` [PATCH 1/4] btrfs-progs: check: Remove the ability to rebuild root overwritting existing tree blocks Qu Wenruo
2018-07-05 8:50 ` Gu, Jinxiang
2018-07-05 9:41 ` Qu Wenruo
2018-07-06 1:53 ` Gu, Jinxiang
2018-08-02 19:36 ` David Sterba
2018-07-05 7:37 ` Qu Wenruo [this message]
2018-07-05 9:33 ` [PATCH 2/4] btrfs-progs: transaction: Error out other than panic when committing transaction Gu, Jinxiang
2018-07-05 7:37 ` [PATCH 3/4] btrfs-progs: check/original: Avoid infinite loop when failed to repair inode Qu Wenruo
2018-07-06 3:22 ` Gu, Jinxiang
2018-07-05 7:37 ` [PATCH 4/4] btrfs-progs: check/original: Don't overwrite return value when we failed to repair Qu Wenruo
2018-07-06 4:57 ` Gu, Jinxiang
2018-08-02 20:03 ` [PATCH 0/4] Some random fuzz test fixes David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180705073731.18459-3-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).