From c756744427eeb12e12ec08dda6271b8ed7dbbd7d Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Tue, 15 Apr 2014 15:16:53 +0800 Subject: [PATCH] LU-4783 mgs: start params log during mgs initialization Params log was introduced by LU-3155 to set parameters permanently with lctl "set_param -P" instead of "conf_param". But in a newly mounted filesystem, the log won't be created automatically until "lctl set_param -P" is called. This causes that the other servers can't make a local copy successfully during their setup, and the misleading console error message "LustreError: 13a-8: Failed to get MGS log params and no local copy." is printed. This patch is to start params log during mgs intialization so that the error message is quieted. Also, test_76b is added to conf-sanity.sh to verify params log setup. Signed-off-by: Emoly Liu Change-Id: Ifc3abc1e35ef20230a1be1cdf1c4cc8f57b2788e Reviewed-on: http://review.whamcloud.com/9737 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/mgc/mgc_request.c | 2 +- lustre/mgs/mgs_handler.c | 11 +++++++++++ lustre/mgs/mgs_internal.h | 23 +++++++++++++++-------- lustre/mgs/mgs_llog.c | 29 +++++++++++++++++++++++++++++ lustre/tests/conf-sanity.sh | 15 +++++++++++++-- 5 files changed, 69 insertions(+), 11 deletions(-) diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index ed4f408..e5ae42b 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1970,7 +1970,7 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) if (rc == 0 && cld->cld_params != NULL) { rc = mgc_process_log(obd, cld->cld_params); if (rc == -ENOENT) { - CDEBUG(D_MGC, "There is no params" + CDEBUG(D_MGC, "There is no params " "config file yet\n"); rc = 0; } diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index fef7e94..bffde6a 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -929,6 +929,7 @@ static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs, struct obd_device *obd; struct lustre_mount_info *lmi; struct llog_ctxt *ctxt; + struct fs_db *fsdb = NULL; int rc; ENTRY; @@ -1000,6 +1001,14 @@ static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs, GOTO(err_llog, rc); } + /* Setup params fsdb and log, so that other servers can make a local + * copy successfully when they are mounted. See LU-4783 */ + rc = mgs_params_fsdb_setup(env, mgs, fsdb); + if (rc) + /* params fsdb and log can be setup later */ + CERROR("%s: %s fsdb and log setup failed: rc = %d\n", + obd->obd_name, PARAMS_FILENAME, rc); + ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, "mgs_ldlm_client", &obd->obd_ldlm_client); @@ -1043,6 +1052,7 @@ static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs, lu_site_purge(env, mgs2lu_dev(mgs)->ld_site, ~0); RETURN(0); err_lproc: + mgs_params_fsdb_cleanup(env, mgs); lproc_mgs_cleanup(mgs); err_llog: ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT); @@ -1216,6 +1226,7 @@ static struct lu_device *mgs_device_fini(const struct lu_env *env, obd_zombie_barrier(); tgt_fini(env, &mgs->mgs_lut); + mgs_params_fsdb_cleanup(env, mgs); mgs_cleanup_fsdb_list(mgs); lproc_mgs_cleanup(mgs); diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 514dc23..d3826b3 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -187,15 +187,22 @@ struct mgs_object { int mgs_init_fsdb_list(struct mgs_device *mgs); int mgs_cleanup_fsdb_list(struct mgs_device *mgs); -int mgs_find_or_make_fsdb(const struct lu_env *env, struct mgs_device *mgs, char *name, - struct fs_db **dbh); +int mgs_params_fsdb_setup(const struct lu_env *env, struct mgs_device *mgs, + struct fs_db *fsdb); +int mgs_params_fsdb_cleanup(const struct lu_env *env, struct mgs_device *mgs); +int mgs_find_or_make_fsdb(const struct lu_env *env, struct mgs_device *mgs, + char *name, struct fs_db **dbh); struct fs_db *mgs_find_fsdb(struct mgs_device *mgs, char *fsname); -int mgs_get_fsdb_srpc_from_llog(const struct lu_env *env, struct mgs_device *mgs, struct fs_db *fsdb); -int mgs_check_index(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti); -int mgs_check_failnid(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti); -int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti, - struct fs_db *fsdb); -int mgs_replace_nids(const struct lu_env *env, struct mgs_device *mgs, char *devname, char *nids); +int mgs_get_fsdb_srpc_from_llog(const struct lu_env *env, + struct mgs_device *mgs, struct fs_db *fsdb); +int mgs_check_index(const struct lu_env *env, struct mgs_device *mgs, + struct mgs_target_info *mti); +int mgs_check_failnid(const struct lu_env *env, struct mgs_device *mgs, + struct mgs_target_info *mti); +int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs, + struct mgs_target_info *mti, struct fs_db *fsdb); +int mgs_replace_nids(const struct lu_env *env, struct mgs_device *mgs, + char *devname, char *nids); int mgs_erase_log(const struct lu_env *env, struct mgs_device *mgs, char *name); int mgs_erase_logs(const struct lu_env *env, struct mgs_device *mgs, diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 98fcc8b..c73ed82 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -1369,6 +1369,7 @@ static int record_start_log(const struct lu_env *env, struct mgs_device *mgs, static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" }; struct llog_ctxt *ctxt; int rc = 0; + ENTRY; if (*llh) GOTO(out, rc = -EBUSY); @@ -3714,6 +3715,34 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg) EXIT; } +/* Setup params fsdb and log + */ +int mgs_params_fsdb_setup(const struct lu_env *env, struct mgs_device *mgs, + struct fs_db *fsdb) +{ + struct llog_handle *params_llh = NULL; + int rc; + ENTRY; + + rc = mgs_find_or_make_fsdb(env, mgs, PARAMS_FILENAME, &fsdb); + if (fsdb != NULL) { + mutex_lock(&fsdb->fsdb_mutex); + rc = record_start_log(env, mgs, ¶ms_llh, PARAMS_FILENAME); + if (rc == 0) + rc = record_end_log(env, ¶ms_llh); + mutex_unlock(&fsdb->fsdb_mutex); + } + + RETURN(rc); +} + +/* Cleanup params fsdb and log + */ +int mgs_params_fsdb_cleanup(const struct lu_env *env, struct mgs_device *mgs) +{ + return mgs_erase_logs(env, mgs, PARAMS_FILENAME); +} + /* Set a permanent (config log) param for a target or fs * \param lcfg buf0 may contain the device (testfs-MDT0000) name * buf1 contains the single parameter diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index fc69e30..9ec414e 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -4374,7 +4374,7 @@ test_75() { # LU-2374 } run_test 75 "The order of --index should be irrelevant" -test_76() { +test_76a() { [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] || { skip "Need MDS version at least 2.4.52" && return 0; } setup @@ -4431,7 +4431,18 @@ test_76() { error "client_cache_count is not saved after remount" stopall } -run_test 76 "set permanent params set_param -P" +run_test 76a "set permanent params set_param -P" + +test_76b() { # LU-4783 + [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] || + { skip "Need MGS version at least 2.5.57" && return 0; } + stopall + setupall + do_facet mgs $LCTL get_param mgs.MGS.live.params || + error "start params log failed" + stopall +} +run_test 76b "verify params log setup correctly" test_77() { # LU-3445 local server_version=$(lustre_version_code $SINGLEMDS) -- 1.8.3.1