Whamcloud - gitweb
Update based on lustre-iokit-20051107.tar.gz from the customer download area.
[fs/lustre-release.git] / lustre / lmv / lmv_objmgr.c
index b2f2e0c..adaa0e4 100644 (file)
@@ -70,7 +70,8 @@ lmv_alloc_obj(struct obd_device *obd,
         LASSERT(mea->mea_magic == MEA_MAGIC_LAST_CHAR
                 || mea->mea_magic == MEA_MAGIC_ALL_CHARS);
 
-        OBD_SLAB_ALLOC(obj, obj_cache, GFP_NOFS, sizeof(*obj));
+        OBD_SLAB_ALLOC(obj, obj_cache, GFP_NOFS,
+                       sizeof(*obj));
         if (!obj)
                 return NULL;
 
@@ -209,6 +210,16 @@ __grab_obj(struct obd_device *obd, struct lustre_id *id)
                 if (obj->state & O_FREEING)
                         continue;
 
+                /* 
+                 * we should make sure, that we have found object belong to
+                 * passed obd. It is possible that, object manager will have two
+                 * objects with the same fid belong to different obds, if client
+                 * and mds runs on the same host. May be it is good idea to have
+                 * objects list assosiated with obd.
+                 */
+                if (obj->obd != obd)
+                        continue;
+
                 /* check if this is what we're looking for. */
                 if (id_equal_fid(&obj->id, id))
                         return __get_obj(obj);
@@ -286,18 +297,20 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea)
         CDEBUG(D_OTHER, "get mea for "DLID4" and create lmv obj\n",
                OLID4(id));
 
-        if (!mea) {
-                unsigned long valid;
+        md.mea = NULL;
+       
+        if (mea == NULL) {
+                __u64 valid;
                 
                 CDEBUG(D_OTHER, "mea isn't passed in, get it now\n");
                 mealen = MEA_SIZE_LMV(lmv);
                 
                 /* time to update mea of parent id */
                 md.mea = NULL;
-                valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
+                valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA;
 
                 rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp,
-                                id, valid, mealen, &req);
+                                id, valid, NULL, NULL, 0, mealen, NULL, &req);
                 if (rc) {
                         CERROR("md_getattr() failed, error %d\n", rc);
                         GOTO(cleanup, obj = ERR_PTR(rc));
@@ -309,7 +322,7 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea)
                         GOTO(cleanup, obj = ERR_PTR(rc));
                 }
 
-                if (!md.mea)
+                if (md.mea == NULL)
                         GOTO(cleanup, obj = ERR_PTR(-ENODATA));
                         
                 mea = md.mea;
@@ -322,17 +335,23 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea)
                        OLID4(id));
                 GOTO(cleanup, obj = ERR_PTR(-ENOMEM));
         }
-        EXIT;
+       
+       if (md.mea != NULL)
+               obd_free_memmd(exp, (struct lov_stripe_md **)&md.mea);
+        
+       EXIT;
 cleanup:
         if (req)
                 ptlrpc_req_finished(req);
         return obj;
 }
 
-/* looks for object with @id and orders to destroy it. It is possible the
- * object will not be destroyed right now, because it is still using by
- * someone. In this case it will be marked as "freeing" and will not be
- * accessible anymore for subsequent callers of lmv_grab_obj(). */
+/*
+ * looks for object with @id and orders to destroy it. It is possible the object
+ * will not be destroyed right now, because it is still using by someone. In
+ * this case it will be marked as "freeing" and will not be accessible anymore
+ * for subsequent callers of lmv_grab_obj().
+ */
 int
 lmv_delete_obj(struct obd_export *exp, struct lustre_id *id)
 {
@@ -349,27 +368,29 @@ lmv_delete_obj(struct obd_export *exp, struct lustre_id *id)
                 __put_obj(obj);
                 rc = 1;
         }
-
         spin_unlock(&obj_list_lock);
+
         RETURN(rc);
 }
 
 int
 lmv_setup_mgr(struct obd_device *obd)
 {
+        ENTRY;
         LASSERT(obd != NULL);
         
         CDEBUG(D_INFO, "LMV object manager setup (%s)\n",
                obd->obd_uuid.uuid);
 
-        return 0;
+        RETURN(0);
 }
 
 void
 lmv_cleanup_mgr(struct obd_device *obd)
 {
-        struct lmv_obj *obj;
         struct list_head *cur, *tmp;
+        struct lmv_obj *obj;
+        ENTRY;
 
         CDEBUG(D_INFO, "LMV object manager cleanup (%s)\n",
                obd->obd_uuid.uuid);
@@ -389,4 +410,5 @@ lmv_cleanup_mgr(struct obd_device *obd)
                 __put_obj(obj);
         }
         spin_unlock(&obj_list_lock);
+        EXIT;
 }