From ff14a77c285b8ca6c1b51fb58478cd5fd4328881 Mon Sep 17 00:00:00 2001 From: shadow Date: Thu, 5 Feb 2009 10:35:55 +0000 Subject: [PATCH] send activate event only when connect finished and import state is FULL. Branch HEAD b=16839 i=nikita i=umka --- lustre/ChangeLog | 9 +++++++++ lustre/cmm/mdc_device.c | 4 +--- lustre/cmm/mdc_internal.h | 1 - lustre/include/lustre_net.h | 2 +- lustre/include/obd.h | 4 +++- lustre/include/obd_class.h | 4 ++-- lustre/ldlm/ldlm_lib.c | 35 +++++++++++++++------------------ lustre/liblustre/llite_lib.c | 5 +---- lustre/liblustre/super.c | 8 ++------ lustre/llite/llite_lib.c | 9 ++------- lustre/lmv/lmv_obd.c | 30 +++++++++++++--------------- lustre/lov/lov_obd.c | 47 ++++++++++++++++++-------------------------- lustre/mdc/mdc_request.c | 4 ++-- lustre/mds/mds_lov.c | 4 +--- lustre/mdt/mdt_handler.c | 29 ++++++++++++++------------- lustre/mgs/mgs_handler.c | 24 +++++++++++----------- lustre/obdclass/llog_test.c | 7 ++++--- lustre/obdclass/obd_mount.c | 4 +--- lustre/obdecho/echo.c | 14 +++++++++++-- lustre/obdecho/echo_client.c | 13 +++++------- lustre/obdfilter/filter.c | 28 ++++++++++++++------------ lustre/ptlrpc/import.c | 7 ------- 22 files changed, 138 insertions(+), 154 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8a7efd9..7d14da4 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -14,6 +14,15 @@ tbd Sun Microsystems, Inc. * File join has been disabled in this release, refer to Bugzilla 16929. Severity : normal +Frequency : start MDS on uncleanly shutdowned MDS device +Bugzilla : 16839 +Descriptoin: ll_sync thread stay in waiting mds<>ost recovery finished +Details : stay in waiting mds<>ost recovery finished produce random bugs + due race between two ll_sync thread for one lov target. send + ACTIVATE event only if connect realy finished and import have + FULL state. + +Severity : normal Frequency : rare, connect and disconnect target at same time Bugzilla : 17310 Descriptoin: ASSERTION(atomic_read(&imp->imp_inflight) == 0 diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index db2d0b1..d3a7c3b 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -130,7 +130,6 @@ static int mdc_obd_add(const struct lu_env *env, CERROR("target %s not set up\n", mdc->obd_name); rc = -EINVAL; } else { - struct lustre_handle *conn = &desc->cl_conn; struct obd_connect_data *ocd; CDEBUG(D_CONFIG, "connect to %s(%s)\n", @@ -153,13 +152,12 @@ static int mdc_obd_add(const struct lu_env *env, OBD_CONNECT_MDS_MDS | OBD_CONNECT_FID | OBD_CONNECT_AT; - rc = obd_connect(env, conn, mdc, &mdc->obd_uuid, ocd, NULL); + rc = obd_connect(env, &desc->cl_exp, mdc, &mdc->obd_uuid, ocd, NULL); OBD_FREE_PTR(ocd); if (rc) { CERROR("target %s connect error %d\n", mdc->obd_name, rc); } else { - desc->cl_exp = class_conn2export(conn); /* set seq controller export for MDC0 if exists */ if (mc->mc_num == 0) ms->ms_control_exp = diff --git a/lustre/cmm/mdc_internal.h b/lustre/cmm/mdc_internal.h index 774912b..e7a1d13 100644 --- a/lustre/cmm/mdc_internal.h +++ b/lustre/cmm/mdc_internal.h @@ -50,7 +50,6 @@ #include struct mdc_cli_desc { - struct lustre_handle cl_conn; /* uuid of remote MDT to connect */ struct obd_uuid cl_srv_uuid; /* mdc uuid */ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 01754a8..67efebc 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1271,7 +1271,7 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req) int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg); int client_obd_cleanup(struct obd_device *obddev); int client_connect_import(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *, void *localdata); int client_disconnect_export(struct obd_export *exp); diff --git a/lustre/include/obd.h b/lustre/include/obd.h index a351c93..f4ee771 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -858,6 +858,8 @@ static inline void oti_free_cookies(struct obd_trans_info *oti) * Events signalled through obd_notify() upcall-chain. */ enum obd_notify_event { + /* Device connect start */ + OBD_NOTIFY_CONNECT, /* Device activated */ OBD_NOTIFY_ACTIVE, /* Device deactivated */ @@ -1215,7 +1217,7 @@ struct obd_ops { * granted by the target, which are guaranteed to be a subset of flags * asked for. If @ocd == NULL, use default parameters. */ int (*o_connect)(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *src, + struct obd_export **exp, struct obd_device *src, struct obd_uuid *cluuid, struct obd_connect_data *ocd, void *localdata); int (*o_reconnect)(const struct lu_env *env, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index e65da9f..b47d60b 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -822,7 +822,7 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) } static inline int obd_connect(const struct lu_env *env, - struct lustre_handle *conn,struct obd_device *obd, + struct obd_export **exp,struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *d, void *localdata) @@ -836,7 +836,7 @@ static inline int obd_connect(const struct lu_env *env, OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, connect); - rc = OBP(obd, connect)(env, conn, obd, cluuid, d, localdata); + rc = OBP(obd, connect)(env, exp, obd, cluuid, d, localdata); /* check that only subset is granted */ LASSERT(ergo(d != NULL, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 3c1b45a..ac044bd 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -385,27 +385,29 @@ int client_obd_cleanup(struct obd_device *obddev) /* ->o_connect() method for client side (OSC and MDC and MGC) */ int client_connect_import(const struct lu_env *env, - struct lustre_handle *dlm_handle, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { struct client_obd *cli = &obd->u.cli; struct obd_import *imp = cli->cl_import; - struct obd_export *exp; struct obd_connect_data *ocd; struct ldlm_namespace *to_be_freed = NULL; + struct lustre_handle conn = { 0 }; int rc; ENTRY; + *exp = NULL; down_write(&cli->cl_sem); - rc = class_connect(dlm_handle, obd, cluuid); + rc = class_connect(&conn, obd, cluuid); if (rc) GOTO(out_sem, rc); + *exp = class_conn2export(&conn); + cli->cl_conn_count++; if (cli->cl_conn_count > 1) GOTO(out_sem, rc); - exp = class_conn2export(dlm_handle); if (obd->obd_namespace != NULL) CERROR("already have namespace!\n"); @@ -415,7 +417,7 @@ int client_connect_import(const struct lu_env *env, if (obd->obd_namespace == NULL) GOTO(out_disco, rc = -ENOMEM); - imp->imp_dlm_handle = *dlm_handle; + imp->imp_dlm_handle = conn; rc = ptlrpc_init_import(imp); if (rc != 0) GOTO(out_ldlm, rc); @@ -431,7 +433,7 @@ int client_connect_import(const struct lu_env *env, LASSERT (imp->imp_state == LUSTRE_IMP_DISCON); GOTO(out_ldlm, rc); } - LASSERT(exp->exp_connection); + LASSERT((*exp)->exp_connection); if (data) { LASSERTF((ocd->ocd_connect_flags & data->ocd_connect_flags) == @@ -451,9 +453,8 @@ out_ldlm: obd->obd_namespace = NULL; out_disco: cli->cl_conn_count--; - class_disconnect(exp); - } else { - class_export_put(exp); + class_disconnect(*exp); + *exp = NULL; } out_sem: up_write(&cli->cl_sem); @@ -846,12 +847,17 @@ int target_handle_connect(struct ptlrpc_request *req) } else { dont_check_exports: rc = obd_connect(req->rq_svc_thread->t_env, - &conn, target, &cluuid, data, + &export, target, &cluuid, data, client_nid); + if (rc == 0) + conn.cookie = export->exp_handle.h_cookie; } } else { rc = obd_reconnect(req->rq_svc_thread->t_env, export, target, &cluuid, data, client_nid); + if (rc == 0) + /* prevous done via class_conn2export */ + class_export_get(export); } if (rc) GOTO(out, rc); @@ -869,15 +875,6 @@ dont_check_exports: lustre_msg_set_handle(req->rq_repmsg, &conn); - /* ownership of this export ref transfers to the request AFTER we - * drop any previous reference the request had, but we don't want - * that to go to zero before we get our new export reference. */ - export = class_conn2export(&conn); - if (!export) { - DEBUG_REQ(D_ERROR, req, "Missing export!"); - GOTO(out, rc = -ENODEV); - } - /* If the client and the server are the same node, we will already * have an export that really points to the client's DLM export, * because we have a shared handles table. diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index 232ce2b..5a34a82 100644 --- a/lustre/liblustre/llite_lib.c +++ b/lustre/liblustre/llite_lib.c @@ -94,7 +94,6 @@ int liblustre_process_log(struct config_llog_instance *cfg, struct lustre_cfg *lcfg; char *peer = "MGS_UUID"; struct obd_device *obd; - struct lustre_handle mgc_conn = {0, }; struct obd_export *exp; char *name = "mgc_dev"; class_uuid_t uuid; @@ -184,15 +183,13 @@ int liblustre_process_log(struct config_llog_instance *cfg, #endif ocd->ocd_version = LUSTRE_VERSION_CODE; - rc = obd_connect(NULL, &mgc_conn, obd, &mgc_uuid, ocd, NULL); + rc = obd_connect(NULL, &exp, obd, &mgc_uuid, ocd, NULL); if (rc) { CERROR("cannot connect to %s at %s: rc = %d\n", LUSTRE_MGS_OBDNAME, mgsnid, rc); GOTO(out_cleanup, rc); } - exp = class_conn2export(&mgc_conn); - ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT); cfg->cfg_flags |= CFG_F_COMPAT146; rc = class_config_parse_llog(ctxt, profile, cfg); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index a410d2f..5f4c017 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -1937,8 +1937,6 @@ llu_fsswop_mount(const char *source, struct obd_statfs osfs; static struct qstr noname = { NULL, 0, 0 }; struct ptlrpc_request *request = NULL; - struct lustre_handle md_conn = {0, }; - struct lustre_handle dt_conn = {0, }; struct lustre_md md; class_uuid_t uuid; struct config_llog_instance cfg = {0, }; @@ -2026,12 +2024,11 @@ llu_fsswop_mount(const char *source, ocd.ocd_version = LUSTRE_VERSION_CODE; /* setup mdc */ - err = obd_connect(NULL, &md_conn, obd, &sbi->ll_sb_uuid, &ocd, NULL); + err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL); if (err) { CERROR("cannot connect to %s: rc = %d\n", mdc, err); GOTO(out_free, err); } - sbi->ll_md_exp = class_conn2export(&md_conn); err = obd_statfs(obd, &osfs, 100000000, 0); if (err) @@ -2057,12 +2054,11 @@ llu_fsswop_mount(const char *source, OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_FID | OBD_CONNECT_AT; ocd.ocd_version = LUSTRE_VERSION_CODE; - err = obd_connect(NULL, &dt_conn, obd, &sbi->ll_sb_uuid, &ocd, NULL); + err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL); if (err) { CERROR("cannot connect to %s: rc = %d\n", osc, err); GOTO(out_md, err); } - sbi->ll_dt_exp = class_conn2export(&dt_conn); sbi->ll_lco.lco_flags = ocd.ocd_connect_flags; sbi->ll_lco.lco_md_exp = sbi->ll_md_exp; sbi->ll_lco.lco_dt_exp = sbi->ll_dt_exp; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 7532fa8..2f20b80 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -166,8 +166,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) struct obd_capa *oc = NULL; struct obd_statfs osfs; struct ptlrpc_request *request = NULL; - struct lustre_handle dt_conn = {0, }; - struct lustre_handle md_conn = {0, }; struct obd_connect_data *data = NULL; struct obd_uuid *uuid; struct lustre_md lmd; @@ -232,7 +230,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) if (sbi->ll_flags & LL_SBI_RMT_CLIENT) data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE; - err = obd_connect(NULL, &md_conn, obd, &sbi->ll_sb_uuid, data, NULL); + err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing " "recovery, of which this client is not a " @@ -243,7 +241,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) CERROR("cannot connect to %s: rc = %d\n", md, err); GOTO(out, err); } - sbi->ll_md_exp = class_conn2export(&md_conn); err = obd_fid_init(sbi->ll_md_exp); if (err) { @@ -372,7 +369,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) obd->obd_upcall.onu_upcall = cl_ocd_update; data->ocd_brw_size = PTLRPC_MAX_BRW_PAGES << CFS_PAGE_SHIFT; - err = obd_connect(NULL, &dt_conn, obd, &sbi->ll_sb_uuid, data, NULL); + err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing " "recovery, of which this client is not a " @@ -384,8 +381,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) GOTO(out_md_fid, err); } - sbi->ll_dt_exp = class_conn2export(&dt_conn); - err = obd_fid_init(sbi->ll_dt_exp); if (err) { CERROR("Can't init data layer FID infrastructure, " diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 7543a8c..f98f511 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -239,7 +239,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, * caller that everything is okay. Real connection will be performed later. */ static int lmv_connect(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { @@ -247,29 +247,30 @@ static int lmv_connect(const struct lu_env *env, struct proc_dir_entry *lmv_proc_dir; #endif struct lmv_obd *lmv = &obd->u.lmv; - struct obd_export *exp; + struct lustre_handle conn = { 0 }; int rc = 0; ENTRY; - rc = class_connect(conn, obd, cluuid); - if (rc) { - CERROR("class_connection() returned %d\n", rc); - RETURN(rc); - } - - exp = class_conn2export(conn); - /* * We don't want to actually do the underlying connections more than * once, so keep track. */ lmv->refcount++; if (lmv->refcount > 1) { - class_export_put(exp); + *exp = NULL; RETURN(0); } - lmv->exp = exp; + rc = class_connect(&conn, obd, cluuid); + if (rc) { + CERROR("class_connection() returned %d\n", rc); + RETURN(rc); + } + + *exp = class_conn2export(&conn); + class_export_get(*exp); + + lmv->exp = *exp; lmv->connected = 0; lmv->cluuid = *cluuid; @@ -383,7 +384,6 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) struct obd_uuid *cluuid = &lmv->cluuid; struct obd_connect_data *mdc_data = NULL; struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; - struct lustre_handle conn = {0, }; struct obd_device *mdc_obd; struct obd_export *mdc_exp; struct lu_fld_target target; @@ -407,15 +407,13 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) RETURN(-EINVAL); } - rc = obd_connect(NULL, &conn, mdc_obd, &lmv_mdc_uuid, + rc = obd_connect(NULL, &mdc_exp, mdc_obd, &lmv_mdc_uuid, &lmv->conn_data, NULL); if (rc) { CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc); RETURN(rc); } - mdc_exp = class_conn2export(&conn); - /* * Init fid sequence client for this mdc and add new fld target. */ diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 4fa94d2..11267e7 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -135,7 +135,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct obd_uuid tgt_uuid; struct obd_device *tgt_obd; struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; - struct lustre_handle conn = {0, }; struct obd_import *imp; #ifdef __KERNEL__ @@ -179,39 +178,28 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, ptlrpc_activate_import(imp); } + rc = obd_register_observer(tgt_obd, obd); + if (rc) { + CERROR("Target %s register_observer error %d\n", + obd_uuid2str(&tgt_uuid), rc); + RETURN(rc); + } + + if (imp->imp_invalid) { CERROR("not connecting OSC %s; administratively " "disabled\n", obd_uuid2str(&tgt_uuid)); - rc = obd_register_observer(tgt_obd, obd); - if (rc) { - CERROR("Target %s register_observer error %d; " - "will not be able to reactivate\n", - obd_uuid2str(&tgt_uuid), rc); - } RETURN(0); } - rc = obd_connect(NULL, &conn, tgt_obd, &lov_osc_uuid, data, NULL); - if (rc) { + rc = obd_connect(NULL, &lov->lov_tgts[index]->ltd_exp, tgt_obd, + &lov_osc_uuid, data, NULL); + if (rc || !lov->lov_tgts[index]->ltd_exp) { CERROR("Target %s connect error %d\n", obd_uuid2str(&tgt_uuid), rc); - RETURN(rc); - } - lov->lov_tgts[index]->ltd_exp = class_conn2export(&conn); - if (!lov->lov_tgts[index]->ltd_exp) { - CERROR("Target %s: null export!\n", obd_uuid2str(&tgt_uuid)); RETURN(-ENODEV); } - rc = obd_register_observer(tgt_obd, obd); - if (rc) { - CERROR("Target %s register_observer error %d\n", - obd_uuid2str(&tgt_uuid), rc); - obd_disconnect(lov->lov_tgts[index]->ltd_exp); - lov->lov_tgts[index]->ltd_exp = NULL; - RETURN(rc); - } - lov->lov_tgts[index]->ltd_reap = 0; if (activate) { lov->lov_tgts[index]->ltd_active = 1; @@ -224,7 +212,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, #ifdef __KERNEL__ lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (lov_proc_dir) { - struct obd_device *osc_obd = class_conn2obd(&conn); + struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; cfs_proc_dir_entry_t *osc_symlink; char name[MAX_STRING_SIZE]; @@ -254,21 +242,24 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, } static int lov_connect(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; + struct lustre_handle conn; int i, rc; ENTRY; CDEBUG(D_CONFIG, "connect #%d\n", lov->lov_connects); - rc = class_connect(conn, obd, cluuid); + rc = class_connect(&conn, obd, cluuid); if (rc) RETURN(rc); + *exp = class_conn2export(&conn); + /* Why should there ever be more than 1 connect? */ lov->lov_connects++; LASSERT(lov->lov_connects == 1); @@ -294,7 +285,7 @@ static int lov_connect(const struct lu_env *env, continue; rc = lov_notify(obd, lov->lov_tgts[i]->ltd_exp->exp_obd, - OBD_NOTIFY_ACTIVE, (void *)&i); + OBD_NOTIFY_CONNECT, (void *)&i); if (rc) { CERROR("%s error sending notify %d\n", obd->obd_name, rc); @@ -628,7 +619,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, GOTO(out, rc = 0); rc = lov_notify(obd, tgt->ltd_exp->exp_obd, - active ? OBD_NOTIFY_ACTIVE : OBD_NOTIFY_INACTIVE, + active ? OBD_NOTIFY_CONNECT : OBD_NOTIFY_INACTIVE, (void *)&index); out: diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index a8c902d..a5698b5 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1799,7 +1799,7 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, } static int mdc_connect(const struct lu_env *env, - struct lustre_handle *dlm_handle, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) @@ -1816,7 +1816,7 @@ static int mdc_connect(const struct lu_env *env, obd->obd_name); } - return client_connect_import(env, dlm_handle, obd, cluuid, data, NULL); + return client_connect_import(env, exp, obd, cluuid, data, NULL); } struct obd_ops mdc_obd_ops = { diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index d0a2076..9c6142f 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -601,7 +601,6 @@ out: int mds_lov_connect(struct obd_device *obd, char * lov_name) { struct mds_obd *mds = &obd->u.mds; - struct lustre_handle conn = {0,}; struct obd_connect_data *data; int rc; ENTRY; @@ -655,14 +654,13 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name) /* send the list of supported checksum types */ data->ocd_cksum_types = OBD_CKSUM_ALL; /* NB: lov_connect() needs to fill in .ocd_index for each OST */ - rc = obd_connect(NULL, &conn, mds->mds_osc_obd, &obd->obd_uuid, data, NULL); + rc = obd_connect(NULL, &mds->mds_osc_exp, mds->mds_osc_obd, &obd->obd_uuid, data, NULL); OBD_FREE(data, sizeof(*data)); if (rc) { CERROR("MDS cannot connect to LOV %s (%d)\n", lov_name, rc); mds->mds_osc_obd = ERR_PTR(rc); RETURN(rc); } - mds->mds_osc_exp = class_conn2export(&conn); /* I want to see a callback happen when the OBD moves to a * "For General Use" state, and that's when we'll call diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 5c267db..b46baaf 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4842,39 +4842,40 @@ static int mdt_connect_check_sptlrpc(struct mdt_device *mdt, /* mds_connect copy */ static int mdt_obd_connect(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { struct mdt_thread_info *info; struct lsd_client_data *lcd; - struct obd_export *exp; + struct obd_export *lexp; + struct lustre_handle conn = { 0 }; struct mdt_device *mdt; struct ptlrpc_request *req; int rc; ENTRY; LASSERT(env != NULL); - if (!conn || !obd || !cluuid) + if (!exp || !obd || !cluuid) RETURN(-EINVAL); info = lu_context_key_get(&env->le_ctx, &mdt_thread_key); req = info->mti_pill->rc_req; mdt = mdt_dev(obd->obd_lu_dev); - rc = class_connect(conn, obd, cluuid); + rc = class_connect(&conn, obd, cluuid); if (rc) RETURN(rc); - exp = class_conn2export(conn); - LASSERT(exp != NULL); + lexp = class_conn2export(&conn); + LASSERT(lexp != NULL); - rc = mdt_connect_check_sptlrpc(mdt, exp, req); + rc = mdt_connect_check_sptlrpc(mdt, lexp, req); if (rc) GOTO(out, rc); - rc = mdt_connect_internal(exp, mdt, data); + rc = mdt_connect_internal(lexp, mdt, data); if (rc == 0) { OBD_ALLOC_PTR(lcd); if (lcd != NULL) { @@ -4882,15 +4883,15 @@ static int mdt_obd_connect(const struct lu_env *env, mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key); LASSERT(mti != NULL); - mti->mti_exp = exp; + mti->mti_exp = lexp; memcpy(lcd->lcd_uuid, cluuid, sizeof lcd->lcd_uuid); - exp->exp_mdt_data.med_lcd = lcd; + lexp->exp_mdt_data.med_lcd = lcd; rc = mdt_client_new(env, mdt); if (rc != 0) { OBD_FREE_PTR(lcd); - exp->exp_mdt_data.med_lcd = NULL; + lexp->exp_mdt_data.med_lcd = NULL; } else { - mdt_export_stats_init(obd, exp, localdata); + mdt_export_stats_init(obd, lexp, localdata); } } else rc = -ENOMEM; @@ -4898,9 +4899,9 @@ static int mdt_obd_connect(const struct lu_env *env, out: if (rc != 0) - class_disconnect(exp); + class_disconnect(lexp); else - class_export_put(exp); + *exp = lexp; RETURN(rc); } diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index c91fac8..8861a75 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -63,37 +63,39 @@ /* Establish a connection to the MGS.*/ static int mgs_connect(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { - struct obd_export *exp; + struct obd_export *lexp; + struct lustre_handle conn = { 0 }; int rc; ENTRY; - if (!conn || !obd || !cluuid) + if (!exp || !obd || !cluuid) RETURN(-EINVAL); - rc = class_connect(conn, obd, cluuid); + rc = class_connect(&conn, obd, cluuid); if (rc) RETURN(rc); - exp = class_conn2export(conn); - LASSERT(exp); - mgs_counter_incr(exp, LPROC_MGS_CONNECT); + lexp = class_conn2export(&conn); + LASSERT(lexp); + + mgs_counter_incr(lexp, LPROC_MGS_CONNECT); if (data != NULL) { data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED; - exp->exp_connect_flags = data->ocd_connect_flags; + lexp->exp_connect_flags = data->ocd_connect_flags; data->ocd_version = LUSTRE_VERSION_CODE; } - rc = mgs_client_add(obd, exp, localdata); + rc = mgs_client_add(obd, lexp, localdata); if (rc) { - class_disconnect(exp); + class_disconnect(lexp); } else { - class_export_put(exp); + *exp = lexp; } RETURN(rc); diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index 21be99b..ce887c8 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -501,7 +501,6 @@ static int llog_test_6(struct obd_device *obd, char *name) struct obd_device *mgc_obd; struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); struct obd_uuid *mgs_uuid = &ctxt->loc_exp->exp_obd->obd_uuid; - struct lustre_handle exph = {0, }; struct obd_export *exp; struct obd_uuid uuid = {"LLOG_TEST6_UUID"}; struct llog_handle *llh = NULL; @@ -516,13 +515,13 @@ static int llog_test_6(struct obd_device *obd, char *name) GOTO(ctxt_release, rc = -ENOENT); } - rc = obd_connect(NULL, &exph, mgc_obd, &uuid, + rc = obd_connect(NULL, &exp, mgc_obd, &uuid, NULL /* obd_connect_data */, NULL); if (rc) { CERROR("6: failed to connect to MGC: %s\n", mgc_obd->obd_name); GOTO(ctxt_release, rc); } - exp = class_conn2export(&exph); + LASSERTF(exp->exp_obd == mgc_obd, "%p - %p - %p\n", exp, exp->exp_obd, mgc_obd); nctxt = llog_get_context(mgc_obd, LLOG_CONFIG_REPL_CTXT); rc = llog_create(nctxt, &llh, NULL, name); @@ -552,6 +551,8 @@ parse_out: if (rc) { CERROR("6: llog_close failed: rc = %d\n", rc); } + CDEBUG(D_INFO, "obd %p - %p - %p - %p\n", + mgc_obd, exp, exp->exp_obd, exp->exp_obd->obd_type); rc = obd_disconnect(exp); ctxt_release: llog_ctxt_put(ctxt); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index b632fa3..04d012c 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -567,7 +567,6 @@ DECLARE_MUTEX(mgc_start_lock); */ static int lustre_start_mgc(struct super_block *sb) { - struct lustre_handle mgc_conn = {0, }; struct obd_connect_data *data = NULL; struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *obd; @@ -768,14 +767,13 @@ static int lustre_start_mgc(struct super_block *sb) data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_FID | OBD_CONNECT_AT; data->ocd_version = LUSTRE_VERSION_CODE; - rc = obd_connect(NULL, &mgc_conn, obd, &(obd->obd_uuid), data, NULL); + rc = obd_connect(NULL, &exp, obd, &(obd->obd_uuid), data, NULL); OBD_FREE_PTR(data); if (rc) { CERROR("connect failed %d\n", rc); GOTO(out, rc); } - exp = class_conn2export(&mgc_conn); obd->u.cli.cl_mgc_mgsexp = exp; out: diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index d69cf59..6684c7a 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -66,12 +66,22 @@ enum { }; static int echo_connect(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { + struct lustre_handle conn = { 0 }; + int rc; + data->ocd_connect_flags &= ECHO_CONNECT_SUPPORTED; - return class_connect(conn, obd, cluuid); + rc = class_connect(&conn, obd, cluuid); + if (rc) { + CERROR("can't connect %d\n", rc); + return rc; + } + *exp = class_conn2export(&conn); + + return 0; } static int echo_disconnect(struct obd_export *exp) diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 01b9572..16cab35 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1870,7 +1870,6 @@ static int echo_client_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) { struct echo_client_obd *ec = &obddev->u.echo_client; struct obd_device *tgt; - struct lustre_handle conn = {0, }; struct obd_uuid echo_uuid = { "ECHO_UUID" }; struct obd_connect_data *ocd = NULL; int rc; @@ -1906,7 +1905,7 @@ static int echo_client_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) ocd->ocd_version = LUSTRE_VERSION_CODE; ocd->ocd_group = FILTER_GROUP_ECHO; - rc = obd_connect(NULL, &conn, tgt, &echo_uuid, ocd, NULL); + rc = obd_connect(NULL, &ec->ec_exp, tgt, &echo_uuid, ocd, NULL); OBD_FREE(ocd, sizeof(*ocd)); @@ -1915,7 +1914,6 @@ static int echo_client_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) lustre_cfg_string(lcfg, 1)); return (rc); } - ec->ec_exp = class_conn2export(&conn); RETURN(rc); } @@ -1939,18 +1937,17 @@ static int echo_client_cleanup(struct obd_device *obddev) } static int echo_client_connect(const struct lu_env *env, - struct lustre_handle *conn, + struct obd_export **exp, struct obd_device *src, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { - struct obd_export *exp; int rc; + struct lustre_handle conn = { 0 }; ENTRY; - rc = class_connect(conn, src, cluuid); + rc = class_connect(&conn, src, cluuid); if (rc == 0) { - exp = class_conn2export(conn); - class_export_put(exp); + *exp = class_conn2export(&conn); } RETURN (rc); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 1341e2b..7cec53e 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2773,34 +2773,35 @@ static int filter_reconnect(const struct lu_env *env, /* nearly identical to mds_connect */ static int filter_connect(const struct lu_env *env, - struct lustre_handle *conn, struct obd_device *obd, + struct obd_export **exp, struct obd_device *obd, struct obd_uuid *cluuid, struct obd_connect_data *data, void *localdata) { struct lvfs_run_ctxt saved; - struct obd_export *exp; + struct lustre_handle conn = { 0 }; + struct obd_export *lexp; struct filter_export_data *fed; struct lsd_client_data *lcd = NULL; __u32 group; int rc; ENTRY; - if (conn == NULL || obd == NULL || cluuid == NULL) + if (exp == NULL || obd == NULL || cluuid == NULL) RETURN(-EINVAL); - rc = class_connect(conn, obd, cluuid); + rc = class_connect(&conn, obd, cluuid); if (rc) RETURN(rc); - exp = class_conn2export(conn); - LASSERT(exp != NULL); + lexp = class_conn2export(&conn); + LASSERT(lexp != NULL); - fed = &exp->exp_filter_data; + fed = &lexp->exp_filter_data; - rc = filter_connect_internal(exp, data); + rc = filter_connect_internal(lexp, data); if (rc) GOTO(cleanup, rc); - filter_export_stats_init(obd, exp, localdata); + filter_export_stats_init(obd, lexp, localdata); if (obd->obd_replayable) { OBD_ALLOC(lcd, sizeof(*lcd)); if (!lcd) { @@ -2810,7 +2811,7 @@ static int filter_connect(const struct lu_env *env, memcpy(lcd->lcd_uuid, cluuid, sizeof(lcd->lcd_uuid)); fed->fed_lcd = lcd; - rc = filter_client_add(obd, exp, -1); + rc = filter_client_add(obd, lexp, -1); if (rc) GOTO(cleanup, rc); } @@ -2818,7 +2819,7 @@ static int filter_connect(const struct lu_env *env, group = data->ocd_group; CWARN("%s: Received MDS connection ("LPX64"); group %d\n", - obd->obd_name, exp->exp_handle.h_cookie, group); + obd->obd_name, lexp->exp_handle.h_cookie, group); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); rc = filter_read_groups(obd, group, 1); @@ -2836,9 +2837,10 @@ cleanup: OBD_FREE_PTR(lcd); fed->fed_lcd = NULL; } - class_disconnect(exp); + class_disconnect(lexp); + *exp = NULL; } else { - class_export_put(exp); + *exp = lexp; } RETURN(rc); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 6a19364..65eedd1 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -810,14 +810,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, 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); -- 1.8.3.1