Skip to contentSkip to conversation

btrfs: wait for delayed iputs on no space

PATCH In review Zhaolei 2 participants 3 messages Mar 27, 2015 – Mar 31, 2015 Btrfs file system

lore
Share & tools
lore

Zhaolei

author
#0 lore raw

PATCH 1/1 btrfs: wait for delayed iputs on no space

From: Zhao Lei <[email protected]>

This is another fix of no_space case.

All patchs for fix no_space bug are available at fix_no_space branch on:
git://github.com/zhaoleidd/btrfs

Any suggestions are welcome.

Zhao Lei (1):
btrfs: wait for delayed iputs on no space

 fs/btrfs/extent-tree.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
1.8.5.1
author
#1 lore raw

PATCH 1/1 btrfs: wait for delayed iputs on no space

From: Zhao Lei <[email protected]>

btrfs will report no_space when we run following write and delete file loop:
# FILE_SIZE_M=[ 75% of fs space ]
# DEV=[ some dev ]
# MNT=[ some dir ]
#

 # mkfs.btrfs -f "$DEV"
 # mount -o nodatacow "$DEV" "$MNT"
 # for ((i = 0; i < 100; i++)); do dd if=/dev/zero of="$MNT"/file0 bs=1M count="$FILE_SIZE_M"; rm -f "$MNT"/file0; done
 #

Reason:
iput() and evict() is run after write pages to block device, if write pages work is not finished before next write, the "rm"ed space is not freed, and caused above bug.

Fix:
We can add "-o flushoncommit" mount option to avoid above bug, but it have performance problem. Actually, we can to wait for on-the-fly writes only when no-space happened, it is which this patch do.

---
 fs/btrfs/extent-tree.c | 3 +++
 1 file changed, 3 insertions(+)
fs/btrfs/extent-tree.c +3 -0
index 6c1e211..94fb15f 100644
@@ -3683,6 +3683,9 @@ commit_trans:
 		    !atomic_read(&root->fs_info->open_ioctl_trans)) {
 			need_commit--;
 
+			if (need_commit > 0)
+				btrfs_wait_ordered_roots(fs_info, -1);
+
 			trans = btrfs_join_transaction(root);
 			if (IS_ERR(trans))
 				return PTR_ERR(trans);
Signature · 1 line
1.8.5.1
Tested-by on v1 1/1
#2 lore raw
In reply to Zhaolei
Quoted 7 lines · Zhaolei

From: Zhao Lei <[email protected]>

This is another fix of no_space case.

All patchs for fix no_space bug are available at fix_no_space branch on:
git://github.com/zhaoleidd/btrfs

I tested in the environment that applied the following patch to 'fix_no_space' branch.
- Btrfs: fix find_free_dev_extent() malfunction in case device tree has hole

It works fine to me. Thanks.

Quoted 9 lines

Any suggestions are welcome.

Zhao Lei (1):
btrfs: wait for delayed iputs on no space

  fs/btrfs/extent-tree.c | 3 +++
  1 file changed, 3 insertions(+)