#include <lustre_import.h>
#include <lustre_export.h>
#include <obd.h>
+#include <obd_cksum.h>
#include <obd_class.h>
#include "ptlrpc_internal.h"
return rc;
}
-/*
- * This acts as a barrier; all existing requests are rejected, and
- * no new requests will be accepted until the import is valid again.
- */
-void ptlrpc_deactivate_import(struct obd_import *imp)
+/* Must be called with imp_lock held! */
+static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp)
{
ENTRY;
+ LASSERT_SPIN_LOCKED(&imp->imp_lock);
- spin_lock(&imp->imp_lock);
if (imp->imp_invalid) {
spin_unlock(&imp->imp_lock);
EXIT;
}
/*
+ * This acts as a barrier; all existing requests are rejected, and
+ * no new requests will be accepted until the import is valid again.
+ */
+void ptlrpc_deactivate_import(struct obd_import *imp)
+{
+ spin_lock(&imp->imp_lock);
+ ptlrpc_deactivate_and_unlock_import(imp);
+}
+
+/*
* This function will invalidate the import, if necessary, then block
* for all the RPC completions, and finally notify the obd to
* invalidate its state (ie cancel locks, clear pending requests,
atomic_inc(&imp->imp_inval_count);
- ptlrpc_deactivate_import(imp);
+ /*
+ * 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)
+ goto out;
+
+ if (!imp->imp_invalid || imp->imp_obd->obd_no_recov)
+ ptlrpc_deactivate_import(imp);
LASSERT(imp->imp_invalid);
rc = l_wait_event(imp->imp_recovery_waitq,
(atomic_read(&imp->imp_inflight) == 0), &lwi);
- if (rc)
- CDEBUG(D_HA, "%s: rc = %d waiting for callback (%d != 0)\n",
+ if (rc) {
+ struct list_head *tmp, *n;
+ struct ptlrpc_request *req;
+
+ CERROR("%s: rc = %d waiting for callback (%d != 0)\n",
obd2cli_tgt(imp->imp_obd), 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");
+ }
+ spin_unlock(&imp->imp_lock);
+ LASSERT(atomic_read(&imp->imp_inflight) == 0);
+ }
+out:
obd_import_event(imp->imp_obd, imp, IMP_EVENT_INVALIDATE);
sptlrpc_import_flush_all_ctx(imp);
EXIT;
}
+int ptlrpc_reconnect_import(struct obd_import *imp)
+{
+
+ ptlrpc_set_import_discon(imp, 0);
+ /* Force a new connect attempt */
+ ptlrpc_invalidate_import(imp);
+ /* Do a fresh connect next time by zeroing the handle */
+ ptlrpc_disconnect_import(imp, 1);
+ /* Wait for all invalidate calls to finish */
+ if (atomic_read(&imp->imp_inval_count) > 0) {
+ int rc;
+ struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
+ rc = l_wait_event(imp->imp_recovery_waitq,
+ (atomic_read(&imp->imp_inval_count) == 0),
+ &lwi);
+ if (rc)
+ CERROR("Interrupted, inval=%d\n",
+ atomic_read(&imp->imp_inval_count));
+ }
+
+ /* Allow reconnect attempts */
+ imp->imp_obd->obd_no_recov = 0;
+ /* Remove 'invalid' flag */
+ ptlrpc_activate_import(imp);
+ /* Attempt a new connect */
+ ptlrpc_recover_import(imp, NULL);
+ return 0;
+}
+
+EXPORT_SYMBOL(ptlrpc_reconnect_import);
+
static int import_select_connection(struct obd_import *imp)
{
struct obd_import_conn *imp_conn = NULL, *conn;
{
struct ptlrpc_request *req;
struct list_head *tmp;
-
+
if (list_empty(&imp->imp_replay_list))
return 0;
tmp = imp->imp_replay_list.next;
req = list_entry(tmp, struct ptlrpc_request, rq_replay_list);
*transno = req->rq_transno;
+ if (req->rq_transno == 0) {
+ DEBUG_REQ(D_ERROR, req, "zero transno in replay");
+ LBUG();
+ }
+
return 1;
}
struct obd_import_conn,
oic_item);
- if (imp->imp_conn_current != imp_conn) {
+ /* XXX: When the failover node is the primary node, it is possible
+ * 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) {
ptlrpc_ping_import_soon(imp);
wake_pinger = 1;
}
spin_unlock(&imp->imp_lock);
}
- if (msg_flags & MSG_CONNECT_NEXT_VER) {
- imp->imp_msg_magic = LUSTRE_MSG_MAGIC_V2;
- CDEBUG(D_RPCTRACE, "connect to %s with lustre_msg_v2\n",
- obd2cli_tgt(imp->imp_obd));
- } else {
- CDEBUG(D_RPCTRACE, "connect to %s with lustre_msg_v1\n",
- obd2cli_tgt(imp->imp_obd));
- }
+ /* if applies, adjust the imp->imp_msg_magic here
+ * according to reply flags */
imp->imp_remote_handle =
*lustre_msg_get_handle(request->rq_repmsg);
IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
- ptlrpc_activate_import(imp);
+ 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);
} else {
spin_unlock(&imp->imp_lock);
if (memcmp(&imp->imp_remote_handle,
lustre_msg_get_handle(request->rq_repmsg),
sizeof(imp->imp_remote_handle))) {
- int level = D_ERROR;
- /* Old MGC can reconnect to a restarted MGS */
- if (strcmp(imp->imp_obd->obd_type->typ_name,
- LUSTRE_MGC_NAME) == 0) {
- level = D_CONFIG;
- }
- CDEBUG(level,
- "%s@%s changed handle from "LPX64" to "LPX64
- "; copying, but this may foreshadow disaster\n",
+
+ CWARN("%s@%s changed server handle from "
+ LPX64" to "LPX64" - evicting.\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);
+ cookie);
imp->imp_remote_handle =
*lustre_msg_get_handle(request->rq_repmsg);
+
+ IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
+ GOTO(finish, rc = 0);
} else {
CDEBUG(D_HA, "reconnected to %s@%s after partition\n",
obd2cli_tgt(imp->imp_obd),
newer : older, LUSTRE_VERSION_STRING);
}
+ if (ocd->ocd_connect_flags & OBD_CONNECT_CKSUM) {
+ /* We sent to the server ocd_cksum_types with bits set
+ * for algorithms we understand. The server masked off
+ * the checksum types it doesn't support */
+ if ((ocd->ocd_cksum_types & OBD_CKSUM_ALL) == 0) {
+ LCONSOLE_WARN("The negotiation of the checksum "
+ "alogrithm to use with server %s "
+ "failed (%x/%x), disabling "
+ "checksums\n",
+ obd2cli_tgt(imp->imp_obd),
+ ocd->ocd_cksum_types,
+ OBD_CKSUM_ALL);
+ cli->cl_checksum = 0;
+ cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
+ cli->cl_cksum_type = OBD_CKSUM_CRC32;
+ } else {
+ cli->cl_supp_cksum_types = ocd->ocd_cksum_types;
+
+ if (ocd->ocd_cksum_types & OSC_DEFAULT_CKSUM)
+ cli->cl_cksum_type = OSC_DEFAULT_CKSUM;
+ else if (ocd->ocd_cksum_types & OBD_CKSUM_ADLER)
+ cli->cl_cksum_type = OBD_CKSUM_ADLER;
+ else
+ cli->cl_cksum_type = OBD_CKSUM_CRC32;
+ }
+ } else {
+ /* The server does not support OBD_CONNECT_CKSUM.
+ * Enforce CRC32 for backward compatibility*/
+ cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
+ cli->cl_cksum_type = OBD_CKSUM_CRC32;
+ }
+
if (ocd->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
cli->cl_max_pages_per_rpc =
ocd->ocd_brw_size >> CFS_PAGE_SHIFT;
out:
if (rc != 0) {
IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
+ spin_lock(&imp->imp_lock);
if (aa->pcaa_initial_connect && !imp->imp_initial_recov &&
(request->rq_import_generation == imp->imp_generation))
- ptlrpc_deactivate_import(imp);
+ ptlrpc_deactivate_and_unlock_import(imp);
+ else
+ spin_unlock(&imp->imp_lock);
if ((imp->imp_recon_bk && imp->imp_last_recon) ||
(rc == -EACCES)) {