On Sat, Sep 05, 2020 at 08:13:02AM -0400, Mikulas Patocka wrote: > When running in a dax mode, if the user maps a page with MAP_PRIVATE and > PROT_WRITE, the xfs filesystem would incorrectly update ctime and mtime > when the user hits a COW fault. > > This breaks building of the Linux kernel. > How to reproduce: > 1. extract the Linux kernel tree on dax-mounted xfs filesystem > 2. run make clean > 3. run make -j12 > 4. run make -j12 > - at step 4, make would incorrectly rebuild the whole kernel (although it > was already built in step 3). > > The reason for the breakage is that almost all object files depend on > objtool. When we run objtool, it takes COW page fault on its .data > section, and these faults will incorrectly update the timestamp of the > objtool binary. The updated timestamp causes make to rebuild the whole > tree. > > Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx> > Cc: stable@xxxxxxxxxxxxxxx > > --- > fs/xfs/xfs_file.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > Index: linux-2.6/fs/xfs/xfs_file.c > =================================================================== > --- linux-2.6.orig/fs/xfs/xfs_file.c 2020-09-05 10:01:42.000000000 +0200 > +++ linux-2.6/fs/xfs/xfs_file.c 2020-09-05 13:59:12.000000000 +0200 > @@ -1223,6 +1223,13 @@ __xfs_filemap_fault( > return ret; > } > > +static bool > +xfs_is_write_fault( Call this xfs_is_shared_dax_write_fault, and throw in the IS_DAX() test? You might as well make it a static inline. > + struct vm_fault *vmf) > +{ > + return vmf->flags & FAULT_FLAG_WRITE && vmf->vma->vm_flags & VM_SHARED; Also, is "shortcutting the normal fault path" the reason for ext2 and xfs both being broken? /me puzzles over why write_fault is always true for page_mkwrite and pfn_mkwrite, but not for fault and huge_fault... Also: Can you please turn this (checking for timestamp update behavior wrt shared and private mapping write faults) into an fstest so we don't mess this up again? --D > +} > + > static vm_fault_t > xfs_filemap_fault( > struct vm_fault *vmf) > @@ -1230,7 +1237,7 @@ xfs_filemap_fault( > /* DAX can shortcut the normal fault path on write faults! */ > return __xfs_filemap_fault(vmf, PE_SIZE_PTE, > IS_DAX(file_inode(vmf->vma->vm_file)) && > - (vmf->flags & FAULT_FLAG_WRITE)); > + xfs_is_write_fault(vmf)); > } > > static vm_fault_t > @@ -1243,7 +1250,7 @@ xfs_filemap_huge_fault( > > /* DAX can shortcut the normal fault path on write faults! */ > return __xfs_filemap_fault(vmf, pe_size, > - (vmf->flags & FAULT_FLAG_WRITE)); > + xfs_is_write_fault(vmf)); > } > > static vm_fault_t >