Commit d5b55a7a authored by Zhao Lei's avatar Zhao Lei Committed by Sasha Levin

btrfs: Fix no_space in write and rm loop

[ Upstream commit 08acfd9d ]

commit e1746e83 upstream.

I see no_space in v4.4-rc1 again in xfstests generic/102.
It happened randomly in some node only.
(one of 4 phy-node, and a kvm with non-virtio block driver)

By bisect, we can found the first-bad is:
 commit bdced438 ("block: setup bi_phys_segments after splitting")'
But above patch only triggered the bug by making bio operation
faster(or slower).

Main reason is in our space_allocating code, we need to commit
page writeback before wait it complish, this patch fixed above
bug.

BTW, there is another reason for generic/102 fail, caused by
disable default mixed-blockgroup, I'll fix it in xfstests.
Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 42bd8f4f
......@@ -3975,8 +3975,10 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes, u64 write_bytes)
!atomic_read(&root->fs_info->open_ioctl_trans)) {
need_commit--;
if (need_commit > 0)
if (need_commit > 0) {
btrfs_start_delalloc_roots(fs_info, 0, -1);
btrfs_wait_ordered_roots(fs_info, -1);
}
trans = btrfs_join_transaction(root);
if (IS_ERR(trans))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment