Whamcloud - gitweb
LU-5100 llite: set dir LOV xattr length variable
[fs/lustre-release.git] / lustre / lod / lod_object.c
index 8b51dd8..5674a36 100644 (file)
@@ -260,12 +260,12 @@ static struct dt_index_operations lod_index_ops = {
  * \param[in] env      execution environment.
  * \param[in] dt       the striped directory object to be iterated.
  * \param[in] attr     the attribute of iterator, mostly used to indicate
- *                     the entry attribute in the object to be iterated.
+ *                      the entry attribute in the object to be iterated.
  * \param[in] capa     capability(useless in current implementation)
  *
  * \retval     initialized iterator(dt_it) if successful initialize the
- *             iteration. lit_stripe_index will be used to indicate the
- *             current iterate position among stripes.
+ *              iteration. lit_stripe_index will be used to indicate the
+ *              current iterate position among stripes.
  * \retval     ERR pointer if initialization is failed.
  */
 static struct dt_it *lod_striped_it_init(const struct lu_env *env,
@@ -538,7 +538,7 @@ static int lod_striped_it_key_size(const struct lu_env *env,
  * \param[in] env      execution environment.
  * \param[in] di       the iterator for striped directory.
  * \param[in] attr     the attribute of iterator, mostly used to indicate
- *                     the entry attribute in the object to be iterated.
+ *                      the entry attribute in the object to be iterated.
  * \param[out] rec     hold the return record.
  *
  * \retval     0 if successfully get the entry.
@@ -568,7 +568,7 @@ static int lod_striped_it_rec(const struct lu_env *env, const struct dt_it *di,
  * \param[in] env      execution environment.
  * \param[in] di       the iterator for striped directory.
  * \param[in] attr     the attribute of iterator, mostly used to indicate
- *                     the entry attribute in the object to be iterated.
+ *                      the entry attribute in the object to be iterated.
  *
  * \retval     rec_size if successfully get the entry size.
  * \retval     negative error if can not get entry size.
@@ -929,12 +929,13 @@ static int lod_declare_attr_set(const struct lu_env *env,
         */
        LASSERT(lo->ldo_stripe);
        for (i = 0; i < lo->ldo_stripenr; i++) {
-               LASSERT(lo->ldo_stripe[i]);
-
-               rc = dt_declare_attr_set(env, lo->ldo_stripe[i], attr, handle);
-               if (rc) {
-                       CERROR("failed declaration: %d\n", rc);
-                       break;
+               if (likely(lo->ldo_stripe[i] != NULL)) {
+                       rc = dt_declare_attr_set(env, lo->ldo_stripe[i], attr,
+                                                handle);
+                       if (rc != 0) {
+                               CERROR("failed declaration: %d\n", rc);
+                               break;
+                       }
                }
        }
 
@@ -1003,13 +1004,16 @@ static int lod_attr_set(const struct lu_env *env,
         */
        LASSERT(lo->ldo_stripe);
        for (i = 0; i < lo->ldo_stripenr; i++) {
-               LASSERT(lo->ldo_stripe[i]);
-               if (dt_object_exists(lo->ldo_stripe[i]) == 0)
-                       continue;
-               rc = dt_attr_set(env, lo->ldo_stripe[i], attr, handle, capa);
-               if (rc) {
-                       CERROR("failed declaration: %d\n", rc);
-                       break;
+               if (likely(lo->ldo_stripe[i] != NULL)) {
+                       if (dt_object_exists(lo->ldo_stripe[i]) == 0)
+                               continue;
+
+                       rc = dt_attr_set(env, lo->ldo_stripe[i], attr,
+                                        handle, capa);
+                       if (rc != 0) {
+                               CERROR("failed declaration: %d\n", rc);
+                               break;
+                       }
                }
        }
 
@@ -1764,7 +1768,7 @@ static int lod_xattr_set_lov_on_dir(const struct lu_env *env,
        LASSERT(buf != NULL && buf->lb_buf != NULL);
        lum = buf->lb_buf;
 
-       rc = lod_verify_striping(d, buf, 0);
+       rc = lod_verify_striping(d, buf, false);
        if (rc)
                RETURN(rc);
 
@@ -2243,10 +2247,12 @@ static int lod_cache_parent_lov_striping(const struct lu_env *env,
 
        rc = 0;
        v1 = info->lti_ea_store;
-       if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V1))
+       if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V1)) {
                lustre_swab_lov_user_md_v1(v1);
-       else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V3))
+       } else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V3)) {
+               v3 = (struct lov_user_md_v3 *)v1;
                lustre_swab_lov_user_md_v3(v3);
+       }
 
        if (v1->lmm_magic != LOV_MAGIC_V3 && v1->lmm_magic != LOV_MAGIC_V1)
                GOTO(unlock, rc = 0);
@@ -2777,12 +2783,13 @@ static int lod_declare_object_destroy(const struct lu_env *env,
        if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_MDTOBJ))
                RETURN(0);
 
-       /* declare destroy for all underlying objects */
+       /* declare destroy all striped objects */
        for (i = 0; i < lo->ldo_stripenr; i++) {
-               LASSERT(lo->ldo_stripe[i]);
-               rc = dt_declare_destroy(env, lo->ldo_stripe[i], th);
-               if (rc != 0)
-                       break;
+               if (likely(lo->ldo_stripe[i] != NULL)) {
+                       rc = dt_declare_destroy(env, lo->ldo_stripe[i], th);
+                       if (rc != 0)
+                               break;
+               }
        }
 
        RETURN(rc);
@@ -2834,10 +2841,13 @@ static int lod_object_destroy(const struct lu_env *env,
 
        /* destroy all striped objects */
        for (i = 0; i < lo->ldo_stripenr; i++) {
-               LASSERT(lo->ldo_stripe[i]);
-               rc = dt_destroy(env, lo->ldo_stripe[i], th);
-               if (rc != 0)
-                       break;
+               if (likely(lo->ldo_stripe[i] != NULL) &&
+                   (!OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LOST_SPEOBJ) ||
+                    i == cfs_fail_val)) {
+                       rc = dt_destroy(env, lo->ldo_stripe[i], th);
+                       if (rc != 0)
+                               break;
+               }
        }
 
        RETURN(rc);