Skip to content

Commit abd7d65

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: IOMAP_ZERO and IOMAP_UNSHARE already hold invalidate_lock
All XFS callers of iomap_zero_range and iomap_file_unshare already hold invalidate_lock, so we can't take it again in iomap_file_buffered_write_punch_delalloc. Use the passed in flags argument to detect if we're called from a zero or unshare operation and don't take the lock again in this case. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent acfbac7 commit abd7d65

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

fs/xfs/xfs_iomap.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,10 +1239,18 @@ xfs_buffered_write_iomap_end(
12391239
if (start_byte >= end_byte)
12401240
return 0;
12411241

1242-
filemap_invalidate_lock(inode->i_mapping);
1243-
iomap_write_delalloc_release(inode, start_byte, end_byte, flags, iomap,
1244-
xfs_buffered_write_delalloc_punch);
1245-
filemap_invalidate_unlock(inode->i_mapping);
1242+
/* For zeroing operations the callers already hold invalidate_lock. */
1243+
if (flags & (IOMAP_UNSHARE | IOMAP_ZERO)) {
1244+
rwsem_assert_held_write(&inode->i_mapping->invalidate_lock);
1245+
iomap_write_delalloc_release(inode, start_byte, end_byte, flags,
1246+
iomap, xfs_buffered_write_delalloc_punch);
1247+
} else {
1248+
filemap_invalidate_lock(inode->i_mapping);
1249+
iomap_write_delalloc_release(inode, start_byte, end_byte, flags,
1250+
iomap, xfs_buffered_write_delalloc_punch);
1251+
filemap_invalidate_unlock(inode->i_mapping);
1252+
}
1253+
12461254
return 0;
12471255
}
12481256

0 commit comments

Comments
 (0)