Whamcloud - gitweb
LU-9034 mgc: relate sptlrpc & params to MGC 88/24988/7
authorHongchao Zhang <hongchao.zhang@intel.com>
Tue, 11 Oct 2016 17:41:55 +0000 (01:41 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 3 Feb 2017 00:25:59 +0000 (00:25 +0000)
If sptlrpc or params config logs come from different MGC,
it should be regarded as different logs, this patch binds
these config logs with MGC obd device to separate them.

Change-Id: Ib4f55c7b20bfe722a6a6f7511324a37e98cf9c66
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Reviewed-on: https://review.whamcloud.com/24988
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/mgc/mgc_request.c

index 1de68f5..d5b4f40 100644 (file)
@@ -286,18 +286,19 @@ static struct config_llog_data *config_recover_log_add(struct obd_device *obd,
         return cld;
 }
 
         return cld;
 }
 
-static struct config_llog_data *config_params_log_add(struct obd_device *obd,
-       struct config_llog_instance *cfg, struct super_block *sb)
+static struct config_llog_data *config_log_find_or_add(struct obd_device *obd,
+                               char *logname, struct super_block *sb, int type,
+                               struct config_llog_instance *cfg)
 {
        struct config_llog_instance     lcfg = *cfg;
        struct config_llog_data         *cld;
 
 {
        struct config_llog_instance     lcfg = *cfg;
        struct config_llog_data         *cld;
 
-       lcfg.cfg_instance = sb;
+       lcfg.cfg_instance = sb != NULL ? (void *)sb : (void *)obd;
+       cld = config_log_find(logname, &lcfg);
+       if (unlikely(cld != NULL))
+               return cld;
 
 
-       cld = do_config_log_add(obd, PARAMS_FILENAME, CONFIG_T_PARAMS,
-                               &lcfg, sb);
-
-       return cld;
+       return do_config_log_add(obd, logname, type, &lcfg, sb);
 }
 
 /** Add this log to the list of active logs watched by an MGC.
 }
 
 /** Add this log to the list of active logs watched by an MGC.
@@ -335,20 +336,18 @@ config_log_add(struct obd_device *obd, char *logname,
        memcpy(seclogname, logname, ptr - logname);
        strcpy(seclogname + (ptr - logname), "-sptlrpc");
 
        memcpy(seclogname, logname, ptr - logname);
        strcpy(seclogname + (ptr - logname), "-sptlrpc");
 
-       sptlrpc_cld = config_log_find(seclogname, NULL);
-       if (sptlrpc_cld == NULL) {
-               sptlrpc_cld = do_config_log_add(obd, seclogname,
-                                               CONFIG_T_SPTLRPC, NULL, NULL);
-               if (IS_ERR(sptlrpc_cld)) {
-                       CERROR("can't create sptlrpc log: %s\n", seclogname);
-                       GOTO(out, rc = PTR_ERR(sptlrpc_cld));
-               }
+       sptlrpc_cld = config_log_find_or_add(obd, seclogname, NULL,
+                                            CONFIG_T_SPTLRPC, cfg);
+       if (IS_ERR(sptlrpc_cld)) {
+               CERROR("can't create sptlrpc log: %s\n", seclogname);
+               GOTO(out, rc = PTR_ERR(sptlrpc_cld));
        }
 
        }
 
-       nodemap_cld = config_log_find(LUSTRE_NODEMAP_NAME, NULL);
-       if (!nodemap_cld && IS_SERVER(lsi) && !IS_MGS(lsi)) {
-               nodemap_cld = do_config_log_add(obd, LUSTRE_NODEMAP_NAME,
-                                               CONFIG_T_NODEMAP, NULL, NULL);
+       nodemap_cld = NULL;
+       if (IS_SERVER(lsi) && !IS_MGS(lsi)) {
+               nodemap_cld = config_log_find_or_add(obd, LUSTRE_NODEMAP_NAME,
+                                                    NULL, CONFIG_T_NODEMAP,
+                                                    cfg);
                if (IS_ERR(nodemap_cld)) {
                        rc = PTR_ERR(nodemap_cld);
                        CERROR("%s: cannot create nodemap log: rc = %d\n",
                if (IS_ERR(nodemap_cld)) {
                        rc = PTR_ERR(nodemap_cld);
                        CERROR("%s: cannot create nodemap log: rc = %d\n",
@@ -357,7 +356,8 @@ config_log_add(struct obd_device *obd, char *logname,
                }
        }
 
                }
        }
 
-       params_cld = config_params_log_add(obd, cfg, sb);
+       params_cld = config_log_find_or_add(obd, PARAMS_FILENAME, sb,
+                                           CONFIG_T_PARAMS, cfg);
        if (IS_ERR(params_cld)) {
                rc = PTR_ERR(params_cld);
                CERROR("%s: can't create params log: rc = %d\n",
        if (IS_ERR(params_cld)) {
                rc = PTR_ERR(params_cld);
                CERROR("%s: can't create params log: rc = %d\n",