ext4: wait for outstanding dio during truncate in nojournal mode
authorJan Kara <jack@suse.cz>
Fri, 24 May 2019 03:07:08 +0000 (23:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 May 2019 13:46:00 +0000 (06:46 -0700)
commit5220582c427bb377c8c4b28ed911f545e7da859d
treedcdd9cab37becfe9a42b166c269f92075a4d8df6
parent71e430fd593b2627baaa67e808ff27131b1418e0
ext4: wait for outstanding dio during truncate in nojournal mode

commit 82a25b027ca48d7ef197295846b352345853dfa8 upstream.

We didn't wait for outstanding direct IO during truncate in nojournal
mode (as we skip orphan handling in that case). This can lead to fs
corruption or stale data exposure if truncate ends up freeing blocks
and these get reallocated before direct IO finishes. Fix the condition
determining whether the wait is necessary.

CC: stable@vger.kernel.org
Fixes: 1c9114f9c0f1 ("ext4: serialize unlocked dio reads with truncate")
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/inode.c