return 0;
}
+int ptlrpc_connect_import(struct obd_import *imp)
+{
+ spin_lock(&imp->imp_lock);
+ return ptlrpc_connect_import_locked(imp);
+}
+
/**
* Attempt to (re)connect import \a imp. This includes all preparations,
* initializing CONNECT RPC request and passing it to ptlrpcd for
* actual sending.
+ *
+ * Assumes imp->imp_lock is held, and releases it.
+ *
* Returns 0 on success or error code.
*/
-int ptlrpc_connect_import(struct obd_import *imp)
+int ptlrpc_connect_import_locked(struct obd_import *imp)
{
struct obd_device *obd = imp->imp_obd;
int initial_connect = 0;
int rc;
ENTRY;
- spin_lock(&imp->imp_lock);
+ assert_spin_locked(&imp->imp_lock);
+
if (imp->imp_state == LUSTRE_IMP_CLOSED) {
spin_unlock(&imp->imp_lock);
CERROR("can't connect to a closed import\n");
req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_DISCONNECT,
LUSTRE_OBD_VERSION, rq_opc);
if (req == NULL)
- RETURN(NULL);
+ RETURN(ERR_PTR(-ENOMEM));
/* We are disconnecting, do not retry a failed DISCONNECT rpc if
* it fails. We can get through the above with a down server
connect = 1;
}
}
- spin_unlock(&imp->imp_lock);
if (connect) {
- rc = ptlrpc_connect_import(imp);
+ rc = ptlrpc_connect_import_locked(imp);
if (rc >= 0)
ptlrpc_pinger_add_import(imp);
+ } else {
+ spin_unlock(&imp->imp_lock);
}
return 0;