From: wangdi Date: Mon, 10 Mar 2008 13:31:56 +0000 (+0000) Subject: Branch: HEAD X-Git-Tag: v1_7_0_51~144 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=0dfa288ba31a5bdc2929357e7180bb42be553267 Branch: HEAD b=13464 Set import disconnection before mgc reconnection, and refine the previous 13464 fix. i=nathan,adilger --- diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 748fe49..a5e0db1 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -870,6 +870,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose); int ptlrpc_import_recovery_state_machine(struct obd_import *imp); /* ptlrpc/pack_generic.c */ +int ptlrpc_reconnect_import(struct obd_import *imp); int lustre_msg_swabbed(struct lustre_msg *msg); int lustre_msg_check_version(struct lustre_msg *msg, __u32 version); void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, int *lens, diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 39a5632..150fc0d 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -772,33 +772,6 @@ static int mgc_target_register(struct obd_export *exp, RETURN(rc); } -int mgc_reconnect_import(struct obd_import *imp) -{ - /* 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; -} - int mgc_set_info_async(struct obd_export *exp, obd_count keylen, void *key, obd_count vallen, void *val, struct ptlrpc_request_set *set) @@ -837,7 +810,7 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen, ptlrpc_import_state_name(imp->imp_state)); /* Resurrect if we previously died */ if (imp->imp_invalid || value > 1) - mgc_reconnect_import(imp); + ptlrpc_reconnect_import(imp); RETURN(0); } /* FIXME move this to mgc_process_config */ diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 5759083..a797029 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -660,25 +660,25 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, DEBUG_REQ(D_ERROR, req, "IMP_CLOSED "); *status = -EIO; } else if (req->rq_send_state == LUSTRE_IMP_CONNECTING && - imp->imp_state == LUSTRE_IMP_CONNECTING) { + imp->imp_state == LUSTRE_IMP_CONNECTING) { /* allow CONNECT even if import is invalid */ ; - } else if (imp->imp_invalid) { - /* if it is mgc, wait for recovry. b=13464 */ - if (imp->imp_recon_bk && !imp->imp_obd->obd_no_recov) - delay = 1; + } else if (imp->imp_invalid && (!imp->imp_recon_bk || + imp->imp_obd->obd_no_recov)) { /* If the import has been invalidated (such as by an OST - * failure) the request must fail with -ESHUTDOWN. This - * indicates the requests should be discarded; an -EIO - * may result in a resend of the request. */ + * failure), and if the import(MGC) tried all of its connection + * list (Bug 13464), the request must fail with -ESHUTDOWN. + * This indicates the requests should be discarded; an -EIO + * may result in a resend of the request. */ if (!imp->imp_deactive) - DEBUG_REQ(D_ERROR, req, "IMP_INVALID"); + DEBUG_REQ(D_ERROR, req, "IMP_INVALID"); *status = -ESHUTDOWN; /* bz 12940 */ } else if (req->rq_import_generation != imp->imp_generation) { DEBUG_REQ(D_ERROR, req, "req wrong generation:"); *status = -EIO; } else if (req->rq_send_state != imp->imp_state) { - if (imp->imp_obd->obd_no_recov || imp->imp_dlm_fake || - req->rq_no_delay) + if (imp->imp_obd->obd_no_recov) + *status = -ESHUTDOWN; + else if (imp->imp_dlm_fake || req->rq_no_delay) *status = -EWOULDBLOCK; else delay = 1; diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index c570f12..9d06364 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -271,6 +271,37 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) 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;