From 83d544ce923594470aca62bf3e15720de828adac Mon Sep 17 00:00:00 2001 From: tappro Date: Sat, 2 Sep 2006 20:12:15 +0000 Subject: [PATCH] use own uuid for mdc instead of uuid of mdt itself to fix unclean umount --- lustre/cmm/mdc_device.c | 15 ++++++--------- lustre/cmm/mdc_internal.h | 2 ++ lustre/mdt/mdt_handler.c | 14 +++++++++----- lustre/mdt/mdt_internal.h | 2 +- lustre/mgs/mgs_llog.c | 14 ++++++++------ 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index 1941440..930594f 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -55,10 +55,11 @@ static int mdc_add_obd(const struct lu_context *ctx, struct mdc_device *mc, struct lustre_cfg *cfg) { struct mdc_cli_desc *desc = &mc->mc_desc; - struct obd_device *mdc, *mdt; + struct obd_device *mdc; const char *srv = lustre_cfg_string(cfg, 0); const char *uuid_str = lustre_cfg_string(cfg, 1); const char *index = lustre_cfg_string(cfg, 2); + const char *mdc_uuid_str = lustre_cfg_string(cfg, 4); char *p; int rc = 0; @@ -72,16 +73,11 @@ static int mdc_add_obd(const struct lu_context *ctx, RETURN(-EINVAL); } - /* find local MDT obd to get group uuid */ - mdt = class_name2obd(srv); - if (mdt == NULL) { - CERROR("No such OBD %s\n", srv); - LBUG(); - } obd_str2uuid(&desc->cl_srv_uuid, uuid_str); + obd_str2uuid(&desc->cl_cli_uuid, mdc_uuid_str); /* try to find MDC OBD connected to the needed MDT */ mdc = class_find_client_obd(&desc->cl_srv_uuid, LUSTRE_MDC_NAME, - &mdt->obd_uuid); + &desc->cl_cli_uuid); if (!mdc) { CERROR("Cannot find MDC OBD connected to %s\n", uuid_str); rc = -ENOENT; @@ -94,7 +90,8 @@ static int mdc_add_obd(const struct lu_context *ctx, CDEBUG(D_CONFIG, "connect to %s(%s)\n", mdc->obd_name, mdc->obd_uuid.uuid); - rc = obd_connect(ctx, conn, mdc, &mdt->obd_uuid, NULL); + + rc = obd_connect(ctx, conn, mdc, &mdc->obd_uuid, NULL); if (rc) { CERROR("target %s connect error %d\n", diff --git a/lustre/cmm/mdc_internal.h b/lustre/cmm/mdc_internal.h index 50e884a..bb8e4a0 100644 --- a/lustre/cmm/mdc_internal.h +++ b/lustre/cmm/mdc_internal.h @@ -39,6 +39,8 @@ struct mdc_cli_desc { struct lustre_handle cl_conn; /* uuid of remote MDT to connect */ struct obd_uuid cl_srv_uuid; + /* mdc uuid */ + struct obd_uuid cl_cli_uuid; /* export of mdc obd */ struct obd_export *cl_exp; }; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 493199a..b22e03f 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1965,9 +1965,9 @@ static int mdt_seq_init_cli(const struct lu_context *ctx, struct lustre_cfg *cfg) { struct lu_site *ls = m->mdt_md_dev.md_lu_dev.ld_site; - struct obd_device *mdc; - struct obd_uuid *uuidp; - char *uuid_str; + struct obd_device *mdc, *mdt; + struct obd_uuid *uuidp, *mdcuuidp; + char *uuid_str, *mdc_uuid_str; int rc; int index; struct mdt_thread_info *info; @@ -1975,7 +1975,8 @@ static int mdt_seq_init_cli(const struct lu_context *ctx, ENTRY; info = lu_context_key_get(ctx, &mdt_thread_key); - uuidp = &info->mti_u.uuid; + uuidp = &info->mti_u.uuid[0]; + mdcuuidp = &info->mti_u.uuid[1]; LASSERT(index_string); @@ -1991,8 +1992,11 @@ static int mdt_seq_init_cli(const struct lu_context *ctx, RETURN(0); uuid_str = lustre_cfg_string(cfg, 1); + mdc_uuid_str = lustre_cfg_string(cfg, 4); obd_str2uuid(uuidp, uuid_str); - mdc = class_find_client_obd(uuidp, LUSTRE_MDC_NAME, NULL); + obd_str2uuid(mdcuuidp, mdc_uuid_str); + + mdc = class_find_client_obd(uuidp, LUSTRE_MDC_NAME, mdcuuidp); if (!mdc) { CERROR("can't find controller MDC by uuid %s\n", uuid_str); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 2bb6910..b046f75 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -283,7 +283,7 @@ struct mdt_thread_info { ldlm_policy_data_t mti_policy; /* for mdt_object_lock() */ struct ldlm_res_id mti_res_id; /* for mdt_object_lock() */ union { - struct obd_uuid uuid; /* for mdt_seq_init_cli() */ + struct obd_uuid uuid[2]; /* for mdt_seq_init_cli() */ char ns_name[48]; /* for mdt_init0() */ struct lustre_cfg_bufs bufs; /* for mdt_stack_fini() */ struct kstatfs ksfs; /* for mdt_statfs() */ diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 4873ffe..2d2a8bf 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -654,11 +654,12 @@ static int record_lmv_setup(struct obd_device *obd, struct llog_handle *llh, static inline int record_mdc_add(struct obd_device *obd, struct llog_handle *llh, - char *logname, char *uuid, - char *index, char *gen) + char *logname, char *mdcuuid, + char *mdtuuid, char *index, + char *gen) { return record_base(obd,llh,logname,0,LCFG_ADD_MDC, - uuid,index,gen,0); + mdtuuid,index,gen,mdcuuid); } static inline int record_lov_add(struct obd_device *obd, @@ -1194,7 +1195,8 @@ static int mgs_write_log_mdc_to_lmv(struct obd_device *obd, struct fs_db *fsdb, rc = record_setup(obd, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0); rc = mgs_write_log_failnids(obd, mti, llh, mdcname); snprintf(index, sizeof(index), "%d", mti->mti_stripe_index); - rc = record_mdc_add(obd, llh, lmvname, mti->mti_uuid, index, "1"); + rc = record_mdc_add(obd, llh, lmvname, mdcuuid, mti->mti_uuid, + index, "1"); rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc"); rc = record_end_log(obd, &llh); @@ -1237,11 +1239,11 @@ static int mgs_write_log_mdc_to_mdt(struct obd_device *obd, struct fs_db *fsdb, libcfs_nid2str(mti->mti_nids[i])); rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid); } - rc = record_attach(obd, llh, mdcname, LUSTRE_MDC_NAME, mdtuuid); + rc = record_attach(obd, llh, mdcname, LUSTRE_MDC_NAME, mdcuuid); rc = record_setup(obd, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0); rc = mgs_write_log_failnids(obd, mti, llh, mdcname); snprintf(index, sizeof(index), "%d", idx); - rc = record_mdc_add(obd, llh, logname, mti->mti_uuid /*mdcname*/, + rc = record_mdc_add(obd, llh, logname, mdcuuid, mti->mti_uuid, index, "1"); rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc"); rc = record_end_log(obd, &llh); -- 1.8.3.1