From 9b0236e44aa487db1652ec8d92bd5724473b2d62 Mon Sep 17 00:00:00 2001 From: braam Date: Fri, 28 Jun 2002 01:53:38 +0000 Subject: [PATCH] - more fixes to export handling. Probably tomorrow they can be completed. --- lustre/include/linux/lustre_net.h | 2 ++ lustre/include/linux/obd_class.h | 1 + lustre/ost/ost_handler.c | 21 +++++++++++++-------- lustre/ptlrpc/service.c | 18 ++++++------------ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lustre/include/linux/lustre_net.h b/lustre/include/linux/lustre_net.h index 245639b..781191b 100644 --- a/lustre/include/linux/lustre_net.h +++ b/lustre/include/linux/lustre_net.h @@ -175,6 +175,8 @@ struct ptlrpc_request { ptl_md_t rq_req_md; ptl_handle_md_t rq_req_md_h; + struct lustre_peer rq_peer; /* XXX see service.c can this be factored away? */ + struct obd_export *rq_export; struct ptlrpc_connection *rq_connection; struct ptlrpc_client *rq_client; struct ptlrpc_service *rq_svc; diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 96259cd..0c9d9f2 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -73,6 +73,7 @@ struct obd_export { struct lustre_handle export_import; /* client handle */ struct list_head export_chain; struct obd_device *export_obd; + struct ptlrpc_connection *export_connection; unsigned int export_id; void *export_data; /* device specific data */ }; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 87bbd65..4e9ef59 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -174,6 +174,7 @@ static int ost_connect(struct ptlrpc_request *req) { struct ost_body *body; struct obd_device *target; + struct obd_export *export; struct obd_conn conn; char *uuid; int rc, size = sizeof(*body), i; @@ -209,6 +210,12 @@ static int ost_connect(struct ptlrpc_request *req) req->rq_repmsg->addr = conn.addr; req->rq_repmsg->cookie = conn.cookie; + export = gen_client(&conn); + if (!export) + LBUG(); + + req->rq_export = export; + export->export_connection = req->rq_connection; CDEBUG(D_IOCTL, "rep buffer %p, id %d\n", req->rq_repmsg, conn.oc_id); body = lustre_msg_buf(req->rq_repmsg, 0); body->connid = conn.oc_id; @@ -486,14 +493,12 @@ static int ost_handle(struct ptlrpc_request *req) GOTO(out, rc = -EINVAL); } - if (req->rq_reqmsg->opc != OST_CONNECT) { - struct obd_export *export; - export = gen_client((struct obd_conn *) req->rq_reqmsg); - if (!export) - GOTO(out, rc = -ENOTCONN); - if (strcmp(req->rq_obd->obd_type->typ_name, "ost") != 0) - GOTO(out, rc = -EINVAL); - } + if (req->rq_reqmsg->opc != OST_CONNECT && + req->rq_export == NULL) + GOTO(out, rc = -ENOTCONN); + + if (strcmp(req->rq_obd->obd_type->typ_name, "ost") != 0) + GOTO(out, rc = -EINVAL); switch (req->rq_reqmsg->opc) { case OST_CONNECT: diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 535b6fa..ee1e0eb 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -157,24 +157,18 @@ static int handle_incoming_request(struct obd_device *obddev, /* FIXME: this NI should be the incoming NI. * We don't know how to find that from here. */ peer.peer_ni = svc->srv_self.peer_ni; + request.rq_export = gen_client((struct obd_conn *) request.rq_reqmsg); - if (request.rq_reqmsg->conn2) { - request.rq_connection = - (void *)(unsigned long)request.rq_reqmsg->conn2; - ptlrpc_connection_addref(request.rq_connection); - } else { - /* - PHIL? should we perhaps only do this when - we get an incoming connmgr_connect request? - */ + if (request.rq_export) { + request.rq_connection = request.rq_export->export_connection; + ptlrpc_connection_addref(request.rq_connection); + } else { request.rq_connection = ptlrpc_get_connection(&peer); - if (!request.rq_connection) - LBUG(); } spin_unlock(&svc->srv_lock); rc = svc->srv_handler(&request); - ptlrpc_put_connection(request.rq_connection); + ptlrpc_put_connection(request.rq_connection); ptl_handled_rpc(svc, start); return rc; } -- 1.8.3.1