xfs: only remap the written blocks in xfs_reflink_end_cow_extent
[platform/kernel/linux-starfive.git] / fs / xfs / xfs_reflink.c
index eb91024..e5b62dc 100644 (file)
@@ -784,6 +784,7 @@ xfs_reflink_end_cow_extent(
                }
        }
        del = got;
+       xfs_trim_extent(&del, *offset_fsb, end_fsb - *offset_fsb);
 
        /* Grab the corresponding mapping in the data fork. */
        nmaps = 1;
@@ -1540,6 +1541,10 @@ xfs_reflink_remap_prep(
        if (ret)
                goto out_unlock;
 
+       xfs_iflags_set(src, XFS_IREMAPPING);
+       if (inode_in != inode_out)
+               xfs_ilock_demote(src, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL);
+
        return 0;
 out_unlock:
        xfs_iunlock2_io_mmap(src, dest);