]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix abnormal long waiting in fsync
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 17 Jul 2014 08:08:36 +0000 (16:08 +0800)
committerChris Mason <clm@fb.com>
Sat, 19 Jul 2014 18:49:44 +0000 (11:49 -0700)
commite6e45f1ceff48cc23c5166595ef2d563f50bb99e
treedc4663942e38f42c4eec30e47804f65ff37ba685
parent5b51f2f95f66cf70ba20f5e46b18c818f770e119
Btrfs: fix abnormal long waiting in fsync

xfstests generic/127 detected this problem.

With commit 6000acea89ab54dc13ec33ec5fa56f882744747c, now fsync will only flush
data within the passed range.  This is the cause of the above problem,
-- btrfs's fsync has a stage called 'sync log' which will wait for all the
ordered extents it've recorded to finish.

In xfstests/generic/127, with mixed operations such as truncate, fallocate,
punch hole, and mapwrite, we get some pre-allocated extents, and mapwrite will
mmap, and then msync.  And I find that msync will wait for quite a long time
(about 20s in my case), thanks to ftrace, it turns out that the previous
fallocate calls 'btrfs_wait_ordered_range()' to flush dirty pages, but as the
range of dirty pages may be larger than 'btrfs_wait_ordered_range()' wants,
there can be some ordered extents created but not getting corresponding pages
flushed, then they're left in memory until we fsync which runs into the
stage 'sync log', and fsync will just wait for the system writeback thread
to flush those pages and get ordered extents finished, so the latency is
inevitable.

This adds a flush similar to btrfs_start_ordered_extent() in
btrfs_wait_logged_extents() to fix that.

Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ordered-data.c