Commit e28cd3e5 authored by Shiyang Ruan's avatar Shiyang Ruan Committed by akpm

fsdax: output address in dax_iomap_pfn() and rename it

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().

[ruansy.fnst@fujitsu.com: initialize `rc', per Dan]
  Link: https://lore.kernel.org/linux-fsdevel/Yp8FUZnO64Qvyx5G@kili/
  Link: https://lkml.kernel.org/r/20220607143837.161174-1-ruansy.fnst@fujitsu.com
Link: https://lkml.kernel.org/r/20220603053738.1218681-9-ruansy.fnst@fujitsu.comSigned-off-by: default avatarShiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dan Williams <dan.j.wiliams@intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 6061b69b
...@@ -1026,20 +1026,22 @@ int dax_writeback_mapping_range(struct address_space *mapping, ...@@ -1026,20 +1026,22 @@ int dax_writeback_mapping_range(struct address_space *mapping,
} }
EXPORT_SYMBOL_GPL(dax_writeback_mapping_range); EXPORT_SYMBOL_GPL(dax_writeback_mapping_range);
static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, static int dax_iomap_direct_access(const struct iomap *iomap, loff_t pos,
pfn_t *pfnp) size_t size, void **kaddr, pfn_t *pfnp)
{ {
pgoff_t pgoff = dax_iomap_pgoff(iomap, pos); pgoff_t pgoff = dax_iomap_pgoff(iomap, pos);
int id, rc; int id, rc = 0;
long length; long length;
id = dax_read_lock(); id = dax_read_lock();
length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size),
DAX_ACCESS, NULL, pfnp); DAX_ACCESS, kaddr, pfnp);
if (length < 0) { if (length < 0) {
rc = length; rc = length;
goto out; goto out;
} }
if (!pfnp)
goto out_check_addr;
rc = -EINVAL; rc = -EINVAL;
if (PFN_PHYS(length) < size) if (PFN_PHYS(length) < size)
goto out; goto out;
...@@ -1049,6 +1051,12 @@ static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, ...@@ -1049,6 +1051,12 @@ static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size,
if (length > 1 && !pfn_t_devmap(*pfnp)) if (length > 1 && !pfn_t_devmap(*pfnp))
goto out; goto out;
rc = 0; rc = 0;
out_check_addr:
if (!kaddr)
goto out;
if (!*kaddr)
rc = -EFAULT;
out: out:
dax_read_unlock(id); dax_read_unlock(id);
return rc; return rc;
...@@ -1456,7 +1464,7 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf, ...@@ -1456,7 +1464,7 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf,
return pmd ? VM_FAULT_FALLBACK : VM_FAULT_SIGBUS; return pmd ? VM_FAULT_FALLBACK : VM_FAULT_SIGBUS;
} }
err = dax_iomap_pfn(&iter->iomap, pos, size, &pfn); err = dax_iomap_direct_access(&iter->iomap, pos, size, NULL, &pfn);
if (err) if (err)
return pmd ? VM_FAULT_FALLBACK : dax_fault_return(err); return pmd ? VM_FAULT_FALLBACK : dax_fault_return(err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment