Skip to content

Commit 1eb6fc0

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: split write fault handling out of __xfs_filemap_fault
Only two of the callers of __xfs_filemap_fault every handle read faults. Split the write_fault handling out of __xfs_filemap_fault so that all callers call that directly either conditionally or unconditionally and only leave the read fault handling in __xfs_filemap_fault. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 1171de3 commit 1eb6fc0

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

fs/xfs/xfs_file.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,16 @@ xfs_dax_read_fault(
14341434
return ret;
14351435
}
14361436

1437+
/*
1438+
* Locking for serialisation of IO during page faults. This results in a lock
1439+
* ordering of:
1440+
*
1441+
* mmap_lock (MM)
1442+
* sb_start_pagefault(vfs, freeze)
1443+
* invalidate_lock (vfs/XFS_MMAPLOCK - truncate serialisation)
1444+
* page_lock (MM)
1445+
* i_lock (XFS - extent map serialisation)
1446+
*/
14371447
static vm_fault_t
14381448
xfs_write_fault(
14391449
struct vm_fault *vmf,
@@ -1471,26 +1481,13 @@ xfs_write_fault(
14711481
return ret;
14721482
}
14731483

1474-
/*
1475-
* Locking for serialisation of IO during page faults. This results in a lock
1476-
* ordering of:
1477-
*
1478-
* mmap_lock (MM)
1479-
* sb_start_pagefault(vfs, freeze)
1480-
* invalidate_lock (vfs/XFS_MMAPLOCK - truncate serialisation)
1481-
* page_lock (MM)
1482-
* i_lock (XFS - extent map serialisation)
1483-
*/
14841484
static vm_fault_t
14851485
__xfs_filemap_fault(
14861486
struct vm_fault *vmf,
1487-
unsigned int order,
1488-
bool write_fault)
1487+
unsigned int order)
14891488
{
14901489
struct inode *inode = file_inode(vmf->vma->vm_file);
14911490

1492-
if (write_fault)
1493-
return xfs_write_fault(vmf, order);
14941491
if (IS_DAX(inode))
14951492
return xfs_dax_read_fault(vmf, order);
14961493

@@ -1511,9 +1508,9 @@ xfs_filemap_fault(
15111508
struct vm_fault *vmf)
15121509
{
15131510
/* DAX can shortcut the normal fault path on write faults! */
1514-
return __xfs_filemap_fault(vmf, 0,
1515-
IS_DAX(file_inode(vmf->vma->vm_file)) &&
1516-
xfs_is_write_fault(vmf));
1511+
if (IS_DAX(file_inode(vmf->vma->vm_file)) && xfs_is_write_fault(vmf))
1512+
return xfs_write_fault(vmf, 0);
1513+
return __xfs_filemap_fault(vmf, 0);
15171514
}
15181515

15191516
static vm_fault_t
@@ -1525,15 +1522,16 @@ xfs_filemap_huge_fault(
15251522
return VM_FAULT_FALLBACK;
15261523

15271524
/* DAX can shortcut the normal fault path on write faults! */
1528-
return __xfs_filemap_fault(vmf, order,
1529-
xfs_is_write_fault(vmf));
1525+
if (xfs_is_write_fault(vmf))
1526+
return xfs_write_fault(vmf, order);
1527+
return __xfs_filemap_fault(vmf, order);
15301528
}
15311529

15321530
static vm_fault_t
15331531
xfs_filemap_page_mkwrite(
15341532
struct vm_fault *vmf)
15351533
{
1536-
return __xfs_filemap_fault(vmf, 0, true);
1534+
return xfs_write_fault(vmf, 0);
15371535
}
15381536

15391537
/*
@@ -1545,8 +1543,7 @@ static vm_fault_t
15451543
xfs_filemap_pfn_mkwrite(
15461544
struct vm_fault *vmf)
15471545
{
1548-
1549-
return __xfs_filemap_fault(vmf, 0, true);
1546+
return xfs_write_fault(vmf, 0);
15501547
}
15511548

15521549
static const struct vm_operations_struct xfs_file_vm_ops = {

0 commit comments

Comments
 (0)