[PATCH v10 0/8] fsdax,xfs: Add reflink&dedupe support for fsdax

2021-09-27 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 V9: - Rebased on v5.15-rc3 - Patch 3: Fix build error when CONFIG_FS_DAX_PMD not set - Patch 4: Add 'const' prefix for iomap_iter - Patch 7: Introduce xfs_

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

2021-09-27 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 Reviewed-

[PATCH v10 2/8] fsdax: Introduce dax_iomap_cow_copy()

2021-09-27 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 better

[PATCH v10 3/8] fsdax: Replace mmap entry in case of CoW

2021-09-27 Thread Shiyang Ruan
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 Signed-off-by: S

[PATCH v10 4/8] fsdax: Convert dax_iomap_zero to iter model

2021-09-27 Thread Shiyang Ruan
Let dax_iomap_zero() support iter model. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/dax.c | 3 ++- fs/iomap/buffered-io.c | 3 +-- include/linux/dax.h| 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs

[PATCH v10 5/8] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero

2021-09-27 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 CoW operation for not aligned case in dax_iomap_zero(). Signed-off-by: Shiyang Ruan Reviewed-by: Ritesh Harjani Reviewed-by: Darrick J. Wong Reviewed-by: Christop

[PATCH v10 6/8] fsdax: Dedup file range to use a compare function

2021-09-27 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 Rev

[PATCH v10 7/8] xfs: support CoW in fsdax mode

2021-09-27 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. So, add a CoW identification in ->iomap_begin(), and implement ->iomap_end() to do the remapping work. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_bmap_util.c |

[PATCH v10 8/8] xfs: Add dax dedupe support

2021-09-27 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 Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_file.c|