Skip to contentSkip to conversation

xfs: only flush the unshared range in xfs_reflink_unshare

PATCH In review Darrick J. Wong 2 participants 2 messages Nov 3, 2020 – Nov 4, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: only flush the unshared range in xfs_reflink_unshare

From: Darrick J. Wong <[email protected]>

There's no reason to flush an entire file when we're unsharing part of a file. Therefore, only initiate writeback on the selected range.

---
 fs/xfs/xfs_reflink.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_reflink.c +2 -1
index 16098dc42add..6fa05fb78189 100644
@@ -1502,7 +1502,8 @@ xfs_reflink_unshare(
 			&xfs_buffered_write_iomap_ops);
 	if (error)
 		goto out;
-	error = filemap_write_and_wait(inode->i_mapping);
+
+	error = filemap_write_and_wait_range(inode->i_mapping, offset, len);
 	if (error)
 		goto out;
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · IST Darrick J. Wong

From: Darrick J. Wong <[email protected]>

There's no reason to flush an entire file when we're unsharing part of a file. Therefore, only initiate writeback on the selected range.

Looks good to me.

Quoted 20 lines
---
 fs/xfs/xfs_reflink.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_reflink.c +2 -1
index 16098dc42add..6fa05fb78189 100644
@@ -1502,7 +1502,8 @@ xfs_reflink_unshare(
 			&xfs_buffered_write_iomap_ops);
 	if (error)
 		goto out;
-	error = filemap_write_and_wait(inode->i_mapping);
+
+	error = filemap_write_and_wait_range(inode->i_mapping, offset, len);
 	if (error)
 		goto out;
 
Signature · 1 line
chandan