Whamcloud - gitweb
- More changes in the connection handle stuff. We are back to where
authorbraam <braam>
Thu, 27 Jun 2002 23:15:06 +0000 (23:15 +0000)
committerbraam <braam>
Thu, 27 Jun 2002 23:15:06 +0000 (23:15 +0000)
  obdecho works over the net.

lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_net.h
lustre/include/linux/obd.h
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/ptlrpc/client.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/rpc.c
lustre/ptlrpc/service.c

index 9b096a3..ca6c12b 100644 (file)
@@ -52,8 +52,9 @@ struct lustre_handle {
 };
 
 struct lustre_msg {
-        __u64 conn;  /* pointer to ptlrpc_connection */
-        __u64 token; /* security token */
+        __u64 addr;
+        __u64 cookie; /* security token */
+        __u64 conn2; /* pointer to ptlrpc_connection: should go */
 
         __u64 last_rcvd;
         __u64 last_committed;
index 56452cd..245639b 100644 (file)
@@ -248,6 +248,17 @@ struct ptlrpc_service {
         int (*srv_handler)(struct ptlrpc_request *req);
 };
 
+static inline void ptlrpc_hdl2req(struct ptlrpc_request *req, struct lustre_handle *h)
+{
+        req->rq_reqmsg->addr = h->addr;
+        req->rq_reqmsg->cookie = h->cookie;
+}
+struct ptlrpc_request *ptlrpc_prep_req2(struct ptlrpc_client *cl,
+                                        struct ptlrpc_connection *conn,
+                                        struct lustre_handle *handle, 
+                                       int opcode, int count, int *lengths,
+                                        char **bufs);
+
 typedef void (*bulk_callback_t)(struct ptlrpc_bulk_desc *, void *);
 
 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
index 60d9724..2b9c633 100644 (file)
@@ -150,7 +150,7 @@ struct ost_obd {
 };
 
 struct osc_obd {
-        struct obd_device *osc_tgt;
+        struct lustre_handle osc_connh;
         struct ptlrpc_client *osc_client;
         struct ptlrpc_client *osc_ldlm_client;
         struct ptlrpc_connection *osc_conn;
index 2312ef3..3c85846 100644 (file)
@@ -52,6 +52,7 @@ static void osc_con2dlmcl(struct obd_conn *conn, struct ptlrpc_client **cl,
 static int osc_connect(struct obd_conn *conn, struct obd_device *obd)
 {
         struct osc_obd *osc = &obd->u.osc;
+        struct obd_import *import;
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
@@ -60,6 +61,15 @@ static int osc_connect(struct obd_conn *conn, struct obd_device *obd)
         int rc, size = sizeof(osc->osc_target_uuid);
         ENTRY;
 
+        OBD_ALLOC(import, sizeof(*import)); 
+        if (!import)
+                RETURN(-ENOMEM);
+                  
+        MOD_INC_USE_COUNT;
+        rc = gen_connect(conn, obd);
+        if (rc) 
+                GOTO(out, rc);
+
         osc_obd2cl(obd, &cl, &connection);
         request = ptlrpc_prep_req(cl, connection, OST_CONNECT, 1, &size, &tmp);
         if (!request)
@@ -78,14 +88,19 @@ static int osc_connect(struct obd_conn *conn, struct obd_device *obd)
         body = lustre_msg_buf(request->rq_repmsg, 0);
         CDEBUG(D_INODE, "received connid %d\n", body->connid);
 
+
+        /* XXX: Make this a handle */
+        osc->osc_connh.addr = request->rq_repmsg->addr;
+        osc->osc_connh.cookie = request->rq_repmsg->cookie;
         /* This might be redundant. */
         cl->cli_target_devno = request->rq_repmsg->target_id;
         osc->osc_ldlm_client->cli_target_devno = cl->cli_target_devno;
-        /* XXX: Make this a handle */
         conn->oc_id = body->connid;
         EXIT;
  out:
         ptlrpc_free_req(request);
+        if (rc)
+                MOD_DEC_USE_COUNT;
         return rc;
 }
 
@@ -95,12 +110,13 @@ static int osc_disconnect(struct obd_conn *conn)
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
         struct ost_body *body;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         int rc, size = sizeof(*body);
         ENTRY;
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_DISCONNECT, 1, &size,
-                                  NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh,
+                                  OST_DISCONNECT, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -110,7 +126,12 @@ static int osc_disconnect(struct obd_conn *conn)
         request->rq_replen = lustre_msg_size(0, NULL);
 
         rc = ptlrpc_queue_wait(request);
-        GOTO(out, rc);
+        if (rc) 
+                GOTO(out, rc);
+        rc = gen_disconnect(conn);
+        if (!rc)
+                MOD_DEC_USE_COUNT;
+
  out:
         ptlrpc_free_req(request);
         return rc;
@@ -120,13 +141,15 @@ static int osc_getattr(struct obd_conn *conn, struct obdo *oa)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_GETATTR, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                   OST_GETATTR, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -159,13 +182,15 @@ static int osc_open(struct obd_conn *conn, struct obdo *oa)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_OPEN, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                   OST_OPEN, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -196,13 +221,15 @@ static int osc_close(struct obd_conn *conn, struct obdo *oa)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_CLOSE, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                   OST_CLOSE, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -232,13 +259,15 @@ static int osc_setattr(struct obd_conn *conn, struct obdo *oa)
 {
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ptlrpc_connection *connection;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_SETATTR, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                  OST_SETATTR, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -262,6 +291,7 @@ static int osc_create(struct obd_conn *conn, struct obdo *oa)
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ost_body *body;
         struct mds_objid *objid;
         struct lov_object_id *lov_id;
@@ -273,7 +303,8 @@ static int osc_create(struct obd_conn *conn, struct obdo *oa)
                 RETURN(-EINVAL);
         }
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_CREATE, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                  OST_CREATE, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -311,6 +342,7 @@ static int osc_punch(struct obd_conn *conn, struct obdo *oa, obd_size count,
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
@@ -320,7 +352,8 @@ static int osc_punch(struct obd_conn *conn, struct obdo *oa, obd_size count,
                 RETURN(-EINVAL);
         }
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_PUNCH, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                   OST_PUNCH, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -351,6 +384,7 @@ static int osc_destroy(struct obd_conn *conn, struct obdo *oa)
         struct ptlrpc_request *request;
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ost_body *body;
         int rc, size = sizeof(*body);
         ENTRY;
@@ -360,7 +394,8 @@ static int osc_destroy(struct obd_conn *conn, struct obdo *oa)
                 RETURN(-EINVAL);
         }
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_DESTROY, 1, &size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                   OST_DESTROY, 1, &size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
@@ -414,6 +449,7 @@ static int osc_brw_read(struct obd_conn *conn, obd_count num_oa,
 {
         struct ptlrpc_client *cl;
         struct ptlrpc_connection *connection;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct ptlrpc_request *request;
         struct ost_body *body;
         struct list_head *tmp;
@@ -429,7 +465,8 @@ static int osc_brw_read(struct obd_conn *conn, obd_count num_oa,
         size[2] = pages * sizeof(struct niobuf_remote);
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_BRW, 3, size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                  OST_BRW, 3, size, NULL);
         if (!request)
                 GOTO(out, rc = -ENOMEM);
 
@@ -520,6 +557,7 @@ static int osc_brw_write(struct obd_conn *conn, obd_count num_oa,
         struct ptlrpc_connection *connection;
         struct ptlrpc_request *request;
         struct ptlrpc_bulk_desc *desc;
+        struct osc_obd *osc = &gen_conn2obd(conn)->u.osc;
         struct obd_ioobj ioo;
         struct ost_body *body;
         struct niobuf_local *local;
@@ -541,7 +579,8 @@ static int osc_brw_write(struct obd_conn *conn, obd_count num_oa,
                 RETURN(-ENOMEM);
 
         osc_con2cl(conn, &cl, &connection);
-        request = ptlrpc_prep_req(cl, connection, OST_BRW, 3, size, NULL);
+        request = ptlrpc_prep_req2(cl, connection, &osc->osc_connh, 
+                                  OST_BRW, 3, size, NULL);
         if (!request)
                 GOTO(out, rc = -ENOMEM);
         body = lustre_msg_buf(request->rq_reqmsg, 0);
@@ -659,6 +698,7 @@ static int osc_enqueue(struct obd_conn *oconn,
 {
         struct obd_device *obddev = gen_conn2obd(oconn);
         struct ptlrpc_connection *conn;
+        struct osc_obd *osc = &gen_conn2obd(oconn)->u.osc;
         struct ptlrpc_client *cl;
         struct ldlm_extent *extent = extentp;
         int rc;
index 3244e9f..87bbd65 100644 (file)
@@ -198,16 +198,16 @@ static int ost_connect(struct ptlrpc_request *req)
                 RETURN(0);
         }
 
-        conn.addr = req->rq_reqmsg->conn;
-        conn.cookie = req->rq_reqmsg->token;
+        conn.addr = req->rq_reqmsg->addr;
+        conn.cookie = req->rq_reqmsg->cookie;
 
         rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
         if (rc)
                 RETURN(rc);
 
         req->rq_status = obd_connect(&conn, target);
-        req->rq_repmsg->conn = conn.addr;
-        req->rq_repmsg->token = conn.cookie;
+        req->rq_repmsg->addr = conn.addr;
+        req->rq_repmsg->cookie = conn.cookie;
 
         CDEBUG(D_IOCTL, "rep buffer %p, id %d\n", req->rq_repmsg, conn.oc_id);
         body = lustre_msg_buf(req->rq_repmsg, 0);
index 61ca919..2746c59 100644 (file)
@@ -177,8 +177,8 @@ struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
         request->rq_type = PTL_RPC_TYPE_REQUEST;
         request->rq_connection = ptlrpc_connection_addref(conn);
 
-        request->rq_reqmsg->conn = (__u64)(unsigned long)conn->c_remote_conn;
-        request->rq_reqmsg->token = conn->c_remote_token;
+        request->rq_reqmsg->conn2 = (__u64)(unsigned long)conn->c_remote_conn;
+        //request->rq_reqmsg->token = conn->c_remote_token;
         request->rq_reqmsg->opc = HTON__u32(opcode);
         request->rq_reqmsg->type = HTON__u32(PTL_RPC_MSG_REQUEST);
         request->rq_reqmsg->target_id = HTON__u32(cl->cli_target_devno);
@@ -198,6 +198,17 @@ struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
 
         RETURN(request);
 }
+struct ptlrpc_request *ptlrpc_prep_req2(struct ptlrpc_client *cl,
+                                        struct ptlrpc_connection *conn,
+                                        struct lustre_handle *handle, 
+                                       int opcode, int count, int *lengths,
+                                       char **bufs)
+{
+        struct ptlrpc_request *req;
+        req = ptlrpc_prep_req(cl, conn, opcode, count, lengths, bufs);
+        ptlrpc_hdl2req(req, handle);
+        return req;
+}
 
 void ptlrpc_req_finished(struct ptlrpc_request *request)
 {
index bbb4729..a95dd67 100644 (file)
@@ -216,8 +216,8 @@ int ptlrpc_reply(struct ptlrpc_service *svc, struct ptlrpc_request *req)
 {
         /* FIXME: we need to increment the count of handled events */
         req->rq_type = PTL_RPC_TYPE_REPLY;
-        req->rq_repmsg->conn = req->rq_connection->c_remote_conn;
-        req->rq_repmsg->token = req->rq_connection->c_remote_token;
+        //req->rq_repmsg->conn = req->rq_connection->c_remote_conn;
+        //req->rq_repmsg->token = req->rq_connection->c_remote_token;
         req->rq_repmsg->status = HTON__u32(req->rq_status);
         req->rq_reqmsg->type = HTON__u32(req->rq_type);
         return ptl_send_buf(req, req->rq_connection, svc->srv_rep_portal);
index 3ecbac6..ec61517 100644 (file)
@@ -184,6 +184,7 @@ EXPORT_SYMBOL(ptlrpc_replay_req);
 EXPORT_SYMBOL(ptlrpc_restart_req);
 EXPORT_SYMBOL(ptlrpc_prep_req);
 EXPORT_SYMBOL(ptlrpc_free_req);
+EXPORT_SYMBOL(ptlrpc_prep_req2);
 EXPORT_SYMBOL(ptlrpc_req_finished);
 EXPORT_SYMBOL(ptlrpc_prep_bulk);
 EXPORT_SYMBOL(ptlrpc_free_bulk);
index de5f4c3..535b6fa 100644 (file)
@@ -158,21 +158,9 @@ static int handle_incoming_request(struct obd_device *obddev,
          * We don't know how to find that from here. */
         peer.peer_ni = svc->srv_self.peer_ni;
 
-        if (request.rq_reqmsg->conn) {
+        if (request.rq_reqmsg->conn2) {
                 request.rq_connection =
-                        (void *)(unsigned long)request.rq_reqmsg->conn;
-                if (request.rq_reqmsg->token !=
-                    request.rq_connection->c_token) {
-                        struct ptlrpc_connection *tmp;
-                        tmp = ptlrpc_get_connection(&peer);
-                        CERROR("rq_reqmsg->conn: %p\n", request.rq_connection);
-                        CERROR("real connection: %p\n", tmp);
-                        CERROR("rq_reqmsg->token: %Lu\n",
-                               (unsigned long long)request.rq_reqmsg->token);
-                        CERROR("real token      : %Lu\n",
-                               (unsigned long long)tmp->c_token);
-                        LBUG();
-                }
+                        (void *)(unsigned long)request.rq_reqmsg->conn2;
                 ptlrpc_connection_addref(request.rq_connection);
         } else {
                 /*