diff options
author | Jan Kara <jack@suse.cz> | 2021-02-04 18:05:42 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2021-07-13 14:29:00 +0200 |
commit | d4f5258eae7b38c2a28d0a7b28a6d0a8c1f9fe8e (patch) | |
tree | 9878725ed6feb4691c42d900917fe89775ee8439 /fs/ext4/truncate.h | |
parent | 7506ae6a7033f617ca5fea53e356fb1f7bd98010 (diff) | |
download | linux-d4f5258eae7b38c2a28d0a7b28a6d0a8c1f9fe8e.tar.bz2 |
ext4: Convert to use mapping->invalidate_lock
Convert ext4 to use mapping->invalidate_lock instead of its private
EXT4_I(inode)->i_mmap_sem. This is mostly search-and-replace. By this
conversion we fix a long standing race between hole punching and read(2)
/ readahead(2) paths that can lead to stale page cache contents.
CC: <linux-ext4@vger.kernel.org>
CC: Ted Tso <tytso@mit.edu>
Acked-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext4/truncate.h')
-rw-r--r-- | fs/ext4/truncate.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ext4/truncate.h b/fs/ext4/truncate.h index bcbe3668c1d4..ce84aa2786c7 100644 --- a/fs/ext4/truncate.h +++ b/fs/ext4/truncate.h @@ -11,14 +11,16 @@ */ static inline void ext4_truncate_failed_write(struct inode *inode) { + struct address_space *mapping = inode->i_mapping; + /* * We don't need to call ext4_break_layouts() because the blocks we * are truncating were never visible to userspace. */ - down_write(&EXT4_I(inode)->i_mmap_sem); - truncate_inode_pages(inode->i_mapping, inode->i_size); + filemap_invalidate_lock(mapping); + truncate_inode_pages(mapping, inode->i_size); ext4_truncate(inode); - up_write(&EXT4_I(inode)->i_mmap_sem); + filemap_invalidate_unlock(mapping); } /* |