Whamcloud - gitweb
LU-4783 mgs: start params log during mgs initialization 37/9737/6
authorEmoly Liu <emoly.liu@intel.com>
Tue, 15 Apr 2014 07:16:53 +0000 (15:16 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 24 Apr 2014 15:46:27 +0000 (15:46 +0000)
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 <emoly.liu@intel.com>
Change-Id: Ifc3abc1e35ef20230a1be1cdf1c4cc8f57b2788e
Reviewed-on: http://review.whamcloud.com/9737
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h
lustre/mgs/mgs_llog.c
lustre/tests/conf-sanity.sh

index 09a6bce..52d0f37 100644 (file)
@@ -1974,7 +1974,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;
                        }
index a9b0857..0403483 100644 (file)
@@ -1082,6 +1082,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;
@@ -1153,6 +1154,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);
 
@@ -1196,6 +1205,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);
@@ -1369,6 +1379,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);
 
index 457fbbb..0a33f81 100644 (file)
@@ -188,15 +188,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,
index 820acba..f3cc754 100644 (file)
@@ -1393,6 +1393,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);
@@ -3776,6 +3777,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, &params_llh, PARAMS_FILENAME);
+               if (rc == 0)
+                       rc = record_end_log(env, &params_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
index a2ede68..cb29b9a 100644 (file)
@@ -4396,7 +4396,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
@@ -4453,7 +4453,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)