diff options
author | Boaz Harrosh <boaz@plexistor.com> | 2015-04-15 19:15:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:20 -0400 |
commit | 0e3b210ce1722168227cb3bc7746256d0c0afece (patch) | |
tree | 61e29f2d7d7c5e12029cafcbb0c42165a2cc1f20 /fs | |
parent | dd9061846a3ba01b0fa45423aaa087e4a69187fa (diff) |
dax: use pfn_mkwrite to update c/mtime + freeze protection
From: Yigal Korman <yigal@plexistor.com>
[v1]
Without this patch, c/mtime is not updated correctly when mmap'ed page is
first read from and then written to.
A new xfstest is submitted for testing this (generic/080)
[v2]
Jan Kara has pointed out that if we add the
sb_start/end_pagefault pair in the new pfn_mkwrite we
are then fixing another bug where: A user could start
writing to the page while filesystem is frozen.
Signed-off-by: Yigal Korman <yigal@plexistor.com>
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dax.c | 17 | ||||
-rw-r--r-- | fs/ext2/file.c | 1 | ||||
-rw-r--r-- | fs/ext4/file.c | 1 |
3 files changed, 19 insertions, 0 deletions
@@ -464,6 +464,23 @@ int dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf, | |||
464 | EXPORT_SYMBOL_GPL(dax_fault); | 464 | EXPORT_SYMBOL_GPL(dax_fault); |
465 | 465 | ||
466 | /** | 466 | /** |
467 | * dax_pfn_mkwrite - handle first write to DAX page | ||
468 | * @vma: The virtual memory area where the fault occurred | ||
469 | * @vmf: The description of the fault | ||
470 | * | ||
471 | */ | ||
472 | int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | ||
473 | { | ||
474 | struct super_block *sb = file_inode(vma->vm_file)->i_sb; | ||
475 | |||
476 | sb_start_pagefault(sb); | ||
477 | file_update_time(vma->vm_file); | ||
478 | sb_end_pagefault(sb); | ||
479 | return VM_FAULT_NOPAGE; | ||
480 | } | ||
481 | EXPORT_SYMBOL_GPL(dax_pfn_mkwrite); | ||
482 | |||
483 | /** | ||
467 | * dax_zero_page_range - zero a range within a page of a DAX file | 484 | * dax_zero_page_range - zero a range within a page of a DAX file |
468 | * @inode: The file being truncated | 485 | * @inode: The file being truncated |
469 | * @from: The file offset that is being truncated to | 486 | * @from: The file offset that is being truncated to |
diff --git a/fs/ext2/file.c b/fs/ext2/file.c index e31701713516..866a3ce3f864 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c | |||
@@ -39,6 +39,7 @@ static int ext2_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
39 | static const struct vm_operations_struct ext2_dax_vm_ops = { | 39 | static const struct vm_operations_struct ext2_dax_vm_ops = { |
40 | .fault = ext2_dax_fault, | 40 | .fault = ext2_dax_fault, |
41 | .page_mkwrite = ext2_dax_mkwrite, | 41 | .page_mkwrite = ext2_dax_mkwrite, |
42 | .pfn_mkwrite = dax_pfn_mkwrite, | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) | 45 | static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 598abbbe6786..aa78c70553f4 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -206,6 +206,7 @@ static int ext4_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
206 | static const struct vm_operations_struct ext4_dax_vm_ops = { | 206 | static const struct vm_operations_struct ext4_dax_vm_ops = { |
207 | .fault = ext4_dax_fault, | 207 | .fault = ext4_dax_fault, |
208 | .page_mkwrite = ext4_dax_mkwrite, | 208 | .page_mkwrite = ext4_dax_mkwrite, |
209 | .pfn_mkwrite = dax_pfn_mkwrite, | ||
209 | }; | 210 | }; |
210 | #else | 211 | #else |
211 | #define ext4_dax_vm_ops ext4_file_vm_ops | 212 | #define ext4_dax_vm_ops ext4_file_vm_ops |