* -------------------------------------------------------------------------- */
int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp,
- struct obd_uuid *cluuid)
+ struct obd_uuid *cluuid, int initial_conn)
{
- if (exp->exp_connection) {
+ if (exp->exp_connection && !initial_conn) {
struct lustre_handle *hdl;
hdl = &exp->exp_imp_reverse->imp_remote_handle;
/* Might be a re-connect after a partition. */
-#warning "FIXME ASAP"
- memcpy(&hdl->cookie, &conn->cookie, sizeof(conn->cookie));
- if (1 || !memcmp(&conn->cookie, &hdl->cookie, sizeof conn->cookie)) {
+ if (!memcmp(&conn->cookie, &hdl->cookie, sizeof conn->cookie)) {
CERROR("%s reconnecting\n", cluuid->uuid);
conn->cookie = exp->exp_handle.h_cookie;
- /*RETURN(EALREADY);*/
- RETURN(0);
+ RETURN(EALREADY);
} else {
CERROR("%s reconnecting from %s, "
"handle mismatch (ours "LPX64", theirs "
char *str, *tmp;
int rc = 0, abort_recovery;
unsigned long flags;
+ int initial_conn = 0;
ENTRY;
OBD_RACE(OBD_FAIL_TGT_CONN_RACE);
if (obd_uuid_equals(&cluuid, &target->obd_uuid))
goto dont_check_exports;
+ if (lustre_msg_get_op_flags(req->rq_reqmsg) & MSG_CONNECT_INITIAL)
+ initial_conn = 1;
+
spin_lock(&target->obd_dev_lock);
list_for_each(p, &target->obd_exports) {
export = list_entry(p, struct obd_export, exp_obd_chain);
spin_unlock(&target->obd_dev_lock);
LASSERT(export->exp_obd == target);
- rc = target_handle_reconnect(&conn, export, &cluuid);
+ rc = target_handle_reconnect(&conn, export, &cluuid,
+ initial_conn);
break;
}
export = NULL;
/* If we found an export, we already unlocked. */
if (!export) {
spin_unlock(&target->obd_dev_lock);
- } else if (req->rq_reqmsg->conn_cnt == 1) {
+ } else if (req->rq_reqmsg->conn_cnt == 1 && !initial_conn) {
CERROR("%s reconnected with 1 conn_cnt; cookies not random?\n",
cluuid.uuid);
-#warning "FIXME ASAP"
- /*GOTO(out, rc = -EALREADY);*/
+ GOTO(out, rc = -EALREADY);
}
/* Tell the client if we're in recovery. */
/* If this is the first client, start the recovery timer */
+ CWARN("%s: connection from %s %s\n", target->obd_name, cluuid.uuid,
+ target->obd_recovering ? "(recovering)" : "");
if (target->obd_recovering) {
lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_RECOVERING);
target_start_recovery_timer(target, handler);
LASSERT(export != NULL);
spin_lock_irqsave(&export->exp_lock, flags);
-#warning "FIXME ASAP"
- if (0 && export->exp_conn_cnt >= req->rq_reqmsg->conn_cnt) {
+ if (initial_conn) {
+ req->rq_repmsg->conn_cnt = export->exp_conn_cnt + 1;
+ } else if (export->exp_conn_cnt >= req->rq_reqmsg->conn_cnt) {
CERROR("%s: already connected at a higher conn_cnt: %d > %d\n",
cluuid.uuid, export->exp_conn_cnt,
req->rq_reqmsg->conn_cnt);
spin_unlock_irqrestore(&export->exp_lock, flags);
GOTO(out, rc = -EALREADY);
- }
+ }
export->exp_conn_cnt = req->rq_reqmsg->conn_cnt;
spin_unlock_irqrestore(&export->exp_lock, flags);
IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CONNECTING);
- imp->imp_conn_cnt++;
imp->imp_resend_replay = 0;
if (imp->imp_remote_handle.cookie == 0) {
initial_connect = 1;
} else {
committed_before_reconnect = imp->imp_peer_committed_transno;;
-
+ imp->imp_conn_cnt++;
}
aa->pcaa_peer_committed = committed_before_reconnect;
aa->pcaa_initial_connect = initial_connect;
- if (aa->pcaa_initial_connect)
- imp->imp_replayable = 1;
+ if (aa->pcaa_initial_connect) {
+ lustre_msg_add_op_flags(request->rq_reqmsg,
+ MSG_CONNECT_INITIAL);
+ imp->imp_replayable = 1;
+ }
ptlrpcd_add_req(request);
rc = 0;
} else {
imp->imp_replayable = 0;
}
+ LASSERTF(imp->imp_conn_cnt < request->rq_repmsg->conn_cnt,
+ "imp conn_cnt %d req conn_cnt %d",
+ imp->imp_conn_cnt, request->rq_repmsg->conn_cnt);
+ imp->imp_conn_cnt = request->rq_repmsg->conn_cnt;
imp->imp_remote_handle = request->rq_repmsg->handle;
IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
GOTO(finish, rc = 0);
imp->imp_last_replay_transno = 0;
IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
} else {
+ CWARN("oops! we get evicted from %s\n", imp->imp_target_uuid.uuid);
imp->imp_remote_handle = request->rq_repmsg->handle;
IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
}