+ imp->imp_dlm_handle = *conn;
+
+ imp->imp_state = LUSTRE_IMP_NEW;
+ rc = ptlrpc_queue_wait(request);
+ if (rc)
+ GOTO(out_req, rc);
+
+ exp->exp_connection = ptlrpc_connection_addref(imp->imp_connection);
+
+ imp->imp_state = LUSTRE_IMP_FULL;
+ imp->imp_remote_handle = request->rq_repmsg->handle;
+
+out_req:
+ ptlrpc_req_finished(request);
+out_disco:
+ if (rc)
+ class_disconnect(exp, 0);
+ class_export_put(exp);
+ RETURN(rc);
+}
+
+
+/* modelled after ptlrpc_import_disconnect() */
+int ptlbd_cl_disconnect(struct obd_export *exp, int failover)
+{
+ struct obd_device *obd = exp->exp_obd;
+ struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
+ struct obd_import *imp = ptlbd->bd_import;
+ struct ptlrpc_request *request;
+ int rc, err;
+ ENTRY;
+
+ if (!obd)
+ RETURN(-EINVAL);
+
+ request = ptlrpc_prep_req(imp, PTLBD_DISCONNECT, 0, NULL, NULL);
+ if (!request)
+ GOTO(out_req, rc = -ENOMEM);
+
+ request->rq_replen = lustre_msg_size(0, NULL);
+ request->rq_send_state = LUSTRE_IMP_FULL;
+
+ rc = ptlrpc_queue_wait(request);
+
+out_req:
+ if (request)
+ ptlrpc_req_finished(request);
+ err = class_disconnect(exp, 0);
+ memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle));
+ if (!rc && err)
+ rc = err;
+ RETURN(rc);