int pcaa_initial_connect;
};
+static void __import_set_state(struct obd_import *imp,
+ enum lustre_imp_state state)
+{
+ imp->imp_state = state;
+ imp->imp_state_hist[imp->imp_state_hist_idx].ish_state = state;
+ imp->imp_state_hist[imp->imp_state_hist_idx].ish_time =
+ cfs_time_current_sec();
+ imp->imp_state_hist_idx = (imp->imp_state_hist_idx + 1) %
+ IMP_STATE_HIST_LEN;
+}
+
/* A CLOSED import should remain so. */
#define IMPORT_SET_STATE_NOLOCK(imp, state) \
do { \
imp, obd2cli_tgt(imp->imp_obd), \
ptlrpc_import_state_name(imp->imp_state), \
ptlrpc_import_state_name(state)); \
- imp->imp_state = state; \
+ __import_set_state(imp, state); \
} \
} while(0)
libcfs_nid2str(imp->imp_connection->c_peer.nid));
} else {
LCONSOLE_ERROR_MSG(0x166, "%s: Connection to service "
- "%.*s via nid %s was lost; in progress"
- "operations using this service will"
- "fail.\n",
- imp->imp_obd->obd_name,
- target_len, target_start,
- libcfs_nid2str(imp->imp_connection->c_peer.nid));
+ "%.*s via nid %s was lost; in progress "
+ "operations using this service will fail.\n",
+ imp->imp_obd->obd_name,
+ target_len, target_start,
+ libcfs_nid2str(imp->imp_connection->c_peer.nid));
}
ptlrpc_deactivate_timeouts(imp);
IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
ptlrpc_deactivate_and_unlock_import(imp);
}
-static unsigned int
+static unsigned int
ptlrpc_inflight_deadline(struct ptlrpc_request *req, time_t now)
{
long dl;
- if (!(((req->rq_phase & (RQ_PHASE_RPC | RQ_PHASE_UNREGISTERING)) &&
- !req->rq_waiting) ||
+ if (!(((req->rq_phase == RQ_PHASE_RPC) && !req->rq_waiting) ||
(req->rq_phase == RQ_PHASE_BULK) ||
(req->rq_phase == RQ_PHASE_NEW)))
return 0;
* If this is an invalid MGC connection, then don't bother
* waiting for imp_inflight to drop to 0.
*/
- if (imp->imp_invalid && imp->imp_recon_bk && !imp->imp_obd->obd_no_recov)
+ if (imp->imp_invalid && imp->imp_recon_bk &&!imp->imp_obd->obd_no_recov)
goto out;
if (!imp->imp_invalid || imp->imp_obd->obd_no_recov)
LASSERT(imp->imp_invalid);
/* Wait forever until inflight == 0. We really can't do it another
- * way because in some cases we need to wait for very long reply
+ * way because in some cases we need to wait for very long reply
* unlink. We can't do anything before that because there is really
* no guarantee that some rdma transfer is not in progress right now. */
do {
- /* Calculate max timeout for waiting on rpcs to error
+ /* Calculate max timeout for waiting on rpcs to error
* out. Use obd_timeout if calculated value is smaller
* than it. */
- timeout = ptlrpc_inflight_timeout(imp);
- timeout += timeout / 3;
-
- if (timeout == 0)
- timeout = obd_timeout;
-
- CDEBUG(D_RPCTRACE, "Sleeping %d sec for inflight to error out\n",
+ if (!OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) {
+ timeout = ptlrpc_inflight_timeout(imp);
+ timeout += timeout / 3;
+
+ if (timeout == 0)
+ timeout = obd_timeout;
+ } else {
+ /* decrease the interval to increase race condition */
+ timeout = 1;
+ }
+
+ CDEBUG(D_RPCTRACE,"Sleeping %d sec for inflight to error out\n",
timeout);
/* Wait for all requests to error out and call completion
* have been locally cancelled by ptlrpc_abort_inflight. */
lwi = LWI_TIMEOUT_INTERVAL(
cfs_timeout_cap(cfs_time_seconds(timeout)),
- cfs_time_seconds(1), NULL, NULL);
+ (timeout > 1)?cfs_time_seconds(1):cfs_time_seconds(1)/2,
+ NULL, NULL);
rc = l_wait_event(imp->imp_recovery_waitq,
(atomic_read(&imp->imp_inflight) == 0), &lwi);
if (rc) {
cli_tgt, rc, atomic_read(&imp->imp_inflight));
spin_lock(&imp->imp_lock);
- list_for_each_safe(tmp, n, &imp->imp_sending_list) {
- req = list_entry(tmp, struct ptlrpc_request,
- rq_list);
- DEBUG_REQ(D_ERROR, req, "still on sending list");
- }
- list_for_each_safe(tmp, n, &imp->imp_delayed_list) {
- req = list_entry(tmp, struct ptlrpc_request,
- rq_list);
- DEBUG_REQ(D_ERROR, req, "still on delayed list");
- }
-
- if (atomic_read(&imp->imp_unregistering) == 0) {
- /* We know that only "unregistering" rpcs may
- * still survive in sending or delaying lists
- * (They are waiting for long reply unlink in
+ if (atomic_read(&imp->imp_inflight) == 0) {
+ int count = atomic_read(&imp->imp_unregistering);
+
+ /* We know that "unregistering" rpcs only can
+ * survive in sending or delaying lists (they
+ * maybe waiting for long reply unlink in
* sluggish nets). Let's check this. If there
- * is no unregistering and inflight != 0 this
+ * is no inflight and unregistering != 0, this
* is bug. */
- LASSERT(atomic_read(&imp->imp_inflight) == 0);
-
+ LASSERTF(count == 0, "Some RPCs are still "
+ "unregistering: %d\n", count);
+
/* Let's save one loop as soon as inflight have
* dropped to zero. No new inflights possible at
* this point. */
rc = 0;
} else {
+ list_for_each_safe(tmp, n,
+ &imp->imp_sending_list) {
+ req = list_entry(tmp,
+ struct ptlrpc_request,
+ rq_list);
+ DEBUG_REQ(D_ERROR, req,
+ "still on sending list");
+ }
+ list_for_each_safe(tmp, n,
+ &imp->imp_delayed_list) {
+ req = list_entry(tmp,
+ struct ptlrpc_request,
+ rq_list);
+ DEBUG_REQ(D_ERROR, req,
+ "still on delayed list");
+ }
+
CERROR("%s: RPCs in \"%s\" phase found (%d). "
"Network is sluggish? Waiting them "
"to error out.\n", cli_tgt,
}
} while (rc != 0);
- /*
+ /*
* Let's additionally check that no new rpcs added to import in
- * "invalidate" state.
+ * "invalidate" state.
*/
LASSERT(atomic_read(&imp->imp_inflight) == 0);
out:
sptlrpc_import_flush_all_ctx(imp);
atomic_dec(&imp->imp_inval_count);
- cfs_waitq_signal(&imp->imp_recovery_waitq);
+ cfs_waitq_broadcast(&imp->imp_recovery_waitq);
}
/* unset imp_invalid */
continue;
}
- /* If we have not tried this connection since the
+ /* If we have not tried this connection since
the last successful attempt, go with this one */
if ((conn->oic_last_attempt == 0) ||
cfs_time_beforeq_64(conn->oic_last_attempt,
}
/* if not found, simply choose the current one */
- if (!imp_conn) {
+ if (!imp_conn || imp->imp_force_reconnect) {
LASSERT(imp->imp_conn_current);
imp_conn = imp->imp_conn_current;
tried_all = 0;
if (imp->imp_conn_current != imp_conn) {
if (imp->imp_conn_current)
- LCONSOLE_INFO("Changing connection for %s to %s/%s\n",
- imp->imp_obd->obd_name,
- imp_conn->oic_uuid.uuid,
- libcfs_nid2str(imp_conn->oic_conn->c_peer.nid));
+ CDEBUG(D_HA, "Changing connection for %s to %s/%s\n",
+ imp->imp_obd->obd_name, imp_conn->oic_uuid.uuid,
+ libcfs_nid2str(imp_conn->oic_conn->c_peer.nid));
imp->imp_conn_current = imp_conn;
}
/*
* must be called under imp_lock
*/
-int ptlrpc_first_transno(struct obd_import *imp, __u64 *transno)
+static int ptlrpc_first_transno(struct obd_import *imp, __u64 *transno)
{
struct ptlrpc_request *req;
struct list_head *tmp;
else
committed_before_reconnect = imp->imp_peer_committed_transno;
- set_transno = ptlrpc_first_transno(imp, &imp->imp_connect_data.ocd_transno);
+ set_transno = ptlrpc_first_transno(imp,
+ &imp->imp_connect_data.ocd_transno);
spin_unlock(&imp->imp_lock);
if (new_uuid) {
GOTO(out, rc);
}
+ /* Report the rpc service time to the server so that it knows how long
+ * to wait for clients to join recovery */
+ lustre_msg_set_service_time(request->rq_reqmsg,
+ at_timeout2est(request->rq_timeout));
+
+ /* The amount of time we give the server to process the connect req.
+ * import_select_connection will increase the net latency on
+ * repeated reconnect attempts to cover slow networks.
+ * We override/ignore the server rpc completion estimate here,
+ * which may be large if this is a reconnect attempt */
+ request->rq_timeout = INITIAL_CONNECT_TIMEOUT;
+ lustre_msg_set_timeout(request->rq_reqmsg, request->rq_timeout);
+
#ifndef __KERNEL__
lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_LIBCLIENT);
#endif
spin_unlock(&imp->imp_lock);
lustre_msg_add_op_flags(request->rq_reqmsg,
MSG_CONNECT_INITIAL);
- if (AT_OFF)
- /* AT will use INITIAL_CONNECT_TIMEOUT the first
- time, adaptive after that. */
- request->rq_timeout = INITIAL_CONNECT_TIMEOUT;
}
if (set_transno)
* to have two identical connections in imp_conn_list. We must
* compare not conn's pointers but NIDs, otherwise we can defeat
* connection throttling. (See bug 14774.) */
- if (imp->imp_conn_current->oic_conn->c_self !=
- imp_conn->oic_conn->c_self) {
+ if (imp->imp_conn_current->oic_conn->c_peer.nid !=
+ imp_conn->oic_conn->c_peer.nid) {
ptlrpc_ping_import_soon(imp);
wake_pinger = 1;
}
#else
- /* liblustre has no pinger thead, so we wakup pinger anyway */
+ /* liblustre has no pinger thread, so we wakeup pinger anyway */
wake_pinger = 1;
#endif
EXIT;
}
+static int ptlrpc_busy_reconnect(int rc)
+{
+ return (rc == -EBUSY) || (rc == -EAGAIN);
+}
+
+
static int ptlrpc_connect_interpret(const struct lu_env *env,
struct ptlrpc_request *request,
- void * data, int rc)
+ void *data, int rc)
{
struct ptlrpc_connect_async_args *aa = data;
struct obd_import *imp = request->rq_import;
struct client_obd *cli = &imp->imp_obd->u.cli;
struct lustre_handle old_hdl;
+ __u64 old_connect_flags;
int msg_flags;
ENTRY;
spin_unlock(&imp->imp_lock);
RETURN(0);
}
- spin_unlock(&imp->imp_lock);
- if (rc)
+ if (rc) {
+ /* if this reconnect to busy export - not need select new target
+ * for connecting*/
+ imp->imp_force_reconnect = ptlrpc_busy_reconnect(rc);
+ spin_unlock(&imp->imp_lock);
GOTO(out, rc);
+ }
LASSERT(imp->imp_conn_current);
msg_flags = lustre_msg_get_op_flags(request->rq_repmsg);
/* All imports are pingable */
- spin_lock(&imp->imp_lock);
imp->imp_pingable = 1;
+ imp->imp_force_reconnect = 0;
if (aa->pcaa_initial_connect) {
if (msg_flags & MSG_CONNECT_REPLAYABLE) {
IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY_LOCKS);
} else {
IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
- }
-
- spin_lock(&imp->imp_lock);
- if (imp->imp_invalid) {
- spin_unlock(&imp->imp_lock);
ptlrpc_activate_import(imp);
- } else {
- spin_unlock(&imp->imp_lock);
}
GOTO(finish, rc = 0);
if (memcmp(&imp->imp_remote_handle,
lustre_msg_get_handle(request->rq_repmsg),
sizeof(imp->imp_remote_handle))) {
- int level = msg_flags & MSG_CONNECT_RECOVERING ? D_HA :
- D_WARNING;
+ int level = msg_flags & MSG_CONNECT_RECOVERING ?
+ D_HA : D_WARNING;
/* Bug 16611/14775: if server handle have changed,
* that means some sort of disconnection happened.
* participate since we can reestablish all of our state
* with server again */
CDEBUG(level,"%s@%s changed server handle from "
- LPX64" to "LPX64"%s \n" "but is still in recovery \n",
+ LPX64" to "LPX64"%s\n",
obd2cli_tgt(imp->imp_obd),
imp->imp_connection->c_remote_uuid.uuid,
imp->imp_remote_handle.cookie,
lustre_msg_get_handle(request->rq_repmsg)->
cookie,
(MSG_CONNECT_RECOVERING & msg_flags) ?
- "but is still in recovery" : "");
+ " but is still in recovery" : "");
imp->imp_remote_handle =
*lustre_msg_get_handle(request->rq_repmsg);
imp->imp_obd->obd_name);
GOTO(out, rc = -ENODEV);
}
+ old_connect_flags = exp->exp_connect_flags;
exp->exp_connect_flags = ocd->ocd_connect_flags;
imp->imp_obd->obd_self_export->exp_connect_flags =
ocd->ocd_connect_flags;
ocd->ocd_brw_size >> CFS_PAGE_SHIFT;
}
- imp->imp_obd->obd_namespace->ns_connect_flags =
- ocd->ocd_connect_flags;
- imp->imp_obd->obd_namespace->ns_orig_connect_flags =
- ocd->ocd_connect_flags;
+ /* Reset ns_connect_flags only for initial connect. It might be
+ * changed in while using FS and if we reset it in reconnect
+ * this leads to losing user settings done before such as
+ * disable lru_resize, etc. */
+ if (old_connect_flags != exp->exp_connect_flags ||
+ aa->pcaa_initial_connect) {
+ CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server "
+ "flags: "LPX64"\n", imp->imp_obd->obd_name,
+ ocd->ocd_connect_flags);
+ imp->imp_obd->obd_namespace->ns_connect_flags =
+ ocd->ocd_connect_flags;
+ imp->imp_obd->obd_namespace->ns_orig_connect_flags =
+ ocd->ocd_connect_flags;
+ }
if ((ocd->ocd_connect_flags & OBD_CONNECT_AT) &&
(imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2))
imp->imp_last_recon = 0;
spin_unlock(&imp->imp_lock);
- cfs_waitq_signal(&imp->imp_recovery_waitq);
+ cfs_waitq_broadcast(&imp->imp_recovery_waitq);
RETURN(rc);
}
{
ENTRY;
atomic_dec(&req->rq_import->imp_replay_inflight);
- if (req->rq_status == 0) {
+ if (req->rq_status == 0 &&
+ !req->rq_import->imp_vbr_failed) {
ptlrpc_import_recovery_state_machine(req->rq_import);
} else {
- CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, "
- "reconnecting\n",
- req->rq_import->imp_obd->obd_name, req->rq_status);
+ if (req->rq_import->imp_vbr_failed) {
+ CDEBUG(D_WARNING,
+ "%s: version recovery fails, reconnecting\n",
+ req->rq_import->imp_obd->obd_name);
+ spin_lock(&req->rq_import->imp_lock);
+ req->rq_import->imp_vbr_failed = 0;
+ spin_unlock(&req->rq_import->imp_lock);
+ } else {
+ CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, "
+ "reconnecting\n",
+ req->rq_import->imp_obd->obd_name,
+ req->rq_status);
+ }
ptlrpc_connect_import(req->rq_import, NULL);
}
req->rq_send_state = LUSTRE_IMP_REPLAY_WAIT;
lustre_msg_add_flags(req->rq_reqmsg,
MSG_LOCK_REPLAY_DONE | MSG_REQ_REPLAY_DONE);
- req->rq_timeout *= 3;
+ if (AT_OFF)
+ req->rq_timeout *= 3;
req->rq_interpret_reply = completed_replay_interpret;
ptlrpcd_add_req(req, PSCOPE_OTHER);
ENTRY;
- ptlrpc_daemonize("ll_imp_inval");
+ cfs_daemonize_ctxt("ll_imp_inval");
CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
ptlrpc_import_recovery_state_machine(imp);
+ class_import_put(imp);
RETURN(0);
}
#endif
imp->imp_connection->c_remote_uuid.uuid);
#ifdef __KERNEL__
+ /* bug 17802: XXX client_disconnect_export vs connect request
+ * race. if client will evicted at this time, we start
+ * invalidate thread without reference to import and import can
+ * be freed at same time. */
+ class_import_get(imp);
rc = cfs_kernel_thread(ptlrpc_invalidate_import_thread, imp,
CLONE_VM | CLONE_FILES);
- if (rc < 0)
+ if (rc < 0) {
+ class_import_put(imp);
CERROR("error starting invalidate thread: %d\n", rc);
- else
+ } else {
rc = 0;
+ }
RETURN(rc);
#else
ptlrpc_invalidate_import(imp);
}
if (imp->imp_state == LUSTRE_IMP_FULL) {
- cfs_waitq_signal(&imp->imp_recovery_waitq);
+ cfs_waitq_broadcast(&imp->imp_recovery_waitq);
ptlrpc_wake_delayed(imp);
}
else
IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED);
memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle));
- imp->imp_conn_cnt = 0;
/* Try all connections in the future - bz 12758 */
imp->imp_last_recon = 0;
spin_unlock(&imp->imp_lock);
RETURN(rc);
}
+void ptlrpc_cleanup_imp(struct obd_import *imp)
+{
+ ENTRY;
+
+ spin_lock(&imp->imp_lock);
+ IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED);
+ imp->imp_generation++;
+ spin_unlock(&imp->imp_lock);
+ ptlrpc_abort_inflight(imp);
+
+ EXIT;
+}
/* Adaptive Timeout utils */
extern unsigned int at_min, at_max, at_history;
time_t binlimit = max_t(time_t, at_history / AT_BINS, 1);
LASSERT(at);
-#if 0
- CDEBUG(D_INFO, "add %u to %p time=%lu v=%u (%u %u %u %u)\n",
+ CDEBUG(D_OTHER, "add %u to %p time=%lu v=%u (%u %u %u %u)\n",
val, at, now - at->at_binstart, at->at_current,
at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]);
-#endif
+
if (val == 0)
/* 0's don't count, because we never want our timeout to
drop to 0, and because 0 could mean an error */
at->at_current = min(at->at_current, at_max);
at->at_current = max(at->at_current, at_min);
-#if 0
if (at->at_current != old)
- CDEBUG(D_ADAPTTO, "AT %p change: old=%u new=%u delta=%d "
+ CDEBUG(D_OTHER, "AT %p change: old=%u new=%u delta=%d "
"(val=%u) hist %u %u %u %u\n", at,
old, at->at_current, at->at_current - old, val,
at->at_hist[0], at->at_hist[1], at->at_hist[2],
at->at_hist[3]);
-#endif
/* if we changed, report the old value */
old = (at->at_current != old) ? old : 0;