Skip to content

Commit 9a0dd42

Browse files
jankaradjbw
authored andcommitted
dax: Allow dax_iomap_fault() to return pfn
For synchronous page fault dax_iomap_fault() will need to return PFN which will then need to be inserted into page tables after fsync() completes. Add necessary parameter to dax_iomap_fault(). Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent cec04e8 commit 9a0dd42

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

fs/dax.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ static int dax_fault_return(int error)
10791079
return VM_FAULT_SIGBUS;
10801080
}
10811081

1082-
static int dax_iomap_pte_fault(struct vm_fault *vmf,
1082+
static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp,
10831083
const struct iomap_ops *ops)
10841084
{
10851085
struct vm_area_struct *vma = vmf->vma;
@@ -1280,7 +1280,7 @@ static int dax_pmd_load_hole(struct vm_fault *vmf, struct iomap *iomap,
12801280
return VM_FAULT_FALLBACK;
12811281
}
12821282

1283-
static int dax_iomap_pmd_fault(struct vm_fault *vmf,
1283+
static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp,
12841284
const struct iomap_ops *ops)
12851285
{
12861286
struct vm_area_struct *vma = vmf->vma;
@@ -1425,7 +1425,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
14251425
return result;
14261426
}
14271427
#else
1428-
static int dax_iomap_pmd_fault(struct vm_fault *vmf,
1428+
static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp,
14291429
const struct iomap_ops *ops)
14301430
{
14311431
return VM_FAULT_FALLBACK;
@@ -1436,6 +1436,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
14361436
* dax_iomap_fault - handle a page fault on a DAX file
14371437
* @vmf: The description of the fault
14381438
* @pe_size: Size of the page to fault in
1439+
* @pfnp: PFN to insert for synchronous faults if fsync is required
14391440
* @ops: Iomap ops passed from the file system
14401441
*
14411442
* When a page fault occurs, filesystems may call this helper in
@@ -1444,13 +1445,13 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
14441445
* successfully.
14451446
*/
14461447
int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
1447-
const struct iomap_ops *ops)
1448+
pfn_t *pfnp, const struct iomap_ops *ops)
14481449
{
14491450
switch (pe_size) {
14501451
case PE_SIZE_PTE:
1451-
return dax_iomap_pte_fault(vmf, ops);
1452+
return dax_iomap_pte_fault(vmf, pfnp, ops);
14521453
case PE_SIZE_PMD:
1453-
return dax_iomap_pmd_fault(vmf, ops);
1454+
return dax_iomap_pmd_fault(vmf, pfnp, ops);
14541455
default:
14551456
return VM_FAULT_FALLBACK;
14561457
}

fs/ext2/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int ext2_dax_fault(struct vm_fault *vmf)
9999
}
100100
down_read(&ei->dax_sem);
101101

102-
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, &ext2_iomap_ops);
102+
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, &ext2_iomap_ops);
103103

104104
up_read(&ei->dax_sem);
105105
if (vmf->flags & FAULT_FLAG_WRITE)

fs/ext4/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
306306
down_read(&EXT4_I(inode)->i_mmap_sem);
307307
}
308308
if (!IS_ERR(handle))
309-
result = dax_iomap_fault(vmf, pe_size, &ext4_iomap_ops);
309+
result = dax_iomap_fault(vmf, pe_size, NULL, &ext4_iomap_ops);
310310
else
311311
result = VM_FAULT_SIGBUS;
312312
if (write) {

fs/xfs/xfs_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ __xfs_filemap_fault(
10401040

10411041
xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED);
10421042
if (IS_DAX(inode)) {
1043-
ret = dax_iomap_fault(vmf, pe_size, &xfs_iomap_ops);
1043+
ret = dax_iomap_fault(vmf, pe_size, NULL, &xfs_iomap_ops);
10441044
} else {
10451045
if (write_fault)
10461046
ret = iomap_page_mkwrite(vmf, &xfs_iomap_ops);
@@ -1111,7 +1111,7 @@ xfs_filemap_pfn_mkwrite(
11111111
if (vmf->pgoff >= size)
11121112
ret = VM_FAULT_SIGBUS;
11131113
else if (IS_DAX(inode))
1114-
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, &xfs_iomap_ops);
1114+
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, &xfs_iomap_ops);
11151115
xfs_iunlock(ip, XFS_MMAPLOCK_SHARED);
11161116
sb_end_pagefault(inode->i_sb);
11171117
return ret;

include/linux/dax.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ bool dax_write_cache_enabled(struct dax_device *dax_dev);
9595
ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
9696
const struct iomap_ops *ops);
9797
int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
98-
const struct iomap_ops *ops);
98+
pfn_t *pfnp, const struct iomap_ops *ops);
9999
int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index);
100100
int dax_invalidate_mapping_entry_sync(struct address_space *mapping,
101101
pgoff_t index);

0 commit comments

Comments
 (0)