text: [PATCH 6/7] writeback: scale IO chunk size up to half device bandwidth
  From:
  Wu Fengguang
  Date:
  Sun Jun 19 2011 - 11:29:34 EST ]
  Originally, MAX_WRITEBACK_PAGES was hard-coded to 1024 because of a
  concern of not holding I_SYNC for too long. (At least, that was the
  comment previously.) This doesn't make sense now because the only
  time we wait for I_SYNC is if we are calling sync or fsync, and in
  that case we need to write out all of the data anyway. Previously
  there may have been other code paths that waited on I_SYNC, but not
  any more. -- Theodore Ts'o
  So remove the MAX_WRITEBACK_PAGES constraint. The writeback pages
  will adapt to as large as the storage device can write within 500ms.
  XFS is observed to do IO completions in a batch, and the batch size is
  equal to the write chunk size. To avoid dirty pages to suddenly drop
  out of balance_dirty_pages()'s dirty control scope and create large
  fluctuations, the chunk size is also limited to half the control scope.
  The balance_dirty_pages() control scrope is
  [(background_thresh + dirty_thresh) / 2, dirty_thresh]
  which is by default [15%, 20%] * dirty_pages, with the size
  dirty_thresh / DIRTY_FULL_SCOPE.
  The adpative write chunk size will be rounded to the nearest 4MB
  boundary.
  CC: Theodore Ts'o <tytso@xxxxxxx>
  CC: Dave Chinner <david@xxxxxxxxxxxxx>
  CC: Chris Mason <chris.mason@xxxxxxxxxx>
  CC: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
  Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
  ---
  fs/fs-writeback.c | 23 ++++++++++-------------
  include/linux/writeback.h | 11 +++++++++++
  2 files changed, 21 insertions(+), 13 deletions(-)
  --- linux-next.orig/include/linux/writeback.h 2011-06-16 22:17:10.000000000 +0800
  +++ linux-next/include/linux/writeback.h 2011-06-16 22:17:27)
  @@ -25,9 +29,16 @@
  * knocks down the global dirty threshold quickly, in which case the global
  * dirty limit will follow down slowly to prevent livelocking all dirtier tasks.
  */
  +#define DIRTY_SCOPE 8
  +#define DIRTY_FULL_SCOPE (DIRTY_SCOPE / 2)
  #define DIRTY_MAXPAUSE 16
  #define DIRTY_PASSGOOD 8
  +/*
  + * 4MB minimal write chunk size
  + */
  +#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_CACHE_SHIFT - 10))
  +
  struct backing_dev_info;
  /*
  --- linux-next.orig/fs/fs-writeback.c 2011-06-16 22:17:10.000000000 +0800
  +++ linux-next/fs/fs-writeback.c 2011-06-16 22:17:11.000000000 +0800
  @@ -30,15 +30,6 @@
  #include "internal.h"
  /*
  - *L
  -
  -/*
  *;
  --
  To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
  the body of a message to majordomo@xxxxxxxxxxxxxxx
  More majordomo info at
  Please read the FAQ at ]