Whamcloud - gitweb
LU-1581 utils: unknown fstype
[fs/lustre-release.git] / lustre / lov / lov_page.c
index d51afee..03335ff 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  * GPL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -109,6 +109,30 @@ static void lov_page_assume(const struct lu_env *env,
         lov_page_own(env, slice, io, 0);
 }
 
+static int lov_page_cache_add(const struct lu_env *env,
+                             const struct cl_page_slice *slice,
+                             struct cl_io *io)
+{
+       struct lov_io     *lio = lov_env_io(env);
+       struct lov_io_sub *sub;
+       int rc = 0;
+
+       LINVRNT(lov_page_invariant(slice));
+       LINVRNT(!cl2lov_page(slice)->lps_invalid);
+       ENTRY;
+
+       sub = lov_page_subio(env, lio, slice);
+       if (!IS_ERR(sub)) {
+               rc = cl_page_cache_add(sub->sub_env, sub->sub_io,
+                                      slice->cpl_page->cp_child, CRT_WRITE);
+               lov_sub_put(sub);
+       } else {
+               rc = PTR_ERR(sub);
+               CL_PAGE_DEBUG(D_ERROR, env, slice->cpl_page, "rc = %d\n", rc);
+       }
+       RETURN(rc);
+}
+
 static int lov_page_print(const struct lu_env *env,
                           const struct cl_page_slice *slice,
                           void *cookie, lu_printer_t printer)
@@ -122,6 +146,11 @@ static const struct cl_page_operations lov_page_ops = {
         .cpo_fini   = lov_page_fini,
         .cpo_own    = lov_page_own,
         .cpo_assume = lov_page_assume,
+       .io = {
+               [CRT_WRITE] = {
+                       .cpo_cache_add = lov_page_cache_add
+               }
+       },
         .cpo_print  = lov_page_print
 };
 
@@ -184,19 +213,9 @@ struct cl_page *lov_page_init_raid0(const struct lu_env *env,
                 lpg->lps_invalid = 0;
                 result = NULL;
         } else {
-                /*
-                 * This is only possible when TRANSIENT page
-                 * is being created, and CACHEABLE sub-page
-                 * (attached to already existing top-page) has
-                 * been found. Tell cl_page_find() to use
-                 * existing page.
-                 */
-                LASSERT(subpage->cp_type == CPT_CACHEABLE);
-                LASSERT(page->cp_type == CPT_TRANSIENT);
-                /* TODO: this is problematic, what if the page is being freed? */
-                result = cl_page_top(subpage);
-                cl_page_get(result);
-                cl_page_put(env, subpage);
+                CL_PAGE_DEBUG(D_ERROR, env, page, "parent page\n");
+                CL_PAGE_DEBUG(D_ERROR, env, subpage, "child page\n");
+                LASSERT(0);
         }
 
         EXIT;