Whamcloud - gitweb
LU-10937 mgc: restore mgc binding for sptlrpc
[fs/lustre-release.git] / lustre / obdclass / obd_config.c
index 64aca1a..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) {
@@ -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