Whamcloud - gitweb
LU-10629 lod: Clear OST pool with setstripe
[fs/lustre-release.git] / lustre / lov / lovsub_object.c
index 12aa04e..16d4df7 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) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -66,7 +62,7 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj,
         below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under);
         if (below != NULL) {
                 lu_object_add(obj, below);
-               cl_object_page_init(lu2cl(obj), sizeof(struct lovsub_page));
+               cl_object_page_init(lu2cl(obj), 0);
                 result = 0;
         } else
                 result = -ENOMEM;
@@ -83,13 +79,17 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj)
         /* We can't assume lov was assigned here, because of the shadow
          * object handling in lu_object_find.
          */
-        if (lov) {
-                LASSERT(lov->lo_type == LLT_RAID0);
-                LASSERT(lov->u.raid0.lo_sub[los->lso_index] == los);
-               spin_lock(&lov->u.raid0.lo_sub_lock);
-               lov->u.raid0.lo_sub[los->lso_index] = NULL;
-               spin_unlock(&lov->u.raid0.lo_sub_lock);
-        }
+       if (lov != NULL) {
+               int index = lov_comp_entry(los->lso_index);
+               int stripe = lov_comp_stripe(los->lso_index);
+               struct lov_layout_raid0 *r0 = lov_r0(lov, index);
+
+               LASSERT(lov->lo_type == LLT_COMP);
+               LASSERT(r0->lo_sub[stripe] == los);
+               spin_lock(&r0->lo_sub_lock);
+               r0->lo_sub[stripe] = NULL;
+               spin_unlock(&r0->lo_sub_lock);
+       }
 
         lu_object_fini(obj);
         lu_object_header_fini(&los->lso_header.coh_lu);
@@ -108,10 +108,11 @@ static int lovsub_object_print(const struct lu_env *env, void *cookie,
 static int lovsub_attr_update(const struct lu_env *env, struct cl_object *obj,
                              const struct cl_attr *attr, unsigned valid)
 {
+       struct lovsub_object *los = cl2lovsub(obj);
        struct lov_object *lov = cl2lovsub(obj)->lso_super;
 
        ENTRY;
-       lov_r0(lov)->lo_attr_valid = 0;
+       lov_r0(lov, lov_comp_entry(los->lso_index))->lo_attr_valid = 0;
        RETURN(0);
 }
 
@@ -134,7 +135,7 @@ static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj,
                                struct cl_req_attr *attr)
 {
        struct lovsub_object *subobj = cl2lovsub(obj);
-
+       struct lov_stripe_md *lsm = subobj->lso_super->lo_lsm;
        ENTRY;
        cl_req_attr_set(env, &subobj->lso_super->lo_cl, attr);
 
@@ -142,13 +143,14 @@ static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj,
         * There is no OBD_MD_* flag for obdo::o_stripe_idx, so set it
         * unconditionally. It never changes anyway.
         */
-       attr->cra_oa->o_stripe_idx = subobj->lso_index;
+       attr->cra_oa->o_stripe_idx = lov_comp_stripe(subobj->lso_index);
+       lov_lsm2layout(lsm, lsm->lsm_entries[lov_comp_entry(subobj->lso_index)],
+                      &attr->cra_oa->o_layout);
+       attr->cra_oa->o_valid |= OBD_MD_FLOSTLAYOUT;
        EXIT;
 }
 
 static const struct cl_object_operations lovsub_ops = {
-       .coo_page_init    = lovsub_page_init,
-       .coo_lock_init    = lovsub_lock_init,
        .coo_attr_update  = lovsub_attr_update,
        .coo_glimpse      = lovsub_object_glimpse,
        .coo_req_attr_set = lovsub_req_attr_set