import.c
来自「lustre 1.6.5 source code」· C语言 代码 · 共 1,348 行 · 第 1/4 页
C
1,348 行
spin_unlock(&imp->imp_lock); } /* Determine what recovery state to move the import to. */ if (MSG_CONNECT_RECONNECT & msg_flags) { memset(&old_hdl, 0, sizeof(old_hdl)); if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg), sizeof (old_hdl))) { CERROR("%s@%s didn't like our handle "LPX64 ", failed\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid, imp->imp_dlm_handle.cookie); GOTO(out, rc = -ENOTCONN); } if (memcmp(&imp->imp_remote_handle, lustre_msg_get_handle(request->rq_repmsg), sizeof(imp->imp_remote_handle))) { 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); 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), imp->imp_connection->c_remote_uuid.uuid); } if (imp->imp_invalid) { CDEBUG(D_HA, "%s: reconnected but import is invalid; " "marking evicted\n", imp->imp_obd->obd_name); IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED); } else if (MSG_CONNECT_RECOVERING & msg_flags) { CDEBUG(D_HA, "%s: reconnected to %s during replay\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd)); spin_lock(&imp->imp_lock); imp->imp_resend_replay = 1; spin_unlock(&imp->imp_lock); IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY); } else { IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER); } } else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) { LASSERT(imp->imp_replayable); imp->imp_remote_handle = *lustre_msg_get_handle(request->rq_repmsg); imp->imp_last_replay_transno = 0; IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY); } else { DEBUG_REQ(D_HA, request, "evicting (not initial connect and " "flags reconnect/recovering not set: %x)",msg_flags); imp->imp_remote_handle = *lustre_msg_get_handle(request->rq_repmsg); IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED); } /* Sanity checks for a reconnected import. */ if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) { CERROR("imp_replayable flag does not match server " "after reconnect. We should LBUG right here.\n"); } if (lustre_msg_get_last_committed(request->rq_repmsg) < aa->pcaa_peer_committed) { CERROR("%s went back in time (transno "LPD64 " was previously committed, server now claims "LPD64 ")! See https://bugzilla.clusterfs.com/" "long_list.cgi?buglist=9646\n", obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed, lustre_msg_get_last_committed(request->rq_repmsg)); }finish: rc = ptlrpc_import_recovery_state_machine(imp); if (rc != 0) { if (rc == -ENOTCONN) { CDEBUG(D_HA, "evicted/aborted by %s@%s during recovery;" "invalidating and reconnecting\n", obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid); ptlrpc_connect_import(imp, NULL); RETURN(0); } } else { struct obd_connect_data *ocd; struct obd_export *exp; ocd = lustre_swab_repbuf(request, REPLY_REC_OFF, sizeof(*ocd), lustre_swab_connect); spin_lock(&imp->imp_lock); list_del(&imp->imp_conn_current->oic_item); list_add(&imp->imp_conn_current->oic_item, &imp->imp_conn_list); imp->imp_last_success_conn = imp->imp_conn_current->oic_last_attempt; if (ocd == NULL) { spin_unlock(&imp->imp_lock); CERROR("Wrong connect data from server\n"); rc = -EPROTO; GOTO(out, rc); } imp->imp_connect_data = *ocd; exp = class_conn2export(&imp->imp_dlm_handle); spin_unlock(&imp->imp_lock); /* check that server granted subset of flags we asked for. */ LASSERTF((ocd->ocd_connect_flags & imp->imp_connect_flags_orig) == ocd->ocd_connect_flags, LPX64" != "LPX64, imp->imp_connect_flags_orig, ocd->ocd_connect_flags); if (!exp) { /* This could happen if export is cleaned during the connect attempt */ CERROR("Missing export for %s\n", imp->imp_obd->obd_name); GOTO(out, rc = -ENODEV); } exp->exp_connect_flags = ocd->ocd_connect_flags; imp->imp_obd->obd_self_export->exp_connect_flags = ocd->ocd_connect_flags; class_export_put(exp); obd_import_event(imp->imp_obd, imp, IMP_EVENT_OCD); if (!ocd->ocd_ibits_known && ocd->ocd_connect_flags & OBD_CONNECT_IBITS) CERROR("Inodebits aware server returned zero compatible" " bits?\n"); if ((ocd->ocd_connect_flags & OBD_CONNECT_VERSION) && (ocd->ocd_version > LUSTRE_VERSION_CODE + LUSTRE_VERSION_OFFSET_WARN || ocd->ocd_version < LUSTRE_VERSION_CODE - LUSTRE_VERSION_OFFSET_WARN)) { /* Sigh, some compilers do not like #ifdef in the middle of macro arguments */#ifdef __KERNEL__ const char *older = "older. Consider upgrading this client";#else const char *older = "older. Consider recompiling this application";#endif const char *newer = "newer than client version"; LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) " "is much %s (%s)\n", obd2cli_tgt(imp->imp_obd), OBD_OCD_VERSION_MAJOR(ocd->ocd_version), OBD_OCD_VERSION_MINOR(ocd->ocd_version), OBD_OCD_VERSION_PATCH(ocd->ocd_version), OBD_OCD_VERSION_FIX(ocd->ocd_version), ocd->ocd_version > LUSTRE_VERSION_CODE ? 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; } 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)) /* We need a per-message support flag, because a. we don't know if the incoming connect reply supports AT or not (in reply_in_callback) until we unpack it. b. failovered server means export and flags are gone (in ptlrpc_send_reply). Can only be set when we know AT is supported at both ends */ imp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT; else imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT; LASSERT((cli->cl_max_pages_per_rpc <= PTLRPC_MAX_BRW_PAGES) && (cli->cl_max_pages_per_rpc > 0)); } 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_and_unlock_import(imp); else spin_unlock(&imp->imp_lock); if (imp->imp_recon_bk && imp->imp_last_recon) { /* Give up trying to reconnect */ imp->imp_obd->obd_no_recov = 1; ptlrpc_deactivate_import(imp); } if (rc == -EPROTO) { struct obd_connect_data *ocd; ocd = lustre_swab_repbuf(request, REPLY_REC_OFF, sizeof *ocd, lustre_swab_connect); if (ocd && (ocd->ocd_connect_flags & OBD_CONNECT_VERSION) && (ocd->ocd_version != LUSTRE_VERSION_CODE)) { /* Actually servers are only supposed to refuse connection from liblustre clients, so we should never see this from VFS context */ LCONSOLE_ERROR_MSG(0x16a, "Server %s version " "(%d.%d.%d.%d)" " refused connection from this client " "with an incompatible version (%s). " "Client must be recompiled\n", obd2cli_tgt(imp->imp_obd), OBD_OCD_VERSION_MAJOR(ocd->ocd_version), OBD_OCD_VERSION_MINOR(ocd->ocd_version), OBD_OCD_VERSION_PATCH(ocd->ocd_version), OBD_OCD_VERSION_FIX(ocd->ocd_version), LUSTRE_VERSION_STRING); ptlrpc_deactivate_import(imp); IMPORT_SET_STATE(imp, LUSTRE_IMP_CLOSED); } RETURN(-EPROTO); } ptlrpc_maybe_ping_import_soon(imp); CDEBUG(D_HA, "recovery of %s on %s failed (%d)\n", obd2cli_tgt(imp->imp_obd), (char *)imp->imp_connection->c_remote_uuid.uuid, rc); } spin_lock(&imp->imp_lock); imp->imp_last_recon = 0; spin_unlock(&imp->imp_lock); cfs_waitq_signal(&imp->imp_recovery_waitq); RETURN(rc);}static int completed_replay_interpret(struct ptlrpc_request *req, void * data, int rc){ ENTRY; atomic_dec(&req->rq_import->imp_replay_inflight); if (req->rq_status == 0) { 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); ptlrpc_connect_import(req->rq_import, NULL); } RETURN(0);}static int signal_completed_replay(struct obd_import *imp){ struct ptlrpc_request *req; ENTRY; LASSERT(atomic_read(&imp->imp_replay_inflight) == 0); atomic_inc(&imp->imp_replay_inflight); req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING, 1, NULL, NULL); if (!req) { atomic_dec(&imp->imp_replay_inflight); RETURN(-ENOMEM); } ptlrpc_req_set_repsize(req, 1, NULL); req->rq_send_state = LUSTRE_IMP_REPLAY_WAIT; lustre_msg_add_flags(req->rq_reqmsg, MSG_LAST_REPLAY); req->rq_timeout *= 3; req->rq_interpret_reply = completed_replay_interpret; ptlrpcd_add_req(req); RETURN(0);}#ifdef __KERNEL__static int ptlrpc_invalidate_import_thread(void *data){ struct obd_import *imp = data; ENTRY;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?