- struct ptlrpc_request *request;
- struct list_head *tmp;
- int rc = -EINVAL;
-
- /* XXX c_lock semantics! */
- conn->c_level = LUSTRE_CONN_CON;
-
- /* XXX this code MUST be shared with class_obd_connect! */
- list_for_each(tmp, &conn->c_imports) {
- struct obd_import *imp = list_entry(tmp, struct obd_import,
- imp_chain);
- struct obd_device *obd = imp->imp_obd;
- struct client_obd *cli = &obd->u.cli;
- int rq_opc = (obd->obd_type->typ_ops->o_brw)
- ? OST_CONNECT : MDS_CONNECT;
- int size[] = { sizeof(cli->cl_target_uuid),
- sizeof(obd->obd_uuid) };
- char *tmp[] = {cli->cl_target_uuid, obd->obd_uuid };
- struct lustre_handle old_hdl;
-
- LASSERT(imp->imp_connection == conn);
- request = ptlrpc_prep_req(imp, rq_opc, 2, size, tmp);
- request->rq_level = LUSTRE_CONN_NEW;
- request->rq_replen = lustre_msg_size(0, NULL);
- /* XXX are (addr, cookie) right? */
- request->rq_reqmsg->addr = imp->imp_handle.addr;
- request->rq_reqmsg->cookie = imp->imp_handle.cookie;
- rc = ptlrpc_queue_wait(request);
- rc = ptlrpc_check_status(request, rc);
- if (rc) {
- CERROR("cannot connect to %s@%s: rc = %d\n",
- cli->cl_target_uuid, conn->c_remote_uuid, rc);
- ptlrpc_free_req(request);
- GOTO(out_disc, rc = -ENOTCONN);
- }