From f84deaedd1ee63f89fa5aee6fa6db1933fd3f13d Mon Sep 17 00:00:00 2001 From: tappro Date: Fri, 23 Jun 2006 15:28:40 +0000 Subject: [PATCH] set CMM_INITIALIZED when first ADD_MDC arrives --- lustre/cmm/cmm_device.c | 24 ++++++++++++++++-------- lustre/cmm/cmm_object.c | 2 +- lustre/cmm/mdc_device.c | 3 ++- lustre/mdt/mdt_handler.c | 3 +-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index c96f119..c20d911 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -156,17 +156,26 @@ static int cmm_process_config(const struct lu_context *ctx, switch(cfg->lcfg_command) { case LCFG_ADD_MDC: err = cmm_add_mdc(ctx, m, cfg); + /* the first ADD_MDC can be counted as setup is finished */ + if (m->cmm_flags & CMM_INITIALIZED == 0) + m->cmm_flags |= CMM_INITIALIZED; break; case LCFG_SETUP: { - const char *index = lustre_cfg_string(cfg, 2), *p; + const char *index = lustre_cfg_string(cfg, 2); + char *p; LASSERT(index); - m->cmm_local_num = simple_strtol(index, &p, 10); - if (*p) { - CERROR("Invalid index in lustre_cgf, offset 2\n"); - RETURN(-EINVAL); + + /* lower layers should be set up at first */ + err = next->ld_ops->ldo_process_config(ctx, next, cfg); + if (err == 0) { + m->cmm_local_num = simple_strtol(index, &p, 10); + if (*p) { + CERROR("Invalid index in lustre_cgf\n"); + RETURN(-EINVAL); + } } - /* no break; to pass cfg further */ + break; } default: err = next->ld_ops->ldo_process_config(ctx, next, cfg); @@ -240,8 +249,7 @@ static int cmm_device_init(const struct lu_context *ctx, err = fld_client_init(&m->cmm_fld, LUSTRE_CLI_FLD_HASH_RRB); if (err) { CERROR("can't init FLD, err %d\n", err); - } else - m->cmm_flags |= CMM_INITIALIZED; + } RETURN(err); } diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index e28677c..88ddf24 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -51,7 +51,7 @@ static int cmm_fld_lookup(struct cmm_device *cm, RETURN(rc); } - if (*mds > cm->cmm_tgt_count) { + if (*mds >= cm->cmm_tgt_count) { CERROR("Got invalid mdsno: "LPU64" (max: %u)\n", *mds, cm->cmm_tgt_count); rc = -EINVAL; diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index feedb68..5ea72ab 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -60,7 +60,8 @@ static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg) struct obd_device *mdc, *mdt; 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), *p; + const char *index = lustre_cfg_string(cfg, 2); + char *p; int rc = 0; ENTRY; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 298567f..85a9e05 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2094,8 +2094,7 @@ static int mdt_init0(struct mdt_device *m, if (rc) GOTO(err_free_ns, rc); - lu_context_exit(&ctx); - lu_context_fini(&ctx); + s->ls_flags |= LS_INITIALIZED; RETURN(0); -- 1.8.3.1