mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
xfs: take the invalidate lock while mapping a pNFS layout
xfs_fs_map_blocks() flushes the page cache under the iolock, but a write fault takes only the invalidate lock. A fault on a shared mapping can then add a delalloc extent before the range is mapped. That trips an ASSERT, or nfsd warns and refuses the layout. Take the invalidate lock with the iolock, as __xfs_file_fallocate() does. Not for stable: pNFS already leaves local writers to shared mappings unsynchronized. Suggested-by: Darrick J. Wong <djwong@kernel.org> Link: https://lore.kernel.org/r/20260519145949.GH9555@frogsfrogsfrogs Signed-off-by: Daejun Park <daejun7.park@samsung.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
29f3c1be4e
commit
23ba20ef28
|
|
@ -168,8 +168,11 @@ xfs_fs_map_blocks(
|
|||
* similar to direct I/O, except that the synchronization is much more
|
||||
* complicated. See the comment near xfs_break_leased_layouts
|
||||
* for a detailed explanation.
|
||||
*
|
||||
* Take the invalidate lock as well, so that page faults cannot add
|
||||
* delalloc extents to the range while it is being mapped.
|
||||
*/
|
||||
xfs_ilock(ip, XFS_IOLOCK_EXCL);
|
||||
xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL);
|
||||
|
||||
error = -EINVAL;
|
||||
limit = mp->m_super->s_maxbytes;
|
||||
|
|
@ -251,13 +254,13 @@ xfs_fs_map_blocks(
|
|||
if (error)
|
||||
goto out_unlock;
|
||||
}
|
||||
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
|
||||
xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL);
|
||||
|
||||
error = xfs_bmbt_to_iomap(ip, iomap, &imap, 0, 0, seq);
|
||||
*device_generation = mp->m_generation;
|
||||
return error;
|
||||
out_unlock:
|
||||
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
|
||||
xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user