Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / mdd / mdd_lov.c
index ec21996..b3ecae2 100644 (file)
 
 #include "mdd_internal.h"
 
-static int mdd_lov_update(struct obd_device *host,
-                          struct obd_device *watched,
-                          enum obd_notify_event ev, void *owner)
+static int mdd_notify(struct obd_device *host, struct obd_device *watched,
+                      enum obd_notify_event ev, void *owner)
 {
         struct mdd_device *mdd = owner;
         int rc = 0;
         ENTRY;
 
         LASSERT(owner != NULL);
-
-        rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_SYNC);
+        switch (ev)
+        {
+                case OBD_NOTIFY_ACTIVE:
+                case OBD_NOTIFY_SYNC:
+                case OBD_NOTIFY_SYNC_NONBLOCK:
+                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_SYNC);
+                        break;
+                case OBD_NOTIFY_CONFIG:
+                        rc = md_do_upcall(NULL, &mdd->mdd_md_dev, MD_LOV_CONFIG);
+                        break;
+                default:
+                        CDEBUG(D_INFO, "Unhandled notification %#x\n", ev);
+        }
 
         RETURN(rc);
 }
@@ -122,7 +132,7 @@ int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd,
          * Add here for obd notify mechanism, when adding a new ost, the mds
          * will notify this mdd.
          */
-        obd->obd_upcall.onu_upcall = mdd_lov_update;
+        obd->obd_upcall.onu_upcall = mdd_notify;
         obd->obd_upcall.onu_owner = mdd;
         mdd->mdd_obd_dev = obd;
 
@@ -332,56 +342,17 @@ static obd_id mdd_lov_create_id(const struct lu_fid *fid)
         return fid_flatten(fid);
 }
 
-static int mdd_lov_objid_alloc(const struct lu_env *env,
-                               struct mdd_device *mdd)
-{
-        struct mdd_thread_info *info = mdd_env_info(env);
-        struct mds_obd *mds = &mdd->mdd_obd_dev->u.mds;
-
-        OBD_ALLOC(info->mti_oti.oti_objid,
-                  mds->mds_lov_desc.ld_tgt_count * sizeof(obd_id));
-        return (info->mti_oti.oti_objid == NULL ? -ENOMEM : 0);
-}
-
-void mdd_lov_objid_update(const struct lu_env *env, struct mdd_device *mdd)
-{
-        struct mdd_thread_info *info = mdd_env_info(env);
-        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,
-                                   struct mdd_device *mdd,
-                                   struct lov_mds_md *lmm)
+void mdd_lov_objid_update(struct mdd_device *mdd, struct lov_mds_md *lmm)
 {
-        struct mds_obd *mds = &mdd->mdd_obd_dev->u.mds;
-        struct mdd_thread_info *info = mdd_env_info(env);
-        mds_objids_from_lmm(info->mti_oti.oti_objid, lmm, &mds->mds_lov_desc);
-}
-
-static void mdd_lov_objid_free(const struct lu_env *env,
-                               struct mdd_device *mdd)
-{
-        struct mdd_thread_info *info = mdd_env_info(env);
-        struct mds_obd *mds = &mdd->mdd_obd_dev->u.mds;
-
-        OBD_FREE(info->mti_oti.oti_objid,
-                 mds->mds_lov_desc.ld_tgt_count * sizeof(obd_id));
-        info->mti_oti.oti_objid = NULL;
+        mds_lov_update_objids(mdd->mdd_obd_dev, lmm);
 }
 
 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 (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,
@@ -399,24 +370,19 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
         int                    rc = 0;
         ENTRY;
 
-        if (create_flags & MDS_OPEN_DELAY_CREATE ||
-            !(create_flags & FMODE_WRITE))
+        if (!md_should_create(create_flags))
                 RETURN(0);
 
         oti_init(oti, NULL);
-        rc = mdd_lov_objid_alloc(env, mdd);
-        if (rc != 0)
-                RETURN(rc);
 
         /* replay case, has objects already, only get lov from eadata */
         if (spec->u.sp_ea.no_lov_create != 0) {
                 *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);
         }
 
-        if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_ALLOC_OBDO))
+        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOC_OBDO))
                 GOTO(out_ids, rc = -ENOMEM);
 
         LASSERT(lov_exp != NULL);
@@ -508,7 +474,7 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
                 oa->o_valid |= OBD_MD_FLFID | OBD_MD_FLGENER;
                 oinfo->oi_oa = oa;
                 oinfo->oi_md = lsm;
-                oinfo->oi_capa = mdo_capa_get(env, child, NULL, 0,
+                oinfo->oi_capa = mdo_capa_get(env, child, NULL,
                                               CAPA_OPC_MDS_DEFAULT);
                 if (IS_ERR(oinfo->oi_capa))
                         oinfo->oi_capa = NULL;
@@ -544,13 +510,10 @@ out_oti:
 out_ids:
         if (lsm)
                 obd_free_memmd(lov_exp, &lsm);
-        if (rc != 0)
-                mdd_lov_objid_free(env, mdd);
 
         return rc;
 }
 
-
 /*
  * used when destroying orphans and from mds_reint_unlink() when MDS wants to
  * destroy objects on OSS.
@@ -702,7 +665,7 @@ int mdd_lov_setattr_async(const struct lu_env *env, struct mdd_object *obj,
         if (rc)
                 RETURN(rc);
 
-        oc = mdo_capa_get(env, obj, NULL, 0, CAPA_OPC_MDS_DEFAULT);
+        oc = mdo_capa_get(env, obj, NULL, CAPA_OPC_MDS_DEFAULT);
         if (IS_ERR(oc))
                 oc = NULL;