提交 1708cc57 编写于 作者: W Wang Shilong 提交者: Chris Mason

Btrfs: fix an oops when we fail to relocate tree blocks

During balance test, we hit an oops:
[ 2013.841551] kernel BUG at fs/btrfs/relocation.c:1174!

The problem is that if we fail to relocate tree blocks, we should
update backref cache, otherwise, some pending nodes are not updated
while snapshot check @cache->last_trans is within one transaction
and won't update it and then oops happen.
Signed-off-by: NWang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: NJosef Bacik <jbacik@fb.com>
Signed-off-by: NChris Mason <clm@fb.com>
上级 e77751aa
...@@ -4009,6 +4009,12 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -4009,6 +4009,12 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
if (!RB_EMPTY_ROOT(&blocks)) { if (!RB_EMPTY_ROOT(&blocks)) {
ret = relocate_tree_blocks(trans, rc, &blocks); ret = relocate_tree_blocks(trans, rc, &blocks);
if (ret < 0) { if (ret < 0) {
/*
* if we fail to relocate tree blocks, force to update
* backref cache when committing transaction.
*/
rc->backref_cache.last_trans = trans->transid - 1;
if (ret != -EAGAIN) { if (ret != -EAGAIN) {
err = ret; err = ret;
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册