mm: Update file times from fault path only if .page_mkwrite is not set
authorJan Kara <jack@suse.cz>
Tue, 12 Jun 2012 14:20:28 +0000 (16:20 +0200)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 30 Jul 2012 21:02:48 +0000 (01:02 +0400)
Filesystems 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.

Tested-by: Kamal Mostafa <kamal@canonical.com>
Tested-by: Peter M. Petrakis <peter.petrakis@canonical.com>
Tested-by: Dann Frazier <dann.frazier@canonical.com>
Tested-by: Massimo Morana <massimo.morana@canonical.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
mm/memory.c

index 2466d1250231f3e2405429ea4de4a97c597d0074..7c7fa7b4b6b6029a4c0396805e3294445ce96642 100644 (file)
@@ -2638,6 +2638,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) {
@@ -2655,10 +2658,6 @@ reuse:
                        }
                }
 
-               /* file_update_time outside page_lock */
-               if (vma->vm_file)
-                       file_update_time(vma->vm_file);
-
                return ret;
        }
 
@@ -3327,12 +3326,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
@@ -3341,7 +3341,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);