Whamcloud - gitweb
LU-10937 mgc: restore mgc binding for sptlrpc
[fs/lustre-release.git] / lustre / obdclass / obd_config.c
index aaab911..8d03b7b 100644 (file)
@@ -948,20 +948,13 @@ void class_del_profiles(void)
 }
 EXPORT_SYMBOL(class_del_profiles);
 
-/* We can't call ll_process_config or lquota_process_config directly because
+/* We can't call lquota_process_config directly because
  * it lives in a module that must be loaded after this one.
  */
-static int (*client_process_config)(struct lustre_cfg *lcfg) = NULL;
 #ifdef HAVE_SERVER_SUPPORT
 static int (*quota_process_config)(struct lustre_cfg *lcfg) = NULL;
 #endif /* HAVE_SERVER_SUPPORT */
 
-void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg))
-{
-        client_process_config = cpc;
-}
-EXPORT_SYMBOL(lustre_register_client_process_config);
-
 /**
  * Rename the proc parameter in \a cfg with a new name \a new_name.
  *
@@ -1207,12 +1200,32 @@ int class_process_config(struct lustre_cfg *lcfg)
         }
         case LCFG_PARAM: {
                 char *tmp;
+
                 /* llite has no obd */
-                if ((class_match_param(lustre_cfg_string(lcfg, 1),
-                                      PARAM_LLITE, NULL) == 0) &&
-                    client_process_config) {
-                        err = (*client_process_config)(lcfg);
-                        GOTO(out, err);
+               if (class_match_param(lustre_cfg_string(lcfg, 1),
+                                     PARAM_LLITE, NULL) == 0) {
+                       struct lustre_sb_info *lsi;
+                       unsigned long addr;
+                       ssize_t count;
+
+                       /* The instance name contains the sb:
+                        * lustre-client-aacfe000
+                        */
+                       tmp = strrchr(lustre_cfg_string(lcfg, 0), '-');
+                       if (!tmp || !*(++tmp))
+                               GOTO(out, err = -EINVAL);
+
+                       if (sscanf(tmp, "%lx", &addr) != 1)
+                               GOTO(out, err = -EINVAL);
+
+                       lsi = s2lsi((struct super_block *)addr);
+                       /* This better be a real Lustre superblock! */
+                       LASSERT(lsi->lsi_lmd->lmd_magic == LMD_MAGIC);
+
+                       count = class_modify_config(lcfg, PARAM_LLITE,
+                                                   lsi->lsi_kobj);
+                       err = count < 0 ? count : 0;
+                       GOTO(out, err);
                 } else if ((class_match_param(lustre_cfg_string(lcfg, 1),
                                               PARAM_SYS, &tmp) == 0)) {
                         /* Global param settings */
@@ -1378,7 +1391,7 @@ ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
                        /* If the prefix doesn't match, return error so we
                         * can pass it down the stack
                         */
-                       return -ENOSYS;
+                       return -EINVAL;
 
                value = strchr(key, '=');
                if (!value || *(value + 1) == 0) {
@@ -1619,9 +1632,9 @@ int class_config_llog_handler(const struct lu_env *env,
                        }
                }
                /* A config command without a start marker before it is
-                  illegal (post 146) */
-               if (!(cfg->cfg_flags & CFG_F_COMPAT146) &&
-                   !(cfg->cfg_flags & CFG_F_MARKER) &&
+                * illegal
+                */
+               if (!(cfg->cfg_flags & CFG_F_MARKER) &&
                    (lcfg->lcfg_command != LCFG_MARKER)) {
                        CWARN("Config not inside markers, ignoring! "
                              "(inst: %p, uuid: %s, flags: %#x)\n",
@@ -1698,6 +1711,7 @@ int class_config_llog_handler(const struct lu_env *env,
                lustre_cfg_bufs_init(&bufs, lcfg);
 
                if (cfg->cfg_instance &&
+                   lcfg->lcfg_command != LCFG_SPTLRPC_CONF &&
                    LUSTRE_CFG_BUFLEN(lcfg, 0) > 0) {
                        inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
                                   sizeof(cfg->cfg_instance) * 2 + 4;
@@ -1726,14 +1740,16 @@ int class_config_llog_handler(const struct lu_env *env,
                  * moving them to index [1] and [2], and insert MGC's
                  * obdname at index [0].
                  */
-               if (cfg->cfg_instance == NULL &&
+               if (cfg->cfg_instance &&
                    lcfg->lcfg_command == LCFG_SPTLRPC_CONF) {
+                       struct obd_device *obd = cfg->cfg_instance;
+
                        lustre_cfg_bufs_set(&bufs, 2, bufs.lcfg_buf[1],
                                            bufs.lcfg_buflen[1]);
                        lustre_cfg_bufs_set(&bufs, 1, bufs.lcfg_buf[0],
                                            bufs.lcfg_buflen[0]);
                        lustre_cfg_bufs_set_string(&bufs, 0,
-                                                  cfg->cfg_obdname);
+                                                  obd->obd_name);
                }
 
                /* Add net info to setup command
@@ -1889,7 +1905,7 @@ static struct lcfg_type_data {
        { LCFG_DEL_CONN, "del_conn", { "1", "2", "3", "4" }  },
        { LCFG_LOV_ADD_OBD, "add_osc", { "ost", "index", "gen", "UUID" } },
        { LCFG_LOV_DEL_OBD, "del_osc", { "1", "2", "3", "4" } },
-       { LCFG_PARAM, "set_param", { "parameter", "value", "3", "4" } },
+       { LCFG_PARAM, "conf_param", { "parameter", "value", "3", "4" } },
        { LCFG_MARKER, "marker", { "1", "2", "3", "4" } },
        { LCFG_LOG_START, "log_start", { "1", "2", "3", "4" } },
        { LCFG_LOG_END, "log_end", { "1", "2", "3", "4" } },
@@ -1903,6 +1919,7 @@ static struct lcfg_type_data {
        { LCFG_POOL_DEL, "del_pool", { "fsname", "pool", "3", "4" } },
        { LCFG_SET_LDLM_TIMEOUT, "set_ldlm_timeout",
          { "parameter", "2", "3", "4" } },
+       { LCFG_SET_PARAM, "set_param", { "parameter", "value", "3", "4" } },
        { 0, NULL, { NULL, NULL, NULL, NULL } }
 };
 
@@ -1970,6 +1987,30 @@ int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size)
                ptr += snprintf(ptr, end - ptr, ", device: %s",
                                lustre_cfg_string(lcfg, 0));
 
+       if (lcfg->lcfg_command == LCFG_SET_PARAM) {
+               /*
+                * set_param -P parameters have param=val here, separate
+                * them through pointer magic and print them out in
+                * native yamlese
+                */
+               char *cfg_str = lustre_cfg_string(lcfg, 1);
+               char *tmp = strchr(cfg_str, '=');
+               size_t len;
+
+               if (tmp == NULL)
+                       return -ENOTTY;
+
+               ptr += snprintf(ptr, end - ptr, ", %s: ", ldata->ltd_bufs[0]);
+               len = tmp - cfg_str + 1;
+               snprintf(ptr, len, "%s", cfg_str);
+               ptr += len - 1;
+
+               ptr += snprintf(ptr, end - ptr, ", %s: ", ldata->ltd_bufs[1]);
+               ptr += snprintf(ptr, end - ptr, "%s", tmp + 1);
+
+               goto out_done;
+       }
+
        for (i = 1; i < lcfg->lcfg_bufcount; i++) {
                if (LUSTRE_CFG_BUFLEN(lcfg, i) > 0)
                        ptr += snprintf(ptr, end - ptr, ", %s: %s",
@@ -1977,6 +2018,7 @@ int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size)
                                        lustre_cfg_string(lcfg, i));
        }
 
+out_done:
        ptr += snprintf(ptr, end - ptr, " }\n");
        /* return consumed bytes */
        rc = ptr - buf;