Whamcloud - gitweb
Fixes and cleanups in lmv.
[fs/lustre-release.git] / lustre / lmv / lmv_objmgr.c
index 59daf9d..1b1c9cd 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <asm/div64.h>
+#include <linux/seq_file.h>
 #else
 #include <liblustre.h>
 #endif
@@ -42,7 +43,6 @@
 #include <linux/lustre_mds.h>
 #include <linux/obd_class.h>
 #include <linux/obd_ost.h>
-#include <linux/seq_file.h>
 #include <linux/lprocfs_status.h>
 #include <linux/lustre_fsfilt.h>
 #include <linux/obd_lmv.h>
@@ -82,12 +82,12 @@ struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
         obj->fid = *fid;
         obj->obd = obd;
 
-        OBD_ALLOC(obj->objs, sizeof(struct lmv_inode) * lmv->count);
+        OBD_ALLOC(obj->objs, sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
         if (!obj->objs) {
                 OBD_FREE(obj, sizeof(*obj));
                 RETURN(NULL);
         }
-        memset(obj->objs, 0,  sizeof(struct lmv_inode) * lmv->count);
+        memset(obj->objs, 0,  sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
 
         spin_lock(&lmv_obj_list_lock);
         list_for_each(cur, &lmv_obj_list) {
@@ -96,7 +96,7 @@ struct lmv_obj *lmv_grab_obj(struct obd_device *obd,
                                 obj2->fid.generation == fid->generation) {
                         /* someone created it already */
                         OBD_FREE(obj->objs,
-                                  sizeof(struct lmv_inode) * lmv->count);
+                                  sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
                         OBD_FREE(obj, sizeof(*obj));
 
                         atomic_inc(&obj2->count);
@@ -140,7 +140,7 @@ void lmv_cleanup_objs(struct obd_device *obd)
 
                 list_del(&obj->list);
                 OBD_FREE(obj->objs,
-                                sizeof(struct lmv_inode) * lmv->count);
+                         sizeof(struct lmv_inode) * lmv->desc.ld_tgt_count);
                 OBD_FREE(obj, sizeof(*obj));
         }
         spin_unlock(&lmv_obj_list_lock);
@@ -162,17 +162,32 @@ int lmv_create_obj_from_attrs(struct obd_export *exp,
                (unsigned long) fid->generation);
 
         if (!mea) {
+                unsigned long valid;
+                
                 CDEBUG(D_OTHER, "mea isn't passed in, get it now\n");
                 mealen = MEA_SIZE_LMV(lmv);
+                
                 /* time to update mea of parent fid */
                 i = fid->mds;
-                rc = md_getattr(lmv->tgts[fid->mds].exp, fid,
-                                OBD_MD_FLEASIZE, mealen, &req);
-                LASSERT(rc == 0);
                 md.mea = NULL;
-                rc = mdc_req2lustre_md(req, 0, NULL, exp, &md);
-                LASSERT(rc == 0);
-                LASSERT(md.mea != NULL);
+                
+                valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
+                rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid,
+                                valid, mealen, &req);
+                if (rc) {
+                        CERROR("md_getattr() failed, rc = %d\n", rc);
+                        GOTO(cleanup, rc);
+                }
+
+                rc = mdc_req2lustre_md(exp, req, 0, NULL, &md);
+                if (rc) {
+                        CERROR("mdc_req2lustre_md() failed, rc = %d\n", rc);
+                        GOTO(cleanup, rc);
+                }
+
+                if (md.mea == NULL)
+                        GOTO(cleanup, rc = -ENODATA);
+                        
                 mea = md.mea;
         }