Push file_update_time() into .page_mkwrite
Subsystems (8)
Jan Kara
reviewerv3 cover Push file_update_time() into .page_mkwrite
Hello,
to provide reliable support for filesystem freezing, filesystems need to have
complete control over when metadata is changed. In particular, file_update_time() calls from page fault code make it impossible for filesystems to prevent inodes from being dirtied while the filesystem is frozen.
To fix the issue, this patch set changes page fault code to call file_update_time() only when ->page_mkwrite() callback is not provided. If the callback is provided, it is the responsibility of the filesystem to perform update of i_mtime / i_ctime if needed. We also push file_update_time() call to all existing ->page_mkwrite() implementations if the time update does not obviously happen by other means. This is including __block_page_mkwrite() so filesystems using it are handled. If you know your filesystem does not need update of modification times in ->page_mkwrite() handler, please speak up and I'll drop the patch for your filesystem.
As a side note, an alternative would be to remove calls of file_update_time() from page fault code altogether and require all filesystems needing it to do that in their ->page_mkwrite() implementation. That is certainly possible although maybe slightly inefficient and would require auditting 100+ vm_operations_structs *shiver*.
Changes since v1:
* Dropped patches for filesystems which don't need them
* Added some acks
* Improved sysfs patch by Alex Elder's suggestion
Changes since v2:
* Dropped patches for more filesystems
Andrew, would you be willing to merge these patches via your tree? This seems to be a final version.
Honza
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jan Kara
reviewerPATCH v3 1/7 fb_defio: Push file_update_time() into fb_deferred_io_mkwrite()
--- drivers/video/fb_defio.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/video/fb_defio.c +2 -0
@@ -104,6 +104,8 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,deferred framebuffer IO. then if userspace touches a page again, we repeat the same scheme */ +file_update_time (vma->vm_file); +/* protect against the workqueue changing the page list */ mutex_lock (&fbdefio->lock);
Signature · 8 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jan Kara
reviewerPATCH v3 2/7 fs: Push file_update_time() into __block_page_mkwrite()
In reply to Jan Kara--- fs/buffer.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
fs/buffer.c +6 -0
@@ -2300,6 +2300,12 @@ int __block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,loff_t size;int ret; +/* +* Update file times before taking page lock. We may end up failing the +* fault so this update may be superfluous but who really cares... +*/ +file_update_time (vma->vm_file); +lock_page (page); size =i_size_read (inode); if ((page->mapping != inode->i_mapping) ||
Signature · 8 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jan Kara
reviewerPATCH v3 3/7 ceph: Push file_update_time() into ceph_page_mkwrite()
In reply to Jan Kara--- fs/ceph/addr.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ceph/addr.c +3 -0
@@ -1181,6 +1181,9 @@ static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)loff_t size, len;int ret; +/* Update time before taking page lock */ +file_update_time (vma->vm_file); + size =i_size_read (inode);if (off +PAGE_CACHE_SIZE <= size) len =PAGE_CACHE_SIZE ;
Signature · 8 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jan Kara
reviewerPATCH v3 4/7 9p: Push file_update_time() into v9fs_vm_page_mkwrite()
In reply to Jan Kara--- fs/9p/vfs_file.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/9p/vfs_file.c +3 -0
@@ -610,6 +610,9 @@ v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)p9_debug (P9_DEBUG_VFS ,"page %p fid %lx\n" , page, (unsigned long )filp->private_data); +/* Update file times before taking page lock */ +file_update_time (filp); + v9inode =V9FS_I (inode);/* make sure the cache has finished storing the page */ v9fs_fscache_wait_on_page_write (inode, page);
Signature · 8 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jan Kara
reviewerPATCH v3 5/7 gfs2: Push file_update_time() into gfs2_page_mkwrite()
In reply to Jan Kara--- fs/gfs2/file.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/gfs2/file.c +3 -0
@@ -375,6 +375,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)*/ vfs_check_frozen (inode->i_sb,SB_FREEZE_WRITE ); +/* Update file times before taking page lock */ +file_update_time (vma->vm_file); +gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); ret =gfs2_glock_nq (&gh);if (ret)
Signature · 1 line
1.7.1
Jan Kara
reviewerPATCH v3 6/7 sysfs: Push file_update_time() into bin_page_mkwrite()
In reply to Jan Kara--- fs/sysfs/bin.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +2 -0
@@ -228,6 +228,8 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ret =0 ;if (bb->vm_ops->page_mkwrite) ret = bb->vm_ops->page_mkwrite (vma, vmf); +else +file_update_time (file);sysfs_put_active (attr_sd);return ret;
Signature · 8 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jan Kara
reviewerPATCH v3 7/7 mm: Update file times from fault path only if .page_mkwrite is not set
In reply to Jan KaraFilesystems wanting to properly support freezing need to have control when file_update_time() is called. After pushing file_update_time() to all relevant .page_mkwrite implementations we can just stop calling file_update_time() when filesystem implements .page_mkwrite.
--- mm/memory.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
mm/memory.c +7 -7
@@ -2621,6 +2621,9 @@ reuse:if (!page_mkwrite) {wait_on_page_locked (dirty_page);set_page_dirty_balance (dirty_page, page_mkwrite); +/* file_update_time outside page_lock */ +if (vma->vm_file) +file_update_time (vma->vm_file); }put_page (dirty_page);if (page_mkwrite) {
@@ -2638,10 +2641,6 @@ reuse: } } -/* file_update_time outside page_lock */ -if (vma->vm_file) -file_update_time (vma->vm_file); -return ret; }
@@ -3310,12 +3309,13 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,if (dirty_page) {struct address_space *mapping = page->mapping; +int dirtied =0 ;if (set_page_dirty (dirty_page)) - page_mkwrite =1 ; + dirtied =1 ;unlock_page (dirty_page);put_page (dirty_page); -if (page_mkwrite && mapping) { +if ((dirtied || page_mkwrite) && mapping) {/* * Some device drivers do not set page.mapping but still * dirty their pages
@@ -3324,7 +3324,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma, }/* file_update_time outside page_lock */ -if (vma->vm_file) +if (vma->vm_file && !page_mkwrite)file_update_time (vma->vm_file); }else {unlock_page (vmf.page);
Signature · 8 lines
1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Kamal Mostafa
Tested-by Tested-by Peter M. Petrakis Tested-by Dann Frazier Tested-by Massimo Morana on the v3 seriesQuoted 4 lines · Jan Kara
Hello,
to provide reliable support for filesystem freezing, filesystems need to have
complete control over when metadata is changed. [...]
This patch set has been tested at Canonical along with the testing for "[PATCH 00/19] Fix filesystem freezing deadlocks".
Please add the following endorsements for these patches (those actually exercised by our test case): 1, 2, 6, 7
-Kamal
Jan Kara
reviewerQuoted 9 lines · Kamal Mostafa
Quoted 4 lines · Jan Kara
Hello,
to provide reliable support for filesystem freezing, filesystems need to have
complete control over when metadata is changed. [...]This patch set has been tested at Canonical along with the testing for "[PATCH 00/19] Fix filesystem freezing deadlocks".
Quoted 7 lines
Please add the following endorsements for these patches (those actually exercised by our test case): 1, 2, 6, 7
Tested-by Kamal Mostafa <[email protected]>Tested-by Peter M. Petrakis <[email protected]>Tested-by Dann Frazier <[email protected]>Tested-by Massimo Morana <[email protected]>
Thanks for testing guys!
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR