From: Goldwyn Rodrigues <rgold...@suse.com>

Set the IOMAP_F_COW flag and create the srcmap based on
current extents to read from.

Signed-off-by: Goldwyn Rodrigues <rgold...@suse.com>
---
 fs/xfs/xfs_iomap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 8321733c16c3..13495d8a1ee2 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1006,7 +1006,10 @@ xfs_file_iomap_begin(
                 */
                if (directio || imap.br_startblock == HOLESTARTBLOCK)
                        imap = cmap;
+               else
+                       xfs_bmbt_to_iomap(ip, srcmap, &cmap, false);
 
+               iomap->flags |= IOMAP_F_COW;
                end_fsb = imap.br_startoff + imap.br_blockcount;
                length = XFS_FSB_TO_B(mp, end_fsb) - offset;
        }
-- 
2.16.4

Reply via email to