Whamcloud - gitweb
A mostly-fix for "mknod /mnt/lustre/foofo p". It doesn't fail outright
[fs/lustre-release.git] / lustre / lov / lov_obd.c
index 4f7363f..c0fd524 100644 (file)
@@ -26,134 +26,97 @@ extern struct obd_device obd_dev[MAX_OBD_DEVICES];
 
 /* obd methods */
 
-static int lov_getinfo(struct obd_device *obd, 
-                       struct lov_desc *desc, 
-                       uuid_t **uuids, 
-                       struct ptlrpc_request **request)
-{
-        struct ptlrpc_request *req;
-        struct mds_status_req *streq;
-        struct lov_obd *lov = &obd->u.lov; 
-        struct mdc_obd *mdc = &lov->mdcobd->u.mdc;
-        int rc, size[2] = {sizeof(*streq)};
-        ENTRY;
-
-        req = ptlrpc_prep_req2(mdc->mdc_client, mdc->mdc_conn, &mdc->mdc_connh,
-                               MDS_LOVINFO, 1, size, NULL);
-        if (!req)
-                GOTO(out, rc = -ENOMEM);
-        
-        *request = req;
-        streq = lustre_msg_buf(req->rq_reqmsg, 0);
-        streq->flags = HTON__u32(MDS_STATUS_LOV);
-        streq->repbuf = HTON__u32(8000);
-        
-        /* prepare for reply */ 
-        req->rq_level = LUSTRE_CONN_CON;
-        size[0] = sizeof(*desc); 
-        size[1] = 8000; 
-        req->rq_replen = lustre_msg_size(2, size);
-        
-        rc = ptlrpc_queue_wait(req);
-        rc = ptlrpc_check_status(req, rc);
-
-        if (!rc) {
-                memcpy(desc, lustre_msg_buf(req->rq_repmsg, 0), sizeof(*desc));
-                *uuids = lustre_msg_buf(req->rq_repmsg, 1);
-                lov_unpackdesc(desc); 
-        }
-        mdc->mdc_max_mdsize = sizeof(*desc) + 
-                desc->ld_tgt_count * sizeof(uuid_t);
-
-        EXIT;
- out:
-        return rc;
-}
-
 static int lov_connect(struct lustre_handle *conn, struct obd_device *obd)
 {
-        int rc;
-        int i;
         struct ptlrpc_request *req;
         struct lov_obd *lov = &obd->u.lov;
-        uuid_t *uuidarray; 
+        struct lustre_handle mdc_conn;
+        uuid_t *uuidarray;
+        int rc;
+        int i;
 
         MOD_INC_USE_COUNT;
         rc = class_connect(conn, obd);
-        if (rc) { 
+        if (rc) {
                 MOD_DEC_USE_COUNT;
-                RETURN(rc); 
+                RETURN(rc);
         }
-        
-        rc = lov_getinfo(obd, &lov->desc, &uuidarray, &req);
-        if (rc) { 
+
+        rc = obd_connect(&mdc_conn, lov->mdcobd);
+        if (rc) {
+                CERROR("cannot connect to mdc: rc = %d\n", rc);
+                GOTO(out, rc = -EINVAL);
+        }
+
+        rc = mdc_getlovinfo(obd, &mdc_conn, &uuidarray, &req);
+        obd_disconnect(&mdc_conn);
+
+        if (rc) {
                 CERROR("cannot get lov info %d\n", rc);
-                GOTO(out, rc); 
+                GOTO(out, rc);
         }
-        
-        if (lov->desc.ld_tgt_count > 1000) { 
+
+
+        if (lov->desc.ld_tgt_count > 1000) {
                 CERROR("configuration error: target count > 1000 (%d)\n",
                        lov->desc.ld_tgt_count);
-                GOTO(out, rc = -EINVAL); 
+                GOTO(out, rc = -EINVAL);
         }
-        
-        if (strcmp(obd->obd_uuid, lov->desc.ld_uuid)) { 
-                CERROR("lov uuid %s not on mds device (%s)\n", 
+
+        if (strcmp(obd->obd_uuid, lov->desc.ld_uuid)) {
+                CERROR("lov uuid %s not on mds device (%s)\n",
                        obd->obd_uuid, lov->desc.ld_uuid);
-                GOTO(out, rc = -EINVAL); 
-        }                
-            
-        if (req->rq_repmsg->bufcount < 2 || req->rq_repmsg->buflens[1] < 
-            sizeof(uuid_t) * lov->desc.ld_tgt_count) { 
-                CERROR("invalid uuid array returned\n");
-                GOTO(out, rc = -EINVAL); 
+                GOTO(out, rc = -EINVAL);
         }
 
-        lov->bufsize = sizeof(struct lov_tgt_desc) *  lov->desc.ld_tgt_count; 
-        OBD_ALLOC(lov->tgts, lov->bufsize); 
-        if (!lov->tgts) { 
-                CERROR("Out of memory\n"); 
-                GOTO(out, rc = -ENOMEM); 
+        if (req->rq_repmsg->bufcount < 2 || req->rq_repmsg->buflens[1] <
+            sizeof(uuid_t) * lov->desc.ld_tgt_count) {
+                CERROR("invalid uuid array returned\n");
+                GOTO(out, rc = -EINVAL);
         }
 
-        uuidarray = lustre_msg_buf(req->rq_repmsg, 1); 
-        for (i = 0 ; i < lov->desc.ld_tgt_count; i++) { 
-                memcpy(lov->tgts[i].uuid, uuidarray[i], sizeof(uuid_t)); 
+        lov->bufsize = sizeof(struct lov_tgt_desc) *  lov->desc.ld_tgt_count;
+        OBD_ALLOC(lov->tgts, lov->bufsize);
+        if (!lov->tgts) {
+                CERROR("Out of memory\n");
+                GOTO(out, rc = -ENOMEM);
         }
 
-        for (i = 0 ; i < lov->desc.ld_tgt_count; i++) { 
+        uuidarray = lustre_msg_buf(req->rq_repmsg, 1);
+        for (i = 0 ; i < lov->desc.ld_tgt_count; i++)
+                memcpy(lov->tgts[i].uuid, uuidarray[i], sizeof(uuid_t));
+
+        for (i = 0 ; i < lov->desc.ld_tgt_count; i++) {
                 struct obd_device *tgt = class_uuid2obd(uuidarray[i]);
-                if (!tgt) { 
-                        CERROR("Target %s not configured\n", uuidarray[i]); 
-                        GOTO(out_mem, rc = -EINVAL); 
+                if (!tgt) {
+                        CERROR("Target %s not configured\n", uuidarray[i]);
+                        GOTO(out_mem, rc = -EINVAL);
                 }
-                rc = obd_connect(&lov->tgts[i].conn, tgt); 
-                if (rc) { 
-                        CERROR("Target %s connect error %d\n", 
-                               uuidarray[i], rc); 
+                rc = obd_connect(&lov->tgts[i].conn, tgt);
+                if (rc) {
+                        CERROR("Target %s connect error %d\n",
+                               uuidarray[i], rc);
                         GOTO(out_mem, rc);
                 }
         }
 
  out_mem:
-        if (rc) { 
-                for (i = 0 ; i < lov->desc.ld_tgt_count; i++) { 
+        if (rc) {
+                for (i = 0 ; i < lov->desc.ld_tgt_count; i++) {
                         int rc2;
                         rc2 = obd_disconnect(&lov->tgts[i].conn);
                         if (rc2)
-                                CERROR("BAD: Target %s disconnect error %d\n", 
-                                       uuidarray[i], rc2); 
+                                CERROR("BAD: Target %s disconnect error %d\n",
+                                       uuidarray[i], rc2);
                 }
                 OBD_FREE(lov->tgts, lov->bufsize);
         }
  out:
-        if (rc) { 
+        if (rc)
                 class_disconnect(conn);
-        }
-        if (req)
-                ptlrpc_free_req(req); 
+
+        ptlrpc_free_req(req);
         return rc;
-        
 }
 
 static int lov_disconnect(struct lustre_handle *conn)
@@ -242,16 +205,16 @@ static int lov_create(struct lustre_handle *conn, struct obdo *oa, struct lov_st
 
         if (!export)
                 RETURN(-EINVAL);
-        lov = &export->export_obd->u.lov;
+        lov = &export->exp_obd->u.lov;
 
-        oa->o_easize =  lov_stripe_md_size(export->export_obd); 
-        if (! *ea) { 
-                OBD_ALLOC(*ea, oa->o_easize); 
-                if (! *ea) 
-                        RETURN(-ENOMEM); 
+        oa->o_easize =  lov_stripe_md_size(export->exp_obd);
+        if (!*ea) {
+                OBD_ALLOC(*ea, oa->o_easize);
+                if (! *ea)
+                        RETURN(-ENOMEM);
         }
 
-        md = *ea; 
+        md = *ea;
         md->lmd_size = oa->o_easize;
         md->lmd_object_id = oa->o_id;
         if (!md->lmd_stripe_count) { 
@@ -301,10 +264,10 @@ struct lov_stripe_md *ea)
                 RETURN(-EINVAL); 
         }
 
-        if (!export || !export->export_obd) 
+        if (!export || !export->exp_obd) 
                 RETURN(-ENODEV); 
 
-        lov = &export->export_obd->u.lov;
+        lov = &export->exp_obd->u.lov;
         md = ea;
 
         for (i = 0; i < md->lmd_stripe_count; i++) {