Skip to content

Commit b17164e

Browse files
Mikulas Patockatorvalds
authored andcommitted
xfs: don't update mtime on COW faults
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@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1ef6ea0 commit b17164e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/xfs/xfs_file.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,14 +1223,22 @@ __xfs_filemap_fault(
12231223
return ret;
12241224
}
12251225

1226+
static inline bool
1227+
xfs_is_write_fault(
1228+
struct vm_fault *vmf)
1229+
{
1230+
return (vmf->flags & FAULT_FLAG_WRITE) &&
1231+
(vmf->vma->vm_flags & VM_SHARED);
1232+
}
1233+
12261234
static vm_fault_t
12271235
xfs_filemap_fault(
12281236
struct vm_fault *vmf)
12291237
{
12301238
/* DAX can shortcut the normal fault path on write faults! */
12311239
return __xfs_filemap_fault(vmf, PE_SIZE_PTE,
12321240
IS_DAX(file_inode(vmf->vma->vm_file)) &&
1233-
(vmf->flags & FAULT_FLAG_WRITE));
1241+
xfs_is_write_fault(vmf));
12341242
}
12351243

12361244
static vm_fault_t
@@ -1243,7 +1251,7 @@ xfs_filemap_huge_fault(
12431251

12441252
/* DAX can shortcut the normal fault path on write faults! */
12451253
return __xfs_filemap_fault(vmf, pe_size,
1246-
(vmf->flags & FAULT_FLAG_WRITE));
1254+
xfs_is_write_fault(vmf));
12471255
}
12481256

12491257
static vm_fault_t

0 commit comments

Comments
 (0)