Whamcloud - gitweb
Move knowledge of the LOV metadata/message structures out of mdc_getlovinfo()
authoradilger <adilger>
Sat, 7 Sep 2002 07:43:02 +0000 (07:43 +0000)
committeradilger <adilger>
Sat, 7 Sep 2002 07:43:02 +0000 (07:43 +0000)
and put it into lov_connect.  This will be needed when we have different
kinds of LOVs that store their data differently.  We still need to do
something about giving the LOV a "name" so that it can distinguish its data
on the MDS from other LOV's that there.

lustre/include/linux/lustre_mds.h
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c

index ec6ecb6..b494315 100644 (file)
@@ -151,7 +151,7 @@ int mdc_enqueue(struct lustre_handle *conn, int lock_type,
                 struct dentry *de, struct lustre_handle *lockh, char *tgt,
                 int tgtlen, void *data, int datalen);
 int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
-                   uuid_t **uuids, struct ptlrpc_request **request);
+                   struct ptlrpc_request **request);
 int mdc_getstatus(struct lustre_handle *conn,
                   struct ll_fid *rootfid, __u64 *last_committed,
                   __u64 *last_xid, struct ptlrpc_request **);
index e73cb24..bba10b8 100644 (file)
@@ -33,6 +33,8 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
 {
         struct ptlrpc_request *req;
         struct lov_obd *lov = &obd->u.lov;
+        struct client_obd *mdc = &lov->mdcobd->u.cli;
+        struct lov_desc *desc = &lov->desc;
         struct lustre_handle mdc_conn;
         uuid_t *uuidarray;
         int rc, rc2;
@@ -52,7 +54,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
                 GOTO(out, rc = -EINVAL);
         }
 
-        rc = mdc_getlovinfo(obd, &mdc_conn, &uuidarray, &req);
+        rc = mdc_getlovinfo(obd, &mdc_conn, &req);
         rc2 = obd_disconnect(&mdc_conn);
         if (rc || rc2) {
                 CERROR("cannot get lov info or disconnect %d/%d\n", rc, rc2);
@@ -60,23 +62,36 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
         }
 
         /* sanity... */
-        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);
+        if (req->rq_repmsg->bufcount < 2 ||
+            req->rq_repmsg->buflens[0] < sizeof(*desc)) {
+                CERROR("invalid descriptor returned\n");
                 GOTO(out, rc = -EINVAL);
         }
-        if (lov->desc.ld_tgt_count > 1000) {
-                CERROR("configuration error: target count > 1000 (%d)\n",
-                       lov->desc.ld_tgt_count);
+
+        memcpy(desc, lustre_msg_buf(req->rq_repmsg, 0), sizeof(*desc));
+        lov_unpackdesc(desc);
+
+        if (req->rq_repmsg->buflens[1] < sizeof(*uuidarray)*desc->ld_tgt_count){
+                CERROR("invalid uuid array returned\n");
                 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");
+
+        mdc->cl_max_mdsize = sizeof(struct lov_mds_md) +
+                desc->ld_tgt_count * sizeof(struct lov_object_id);
+
+        if (memcmp(obd->obd_uuid, desc->ld_uuid, sizeof(desc->ld_uuid))) {
+                CERROR("lov uuid %s not on mds device (%s)\n",
+                       obd->obd_uuid, desc->ld_uuid);
                 GOTO(out, rc = -EINVAL);
         }
 
-        lov->bufsize = sizeof(struct lov_tgt_desc) *  lov->desc.ld_tgt_count;
+        if (desc->ld_tgt_count > 1000) {
+                CERROR("configuration error: target count > 1000 (%d)\n",
+                       desc->ld_tgt_count);
+                GOTO(out, rc = -EINVAL);
+        }
+
+        lov->bufsize = sizeof(struct lov_tgt_desc) * desc->ld_tgt_count;
         OBD_ALLOC(lov->tgts, lov->bufsize);
         if (!lov->tgts) {
                 CERROR("Out of memory\n");
@@ -84,10 +99,10 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
         }
 
         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 < desc->ld_tgt_count; i++)
+                memcpy(lov->tgts[i].uuid, uuidarray[i], sizeof(*uuidarray));
 
-        for (i = 0 ; i < lov->desc.ld_tgt_count; i++) {
+        for (i = 0 ; i < desc->ld_tgt_count; i++) {
                 struct obd_device *tgt = class_uuid2obd(uuidarray[i]);
                 if (!tgt) {
                         CERROR("Target %s not attached\n", uuidarray[i]);
@@ -107,7 +122,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
 
  out_mem:
         if (rc) {
-                for (i = 0 ; i < lov->desc.ld_tgt_count; i++) {
+                for (i = 0 ; i < desc->ld_tgt_count; i++) {
                         rc2 = obd_disconnect(&lov->tgts[i].conn);
                         if (rc2)
                                 CERROR("BAD: Target %s disconnect error %d\n",
index 206dcfc..ea5e21c 100644 (file)
@@ -77,13 +77,10 @@ int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid,
 }
 
 int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
-                   uuid_t **uuids, struct ptlrpc_request **request)
+                   struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_status_req *streq;
-        struct lov_obd *lov = &obd->u.lov;
-        struct client_obd *mdc = &lov->mdcobd->u.cli;
-        struct lov_desc *desc = &lov->desc;
         int rc, size[2] = {sizeof(*streq)};
         ENTRY;
 
@@ -95,28 +92,19 @@ int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
         *request = req;
         streq = lustre_msg_buf(req->rq_reqmsg, 0);
         streq->flags = HTON__u32(MDS_STATUS_LOV);
-        streq->repbuf = HTON__u32(8000);
+        streq->repbuf = HTON__u32(8192);
 
         /* prepare for reply */
         req->rq_level = LUSTRE_CONN_CON;
-        size[0] = sizeof(*desc);
-        size[1] = 8000;
+        size[0] = 512;
+        size[1] = 8192;
         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->cl_max_mdsize = sizeof(struct lov_mds_md) +
-                        desc->ld_tgt_count * sizeof(struct lov_object_id);
-        }
-
-        EXIT;
  out:
-        return rc;
+        RETURN(rc);
 }