[PATCH v8 5/7] fsdax: Dedup file range to use a compare function

2021-08-29 Thread Shiyang Ruan
With dax we cannot deal with readpage() etc. So, we create a dax comparison function which is similar with vfs_dedupe_file_range_compare(). And introduce dax_remap_file_range_prep() for filesystem use. Signed-off-by: Goldwyn Rodrigues Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong

[PATCH v8 6/7] xfs: support CoW in fsdax mode

2021-08-29 Thread Shiyang Ruan
In fsdax mode, WRITE and ZERO on a shared extent need CoW performed. After that, new allocated extents needs to be remapped to the file. Add an implementation of ->iomap_end() for dax write ops to do the remapping work. Signed-off-by: Shiyang Ruan --- fs/dax.c | 39

[PATCH v8 4/7] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero

2021-08-29 Thread Shiyang Ruan
Punch hole on a reflinked file needs dax_iomap_cow_copy() too. Otherwise, data in not aligned area will be not correct. So, add the srcmap to dax_iomap_zero() and replace memset() as dax_iomap_cow_copy(). Signed-off-by: Shiyang Ruan Reviewed-by: Ritesh Harjani Reviewed-by: Darrick J. Wong ---

[PATCH v8 3/7] fsdax: Replace mmap entry in case of CoW

2021-08-29 Thread Shiyang Ruan
We replace the existing entry to the newly allocated one in case of CoW. Also, we mark the entry as PAGECACHE_TAG_TOWRITE so writeback marks this entry as writeprotected. This helps us snapshots so new write pagefaults after snapshots trigger a CoW. Signed-off-by: Goldwyn Rodrigues

[PATCH v8 0/7] fsdax,xfs: Add reflink support for fsdax

2021-08-29 Thread Shiyang Ruan
This patchset is attempt to add CoW support for fsdax, and take XFS, which has both reflink and fsdax feature, as an example. Changes from V7: - Patch 3: Update to iter model[1] - Patch 4: Add the missing memset() in CoW case - Remove iomap_iter2(), use 2 nested iomap_iter() instead - Patch

[PATCH v8 2/7] fsdax: Introduce dax_iomap_cow_copy()

2021-08-29 Thread Shiyang Ruan
In the case where the iomap is a write operation and iomap is not equal to srcmap after iomap_begin, we consider it is a CoW operation. In this case, the destination (iomap->addr) points to a newly allocated extent. It is needed to copy the data from srcmap to the extent. In theory, it is

[PATCH v8 1/7] fsdax: Output address in dax_iomap_pfn() and rename it

2021-08-29 Thread Shiyang Ruan
Add address output in dax_iomap_pfn() in order to perform a memcpy() in CoW case. Since this function both output address and pfn, rename it to dax_iomap_direct_access(). Signed-off-by: Shiyang Ruan Reviewed-by: Christoph Hellwig Reviewed-by: Ritesh Harjani Reviewed-by: Dan Williams ---

[PATCH v8 7/7] xfs: Add dax dedupe support

2021-08-29 Thread Shiyang Ruan
Introduce xfs_mmaplock_two_inodes_and_break_dax_layout() for dax files who are going to be deduped. After that, call compare range function only when files are both DAX or not. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_file.c| 2 +- fs/xfs/xfs_inode.c | 57