Re: [PATCH v7 4/8] fsdax: Add dax_iomap_cow_copy() for dax_iomap_zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2021/8/20 10:39, Dan Williams wrote:
On Sun, Aug 15, 2021 at 11:04 PM Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx> wrote:

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 <ruansy.fnst@xxxxxxxxxxx>
Reviewed-by: Ritesh Harjani <riteshh@xxxxxxxxxxxxx>
Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
  fs/dax.c               | 25 +++++++++++++++----------
  fs/iomap/buffered-io.c |  4 ++--
  include/linux/dax.h    |  3 ++-
  3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index e49ba68cc7e4..91ceb518f66a 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1198,7 +1198,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,
  }
  #endif /* CONFIG_FS_DAX_PMD */

-s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap)
+s64 dax_iomap_zero(loff_t pos, u64 length, const struct iomap *iomap,
+               const struct iomap *srcmap)
  {
         sector_t sector = iomap_sector(iomap, pos & PAGE_MASK);
         pgoff_t pgoff;
@@ -1220,19 +1221,23 @@ s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap)

         if (page_aligned)
                 rc = dax_zero_page_range(iomap->dax_dev, pgoff, 1);
-       else
+       else {
                 rc = dax_direct_access(iomap->dax_dev, pgoff, 1, &kaddr, NULL);
-       if (rc < 0) {
-               dax_read_unlock(id);
-               return rc;
-       }
-
-       if (!page_aligned) {
-               memset(kaddr + offset, 0, size);
+               if (rc < 0)
+                       goto out;
+               if (iomap->addr != srcmap->addr) {
+                       rc = dax_iomap_cow_copy(pos, size, PAGE_SIZE, srcmap,
+                                               kaddr);

Apologies, I'm confused, why is it ok to skip zeroing here?


That was a mistake.  Will be fixed in next version.


--
Thanks,
Ruan.





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux