Whamcloud - gitweb
LU-1200 build: check page_mkwrite parameter
[fs/lustre-release.git] / lustre / llite / llite_mmap.c
index 9de415d..6ce0587 100644 (file)
@@ -29,8 +29,7 @@
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -234,8 +233,12 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage,
                          * This piece of code is definitely needed for RHEL5,
                          * otherwise, SIGBUS will be wrongly returned to
                          * applications. */
-                        ll_invalidate_page(vmpage);
-                        LASSERT(vmpage->mapping == NULL);
+                        write_one_page(vmpage, 1);
+                        lock_page(vmpage);
+                        if (vmpage->mapping != NULL) {
+                                ll_invalidate_page(vmpage);
+                                LASSERT(vmpage->mapping == NULL);
+                        }
                         unlock_page(vmpage);
                 } else if (!PageDirty(vmpage)) {
                         /* race, the page has been cleaned by ptlrpcd after
@@ -331,35 +334,6 @@ out_err:
         RETURN(page);
 }
 
-static int ll_page_mkwrite(struct vm_area_struct *vma, struct page *vmpage)
-{
-        int count = 0;
-        bool printed = false;
-        bool retry;
-        int result;
-
-        do {
-                retry = false;
-                result = ll_page_mkwrite0(vma, vmpage, &retry);
-
-                if (!printed && ++count > 16) {
-                        CWARN("app(%s): the page %lu of file %lu is under heavy"
-                              " contention.\n",
-                              current->comm, page_index(vmpage),
-                              vma->vm_file->f_dentry->d_inode->i_ino);
-                        printed = true;
-                }
-        } while (retry);
-
-        if (result == 0)
-                unlock_page(vmpage);
-        else if (result == -ENODATA)
-                result = 0; /* kernel will know truncate has happened and
-                             * retry */
-
-        return result;
-}
-
 #else
 /**
  * Lustre implementation of a vm_operations_struct::fault() method, called by
@@ -454,7 +428,38 @@ restart:
         }
         return result;
 }
+#endif
+
+#ifndef HAVE_PGMKWRITE_USE_VMFAULT
+static int ll_page_mkwrite(struct vm_area_struct *vma, struct page *vmpage)
+{
+        int count = 0;
+        bool printed = false;
+        bool retry;
+        int result;
+
+        do {
+                retry = false;
+                result = ll_page_mkwrite0(vma, vmpage, &retry);
+
+                if (!printed && ++count > 16) {
+                        CWARN("app(%s): the page %lu of file %lu is under heavy"
+                              " contention.\n",
+                              current->comm, page_index(vmpage),
+                              vma->vm_file->f_dentry->d_inode->i_ino);
+                        printed = true;
+                }
+        } while (retry);
 
+        if (result == 0)
+                unlock_page(vmpage);
+        else if (result == -ENODATA)
+                result = 0; /* kernel will know truncate has happened and
+                             * retry */
+
+        return result;
+}
+#else
 static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
         int count = 0;