Whamcloud - gitweb
- fix objid update call. It should be done before transaction stop. Separate it
authortappro <tappro>
Wed, 22 Nov 2006 13:17:03 +0000 (13:17 +0000)
committertappro <tappro>
Wed, 22 Nov 2006 13:17:03 +0000 (13:17 +0000)
  from freeing lov_create data.
- encapsulate checking no_lov_create flag inside mdd_lov_create

lustre/mdd/mdd_dir.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c

index d16d29e..8be0b93 100644 (file)
@@ -904,24 +904,28 @@ static int mdd_create_data(const struct lu_env *env, struct md_object *pobj,
          */
 
         /* Replay creates has objects already */
+#if 0
         if (spec->u.sp_ea.no_lov_create) {
                 CDEBUG(D_INFO, "we already have lov ea\n");
                 rc = mdd_lov_set_md(env, mdd_pobj, son,
                                     (struct lov_mds_md *)spec->u.sp_ea.eadata,
                                     spec->u.sp_ea.eadatalen, handle, 0);
         } else
+#endif
                 rc = mdd_lov_set_md(env, mdd_pobj, son, lmm,
                                     lmm_size, handle, 0);
 
         if (rc == 0)
                rc = mdd_attr_get_internal_locked(env, son, ma);
 
+        /* update lov_objid data, must be before transaction stop! */
+        if (rc == 0)
+                mdd_lov_objid_update(env, mdd);
+
         mdd_trans_stop(env, mdd, rc, handle);
 out_free:
         /* Finish mdd_lov_create() stuff. */
-        mdd_lov_create_finish(env, mdd, rc);
-        if (lmm)
-                OBD_FREE(lmm, lmm_size);
+        mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec);
         RETURN(rc);
 }
 
@@ -1224,12 +1228,14 @@ static int mdd_create(const struct lu_env *env,
         inserted = 1;
 
         /* Replay creates has objects already. */
+#if 0
         if (spec->u.sp_ea.no_lov_create) {
                 CDEBUG(D_INFO, "we already have lov ea\n");
                 LASSERT(lmm == NULL);
                 lmm = (struct lov_mds_md *)spec->u.sp_ea.eadata;
                 lmm_size = spec->u.sp_ea.eadatalen;
         }
+#endif
         rc = mdd_lov_set_md(env, mdd_pobj, son, lmm, lmm_size, handle, 0);
         if (rc) {
                 CERROR("error on stripe info copy %d \n", rc);
@@ -1287,14 +1293,16 @@ cleanup:
                 }
         }
 
+        /* update lov_objid data, must be before transaction stop! */
+        if (rc == 0)
+                mdd_lov_objid_update(env, mdd);
+
         mdd_pdo_write_unlock(env, mdd_pobj, dlh);
 out_trans:
         mdd_trans_stop(env, mdd, rc, handle);
 out_free:
-        if (lmm && !spec->u.sp_ea.no_lov_create)
-                OBD_FREE(lmm, lmm_size);
-        /* Finish mdd_lov_create() stuff */
-        mdd_lov_create_finish(env, mdd, rc);
+        /* finis lov_create stuff, free all temporary data */
+        mdd_lov_create_finish(env, mdd, lmm, lmm_size, spec);
         mdd_lprocfs_time_end(mdd, &start, LPROC_MDD_CREATE);
         return rc;
 }
index cfcaf24..71db429 100644 (file)
@@ -127,8 +127,10 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                    struct mdd_object *parent, struct mdd_object *child,
                    struct lov_mds_md **lmm, int *lmm_size,
                    const struct md_op_spec *spec, struct lu_attr *la);
-void mdd_lov_create_finish(const struct lu_env *env,
-                           struct mdd_device *mdd, int rc);
+void mdd_lov_objid_update(const struct lu_env *env, struct mdd_device *mdd);
+void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd,
+                           struct lov_mds_md *lmm, int lmm_size,
+                           const struct md_op_spec *spec);
 int mdd_get_md(const struct lu_env *env, struct mdd_object *obj,
                void *md, int *md_size, const char *name);
 int mdd_get_md_locked(const struct lu_env *env, struct mdd_object *obj,
index d67f4bd..ff1a1e0 100644 (file)
@@ -348,11 +348,12 @@ static int mdd_lov_objid_alloc(const struct lu_env *env,
         return (info->mti_oti.oti_objid == NULL ? -ENOMEM : 0);
 }
 
-static void mdd_lov_objid_update(const struct lu_env *env,
-                          struct mdd_device *mdd)
+void mdd_lov_objid_update(const struct lu_env *env, struct mdd_device *mdd)
 {
         struct mdd_thread_info *info = mdd_env_info(env);
-        mds_lov_update_objids(mdd->mdd_obd_dev, info->mti_oti.oti_objid);
+        if (info->mti_oti.oti_objid != NULL)
+                mds_lov_update_objids(mdd->mdd_obd_dev,
+                                      info->mti_oti.oti_objid);
 }
 
 static void mdd_lov_objid_from_lmm(const struct lu_env *env,
@@ -375,16 +376,17 @@ static void mdd_lov_objid_free(const struct lu_env *env,
         info->mti_oti.oti_objid = NULL;
 }
 
-void mdd_lov_create_finish(const struct lu_env *env,
-                           struct mdd_device *mdd, int rc)
+void mdd_lov_create_finish(const struct lu_env *env, struct mdd_device *mdd,
+                           struct lov_mds_md *lmm, int lmm_size,
+                           const struct md_op_spec *spec)
 {
         struct mdd_thread_info *info = mdd_env_info(env);
 
-        if (info->mti_oti.oti_objid != NULL) {
-                if (rc == 0)
-                        mdd_lov_objid_update(env, mdd);
+        if (lmm && !spec->u.sp_ea.no_lov_create)
+                OBD_FREE(lmm, lmm_size);
+
+        if (info->mti_oti.oti_objid != NULL)
                 mdd_lov_objid_free(env, mdd);
-        }
 }
 
 int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
@@ -417,7 +419,9 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
 
         /* replay case, should get lov from eadata */
         if (spec->u.sp_ea.no_lov_create != 0) {
-                mdd_lov_objid_from_lmm(env, mdd, (struct lov_mds_md *)eadata);
+                *lmm = (struct lov_mds_md *)spec->u.sp_ea.eadata;
+                *lmm_size = spec->u.sp_ea.eadatalen;
+                mdd_lov_objid_from_lmm(env, mdd, *lmm);
                 RETURN(0);
         }