Whamcloud - gitweb
LU-1301 mgs: introduce mgs_thread_info
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 9 Aug 2012 13:17:47 +0000 (17:17 +0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 12 Sep 2012 16:45:28 +0000 (12:45 -0400)
use it to save stack

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ibefb8a7adf5ac9c6b12212d27d890467c889e5d9
Reviewed-on: http://review.whamcloud.com/3669
Tested-by: Hudson
Reviewed-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/include/lustre_log.h
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h
lustre/mgs/mgs_llog.c
lustre/obdclass/llog.c
lustre/obdclass/llog_internal.h

index a6ce84f..e0124ac 100644 (file)
@@ -122,6 +122,9 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
                     int flags, struct obd_uuid *uuid);
 int llog_process(const struct lu_env *env, struct llog_handle *loghandle,
                 llog_cb_t cb, void *data, void *catdata);
+int llog_process_or_fork(const struct lu_env *env,
+                        struct llog_handle *loghandle,
+                        llog_cb_t cb, void *data, void *catdata, bool fork);
 int llog_reverse_process(const struct lu_env *env,
                         struct llog_handle *loghandle, llog_cb_t cb,
                         void *data, void *catdata);
index c2a30de..b9e3df2 100644 (file)
@@ -254,7 +254,7 @@ static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                        .tc_thr_name            = "ll_mgs",
                        .tc_nthrs_init          = MGS_NTHRS_INIT,
                        .tc_nthrs_max           = MGS_NTHRS_MAX,
-                       .tc_ctx_tags            = LCT_MD_THREAD,
+                       .tc_ctx_tags            = LCT_MG_THREAD,
                },
                .psc_ops                = {
                        .so_req_handler         = mgs_handle,
@@ -642,23 +642,22 @@ static int mgs_set_info_rpc(struct ptlrpc_request *req)
        struct mgs_device *mgs = exp2mgs_dev(req->rq_export);
        struct lu_env     *env = req->rq_svc_thread->t_env;
         struct mgs_send_param *msp, *rep_msp;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
         int rc;
-        struct lustre_cfg_bufs bufs;
         struct lustre_cfg *lcfg;
-        char fsname[MTI_NAME_MAXLEN];
         ENTRY;
 
         msp = req_capsule_client_get(&req->rq_pill, &RMF_MGS_SEND_PARAM);
         LASSERT(msp);
 
         /* Construct lustre_cfg structure to pass to function mgs_setparam */
-        lustre_cfg_bufs_reset(&bufs, NULL);
-        lustre_cfg_bufs_set_string(&bufs, 1, msp->mgs_param);
-        lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
-       rc = mgs_setparam(env, mgs, lcfg, fsname);
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL);
+       lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, msp->mgs_param);
+       lcfg = lustre_cfg_new(LCFG_PARAM, &mgi->mgi_bufs);
+       rc = mgs_setparam(env, mgs, lcfg, mgi->mgi_fsname);
         if (rc) {
                 CERROR("Error %d in setting the parameter %s for fs %s\n",
-                       rc, msp->mgs_param, fsname);
+                      rc, msp->mgs_param, mgi->mgi_fsname);
                 RETURN(rc);
         }
 
@@ -1010,22 +1009,16 @@ static int mgs_iocontrol_pool(const struct lu_env *env,
                              struct mgs_device *mgs,
                               struct obd_ioctl_data *data)
 {
+       struct mgs_thread_info *mgi = mgs_env_info(env);
         int rc;
         struct lustre_cfg *lcfg = NULL;
         struct llog_rec_hdr rec;
-        char *fsname = NULL;
         char *poolname = NULL;
         ENTRY;
 
-        OBD_ALLOC(fsname, MTI_NAME_MAXLEN);
-        if (fsname == NULL)
-                RETURN(-ENOMEM);
-
         OBD_ALLOC(poolname, LOV_MAXPOOLNAME + 1);
-        if (poolname == NULL) {
-                rc = -ENOMEM;
-                GOTO(out_pool, rc);
-        }
+       if (poolname == NULL)
+               RETURN(-ENOMEM);
         rec.lrh_len = llog_data_len(data->ioc_plen1);
 
         if (data->ioc_type == LUSTRE_CFG_TYPE) {
@@ -1053,47 +1046,41 @@ static int mgs_iocontrol_pool(const struct lu_env *env,
         }
 
         /* first arg is always <fsname>.<poolname> */
-        mgs_extract_fs_pool(lustre_cfg_string(lcfg, 1), fsname,
+       mgs_extract_fs_pool(lustre_cfg_string(lcfg, 1), mgi->mgi_fsname,
                             poolname);
 
         switch (lcfg->lcfg_command) {
-        case LCFG_POOL_NEW: {
+       case LCFG_POOL_NEW:
                 if (lcfg->lcfg_bufcount != 2)
                         RETURN(-EINVAL);
-               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_NEW, fsname,
+               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_NEW, mgi->mgi_fsname,
                                   poolname, NULL);
                 break;
-        }
-        case LCFG_POOL_ADD: {
+       case LCFG_POOL_ADD:
                 if (lcfg->lcfg_bufcount != 3)
                         RETURN(-EINVAL);
-               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_ADD, fsname, poolname,
-                                  lustre_cfg_string(lcfg, 2));
+               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_ADD, mgi->mgi_fsname,
+                                 poolname, lustre_cfg_string(lcfg, 2));
                 break;
-        }
-        case LCFG_POOL_REM: {
+       case LCFG_POOL_REM:
                 if (lcfg->lcfg_bufcount != 3)
                         RETURN(-EINVAL);
-               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_REM, fsname, poolname,
-                                  lustre_cfg_string(lcfg, 2));
+               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_REM, mgi->mgi_fsname,
+                                 poolname, lustre_cfg_string(lcfg, 2));
                 break;
-        }
-        case LCFG_POOL_DEL: {
+       case LCFG_POOL_DEL:
                 if (lcfg->lcfg_bufcount != 2)
                         RETURN(-EINVAL);
-               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_DEL, fsname,
+               rc = mgs_pool_cmd(env, mgs, LCFG_POOL_DEL, mgi->mgi_fsname,
                                   poolname, NULL);
                 break;
-        }
-        default: {
+       default:
                  rc = -EINVAL;
-                 GOTO(out_pool, rc);
-        }
         }
 
         if (rc) {
                 CERROR("OBD_IOC_POOL err %d, cmd %X for pool %s.%s\n",
-                       rc, lcfg->lcfg_command, fsname, poolname);
+                      rc, lcfg->lcfg_command, mgi->mgi_fsname, poolname);
                 GOTO(out_pool, rc);
         }
 
@@ -1101,9 +1088,6 @@ out_pool:
         if (lcfg != NULL)
                 OBD_FREE(lcfg, data->ioc_plen1);
 
-        if (fsname != NULL)
-                OBD_FREE(fsname, MTI_NAME_MAXLEN);
-
         if (poolname != NULL)
                 OBD_FREE(poolname, LOV_MAXPOOLNAME + 1);
 
@@ -1130,9 +1114,9 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
         switch (cmd) {
 
         case OBD_IOC_PARAM: {
+               struct mgs_thread_info *mgi = mgs_env_info(&env);
                 struct lustre_cfg *lcfg;
                 struct llog_rec_hdr rec;
-                char fsname[MTI_NAME_MAXLEN];
 
                 rec.lrh_len = llog_data_len(data->ioc_plen1);
 
@@ -1152,7 +1136,7 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 if (lcfg->lcfg_bufcount < 1)
                         GOTO(out_free, rc = -EINVAL);
 
-               rc = mgs_setparam(&env, mgs, lcfg, fsname);
+               rc = mgs_setparam(&env, mgs, lcfg, mgi->mgi_fsname);
                 if (rc) {
                         CERROR("setparam err %d\n", rc);
                         GOTO(out_free, rc);
@@ -1201,6 +1185,11 @@ out:
        RETURN(rc);
 }
 
+/* context key constructor/destructor: mgs_key_init, mgs_key_fini */
+LU_KEY_INIT_FINI(mgs, struct mgs_thread_info);
+
+LU_CONTEXT_KEY_DEFINE(mgs, LCT_MG_THREAD);
+
 /* use obd ops to offer management infrastructure */
 static struct obd_ops mgs_obd_ops = {
         .o_owner           = THIS_MODULE,
@@ -1220,17 +1209,24 @@ static struct obd_ops mgs_obd_ops = {
 static int __init mgs_init(void)
 {
         struct lprocfs_static_vars lvars;
+       int rc;
 
         lprocfs_mgs_init_vars(&lvars);
         class_register_type(&mgs_obd_ops, NULL,
                             lvars.module_vars, LUSTRE_MGS_NAME, NULL);
 
-        return 0;
+       LU_CONTEXT_KEY_INIT(&mgs_thread_key);
+       rc = lu_context_key_register(&mgs_thread_key);
+       if (rc)
+               class_unregister_type(LUSTRE_MGS_NAME);
+
+       return rc;
 }
 
 static void /*__exit*/ mgs_exit(void)
 {
         class_unregister_type(LUSTRE_MGS_NAME);
+       lu_context_key_degister(&mgs_thread_key);
 }
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
index 0e1fb7e..caee9fd 100644 (file)
@@ -262,6 +262,33 @@ enum {
 void mgs_counter_incr(struct obd_export *exp, int opcode);
 void mgs_stats_counter_init(struct lprocfs_stats *stats);
 
+struct temp_comp
+{
+       struct mgs_target_info  *comp_tmti;
+       struct mgs_target_info  *comp_mti;
+       struct fs_db            *comp_fsdb;
+       struct mgs_device       *comp_mgs;
+       const struct lu_env     *comp_env;
+};
+
+struct mgs_thread_info {
+       struct lustre_cfg_bufs  mgi_bufs;
+       char                    mgi_fsname[MTI_NAME_MAXLEN];
+       struct cfg_marker       mgi_marker;
+       struct temp_comp        mgi_comp;
+};
+
+extern struct lu_context_key mgs_thread_key;
+
+static inline struct mgs_thread_info *mgs_env_info(const struct lu_env *env)
+{
+       struct mgs_thread_info *info;
+
+       info = lu_context_key_get(&env->le_ctx, &mgs_thread_key);
+       LASSERT(info != NULL);
+       return info;
+}
+
 static inline struct mgs_device *exp2mgs_dev(struct obd_export *exp)
 {
        return &exp->exp_obd->u.mgs;
index d1a9b2c..bae69a4 100644 (file)
@@ -289,7 +289,8 @@ static int mgs_get_fsdb_from_llog(const struct lu_env *env,
        if (llog_get_size(loghandle) <= 1)
                cfs_set_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags);
 
-       rc = llog_process(NULL, loghandle, mgs_fsdb_handler, (void *)&d, NULL);
+       rc = llog_process_or_fork(env, loghandle, mgs_fsdb_handler, (void *)&d,
+                                 NULL, false);
        CDEBUG(D_INFO, "get_db = %d\n", rc);
 out_close:
        rc2 = llog_close(NULL, loghandle);
@@ -711,8 +712,8 @@ static int mgs_modify(const struct lu_env *env, struct mgs_device *mgs,
         mml->mml_marker.cm_flags = flags;
         mml->mml_marker.cm_canceltime = flags ? cfs_time_current_sec() : 0;
         mml->mml_modified = 0;
-       rc = llog_process(NULL, loghandle, mgs_modify_handler, (void *)mml,
-                         NULL);
+       rc = llog_process_or_fork(env, loghandle, mgs_modify_handler,
+                                 (void *)mml, NULL, false);
         if (!rc && !mml->mml_modified)
                 rc = -ENODEV;
         OBD_FREE_PTR(mml);
@@ -763,31 +764,31 @@ static int record_base(const struct lu_env *env, struct llog_handle *llh,
                      char *cfgname, lnet_nid_t nid, int cmd,
                      char *s1, char *s2, char *s3, char *s4)
 {
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg     *lcfg;
-        int rc;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
+       struct lustre_cfg     *lcfg;
+       int rc;
 
-        CDEBUG(D_MGS, "lcfg %s %#x %s %s %s %s\n", cfgname,
-               cmd, s1, s2, s3, s4);
+       CDEBUG(D_MGS, "lcfg %s %#x %s %s %s %s\n", cfgname,
+              cmd, s1, s2, s3, s4);
 
-        lustre_cfg_bufs_reset(&bufs, cfgname);
-        if (s1)
-                lustre_cfg_bufs_set_string(&bufs, 1, s1);
-        if (s2)
-                lustre_cfg_bufs_set_string(&bufs, 2, s2);
-        if (s3)
-                lustre_cfg_bufs_set_string(&bufs, 3, s3);
-        if (s4)
-                lustre_cfg_bufs_set_string(&bufs, 4, s4);
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, cfgname);
+       if (s1)
+               lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, s1);
+       if (s2)
+               lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 2, s2);
+       if (s3)
+               lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 3, s3);
+       if (s4)
+               lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 4, s4);
 
-        lcfg = lustre_cfg_new(cmd, &bufs);
-        if (!lcfg)
-                return -ENOMEM;
-        lcfg->lcfg_nid = nid;
+       lcfg = lustre_cfg_new(cmd, &mgi->mgi_bufs);
+       if (!lcfg)
+               return -ENOMEM;
+       lcfg->lcfg_nid = nid;
 
        rc = record_lcfg(env, llh, lcfg);
 
-        lustre_cfg_free(lcfg);
+       lustre_cfg_free(lcfg);
 
         if (rc) {
                 CERROR("error %d: lcfg %s %#x %s %s %s %s\n", rc, cfgname,
@@ -829,36 +830,36 @@ static inline int record_setup(const struct lu_env *env,
 static int record_lov_setup(const struct lu_env *env, struct llog_handle *llh,
                            char *devname, struct lov_desc *desc)
 {
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
-        int rc;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
+       struct lustre_cfg *lcfg;
+       int rc;
 
-        lustre_cfg_bufs_reset(&bufs, devname);
-        lustre_cfg_bufs_set(&bufs, 1, desc, sizeof(*desc));
-        lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
-        if (!lcfg)
-                return -ENOMEM;
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, devname);
+       lustre_cfg_bufs_set(&mgi->mgi_bufs, 1, desc, sizeof(*desc));
+       lcfg = lustre_cfg_new(LCFG_SETUP, &mgi->mgi_bufs);
+       if (!lcfg)
+               return -ENOMEM;
        rc = record_lcfg(env, llh, lcfg);
 
-        lustre_cfg_free(lcfg);
-        return rc;
+       lustre_cfg_free(lcfg);
+       return rc;
 }
 
 static int record_lmv_setup(const struct lu_env *env, struct llog_handle *llh,
                             char *devname, struct lmv_desc *desc)
 {
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
-        int rc;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
+       struct lustre_cfg *lcfg;
+       int rc;
 
-        lustre_cfg_bufs_reset(&bufs, devname);
-        lustre_cfg_bufs_set(&bufs, 1, desc, sizeof(*desc));
-        lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, devname);
+       lustre_cfg_bufs_set(&mgi->mgi_bufs, 1, desc, sizeof(*desc));
+       lcfg = lustre_cfg_new(LCFG_SETUP, &mgi->mgi_bufs);
 
        rc = record_lcfg(env, llh, lcfg);
 
-        lustre_cfg_free(lcfg);
-        return rc;
+       lustre_cfg_free(lcfg);
+       return rc;
 }
 
 static inline int record_mdc_add(const struct lu_env *env,
@@ -894,29 +895,31 @@ static int record_marker(const struct lu_env *env,
                          struct fs_db *fsdb, __u32 flags,
                          char *tgtname, char *comment)
 {
-        struct cfg_marker marker;
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
-        int rc;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
+       struct lustre_cfg *lcfg;
+       int rc;
 
-        if (flags & CM_START)
-                fsdb->fsdb_gen++;
-        marker.cm_step = fsdb->fsdb_gen;
-        marker.cm_flags = flags;
-        marker.cm_vers = LUSTRE_VERSION_CODE;
-        strncpy(marker.cm_tgtname, tgtname, sizeof(marker.cm_tgtname));
-        strncpy(marker.cm_comment, comment, sizeof(marker.cm_comment));
-        marker.cm_createtime = cfs_time_current_sec();
-        marker.cm_canceltime = 0;
-        lustre_cfg_bufs_reset(&bufs, NULL);
-        lustre_cfg_bufs_set(&bufs, 1, &marker, sizeof(marker));
-        lcfg = lustre_cfg_new(LCFG_MARKER, &bufs);
-        if (!lcfg)
-                return -ENOMEM;
+       if (flags & CM_START)
+               fsdb->fsdb_gen++;
+       mgi->mgi_marker.cm_step = fsdb->fsdb_gen;
+       mgi->mgi_marker.cm_flags = flags;
+       mgi->mgi_marker.cm_vers = LUSTRE_VERSION_CODE;
+       strncpy(mgi->mgi_marker.cm_tgtname, tgtname,
+               sizeof(mgi->mgi_marker.cm_tgtname));
+       strncpy(mgi->mgi_marker.cm_comment, comment,
+               sizeof(mgi->mgi_marker.cm_comment));
+       mgi->mgi_marker.cm_createtime = cfs_time_current_sec();
+       mgi->mgi_marker.cm_canceltime = 0;
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL);
+       lustre_cfg_bufs_set(&mgi->mgi_bufs, 1, &mgi->mgi_marker,
+                           sizeof(mgi->mgi_marker));
+       lcfg = lustre_cfg_new(LCFG_MARKER, &mgi->mgi_bufs);
+       if (!lcfg)
+               return -ENOMEM;
        rc = record_lcfg(env, llh, lcfg);
 
-        lustre_cfg_free(lcfg);
-        return rc;
+       lustre_cfg_free(lcfg);
+       return rc;
 }
 
 static int record_start_log(const struct lu_env *env,
@@ -1102,15 +1105,6 @@ next:
         RETURN(rc);
 }
 
-struct temp_comp
-{
-        struct mgs_target_info   *comp_tmti;
-        struct mgs_target_info   *comp_mti;
-        struct fs_db             *comp_fsdb;
-       struct mgs_device        *comp_mgs;
-       const struct lu_env      *comp_env;
-};
-
 static int mgs_write_log_mdc_to_mdt(const struct lu_env *env,
                                    struct mgs_device *mgs,
                                    struct fs_db *fsdb,
@@ -1316,8 +1310,8 @@ static int mgs_steal_llog_for_mdt_from_client(const struct lu_env *env,
        if (rc)
                GOTO(out_close, rc);
 
-       rc = llog_process(NULL, loghandle, mgs_steal_llog_handler,
-                         (void *)comp, NULL);
+       rc = llog_process_or_fork(env, loghandle, mgs_steal_llog_handler,
+                                 (void *)comp, NULL, false);
        CDEBUG(D_MGS, "steal llog re = %d\n", rc);
 out_close:
        llog_close(NULL, loghandle);
@@ -1650,9 +1644,9 @@ static int mgs_write_log_mdt(const struct lu_env *env,
                             struct fs_db *fsdb,
                             struct mgs_target_info *mti)
 {
+       struct mgs_thread_info *mgi = mgs_env_info(env);
         struct llog_handle *llh = NULL;
         char *cliname;
-        struct temp_comp comp = { 0 };
         int rc, i = 0;
         ENTRY;
 
@@ -1728,11 +1722,11 @@ static int mgs_write_log_mdt(const struct lu_env *env,
 #endif
         {
                 /* copy client info about lov/lmv */
-                comp.comp_mti = mti;
-                comp.comp_fsdb = fsdb;
+               mgi->mgi_comp.comp_mti = mti;
+               mgi->mgi_comp.comp_fsdb = fsdb;
 
                rc = mgs_steal_llog_for_mdt_from_client(env, mgs, cliname,
-                                                        &comp);
+                                                       &mgi->mgi_comp);
 
                rc = mgs_write_log_mdc_to_lmv(env, mgs, fsdb, mti, cliname,
                                               fsdb->fsdb_clilmv);
@@ -2071,7 +2065,7 @@ static int mgs_write_log_sys(const struct lu_env *env,
                             struct mgs_device *mgs, struct fs_db *fsdb,
                             struct mgs_target_info *mti, char *sys, char *ptr)
 {
-       struct lustre_cfg_bufs bufs;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
        struct lustre_cfg *lcfg;
        char *tmp, sep;
        int rc, cmd, convert = 1;
@@ -2099,11 +2093,11 @@ static int mgs_write_log_sys(const struct lu_env *env,
        else
                CDEBUG(D_MGS, "global '%s' val=%s\n", sys, tmp);
 
-       lustre_cfg_bufs_reset(&bufs, NULL);
-       lustre_cfg_bufs_set_string(&bufs, 1, sys);
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, NULL);
+       lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, sys);
        if (!convert && *tmp != '\0')
-               lustre_cfg_bufs_set_string(&bufs, 2, tmp);
-       lcfg = lustre_cfg_new(cmd, &bufs);
+               lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 2, tmp);
+       lcfg = lustre_cfg_new(cmd, &mgi->mgi_bufs);
        lcfg->lcfg_num = convert ? simple_strtoul(tmp, NULL, 0) : 0;
        /* truncate the comment to the parameter name */
        ptr = tmp - 1;
@@ -2190,10 +2184,10 @@ static int mgs_srpc_set_param_disk(const struct lu_env *env,
                                    struct mgs_target_info *mti,
                                    char *param)
 {
+       struct mgs_thread_info *mgi = mgs_env_info(env);
         struct llog_handle     *llh = NULL;
         char                   *logname;
         char                   *comment, *ptr;
-        struct lustre_cfg_bufs  bufs;
         struct lustre_cfg      *lcfg;
         int                     rc, len;
         ENTRY;
@@ -2210,9 +2204,9 @@ static int mgs_srpc_set_param_disk(const struct lu_env *env,
         comment[len] = '\0';
 
         /* prepare lcfg */
-        lustre_cfg_bufs_reset(&bufs, mti->mti_svname);
-        lustre_cfg_bufs_set_string(&bufs, 1, param);
-        lcfg = lustre_cfg_new(LCFG_SPTLRPC_CONF, &bufs);
+       lustre_cfg_bufs_reset(&mgi->mgi_bufs, mti->mti_svname);
+       lustre_cfg_bufs_set_string(&mgi->mgi_bufs, 1, param);
+       lcfg = lustre_cfg_new(LCFG_SPTLRPC_CONF, &mgi->mgi_bufs);
         if (lcfg == NULL)
                 GOTO(out_comment, rc = -ENOMEM);
 
@@ -2523,8 +2517,8 @@ int mgs_get_fsdb_srpc_from_llog(const struct lu_env *env,
         msrd.msrd_fsdb = fsdb;
         msrd.msrd_skip = 0;
 
-       rc = llog_process(NULL, llh, mgs_srpc_read_handler, (void *)&msrd,
-                         NULL);
+       rc = llog_process_or_fork(env, llh, mgs_srpc_read_handler,
+                                 (void *)&msrd, NULL, false);
 
 out_close:
        llog_close(NULL, llh);
@@ -2548,7 +2542,7 @@ static int mgs_write_log_param(const struct lu_env *env,
                               struct mgs_device *mgs, struct fs_db *fsdb,
                                struct mgs_target_info *mti, char *ptr)
 {
-        struct lustre_cfg_bufs bufs;
+       struct mgs_thread_info *mgi = mgs_env_info(env);
         char *logname;
         char *tmp;
         int rc = 0, rc2 = 0;
@@ -2680,7 +2674,7 @@ static int mgs_write_log_param(const struct lu_env *env,
                 name_create_mdt_and_lov(&logname, &mdtlovname, fsdb,
                                         mti->mti_stripe_index);
                rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, mti->mti_svname,
-                                  &bufs, mdtlovname, ptr);
+                                 &mgi->mgi_bufs, mdtlovname, ptr);
                 name_destroy(&logname);
                 name_destroy(&mdtlovname);
                 if (rc)
@@ -2688,7 +2682,7 @@ static int mgs_write_log_param(const struct lu_env *env,
 
                 /* Modify clilov */
                 name_create(&logname, mti->mti_fsname, "-client");
-               rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &bufs,
+               rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &mgi->mgi_bufs,
                                   fsdb->fsdb_clilov, ptr);
                 name_destroy(&logname);
                 GOTO(end, rc);
@@ -2734,7 +2728,7 @@ static int mgs_write_log_param(const struct lu_env *env,
 
                 /* Modify client */
                 name_create(&logname, mti->mti_fsname, "-client");
-               rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &bufs,
+               rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &mgi->mgi_bufs,
                                   cname, ptr);
 
                 /* osc params affect the MDT as well */
@@ -2751,8 +2745,8 @@ static int mgs_write_log_param(const struct lu_env *env,
                                 name_create_mdt(&logname, mti->mti_fsname, i);
                                if (!mgs_log_is_empty(env, mgs, logname))
                                        rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
-                                                         logname, &bufs, cname,
-                                                         ptr);
+                                                         logname, &mgi->mgi_bufs,
+                                                         cname, ptr);
                                 if (rc)
                                         break;
                         }
@@ -2785,7 +2779,7 @@ static int mgs_write_log_param(const struct lu_env *env,
                                         continue;
                                 name_create_mdt(&logname, mti->mti_fsname, i);
                                rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
-                                                  logname, &bufs,
+                                                 logname, &mgi->mgi_bufs,
                                                   logname, ptr);
                                 name_destroy(&logname);
                                 if (rc)
@@ -2793,7 +2787,7 @@ static int mgs_write_log_param(const struct lu_env *env,
                         }
                 } else {
                        rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
-                                          mti->mti_svname, &bufs,
+                                         mti->mti_svname, &mgi->mgi_bufs,
                                           mti->mti_svname, ptr);
                         if (rc)
                                 goto active_err;
@@ -2809,7 +2803,7 @@ static int mgs_write_log_param(const struct lu_env *env,
                         GOTO(end, rc = -ENODEV);
 
                rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, mti->mti_svname,
-                                  &bufs, mti->mti_svname, ptr);
+                                 &mgi->mgi_bufs, mti->mti_svname, ptr);
                 GOTO(end, rc);
         }
 
index ee4d1f4..3b0817a 100644 (file)
@@ -462,6 +462,7 @@ int llog_process_or_fork(const struct lu_env *env,
         OBD_FREE_PTR(lpi);
         RETURN(rc);
 }
+EXPORT_SYMBOL(llog_process_or_fork);
 
 int llog_process(const struct lu_env *env, struct llog_handle *loghandle,
                 llog_cb_t cb, void *data, void *catdata)
index 0e8d3b2..a599c61 100644 (file)
@@ -84,7 +84,4 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle,
 int class_config_dump_handler(const struct lu_env *env,
                              struct llog_handle *handle,
                              struct llog_rec_hdr *rec, void *data);
-int llog_process_or_fork(const struct lu_env *env,
-                        struct llog_handle *loghandle,
-                        llog_cb_t cb, void *data, void *catdata, bool fork);
 #endif