Whamcloud - gitweb
LU-2335 build: stop checking for XATTR_ACL_SIZE
[fs/lustre-release.git] / lustre / obdclass / cl_page.c
index 29a570c..cfa1f60 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -64,7 +64,7 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
         ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
 #endif /* !LIBCFS_DEBUG */
 
-#ifdef INVARIANT_CHECK
+#ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
 # define PINVRNT(env, page, expr)                                       \
   do {                                                                    \
           if (unlikely(!(expr))) {                                      \
@@ -72,10 +72,10 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
                   LINVRNT(0);                                           \
           }                                                             \
   } while (0)
-#else /* !INVARIANT_CHECK */
+#else /* !CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK */
 # define PINVRNT(env, page, exp) \
-        ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
-#endif /* !INVARIANT_CHECK */
+        ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
+#endif /* !CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK */
 
 /* Disable page statistic by default due to huge performance penalty. */
 #ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
@@ -296,7 +296,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
         }
        CS_PAGE_DEC(obj, total);
        CS_PAGESTATE_DEC(obj, page->cp_state);
-        lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page);
+       lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
         cl_object_put(env, obj);
         lu_ref_fini(&page->cp_reference);
         OBD_FREE(page, pagesize);
@@ -325,13 +325,14 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env,
        OBD_ALLOC_GFP(page, cl_object_header(o)->coh_page_bufsize,
                        CFS_ALLOC_IO);
        if (page != NULL) {
-               int result;
+               int result = 0;
                cfs_atomic_set(&page->cp_ref, 1);
                if (type == CPT_CACHEABLE) /* for radix tree */
                        cfs_atomic_inc(&page->cp_ref);
                page->cp_obj = o;
                cl_object_get(o);
-               page->cp_obj_ref = lu_object_ref_add(&o->co_lu, "cl_page",page);
+               lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page",
+                                    page);
                page->cp_index = ind;
                cl_page_state_set_trust(page, CPS_CACHED);
                page->cp_type = type;
@@ -1267,6 +1268,8 @@ int cl_page_prep(const struct lu_env *env, struct cl_io *io,
          * PG_writeback without risking other layers deciding to skip this
          * page.
          */
+       if (crt >= CRT_NR)
+               return -EINVAL;
         result = cl_page_invoke(env, io, pg, CL_PAGE_OP(io[crt].cpo_prep));
         if (result == 0)
                 cl_page_io_start(env, pg, crt);
@@ -1312,6 +1315,8 @@ void cl_page_completion(const struct lu_env *env,
         }
 
         cl_page_state_set(env, pg, CPS_CACHED);
+       if (crt >= CRT_NR)
+               return;
         CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(io[crt].cpo_completion),
                                (const struct lu_env *,
                                 const struct cl_page_slice *, int), ioret);
@@ -1351,6 +1356,8 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg,
         PINVRNT(env, pg, crt < CRT_NR);
 
         ENTRY;
+       if (crt >= CRT_NR)
+               RETURN(-EINVAL);
         result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready),
                                 (const struct lu_env *,
                                  const struct cl_page_slice *));
@@ -1387,6 +1394,9 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io,
 
        ENTRY;
 
+       if (crt >= CRT_NR)
+               RETURN(-EINVAL);
+
        cfs_list_for_each_entry(scan, &pg->cp_layers, cpl_linkage) {
                if (scan->cpl_ops->io[crt].cpo_cache_add == NULL)
                        continue;