Message ID | 4a2f9c8918b1386ef6296d52ee4e331b7099b247.1428554023.git.zhaolei@cn.fujitsu.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On 04/09/2015 12:34 AM, Zhaolei wrote: > From: Zhao Lei <zhaolei@cn.fujitsu.com> > > 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. Can you please change this so we only do this flush if the first commit doesn't free up enough space? I think this is going to have a performance impact as the FS fills up. -chris -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi, Chris > -----Original Message----- > From: Chris Mason [mailto:clm@fb.com] > Sent: Monday, April 13, 2015 10:55 PM > To: Zhaolei; linux-btrfs@vger.kernel.org > Subject: Re: [PATCH 8/9] btrfs: wait for delayed iputs on no space > > On 04/09/2015 12:34 AM, Zhaolei wrote: > > From: Zhao Lei <zhaolei@cn.fujitsu.com> > > > > 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. > > Can you please change this so we only do this flush if the first commit doesn't > free up enough space? I think this is going to have a performance impact as > the FS fills up. > btrfs_wait_ordered_roots() can only ensure that all bio are finished, and relative iputs are added into delayed_iputs in end_io. And we need 2 commit to make free space accessable: One for run delayed_iputs(), and another for unpin. It is why I put above line to first commit, to ensure we have enough commit operation to make free space accessable. It is only called then the disk is almost full, and have no performance impact in most case(disk not full). Another way is to call btrfs_wait_ordered_roots() after first commit() try, but give it addition commit(). Thanks Zhaolei -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 0572f14..d5ec383 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3725,6 +3725,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);