.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,
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);
}
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) {
}
/* 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);
}
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);
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);
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);
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,
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/>");
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);
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);
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,
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,
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,
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,
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);
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;
#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);
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;
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;
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;
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);
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);
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;
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)
/* 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);
/* 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 */
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;
}
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)
}
} 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;
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);
}