]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: wait for delayed iputs on no space
authorZhao Lei <zhaolei@cn.fujitsu.com>
Thu, 9 Apr 2015 04:34:43 +0000 (12:34 +0800)
committerChris Mason <clm@fb.com>
Wed, 10 Jun 2015 16:26:34 +0000 (09:26 -0700)
commit8290eca165cc254b9e5522db38ceeba8ba0f1801
treef0b3bb9284f7fd45b4275577d394769488bd0a27
parent78c80bdc646dd158017a666ea43a1a4339639c7c
btrfs: wait for delayed iputs on no space

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.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/extent-tree.c