linux/fs
Jan Kara 169ebd9013 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>
2012-05-06 13:43:41 +08:00
..
9p vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
adfs switch open-coded instances of d_make_root() to new helper 2012-03-20 21:29:35 -04:00
affs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
afs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
autofs4 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
befs switch open-coded instances of d_make_root() to new helper 2012-03-20 21:29:35 -04:00
bfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
btrfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
cachefiles switch touch_atime to struct path 2012-03-20 21:29:41 -04:00
ceph Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client 2012-03-28 10:01:29 -07:00
cifs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
coda vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
configfs make configfs_pin_fs() return root dentry on success 2012-03-20 21:29:48 -04:00
cramfs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
debugfs simple_open: automatically convert to simple_open() 2012-04-05 15:25:50 -07:00
devpts Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
dlm simple_open: automatically convert to simple_open() 2012-04-05 15:25:50 -07:00
ecryptfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
efs switch open-coded instances of d_make_root() to new helper 2012-03-20 21:29:35 -04:00
exofs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
exportfs
ext2 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
ext3 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
ext4 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
fat vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
freevxfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
fscache
fuse vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
gfs2 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
hfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
hfsplus vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
hostfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
hpfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
hppfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
hugetlbfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
isofs switch open-coded instances of d_make_root() to new helper 2012-03-20 21:29:35 -04:00
jbd Power management updates for 3.4 2012-03-21 10:15:51 -07:00
jbd2 Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
jffs2 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
jfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
lockd Merge nfs containerization work from Trond's tree 2012-03-26 11:48:54 -04:00
logfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
minix vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
ncpfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
nfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
nfs_common
nfsd Merge branch 'for-3.4' of git://linux-nfs.org/~bfields/linux 2012-03-29 14:53:25 -07:00
nilfs2 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
nls
notify fs/notify/notification.c: make subsys_initcall function static 2012-03-23 16:58:31 -07:00
ntfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
ocfs2 vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
omfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
openpromfs switch open-coded instances of d_make_root() to new helper 2012-03-20 21:29:35 -04:00
proc vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
pstore vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
qnx4 qnx4: new helper - try_extent() 2012-03-20 21:29:52 -04:00
qnx6 fs: initial qnx6fs addition 2012-03-20 21:29:38 -04:00
quota Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs 2012-03-28 10:00:14 -07:00
ramfs tidy up after d_make_root() conversion 2012-03-20 21:29:37 -04:00
reiserfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
romfs MTD merge for 3.4 2012-03-30 17:31:56 -07:00
squashfs Add an extra mount time sanity check, plus some code cleanups and bug fixes. 2012-03-28 18:05:54 -07:00
sysfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
sysv vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
ubifs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
udf vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
ufs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
xfs vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
aio.c aio: take final put_ioctx() into callers of io_destroy() 2012-03-31 16:03:15 -04:00
anon_inodes.c anon_inodes: move allocation of anon_inode into ->mount() 2012-03-20 21:29:45 -04:00
attr.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
bad_inode.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
binfmt_aout.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
binfmt_elf.c Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
binfmt_elf_fdpic.c Add #includes needed to permit the removal of asm/system.h 2012-03-28 18:30:03 +01:00
binfmt_em86.c __register_binfmt() made void 2012-03-20 21:29:46 -04:00
binfmt_flat.c Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
binfmt_misc.c vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
binfmt_script.c __register_binfmt() made void 2012-03-20 21:29:46 -04:00
binfmt_som.c take removal of PF_FORKNOEXEC to flush_old_exec() 2012-03-20 21:29:51 -04:00
bio-integrity.c fs: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:21 +08:00
bio.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
block_dev.c vfs: Rename end_writeback() to clear_inode() 2012-05-06 13:43:41 +08:00
buffer.c fs: only send IPI to invalidate LRU BH when needed 2012-03-28 17:14:35 -07:00
char_dev.c
compat.c Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
compat_binfmt_elf.c
compat_ioctl.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
dcache.c vfs: fix d_ancestor() case in d_materialize_unique 2012-03-28 09:54:34 -07:00
dcookies.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
direct-io.c Restore direct_io / truncate locking API 2012-02-23 15:56:21 -08:00
drop_caches.c
eventfd.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
eventpoll.c Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
exec.c Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-04-04 10:04:42 -07:00
fcntl.c Wrap accesses to the fd_sets in struct fdtable 2012-02-19 10:30:52 -08:00
fhandle.c
fifo.c
file.c Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
file_table.c vfs: drop_file_write_access() made static 2012-03-20 21:29:32 -04:00
filesystems.c
fs-writeback.c writeback: Avoid iput() from flusher thread 2012-05-06 13:43:41 +08:00
fs_struct.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
generic_acl.c
inode.c writeback: Avoid iput() from flusher thread 2012-05-06 13:43:41 +08:00
internal.h
ioctl.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
ioprio.c block: strip out locking optimization in put_io_context() 2012-02-07 07:51:30 +01:00
Kconfig Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
Kconfig.binfmt fs: binfmt_elf: create Kconfig variable for PIE randomization 2012-01-10 16:30:51 -08:00
libfs.c dentry leak in simple_fill_super() failure exit 2012-04-09 01:39:22 -04:00
locks.c CIFS: Fix VFS lock usage for oplocked files 2012-04-01 13:54:27 -05:00
Makefile fs: initial qnx6fs addition 2012-03-20 21:29:38 -04:00
mbcache.c
mount.h
mpage.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
namei.c Make the "word-at-a-time" helper functions more commonly usable 2012-04-06 13:54:56 -07:00
namespace.c
no-block.c
open.c Wrap accesses to the fd_sets in struct fdtable 2012-02-19 10:30:52 -08:00
pipe.c magic.h: move some FS magic numbers into magic.h 2012-03-23 16:58:31 -07:00
pnode.c
pnode.h
posix_acl.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
proc_namespace.c
read_write.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
read_write.h
readdir.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
select.c Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-29 18:12:23 -07:00
seq_file.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
signalfd.c epoll: ep_unregister_pollwait() can use the freed pwq->whead 2012-02-24 11:42:50 -08:00
splice.c tcp: tcp_sendpages() should call tcp_push() once 2012-04-05 19:04:27 -04:00
stack.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
stat.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
statfs.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
super.c The following text was taken from the original review request: 2012-03-24 10:24:31 -07:00
sync.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00
timerfd.c
utimes.c
xattr.c fs/xattr.c:setxattr(): improve handling of allocation failures 2012-04-05 15:25:50 -07:00
xattr_acl.c fs: reduce the use of module.h wherever possible 2012-02-28 19:31:58 -05:00