From 96a62fcb8206b6f9f2fb0c568fafc88555025938 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 4 Nov 2005 18:53:11 +0000 Subject: [PATCH] Branch b1_4_mountconf b=8159 implement lustre_get_process_llog --- lustre/mgc/mgc_request.c | 3 +- lustre/obdclass/obd_mount.c | 153 +++++++++++++++++--------------------------- lustre/ptlrpc/llog_client.c | 14 ---- 3 files changed, 62 insertions(+), 108 deletions(-) diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 859f6e5..005f9a4 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -181,8 +181,9 @@ static int mgc_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(-ENOENT); } } + else + CERROR("mgc does not have local disk (client only)\n"); - CERROR("mgc does not have local disk (client only)\n"); rc = mgc_obd_setup(obd, len, buf); if (rc) { mgc_cleanup(obd); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index e6b9a14..3c17bee 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -303,81 +303,36 @@ out: return(err); } - /* Get the log "profile" from a remote MGS and process it. FIXME If remote doesn't exist, try local This func should work for both clients and servers */ -int lustre_get_process_log(struct super_block *sb, char * profile, - struct config_llog_instance *cfg) +int lustre_get_process_log(struct super_block *sb, char *profile, + struct config_llog_instance *cfg) { -#if 0 -FIXME - char *peer = "MDS_PEER_UUID"; - struct obd_device *obd; - struct lustre_handle mdc_conn = {0, }; + struct lustre_sb_info *sbi = s2sbi(sb); + struct obd_device *mgc = sbi->lsi_mgc; + struct lustre_handle mgc_conn = {0, }; struct obd_export *exp; - char *mdcname = "mdc_dev"; - char *mdsname; - class_uuid_t uuid; - struct obd_uuid mdc_uuid; struct llog_ctxt *ctxt; - int allow_recov = (lmd->lmd_flags & LMD_FLG_RECOVER) > 0; - int err, rc = 0; - ENTRY; - - LASSERT(lmd->lmd_mgmtnid.primary != PTL_NID_ANY); - - //lustre_generate_random_uuid(uuid); - class_uuid_unparse(uuid, &mdc_uuid); - CDEBUG(D_HA, "generated uuid: %s\n", mdc_uuid.uuid); - - err = do_lcfg(mdcname, lmd->lmd_mgmtnid.primary, LCFG_ADD_UUID, - peer, 0, 0, 0) - if (err < 0) - GOTO(out, err); - - /* FIXME setup MGC, not MDC */ - err = do_lcfg(mdcname, 0, LCFG_ATTACH, - LUSTRE_MDC_NAME, mdc_uuid.uuid, 0, 0) - if (err < 0) - GOTO(out_del_uuid, err); - - /* FIXME get the mds name from the mgmt node */ - sprintf(mdsname, "%s-mds0001", lmd->lmd_dev); - CERROR("MDS device: %s @ %s\n", mdsname, libcfs_nid2str(lcfg->lcfg_nid)); - err = do_lcfg(mdcname, 0, LCFG_SETUP, - mdsname, peer, 0, 0) - if (err < 0) - GOTO(out_detach, err); - - obd = class_name2obd(mdcname); - if (obd == NULL) - GOTO(out_cleanup, err = -EINVAL); - - /* Disable initial recovery on this import */ - err = obd_set_info(obd->obd_self_export, - strlen("initial_recov"), "initial_recov", - sizeof(allow_recov), &allow_recov); - if (err) - GOTO(out_cleanup, err); + int err, rc; + LASSERT(mgc); - err = obd_connect(&mdc_conn, obd, &mdc_uuid, NULL /* ocd */); + err = obd_connect(&mgc_conn, mgc, &(mgc->obd_uuid), NULL); if (err) { - CERROR("cannot connect to %s: rc = %d\n", mdsname, err); - GOTO(out_cleanup, err); + CERROR("cannot connect to MGS: rc = %d\n", err); + return (err); } - - exp = class_conn2export(&mdc_conn); + + exp = class_conn2export(&mgc_conn); ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT); #if 1 rc = class_config_parse_llog(ctxt, profile, cfg); #else - /* - * For debugging, it's useful to just dump the log - */ + /* For debugging, it's useful to just dump the log */ rc = class_config_dump_llog(ctxt, profile, cfg); #endif + switch (rc) { case 0: break; @@ -393,29 +348,13 @@ FIXME break; } + /* We don't so much care about errors in cleaning up the config llog + * connection, as we have already read the config by this point. */ err = obd_disconnect(exp); - -out_cleanup: - err = do_lcfg(mdcname, 0, LCFG_CLEANUP, - 0, 0, 0, 0) - if (err < 0) - GOTO(out, err); - -out_detach: - err = do_lcfg(mdcname, 0, LCFG_DETACH, - 0, 0, 0, 0) - if (err < 0) - GOTO(out, err); - -out_del_uuid: - err = do_lcfg(mdcname, 0, LCFG_DEL_UUID, - peer, 0, 0, 0) -out: - if (rc == 0) - rc = err; - - RETURN(rc); -#endif + if (err) + CERROR("obd_disconnect failed: rc = %d\n", err); + + return (rc); } static int lustre_update_llog(struct obd_device *obd) @@ -461,7 +400,7 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, return(err); } -static int lustre_start_simple(char *obdname, char *type) +static int lustre_start_simple(char *obdname, char *type, char *s1, char *s2) { int err; err = do_lcfg(obdname, 0, LCFG_ATTACH, type, obdname/*uuid*/, 0, 0); @@ -469,7 +408,7 @@ static int lustre_start_simple(char *obdname, char *type) CERROR("%s attach error %d\n", obdname, err); return(err); } - err = do_lcfg(obdname, 0, LCFG_SETUP, 0, 0, 0, 0); + err = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, 0, 0); if (err) { CERROR("%s setup error %d\n", obdname, err); do_lcfg(obdname, 0, LCFG_DETACH, 0, 0, 0, 0); @@ -494,7 +433,7 @@ static int lustre_start_mgs(struct super_block *sb, struct vfsmount *mnt) if (err) GOTO(out_free, err); - if ((err = lustre_start_simple(mgsname, /*LUSTRE_MGS_NAME*/ "mgs"))) + if ((err = lustre_start_simple(mgsname, LUSTRE_MGS_NAME, 0, 0))) GOTO(out_dereg, err); out_free: @@ -528,7 +467,8 @@ static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt) struct lustre_sb_info *sbi = s2sbi(sb); struct obd_device *obd; char* mgcname; - int mgcname_size, err = 0; + int mgcname_size, err = 0, i; + lnet_nid_t nid; mgcname_size = 2 * sizeof(sb) + 5; OBD_ALLOC(mgcname, mgcname_size); @@ -542,16 +482,36 @@ static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt) if (err) GOTO(out_free, err); } - - if ((err = lustre_start_simple(mgcname, LUSTRE_MGC_NAME))) - GOTO(out_dereg, err); - if (sbi->lsi_ldd->ldd_flags & LDD_F_NEED_INDEX) { - // FIXME implement - CERROR("Need new server index from MGS!\n"); - // rewrite last_rcvd, ldd (for new svname) - } + /* Add a uuid for the MGS */ + nid = sbi->lsi_lmd->lmd_mgsnid[0]; + err = do_lcfg(mgcname, nid, LCFG_ADD_UUID, libcfs_nid2str(nid), 0,0,0); + if (err < 0) + GOTO(out_free, err); + /* Start the MGC */ + if ((err = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, "MGS", + libcfs_nid2str(nid)))) + GOTO(out_dereg, err); + + /* Add the redundant MGS's */ + for (i = i; i < sbi->lsi_lmd->lmd_mgsnid_count; i++) { + nid = sbi->lsi_lmd->lmd_mgsnid[i]; + err = do_lcfg(mgcname, nid, LCFG_ADD_UUID, libcfs_nid2str(nid), + 0, 0, 0); + if (err) { + CERROR("Add uuid for %s failed %d\n", + libcfs_nid2str(nid), err); + continue; + } + err = do_lcfg(mgcname, 0, LCFG_ADD_CONN, libcfs_nid2str(nid), + 0, 0, 0); + if (err) + CERROR("Add conn for %s failed %d\n", + libcfs_nid2str(nid), err); + } + + /* Keep the mgc info in the sb */ obd = class_name2obd(mgcname); if (!obd) { CERROR("Can't find mgcobd %s\n", mgcname); @@ -559,6 +519,13 @@ static int lustre_start_mgc(struct super_block *sb, struct vfsmount *mnt) } sbi->lsi_mgc = obd; + /* Get a new index if needed */ + if (sbi->lsi_ldd->ldd_flags & LDD_F_NEED_INDEX) { + // FIXME implement + CERROR("Need new server index from MGS!\n"); + // rewrite last_rcvd, ldd (for new svname) + } + out_free: OBD_FREE(mgcname, mgcname_size); out: diff --git a/lustre/ptlrpc/llog_client.c b/lustre/ptlrpc/llog_client.c index d85da42..83ce394 100644 --- a/lustre/ptlrpc/llog_client.c +++ b/lustre/ptlrpc/llog_client.c @@ -41,7 +41,6 @@ #include #include #include -#include #include /* This is a callback from the llog_* functions. @@ -53,8 +52,6 @@ static int llog_client_create(struct llog_ctxt *ctxt, struct llog_handle **res, struct llogd_body req_body; struct llogd_body *body; struct llog_handle *handle; - struct obd_device *obd = ctxt->loc_obd; - struct mgc_open_llog *mol; struct ptlrpc_request *req = NULL; int size[2] = {sizeof(req_body)}; char *tmp[2] = {(char*) &req_body}; @@ -83,13 +80,6 @@ static int llog_client_create(struct llog_ctxt *ctxt, struct llog_handle **res, req_body.lgd_ctxt_idx = ctxt->loc_idx - 1; if (name) { - mol = mgc_find_open_llog(obd, name); - if (!mol) { - CERROR("The llog have not registered " - "in mgc obd when mount.\n"); - GOTO(err_free, rc = -EINVAL); - } - handle->lgh_mol = mol; size[bufcount] = strlen(name) + 1; tmp[bufcount] = name; bufcount++; @@ -186,13 +176,11 @@ out: static int llog_client_read_header(struct llog_handle *handle) { - struct obd_import *imp = handle->lgh_ctxt->loc_imp; struct ptlrpc_request *req = NULL; struct llogd_body *body; struct llog_log_hdr *hdr; struct llog_rec_hdr *llh_hdr; - struct mgc_open_llog *mol = handle->lgh_mol; int size = sizeof(*body); int repsize = sizeof (*hdr); int rc; @@ -207,8 +195,6 @@ static int llog_client_read_header(struct llog_handle *handle) body->lgd_logid = handle->lgh_id; body->lgd_ctxt_idx = handle->lgh_ctxt->loc_idx - 1; body->lgd_llh_flags = handle->lgh_hdr->llh_flags; - if (mol) - body->lgd_local_version = mol->mol_version; req->rq_replen = lustre_msg_size(1, &repsize); rc = ptlrpc_queue_wait(req); -- 1.8.3.1