vfs: re-implement writeback_inodes_sb(_nr)_if_idle() and rename them
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 10 Jan 2013 05:47:57 +0000 (13:47 +0800)
committerFengguang Wu <fengguang.wu@intel.com>
Sat, 12 Jan 2013 02:47:43 +0000 (10:47 +0800)
commit10ee27a06cc8eb57f83342a8eabcb75deb872d52
treed14f69011b7aa1896f1aef37cb2b64f868bce459
parent9931faca02c604c22335f5a935a501bb2ace6e20
vfs: re-implement writeback_inodes_sb(_nr)_if_idle() and rename them

writeback_inodes_sb(_nr)_if_idle() is re-implemented by replacing down_read()
with down_read_trylock() because

- If ->s_umount is write locked, then the sb is not idle. That is
  writeback_inodes_sb(_nr)_if_idle() needn't wait for the lock.

- writeback_inodes_sb(_nr)_if_idle() grabs s_umount lock when it want to start
  writeback, it may bring us deadlock problem when doing umount. In order to
  fix the problem, ext4 and btrfs implemented their own writeback functions
  instead of writeback_inodes_sb(_nr)_if_idle(), but it introduced the redundant
  code, it is better to implement a new writeback_inodes_sb(_nr)_if_idle().

The name of these two functions is cumbersome, so rename them to
try_to_writeback_inodes_sb(_nr).

This idea came from Christoph Hellwig.
Some code is from the patch of Kamal Mostafa.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
fs/btrfs/extent-tree.c
fs/ext4/inode.c
fs/fs-writeback.c
include/linux/writeback.h