ext4: fix races between changing inode journal mode and ext4_writepages
authorDaeho Jeong <daeho.jeong@samsung.com>
Tue, 26 Apr 2016 03:22:35 +0000 (23:22 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 26 Apr 2016 03:22:35 +0000 (23:22 -0400)
commitc8585c6fcaf2011de54c3592e80a634a2b9e1a7f
tree66b440a3e710ab4b63ae20200735a594bffb74cd
parent4c54659269ecb799133758330e7ea2a6fa4c65ca
ext4: fix races between changing inode journal mode and ext4_writepages

In ext4, there is a race condition between changing inode journal mode
and ext4_writepages(). While ext4_writepages() is executed on a
non-journalled mode inode, the inode's journal mode could be enabled
by ioctl() and then, some pages dirtied after switching the journal
mode will be still exposed to ext4_writepages() in non-journaled mode.
To resolve this problem, we use fs-wide per-cpu rw semaphore by Jan
Kara's suggestion because we don't want to waste ext4_inode_info's
space for this extra rare case.

Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/ext4/ext4.h
fs/ext4/inode.c
fs/ext4/super.c
kernel/locking/percpu-rwsem.c