linux/include
Jan Kara c4a391b53a writeback: do not sync data dirtied after sync start
When there are processes heavily creating small files while sync(2) is
running, it can easily happen that quite some new files are created
between WB_SYNC_NONE and WB_SYNC_ALL pass of sync(2).  That can happen
especially if there are several busy filesystems (remember that sync
traverses filesystems sequentially and waits in WB_SYNC_ALL phase on one
fs before starting it on another fs).  Because WB_SYNC_ALL pass is slow
(e.g.  causes a transaction commit and cache flush for each inode in
ext3), resulting sync(2) times are rather large.

The following script reproduces the problem:

  function run_writers
  {
    for (( i = 0; i < 10; i++ )); do
      mkdir $1/dir$i
      for (( j = 0; j < 40000; j++ )); do
        dd if=/dev/zero of=$1/dir$i/$j bs=4k count=4 &>/dev/null
      done &
    done
  }

  for dir in "$@"; do
    run_writers $dir
  done

  sleep 40
  time sync

Fix the problem by disregarding inodes dirtied after sync(2) was called
in the WB_SYNC_ALL pass.  To allow for this, sync_inodes_sb() now takes
a time stamp when sync has started which is used for setting up work for
flusher threads.

To give some numbers, when above script is run on two ext4 filesystems
on simple SATA drive, the average sync time from 10 runs is 267.549
seconds with standard deviation 104.799426.  With the patched kernel,
the average sync time from 10 runs is 2.995 seconds with standard
deviation 0.096.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Fengguang Wu <fengguang.wu@intel.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-11-13 12:09:07 +09:00
..
acpi ACPI, CPER: Update cper info 2013-10-21 15:12:00 -07:00
asm-generic GPIO bulk changes for the v3.13 development cycle 2013-11-12 15:50:46 +09:00
clocksource drivers: clocksource: add support for ARM architected timer event stream 2013-09-26 09:48:00 +01:00
crypto
drm Revert "drm: mark context support as a legacy subsystem" 2013-09-20 08:32:59 +10:00
dt-bindings The clock changes for 3.13 are an even mix of framework improvements & 2013-11-12 16:11:47 +09:00
keys
kvm
linux writeback: do not sync data dirtied after sync start 2013-11-13 12:09:07 +09:00
math-emu
media Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-09-05 14:54:29 -07:00
memory
misc
net ipv6: reset dst.expires value when clearing expire flag 2013-10-25 19:26:59 -04:00
pcmcia
ras
rdma
rxrpc
scsi Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2013-09-12 16:11:45 -07:00
sound Merge remote-tracking branch 'asoc/topic/twl4030' into asoc-next 2013-11-08 10:43:40 +00:00
target target/iscsi: Bump versions to v4.1.0 2013-09-10 20:23:37 -07:00
trace writeback: do not sync data dirtied after sync start 2013-11-13 12:09:07 +09:00
uapi sound updates for 3.13-rc1 2013-11-12 15:29:53 +09:00
video video: exynos_dp: remove non-DT support for Exynos Display Port 2013-10-16 13:48:09 -07:00
xen Features: 2013-09-04 17:45:39 -07:00
Kbuild