Skip to content

Commit 7b565c9

Browse files
jankaradjbw
authored andcommitted
xfs: Implement xfs_filemap_pfn_mkwrite() using __xfs_filemap_fault()
xfs_filemap_pfn_mkwrite() duplicates a lot of __xfs_filemap_fault(). It will also need to handle flushing for synchronous page faults. So just make that function use __xfs_filemap_fault(). Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent b8a6176 commit 7b565c9

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

fs/xfs/xfs_file.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,37 +1085,16 @@ xfs_filemap_page_mkwrite(
10851085
}
10861086

10871087
/*
1088-
* pfn_mkwrite was originally inteneded to ensure we capture time stamp
1089-
* updates on write faults. In reality, it's need to serialise against
1090-
* truncate similar to page_mkwrite. Hence we cycle the XFS_MMAPLOCK_SHARED
1091-
* to ensure we serialise the fault barrier in place.
1088+
* pfn_mkwrite was originally intended to ensure we capture time stamp updates
1089+
* on write faults. In reality, it needs to serialise against truncate and
1090+
* prepare memory for writing so handle is as standard write fault.
10921091
*/
10931092
static int
10941093
xfs_filemap_pfn_mkwrite(
10951094
struct vm_fault *vmf)
10961095
{
10971096

1098-
struct inode *inode = file_inode(vmf->vma->vm_file);
1099-
struct xfs_inode *ip = XFS_I(inode);
1100-
int ret = VM_FAULT_NOPAGE;
1101-
loff_t size;
1102-
1103-
trace_xfs_filemap_pfn_mkwrite(ip);
1104-
1105-
sb_start_pagefault(inode->i_sb);
1106-
file_update_time(vmf->vma->vm_file);
1107-
1108-
/* check if the faulting page hasn't raced with truncate */
1109-
xfs_ilock(ip, XFS_MMAPLOCK_SHARED);
1110-
size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
1111-
if (vmf->pgoff >= size)
1112-
ret = VM_FAULT_SIGBUS;
1113-
else if (IS_DAX(inode))
1114-
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, &xfs_iomap_ops);
1115-
xfs_iunlock(ip, XFS_MMAPLOCK_SHARED);
1116-
sb_end_pagefault(inode->i_sb);
1117-
return ret;
1118-
1097+
return __xfs_filemap_fault(vmf, PE_SIZE_PTE, true);
11191098
}
11201099

11211100
static const struct vm_operations_struct xfs_file_vm_ops = {

fs/xfs/xfs_trace.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,6 @@ DEFINE_INODE_EVENT(xfs_inode_set_cowblocks_tag);
688688
DEFINE_INODE_EVENT(xfs_inode_clear_cowblocks_tag);
689689
DEFINE_INODE_EVENT(xfs_inode_free_cowblocks_invalid);
690690

691-
DEFINE_INODE_EVENT(xfs_filemap_pfn_mkwrite);
692-
693691
TRACE_EVENT(xfs_filemap_fault,
694692
TP_PROTO(struct xfs_inode *ip, enum page_entry_size pe_size,
695693
bool write_fault),

0 commit comments

Comments
 (0)