Whamcloud - gitweb
LU-9412 lfs: A invalid memory write in llapi_layout_to_lum
[fs/lustre-release.git] / lustre / llite / vvp_page.c
index e2afea4..47d4863 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -63,7 +59,7 @@ static void vvp_page_fini_common(struct vvp_page *vpg)
        struct page *vmpage = vpg->vpg_page;
 
        LASSERT(vmpage != NULL);
-       page_cache_release(vmpage);
+       put_page(vmpage);
 }
 
 static void vvp_page_fini(const struct lu_env *env,
@@ -171,7 +167,6 @@ static void vvp_page_delete(const struct lu_env *env,
        refc = atomic_dec_return(&page->cp_ref);
        LASSERTF(refc >= 1, "page = %p, refc = %d\n", page, refc);
 
-       ClearPageUptodate(vmpage);
        ClearPagePrivate(vmpage);
        vmpage->private = 0;
        /*
@@ -214,11 +209,15 @@ static int vvp_page_prep_write(const struct lu_env *env,
                                struct cl_io *unused)
 {
        struct page *vmpage = cl2vm_page(slice);
+       struct cl_page *pg = slice->cpl_page;
 
        LASSERT(PageLocked(vmpage));
        LASSERT(!PageDirty(vmpage));
 
-       set_page_writeback(vmpage);
+       /* ll_writepage path is not a sync write, so need to set page writeback
+        * flag */
+       if (pg->cp_sync_io == NULL)
+               set_page_writeback(vmpage);
 
        return 0;
 }
@@ -289,19 +288,21 @@ static void vvp_page_completion_write(const struct lu_env *env,
        struct page     *vmpage = vpg->vpg_page;
        ENTRY;
 
-       LASSERT(ergo(pg->cp_sync_io != NULL, PageLocked(vmpage)));
-       LASSERT(PageWriteback(vmpage));
-
        CL_PAGE_HEADER(D_PAGE, env, pg, "completing WRITE with %d\n", ioret);
 
-       /*
-        * Only mark the page error only when it's an async write because
-        * applications won't wait for IO to finish.
-        */
-       if (pg->cp_sync_io == NULL)
+       if (pg->cp_sync_io != NULL) {
+               LASSERT(PageLocked(vmpage));
+               LASSERT(!PageWriteback(vmpage));
+       } else {
+               LASSERT(PageWriteback(vmpage));
+               /*
+                * Only mark the page error only when it's an async write
+                * because applications won't wait for IO to finish.
+                */
                vvp_vmpage_error(vvp_object_inode(pg->cp_obj), vmpage, ioret);
 
-       end_page_writeback(vmpage);
+               end_page_writeback(vmpage);
+       }
        EXIT;
 }
 
@@ -523,7 +524,7 @@ int vvp_page_init(const struct lu_env *env, struct cl_object *obj,
        CLOBINVRNT(env, obj, vvp_object_invariant(obj));
 
        vpg->vpg_page = vmpage;
-       page_cache_get(vmpage);
+       get_page(vmpage);
 
        if (page->cp_type == CPT_CACHEABLE) {
                /* in cache, decref in vvp_page_delete */