Re: [f2fs-dev] [PATCH 0/14 v10] fs: Hole punch vs page cache filling races

2021-07-15 Thread Christoph Hellwig
On Thu, Jul 15, 2021 at 03:40:10PM +0200, Jan Kara wrote: > Hello, > > here is another version of my patches to address races between hole punching > and page cache filling functions for ext4 and other filesystems. The only > change since the last time is a small cleanup applied to changes of > fi

[f2fs-dev] [PATCH 09/14] xfs: Convert double locking of MMAPLOCK to use VFS helpers

2021-07-15 Thread Jan Kara
Convert places in XFS that take MMAPLOCK for two inodes to use helper VFS provides for it (filemap_invalidate_down_write_two()). Note that this changes lock ordering for MMAPLOCK from inode number based ordering to pointer based ordering VFS generally uses. CC: "Darrick J. Wong" Reviewed-by: Darr

[f2fs-dev] [PATCH 06/14] ext2: Convert to using invalidate_lock

2021-07-15 Thread Jan Kara
Ext2 has its private dax_sem used for synchronizing page faults and truncation. Use mapping->invalidate_lock instead as it is meant for this purpose. CC: Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/ext2/ext2.h | 11 --- fs/ext2/file.c | 7 +++ fs/ext2/inode.c |

[f2fs-dev] [PATCH 05/14] ext4: Convert to use mapping->invalidate_lock

2021-07-15 Thread Jan Kara
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: CC: Ted Tso Acke

[f2fs-dev] [PATCH 11/14] f2fs: Convert to using invalidate_lock

2021-07-15 Thread Jan Kara
Use invalidate_lock instead of f2fs' private i_mmap_sem. The intended purpose is exactly the same. 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: Jaegeuk Kim CC: Chao Yu CC: linux-f2fs-devel@li

[f2fs-dev] [PATCH 10/14] zonefs: Convert to using invalidate_lock

2021-07-15 Thread Jan Kara
Use invalidate_lock instead of zonefs' private i_mmap_sem. The intended purpose is exactly the same. CC: Damien Le Moal CC: Johannes Thumshirn CC: Acked-by: Damien Le Moal Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- fs/zonefs/super.c | 23 +-- fs/zonefs/z

[f2fs-dev] [PATCH 04/14] mm: Add functions to lock invalidate_lock for two mappings

2021-07-15 Thread Jan Kara
Some operations such as reflinking blocks among files will need to lock invalidate_lock for two mappings. Add helper functions to do that. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- include/linux/fs.h | 6 ++ mm/filemap.c | 38 +++

[f2fs-dev] [PATCH 03/14] mm: Protect operations adding pages to page cache with invalidate_lock

2021-07-15 Thread Jan Kara
Currently, serializing operations such as page fault, read, or readahead against hole punching is rather difficult. The basic race scheme is like: fallocate(FALLOC_FL_PUNCH_HOLE) read / fault / .. truncate_inode_pages_range()

[f2fs-dev] [PATCH 07/14] xfs: Refactor xfs_isilocked()

2021-07-15 Thread Jan Kara
From: Pavel Reichl Introduce a new __xfs_rwsem_islocked predicate to encapsulate checking the state of a rw_semaphore, then refactor xfs_isilocked to use it. Signed-off-by: Pavel Reichl Suggested-by: Dave Chinner Suggested-by: Eric Sandeen Suggested-by: Darrick J. Wong Reviewed-by: Christoph

[f2fs-dev] [PATCH 08/14] xfs: Convert to use invalidate_lock

2021-07-15 Thread Jan Kara
Use invalidate_lock instead of XFS internal i_mmap_lock. The intended purpose of invalidate_lock is exactly the same. Note that the locking in __xfs_filemap_fault() slightly changes as filemap_fault() already takes invalidate_lock. Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong CC:

[f2fs-dev] [PATCH 0/14 v10] fs: Hole punch vs page cache filling races

2021-07-15 Thread Jan Kara
Hello, here is another version of my patches to address races between hole punching and page cache filling functions for ext4 and other filesystems. The only change since the last time is a small cleanup applied to changes of filemap_fault() in patch 3/14 based on Christoph's & Darrick's feedback

[f2fs-dev] [PATCH 13/14] ceph: Fix race between hole punch and page fault

2021-07-15 Thread Jan Kara
Ceph has a following race between hole punching and page fault: CPU1 CPU2 ceph_fallocate() ... ceph_zero_pagecache_range() ceph_filemap_fault() faults in page in the range being

[f2fs-dev] [PATCH 12/14] fuse: Convert to using invalidate_lock

2021-07-15 Thread Jan Kara
Use invalidate_lock instead of fuse's private i_mmap_sem. The intended purpose is exactly the same. 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: Miklos Szeredi Reviewed-by: Miklos Szeredi Sig

[f2fs-dev] [PATCH 01/14] mm: Fix comments mentioning i_mutex

2021-07-15 Thread Jan Kara
inode->i_mutex has been replaced with inode->i_rwsem long ago. Fix comments still mentioning i_mutex. Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Acked-by: Hugh Dickins Signed-off-by: Jan Kara --- mm/filemap.c| 10 +- mm/madvise.c| 2 +- mm/memory-fail

[f2fs-dev] [PATCH 14/14] cifs: Fix race between hole punch and page fault

2021-07-15 Thread Jan Kara
Cifs has a following race between hole punching and page fault: CPU1CPU2 smb3_fallocate() smb3_punch_hole() truncate_pagecache_range() filemap_fault()

[f2fs-dev] [PATCH 02/14] documentation: Sync file_operations members with reality

2021-07-15 Thread Jan Kara
Sync listing of struct file_operations members with the real one in fs.h. Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- Documentation/filesystems/locking.rst | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Documentat