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)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 24 May 2019 03:07:08 +0000 (23:07 -0400)
commit82a25b027ca48d7ef197295846b352345853dfa8
tree3966300c54590f2562ce3c9453ad22bf75db62e7
parent0a944e8a6c66ca04c7afbaa17e22bf208a8b37f0
ext4: wait for outstanding dio during truncate in nojournal mode

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>
fs/ext4/inode.c