]> git.baikalelectronics.ru Git - kernel.git/commit
writeback: Avoid iput() from flusher thread
authorJan Kara <jack@suse.cz>
Thu, 3 May 2012 12:48:03 +0000 (14:48 +0200)
committerFengguang Wu <fengguang.wu@intel.com>
Sun, 6 May 2012 05:43:41 +0000 (13:43 +0800)
commitf360838f579bec65058222f173277142e4cf58ac
tree513136e110970da388680947c225ef8ca05a6dd7
parent1c20d6230523b61ee6dcf90bebb5cb9611e33e89
writeback: Avoid iput() from flusher thread

Doing iput() from flusher thread (writeback_sb_inodes()) can create problems
because iput() can do a lot of work - for example truncate the inode if it's
the last iput on unlinked file. Some filesystems depend on flusher thread
progressing (e.g. because they need to flush delay allocated blocks to reduce
allocation uncertainty) and so flusher thread doing truncate creates
interesting dependencies and possibilities for deadlocks.

We get rid of iput() in flusher thread by using the fact that I_SYNC inode
flag effectively pins the inode in memory. So if we take care to either hold
i_lock or have I_SYNC set, we can get away without taking inode reference
in writeback_sb_inodes().

As a side effect of these changes, we also fix possible use-after-free in
wb_writeback() because inode_wait_for_writeback() call could try to reacquire
i_lock on the inode that was already free.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
fs/fs-writeback.c
fs/inode.c
include/linux/fs.h
include/linux/writeback.h