/********************** Class functions ********************/
/* Caller must list_del and OBD_FREE each dentry from the list */
-int class_dentry_readdir(struct obd_device *obd, struct dentry *dir,
- struct vfsmount *inmnt,
- cfs_list_t *dentry_list){
+int class_dentry_readdir(const struct lu_env *env,
+ struct mgs_device *mgs, cfs_list_t *dentry_list)
+{
/* see mds_cleanup_pending */
struct lvfs_run_ctxt saved;
struct file *file;
int rc = 0;
ENTRY;
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- dentry = dget(dir);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
+ dentry = dget(mgs->mgs_configs_dir);
if (IS_ERR(dentry))
GOTO(out_pop, rc = PTR_ERR(dentry));
- mnt = mntget(inmnt);
+ mnt = mntget(mgs->mgs_vfsmnt);
if (IS_ERR(mnt)) {
l_dput(dentry);
GOTO(out_pop, rc = PTR_ERR(mnt));
/* filp_close->fput() drops the dentry, mnt refs */
out_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
RETURN(rc);
}
}
/* fsdb->fsdb_mutex is already held in mgs_find_or_make_fsdb*/
-static int mgs_get_fsdb_from_llog(struct obd_device *obd, struct fs_db *fsdb)
+static int mgs_get_fsdb_from_llog(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb)
{
char *logname;
struct llog_handle *loghandle;
int rc, rc2;
ENTRY;
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
name_create(&logname, fsdb->fsdb_name, "-client");
cfs_mutex_lock(&fsdb->fsdb_mutex);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open_create(NULL, ctxt, &loghandle, NULL, logname);
if (rc)
GOTO(out_pop, rc);
if (!rc)
rc = rc2;
out_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
cfs_mutex_unlock(&fsdb->fsdb_mutex);
name_destroy(&logname);
llog_ctxt_put(ctxt);
sptlrpc_rule_set_free(&fsdb->fsdb_srpc_gen);
}
-struct fs_db *mgs_find_fsdb(struct obd_device *obd, char *fsname)
+struct fs_db *mgs_find_fsdb(struct mgs_device *mgs, char *fsname)
{
- struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
cfs_list_t *tmp;
}
/* caller must hold the mgs->mgs_fs_db_lock */
-static struct fs_db *mgs_new_fsdb(struct obd_device *obd, char *fsname)
+static struct fs_db *mgs_new_fsdb(const struct lu_env *env,
+ struct mgs_device *mgs, char *fsname)
{
- struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
int rc;
ENTRY;
GOTO(err, rc);
/* initialise data for NID table */
- mgs_ir_init_fs(obd, fsdb);
+ mgs_ir_init_fs(env, mgs, fsdb);
- lproc_mgs_add_live(obd, fsdb);
+ lproc_mgs_add_live(mgs, fsdb);
}
cfs_list_add(&fsdb->fsdb_list, &mgs->mgs_fs_db_list);
RETURN(NULL);
}
-static void mgs_free_fsdb(struct obd_device *obd, struct fs_db *fsdb)
+static void mgs_free_fsdb(struct mgs_device *mgs, struct fs_db *fsdb)
{
/* wait for anyone with the sem */
cfs_mutex_lock(&fsdb->fsdb_mutex);
- lproc_mgs_del_live(obd, fsdb);
+ lproc_mgs_del_live(mgs, fsdb);
cfs_list_del(&fsdb->fsdb_list);
/* deinitialize fsr */
- mgs_ir_fini_fs(obd, fsdb);
+ mgs_ir_fini_fs(mgs, fsdb);
if (fsdb->fsdb_ost_index_map)
OBD_FREE(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
OBD_FREE_PTR(fsdb);
}
-int mgs_init_fsdb_list(struct obd_device *obd)
+int mgs_init_fsdb_list(struct mgs_device *mgs)
{
- struct mgs_obd *mgs = &obd->u.mgs;
CFS_INIT_LIST_HEAD(&mgs->mgs_fs_db_list);
return 0;
}
-int mgs_cleanup_fsdb_list(struct obd_device *obd)
+int mgs_cleanup_fsdb_list(struct mgs_device *mgs)
{
- struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
cfs_list_t *tmp, *tmp2;
cfs_mutex_lock(&mgs->mgs_mutex);
cfs_list_for_each_safe(tmp, tmp2, &mgs->mgs_fs_db_list) {
fsdb = cfs_list_entry(tmp, struct fs_db, fsdb_list);
- mgs_free_fsdb(obd, fsdb);
+ mgs_free_fsdb(mgs, fsdb);
}
cfs_mutex_unlock(&mgs->mgs_mutex);
return 0;
}
-int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
+int mgs_find_or_make_fsdb(const struct lu_env *env,
+ struct mgs_device *mgs, char *name,
struct fs_db **dbh)
{
- struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
int rc = 0;
cfs_mutex_lock(&mgs->mgs_mutex);
- fsdb = mgs_find_fsdb(obd, name);
+ fsdb = mgs_find_fsdb(mgs, name);
if (fsdb) {
cfs_mutex_unlock(&mgs->mgs_mutex);
*dbh = fsdb;
}
CDEBUG(D_MGS, "Creating new db\n");
- fsdb = mgs_new_fsdb(obd, name);
+ fsdb = mgs_new_fsdb(env, mgs, name);
cfs_mutex_unlock(&mgs->mgs_mutex);
if (!fsdb)
return -ENOMEM;
if (!cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) {
/* populate the db from the client llog */
- rc = mgs_get_fsdb_from_llog(obd, fsdb);
+ rc = mgs_get_fsdb_from_llog(env, mgs, fsdb);
if (rc) {
CERROR("Can't get db from client log %d\n", rc);
- mgs_free_fsdb(obd, fsdb);
+ mgs_free_fsdb(mgs, fsdb);
return rc;
}
}
/* populate srpc rules from params llog */
- rc = mgs_get_fsdb_srpc_from_llog(obd, fsdb);
+ rc = mgs_get_fsdb_srpc_from_llog(env, mgs, fsdb);
if (rc) {
CERROR("Can't get db from params log %d\n", rc);
- mgs_free_fsdb(obd, fsdb);
+ mgs_free_fsdb(mgs, fsdb);
return rc;
}
/* 1 = index in use
0 = index unused
-1= empty client log */
-int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti)
+int mgs_check_index(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct mgs_target_info *mti)
{
struct fs_db *fsdb;
void *imap;
LASSERT(!(mti->mti_flags & LDD_F_NEED_INDEX));
- rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+ rc = mgs_find_or_make_fsdb(env, mgs, mti->mti_fsname, &fsdb);
if (rc) {
CERROR("Can't get db for %s\n", mti->mti_fsname);
RETURN(rc);
0 newly marked as in use
<0 err
+EALREADY for update of an old index */
-static int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
+static int mgs_set_index(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct mgs_target_info *mti)
{
struct fs_db *fsdb;
void *imap;
int rc = 0;
ENTRY;
- rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+ rc = mgs_find_or_make_fsdb(env, mgs, mti->mti_fsname, &fsdb);
if (rc) {
CERROR("Can't get db for %s\n", mti->mti_fsname);
RETURN(rc);
}
/* Modify an existing config log record (for CM_SKIP or CM_EXCLUDE) */
-static int mgs_modify(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti, char *logname,
- char *devname, char *comment, int flags)
+static int mgs_modify(const struct lu_env *env, struct mgs_device *mgs,
+ struct fs_db *fsdb, struct mgs_target_info *mti,
+ char *logname, char *devname, char *comment, int flags)
{
struct llog_handle *loghandle;
struct lvfs_run_ctxt saved;
CDEBUG(D_MGS, "modify %s/%s/%s fl=%x\n", logname, devname, comment,
flags);
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open(NULL, ctxt, &loghandle, NULL, logname,
LLOG_OPEN_EXISTS);
if (rc < 0) {
if (!rc)
rc = rc2;
out_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
if (rc && rc != -ENODEV)
CERROR("modify %s/%s failed %d\n",
mti->mti_svname, comment, rc);
/******************** config log recording functions *********************/
-static int record_lcfg(struct obd_device *obd, struct llog_handle *llh,
+static int record_lcfg(const struct lu_env *env, struct llog_handle *llh,
struct lustre_cfg *lcfg)
{
struct lvfs_run_ctxt saved;
struct llog_rec_hdr rec;
int buflen, rc;
+ struct obd_device *obd = llh->lgh_ctxt->loc_obd;
if (!lcfg || !llh)
return -ENOMEM;
return rc;
}
-static int record_base(struct obd_device *obd, struct llog_handle *llh,
+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)
{
return -ENOMEM;
lcfg->lcfg_nid = nid;
- rc = record_lcfg(obd, llh, lcfg);
+ rc = record_lcfg(env, llh, lcfg);
lustre_cfg_free(lcfg);
}
-static inline int record_add_uuid(struct obd_device *obd,
- struct llog_handle *llh,
- uint64_t nid, char *uuid)
+static inline int record_add_uuid(const struct lu_env *env,
+ struct llog_handle *llh,
+ uint64_t nid, char *uuid)
{
- return record_base(obd,llh,NULL,nid,LCFG_ADD_UUID,uuid,0,0,0);
+ return record_base(env, llh, NULL, nid, LCFG_ADD_UUID, uuid, 0, 0, 0);
}
-static inline int record_add_conn(struct obd_device *obd,
- struct llog_handle *llh,
- char *devname,
- char *uuid)
+static inline int record_add_conn(const struct lu_env *env,
+ struct llog_handle *llh,
+ char *devname, char *uuid)
{
- return record_base(obd,llh,devname,0,LCFG_ADD_CONN,uuid,0,0,0);
+ return record_base(env, llh, devname, 0, LCFG_ADD_CONN, uuid, 0, 0, 0);
}
-static inline int record_attach(struct obd_device *obd, struct llog_handle *llh,
- char *devname, char *type, char *uuid)
+static inline int record_attach(const struct lu_env *env,
+ struct llog_handle *llh, char *devname,
+ char *type, char *uuid)
{
- return record_base(obd,llh,devname,0,LCFG_ATTACH,type,uuid,0,0);
+ return record_base(env, llh,devname, 0, LCFG_ATTACH, type, uuid, 0, 0);
}
-static inline int record_setup(struct obd_device *obd, struct llog_handle *llh,
- char *devname,
- char *s1, char *s2, char *s3, char *s4)
+static inline int record_setup(const struct lu_env *env,
+ struct llog_handle *llh, char *devname,
+ char *s1, char *s2, char *s3, char *s4)
{
- return record_base(obd,llh,devname,0,LCFG_SETUP,s1,s2,s3,s4);
+ return record_base(env, llh, devname, 0, LCFG_SETUP, s1, s2, s3, s4);
}
-static int record_lov_setup(struct obd_device *obd, struct llog_handle *llh,
- char *devname, struct lov_desc *desc)
+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;
lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
if (!lcfg)
return -ENOMEM;
- rc = record_lcfg(obd, llh, lcfg);
+ rc = record_lcfg(env, llh, lcfg);
lustre_cfg_free(lcfg);
return rc;
}
-static int record_lmv_setup(struct obd_device *obd, struct llog_handle *llh,
+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;
lustre_cfg_bufs_set(&bufs, 1, desc, sizeof(*desc));
lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
- rc = record_lcfg(obd, llh, lcfg);
+ rc = record_lcfg(env, llh, lcfg);
lustre_cfg_free(lcfg);
return rc;
}
-static inline int record_mdc_add(struct obd_device *obd,
+static inline int record_mdc_add(const struct lu_env *env,
struct llog_handle *llh,
char *logname, char *mdcuuid,
char *mdtuuid, char *index,
char *gen)
{
- return record_base(obd,llh,logname,0,LCFG_ADD_MDC,
+ return record_base(env,llh,logname,0,LCFG_ADD_MDC,
mdtuuid,index,gen,mdcuuid);
}
-static inline int record_lov_add(struct obd_device *obd,
+static inline int record_lov_add(const struct lu_env *env,
struct llog_handle *llh,
char *lov_name, char *ost_uuid,
char *index, char *gen)
{
- return record_base(obd,llh,lov_name,0,LCFG_LOV_ADD_OBD,
+ return record_base(env,llh,lov_name,0,LCFG_LOV_ADD_OBD,
ost_uuid,index,gen,0);
}
-static inline int record_mount_opt(struct obd_device *obd,
+static inline int record_mount_opt(const struct lu_env *env,
struct llog_handle *llh,
char *profile, char *lov_name,
char *mdc_name)
{
- return record_base(obd,llh,NULL,0,LCFG_MOUNTOPT,
+ return record_base(env,llh,NULL,0,LCFG_MOUNTOPT,
profile,lov_name,mdc_name,0);
}
-static int record_marker(struct obd_device *obd, struct llog_handle *llh,
+static int record_marker(const struct lu_env *env,
+ struct llog_handle *llh,
struct fs_db *fsdb, __u32 flags,
char *tgtname, char *comment)
{
lcfg = lustre_cfg_new(LCFG_MARKER, &bufs);
if (!lcfg)
return -ENOMEM;
- rc = record_lcfg(obd, llh, lcfg);
+ rc = record_lcfg(env, llh, lcfg);
lustre_cfg_free(lcfg);
return rc;
}
-static int record_start_log(struct obd_device *obd,
+static int record_start_log(const struct lu_env *env,
+ struct mgs_device *mgs,
struct llog_handle **llh, char *name)
{
static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" };
if (*llh)
GOTO(out, rc = -EBUSY);
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
if (!ctxt)
GOTO(out, rc = -ENODEV);
+ LASSERT(ctxt->loc_obd == mgs->mgs_obd);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open_create(NULL, ctxt, llh, NULL, name);
if (rc)
GOTO(out_ctxt, rc);
*llh = NULL;
}
out_ctxt:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
out:
if (rc)
RETURN(rc);
}
-static int record_end_log(struct obd_device *obd, struct llog_handle **llh)
+static int record_end_log(const struct lu_env *env, struct llog_handle **llh)
{
struct lvfs_run_ctxt saved;
+ struct obd_device *obd = (*llh)->lgh_ctxt->loc_obd;
int rc = 0;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
RETURN(rc);
}
-static int mgs_log_is_empty(struct obd_device *obd, char *name)
+static int mgs_log_is_empty(const struct lu_env *env,
+ struct mgs_device *mgs, char *name)
{
struct lvfs_run_ctxt saved;
struct llog_handle *llh;
struct llog_ctxt *ctxt;
int rc = 0;
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open(NULL, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
if (rc < 0) {
if (rc == -ENOENT)
out_close:
llog_close(NULL, llh);
out_ctxt:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
/* header is record 1 */
return (rc <= 1);
/******************** config "macros" *********************/
/* write an lcfg directly into a log (with markers) */
-static int mgs_write_log_direct(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_direct(const struct lu_env *env,
+ struct mgs_device *mgs, struct fs_db *fsdb,
char *logname, struct lustre_cfg *lcfg,
char *devname, char *comment)
{
if (!lcfg)
RETURN(-ENOMEM);
- rc = record_start_log(obd, &llh, logname);
+ rc = record_start_log(env, mgs, &llh, logname);
if (rc)
RETURN(rc);
/* FIXME These should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START, devname, comment);
+ rc = record_marker(env, llh, fsdb, CM_START, devname, comment);
- rc = record_lcfg(obd, llh, lcfg);
+ rc = record_lcfg(env, llh, lcfg);
- rc = record_marker(obd, llh, fsdb, CM_END, devname, comment);
- rc = record_end_log(obd, &llh);
+ rc = record_marker(env, llh, fsdb, CM_END, devname, comment);
+ rc = record_end_log(env, &llh);
RETURN(rc);
}
/* write the lcfg in all logs for the given fs */
-int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb,
+int mgs_write_log_direct_all(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
struct mgs_target_info *mti,
struct lustre_cfg *lcfg,
char *devname, char *comment,
int server_only)
{
- struct mgs_obd *mgs = &obd->u.mgs;
cfs_list_t dentry_list;
struct l_linux_dirent *dirent, *n;
char *fsname = mti->mti_fsname;
Actually, we should store as params (text), not llogs. Or
in a database. */
name_create(&logname, fsname, "-params");
- if (mgs_log_is_empty(obd, logname)) {
- struct llog_handle *llh = NULL;
- rc = record_start_log(obd, &llh, logname);
- record_end_log(obd, &llh);
+ if (mgs_log_is_empty(env, mgs, logname)) {
+ struct llog_handle *llh = NULL;
+ rc = record_start_log(env, mgs, &llh, logname);
+ record_end_log(env, &llh);
}
name_destroy(&logname);
if (rc)
RETURN(rc);
/* Find all the logs in the CONFIGS directory */
- rc = class_dentry_readdir(obd, mgs->mgs_configs_dir,
- mgs->mgs_vfsmnt, &dentry_list);
+ rc = class_dentry_readdir(env, mgs, &dentry_list);
if (rc) {
CERROR("Can't read %s dir\n", MOUNT_CONFIGS_DIR);
RETURN(rc);
if (strncmp(fsname, dirent->lld_name, len) == 0) {
CDEBUG(D_MGS, "Changing log %s\n", dirent->lld_name);
/* Erase any old settings of this same parameter */
- mgs_modify(obd, fsdb, mti, dirent->lld_name, devname,
- comment, CM_SKIP);
+ mgs_modify(env, mgs, fsdb, mti, dirent->lld_name,
+ devname, comment, CM_SKIP);
/* Write the new one */
if (lcfg) {
- rc = mgs_write_log_direct(obd, fsdb,
+ rc = mgs_write_log_direct(env, mgs, fsdb,
dirent->lld_name,
lcfg, devname,
comment);
struct mgs_target_info *comp_tmti;
struct mgs_target_info *comp_mti;
struct fs_db *comp_fsdb;
- struct obd_device *comp_obd;
+ struct mgs_device *comp_mgs;
+ const struct lu_env *comp_env;
};
-static int mgs_write_log_mdc_to_mdt(struct obd_device *, struct fs_db *,
- struct mgs_target_info *, char *);
-static int mgs_write_log_osc_to_lov(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_mdc_to_mdt(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
+ struct mgs_target_info *mti,
+ char *logname);
+static int mgs_write_log_osc_to_lov(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *suffix, char *lovname,
enum lustre_sec_part sec_part, int flags);
struct llog_handle *llh,
struct llog_rec_hdr *rec, void *data)
{
- struct obd_device * obd;
+ struct mgs_device *mgs;
struct mgs_target_info *mti, *tmti;
struct fs_db *fsdb;
int cfg_len = rec->lrh_len;
mti = ((struct temp_comp*)data)->comp_mti;
tmti = ((struct temp_comp*)data)->comp_tmti;
fsdb = ((struct temp_comp*)data)->comp_fsdb;
- obd = ((struct temp_comp*)data)->comp_obd;
+ mgs = ((struct temp_comp*)data)->comp_mgs;
if (rec->lrh_type != OBD_CFG_REC) {
CERROR("unhandled lrh_type: %#x\n", rec->lrh_type);
got_an_osc_or_mdc = 1;
strncpy(tmti->mti_svname, marker->cm_tgtname,
sizeof(tmti->mti_svname));
- rc = record_start_log(obd, &mdt_llh, mti->mti_svname);
- rc = record_marker(obd, mdt_llh, fsdb, CM_START,
+ rc = record_start_log(env, mgs, &mdt_llh,
+ mti->mti_svname);
+ rc = record_marker(env, mdt_llh, fsdb, CM_START,
mti->mti_svname,"add osc(copied)");
- rc = record_end_log(obd, &mdt_llh);
+ rc = record_end_log(env, &mdt_llh);
last_step = marker->cm_step;
RETURN(rc);
}
LASSERT(last_step == marker->cm_step);
last_step = -1;
got_an_osc_or_mdc = 0;
- rc = record_start_log(obd, &mdt_llh, mti->mti_svname);
- rc = record_marker(obd, mdt_llh, fsdb, CM_END,
+ rc = record_start_log(env, mgs, &mdt_llh,
+ mti->mti_svname);
+ rc = record_marker(env, mdt_llh, fsdb, CM_END,
mti->mti_svname,"add osc(copied)");
- rc = record_end_log(obd, &mdt_llh);
+ rc = record_end_log(env, &mdt_llh);
RETURN(rc);
}
if (!strncmp(marker->cm_comment,"add mdc",7) &&
strlen(mti->mti_fsname));
tmti->mti_stripe_index = index;
- mgs_write_log_mdc_to_mdt(obd, fsdb, tmti, mti->mti_svname);
+ mgs_write_log_mdc_to_mdt(env, mgs, fsdb,
+ tmti, mti->mti_svname);
memset(tmti, 0, sizeof(*tmti));
RETURN(rc);
}
}
tmti->mti_stripe_index = index;
- mgs_write_log_osc_to_lov(obd, fsdb, tmti, logname,
+ mgs_write_log_osc_to_lov(env, mgs, fsdb, tmti, logname,
mdt_index, lovname,
LUSTRE_SP_MDT, 0);
name_destroy(&logname);
/* fsdb->fsdb_mutex is already held in mgs_write_log_target*/
/* stealed from mgs_get_fsdb_from_llog*/
-static int mgs_steal_llog_for_mdt_from_client(struct obd_device *obd,
+static int mgs_steal_llog_for_mdt_from_client(const struct lu_env *env,
+ struct mgs_device *mgs,
char *client_name,
struct temp_comp* comp)
{
ENTRY;
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
OBD_ALLOC_PTR(tmti);
GOTO(out_ctxt, rc = -ENOMEM);
comp->comp_tmti = tmti;
- comp->comp_obd = obd;
+ comp->comp_mgs = mgs;
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open(NULL, ctxt, &loghandle, NULL, client_name,
LLOG_OPEN_EXISTS);
out_close:
llog_close(NULL, loghandle);
out_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
OBD_FREE_PTR(tmti);
out_ctxt:
llog_ctxt_put(ctxt);
/* lmv is the second thing for client logs */
/* copied from mgs_write_log_lov. Please refer to that. */
-static int mgs_write_log_lmv(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_lmv(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *lmvname)
{
sprintf((char*)lmvdesc->ld_uuid.uuid, "%s_UUID", lmvname);
uuid = (char *)lmvdesc->ld_uuid.uuid;
- rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, lmvname, "lmv setup");
- rc = record_attach(obd, llh, lmvname, "lmv", uuid);
- rc = record_lmv_setup(obd, llh, lmvname, lmvdesc);
- rc = record_marker(obd, llh, fsdb, CM_END, lmvname, "lmv setup");
- rc = record_end_log(obd, &llh);
+ rc = record_start_log(env, mgs, &llh, logname);
+ rc = record_marker(env, llh, fsdb, CM_START, lmvname, "lmv setup");
+ rc = record_attach(env, llh, lmvname, "lmv", uuid);
+ rc = record_lmv_setup(env, llh, lmvname, lmvdesc);
+ rc = record_marker(env, llh, fsdb, CM_END, lmvname, "lmv setup");
+ rc = record_end_log(env, &llh);
OBD_FREE_PTR(lmvdesc);
RETURN(rc);
}
/* lov is the first thing in the mdt and client logs */
-static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti,
+static int mgs_write_log_lov(const struct lu_env *env, struct mgs_device *mgs,
+ struct fs_db *fsdb, struct mgs_target_info *mti,
char *logname, char *lovname)
{
struct llog_handle *llh = NULL;
/* This should always be the first entry in a log.
rc = mgs_clear_log(obd, logname); */
- rc = record_start_log(obd, &llh, logname);
+ rc = record_start_log(env, mgs, &llh, logname);
if (rc)
GOTO(out, rc);
/* FIXME these should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START, lovname, "lov setup");
- rc = record_attach(obd, llh, lovname, "lov", uuid);
- rc = record_lov_setup(obd, llh, lovname, lovdesc);
- rc = record_marker(obd, llh, fsdb, CM_END, lovname, "lov setup");
- rc = record_end_log(obd, &llh);
+ rc = record_marker(env, llh, fsdb, CM_START, lovname, "lov setup");
+ rc = record_attach(env, llh, lovname, "lov", uuid);
+ rc = record_lov_setup(env, llh, lovname, lovdesc);
+ rc = record_marker(env, llh, fsdb, CM_END, lovname, "lov setup");
+ rc = record_end_log(env, &llh);
EXIT;
out:
}
/* add failnids to open log */
-static int mgs_write_log_failnids(struct obd_device *obd,
+static int mgs_write_log_failnids(const struct lu_env *env,
struct mgs_target_info *mti,
struct llog_handle *llh,
char *cliname)
CDEBUG(D_MGS, "add nid %s for failover uuid %s, "
"client %s\n", libcfs_nid2str(nid),
failnodeuuid, cliname);
- rc = record_add_uuid(obd, llh, nid, failnodeuuid);
+ rc = record_add_uuid(env, llh, nid, failnodeuuid);
}
if (failnodeuuid) {
- rc = record_add_conn(obd, llh, cliname, failnodeuuid);
+ rc = record_add_conn(env, llh, cliname, failnodeuuid);
name_destroy(&failnodeuuid);
failnodeuuid = NULL;
}
return rc;
}
-static int mgs_write_log_mdc_to_lmv(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_mdc_to_lmv(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *lmvname)
{
int i, rc;
ENTRY;
- if (mgs_log_is_empty(obd, logname)) {
+ if (mgs_log_is_empty(env, mgs, logname)) {
CERROR("log is empty! Logical error\n");
RETURN(-EINVAL);
}
name_create(&mdcuuid, mdcname, "_UUID");
name_create(&lmvuuid, lmvname, "_UUID");
- rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,
+ rc = record_start_log(env, mgs, &llh, logname);
+ rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname,
"add mdc");
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s for mdt\n",
libcfs_nid2str(mti->mti_nids[i]));
- rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid);
+ rc = record_add_uuid(env, llh, mti->mti_nids[i], nodeuuid);
}
- rc = record_attach(obd, llh, mdcname, LUSTRE_MDC_NAME, lmvuuid);
- rc = record_setup(obd, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
- rc = mgs_write_log_failnids(obd, mti, llh, mdcname);
+ rc = record_attach(env, llh, mdcname, LUSTRE_MDC_NAME, lmvuuid);
+ rc = record_setup(env, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
+ rc = mgs_write_log_failnids(env, mti, llh, mdcname);
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
- rc = record_mdc_add(obd, llh, lmvname, mdcuuid, mti->mti_uuid,
+ rc = record_mdc_add(env, llh, lmvname, mdcuuid, mti->mti_uuid,
index, "1");
- rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname,
+ rc = record_marker(env, llh, fsdb, CM_END, mti->mti_svname,
"add mdc");
- rc = record_end_log(obd, &llh);
+ rc = record_end_log(env, &llh);
name_destroy(&lmvuuid);
name_destroy(&mdcuuid);
}
/* add new mdc to already existent MDS */
-static int mgs_write_log_mdc_to_mdt(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti, char *logname)
+static int mgs_write_log_mdc_to_mdt(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
+ struct mgs_target_info *mti,
+ char *logname)
{
struct llog_handle *llh = NULL;
char *nodeuuid, *mdcname, *mdcuuid, *mdtuuid;
int i, rc;
ENTRY;
- if (mgs_log_is_empty(obd, logname)) {
+ if (mgs_log_is_empty(env, mgs, logname)) {
CERROR("log is empty! Logical error\n");
RETURN (-EINVAL);
}
name_create(&mdcuuid, mdcname, "_UUID");
name_create(&mdtuuid, logname, "_UUID");
- rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname, "add mdc");
+ rc = record_start_log(env, mgs, &llh, logname);
+ rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname, "add mdc");
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s for mdt\n",
libcfs_nid2str(mti->mti_nids[i]));
- rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid);
+ rc = record_add_uuid(env, llh, mti->mti_nids[i], nodeuuid);
}
- rc = record_attach(obd, llh, mdcname, LUSTRE_MDC_NAME, mdcuuid);
- rc = record_setup(obd, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
- rc = mgs_write_log_failnids(obd, mti, llh, mdcname);
+ rc = record_attach(env, llh, mdcname, LUSTRE_MDC_NAME, mdcuuid);
+ rc = record_setup(env, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
+ rc = mgs_write_log_failnids(env, mti, llh, mdcname);
snprintf(index, sizeof(index), "%d", idx);
- rc = record_mdc_add(obd, llh, logname, mdcuuid, mti->mti_uuid,
+ rc = record_mdc_add(env, llh, logname, mdcuuid, mti->mti_uuid,
index, "1");
- rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc");
- rc = record_end_log(obd, &llh);
+ rc = record_marker(env, llh, fsdb, CM_END, mti->mti_svname, "add mdc");
+ rc = record_end_log(env, &llh);
name_destroy(&mdcuuid);
name_destroy(&mdcname);
RETURN(rc);
}
-static int mgs_write_log_mdt0(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti)
+static int mgs_write_log_mdt0(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
+ struct mgs_target_info *mti)
{
char *log = mti->mti_svname;
struct llog_handle *llh = NULL;
failout = (strncmp(ptr, "failout", 7) == 0);
name_create(&lovname, log, "-mdtlov");
- if (mgs_log_is_empty(obd, log))
- rc = mgs_write_log_lov(obd, fsdb, mti, log, lovname);
+ if (mgs_log_is_empty(env, mgs, log))
+ rc = mgs_write_log_lov(env, mgs, fsdb, mti, log, lovname);
sprintf(uuid, "%s_UUID", log);
sprintf(mdt_index, "%d", mti->mti_stripe_index);
/* add MDT itself */
- rc = record_start_log(obd, &llh, log);
+ rc = record_start_log(env, mgs, &llh, log);
if (rc)
GOTO(out, rc);
/* FIXME this whole fn should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START, log, "add mdt");
- rc = record_attach(obd, llh, log, LUSTRE_MDT_NAME, uuid);
- rc = record_mount_opt(obd, llh, log, lovname, NULL);
- rc = record_setup(obd, llh, log, uuid, mdt_index, lovname,
+ rc = record_marker(env, llh, fsdb, CM_START, log, "add mdt");
+ rc = record_attach(env, llh, log, LUSTRE_MDT_NAME, uuid);
+ rc = record_mount_opt(env, llh, log, lovname, NULL);
+ rc = record_setup(env, llh, log, uuid, mdt_index, lovname,
failout ? "n" : "f");
- rc = record_marker(obd, llh, fsdb, CM_END, log, "add mdt");
- rc = record_end_log(obd, &llh);
+ rc = record_marker(env, llh, fsdb, CM_END, log, "add mdt");
+ rc = record_end_log(env, &llh);
out:
name_destroy(&lovname);
OBD_FREE(uuid, sizeof(struct obd_uuid));
}
/* envelope method for all layers log */
-static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti)
+static int mgs_write_log_mdt(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
+ struct mgs_target_info *mti)
{
struct llog_handle *llh = NULL;
char *cliname;
}
/* add mdt */
- rc = mgs_write_log_mdt0(obd, fsdb, mti);
+ rc = mgs_write_log_mdt0(env, mgs, fsdb, mti);
/* Append the mdt info to the client log */
name_create(&cliname, mti->mti_fsname, "-client");
- if (mgs_log_is_empty(obd, cliname)) {
+ if (mgs_log_is_empty(env, mgs, cliname)) {
/* Start client log */
- rc = mgs_write_log_lov(obd, fsdb, mti, cliname,
+ rc = mgs_write_log_lov(env, mgs, fsdb, mti, cliname,
fsdb->fsdb_clilov);
- rc = mgs_write_log_lmv(obd, fsdb, mti, cliname,
+ rc = mgs_write_log_lmv(env, mgs, fsdb, mti, cliname,
fsdb->fsdb_clilmv);
}
comp.comp_mti = mti;
comp.comp_fsdb = fsdb;
- rc = mgs_steal_llog_for_mdt_from_client(obd, cliname,
+ rc = mgs_steal_llog_for_mdt_from_client(env, mgs, cliname,
&comp);
- rc = mgs_write_log_mdc_to_lmv(obd, fsdb, mti, cliname,
+ rc = mgs_write_log_mdc_to_lmv(env, mgs, fsdb, mti, cliname,
fsdb->fsdb_clilmv);
/* add mountopts */
- rc = record_start_log(obd, &llh, cliname);
+ rc = record_start_log(env, mgs, &llh, cliname);
if (rc)
GOTO(out, rc);
- rc = record_marker(obd, llh, fsdb, CM_START, cliname,
+ rc = record_marker(env, llh, fsdb, CM_START, cliname,
"mount opts");
- rc = record_mount_opt(obd, llh, cliname, fsdb->fsdb_clilov,
+ rc = record_mount_opt(env, llh, cliname, fsdb->fsdb_clilov,
fsdb->fsdb_clilmv);
- rc = record_marker(obd, llh, fsdb, CM_END, cliname,
+ rc = record_marker(env, llh, fsdb, CM_END, cliname,
"mount opts");
}
- rc = record_end_log(obd, &llh);
+ rc = record_end_log(env, &llh);
out:
name_destroy(&cliname);
if (i != mti->mti_stripe_index &&
cfs_test_bit(i, fsdb->fsdb_mdt_index_map)) {
name_create_mdt(&mdtname, mti->mti_fsname, i);
- rc = mgs_write_log_mdc_to_mdt(obd, fsdb, mti, mdtname);
+ rc = mgs_write_log_mdc_to_mdt(env, mgs, fsdb,
+ mti, mdtname);
name_destroy(&mdtname);
}
}
}
/* Add the ost info to the client/mdt lov */
-static int mgs_write_log_osc_to_lov(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_osc_to_lov(const struct lu_env *env,
+ struct mgs_device *mgs, struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *suffix, char *lovname,
enum lustre_sec_part sec_part, int flags)
CDEBUG(D_INFO, "adding osc for %s to log %s\n",
mti->mti_svname, logname);
- if (mgs_log_is_empty(obd, logname)) {
+ if (mgs_log_is_empty(env, mgs, logname)) {
CERROR("log is empty! Logical error\n");
RETURN (-EINVAL);
}
#08 L lov_modify_tgts add 0:lov1 1:ost1_UUID 2(index):0 3(gen):1
*/
- rc = record_start_log(obd, &llh, logname);
+ rc = record_start_log(env, mgs, &llh, logname);
if (rc)
GOTO(out, rc);
/* FIXME these should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START | flags, mti->mti_svname,
+ rc = record_marker(env, llh, fsdb, CM_START | flags, mti->mti_svname,
"add osc");
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s\n", libcfs_nid2str(mti->mti_nids[i]));
- rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid);
+ rc = record_add_uuid(env, llh, mti->mti_nids[i], nodeuuid);
}
- rc = record_attach(obd, llh, oscname, LUSTRE_OSC_NAME, lovuuid);
- rc = record_setup(obd, llh, oscname, mti->mti_uuid, nodeuuid, 0, 0);
- rc = mgs_write_log_failnids(obd, mti, llh, oscname);
+ rc = record_attach(env, llh, oscname, LUSTRE_OSC_NAME, lovuuid);
+ rc = record_setup(env, llh, oscname, mti->mti_uuid, nodeuuid, 0, 0);
+ rc = mgs_write_log_failnids(env, mti, llh, oscname);
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
- rc = record_lov_add(obd, llh, lovname, mti->mti_uuid, index, "1");
- rc = record_marker(obd, llh, fsdb, CM_END | flags, mti->mti_svname,
+ rc = record_lov_add(env, llh, lovname, mti->mti_uuid, index, "1");
+ rc = record_marker(env, llh, fsdb, CM_END | flags, mti->mti_svname,
"add osc");
- rc = record_end_log(obd, &llh);
+ rc = record_end_log(env, &llh);
out:
name_destroy(&lovuuid);
name_destroy(&oscuuid);
RETURN(rc);
}
-static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_ost(const struct lu_env *env,
+ struct mgs_device *mgs, struct fs_db *fsdb,
struct mgs_target_info *mti)
{
struct llog_handle *llh = NULL;
/* If the ost log already exists, that means that someone reformatted
the ost and it called target_add again. */
- if (!mgs_log_is_empty(obd, mti->mti_svname)) {
+ if (!mgs_log_is_empty(env, mgs, mti->mti_svname)) {
LCONSOLE_ERROR_MSG(0x141, "The config log for %s already "
"exists, yet the server claims it never "
"registered. It may have been reformatted, "
*/
if (class_find_param(ptr, PARAM_FAILMODE, &ptr) == 0)
failout = (strncmp(ptr, "failout", 7) == 0);
- rc = record_start_log(obd, &llh, mti->mti_svname);
+ rc = record_start_log(env, mgs, &llh, mti->mti_svname);
if (rc)
RETURN(rc);
/* FIXME these should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add ost");
+ rc = record_marker(env, llh, fsdb, CM_START, mti->mti_svname,"add ost");
if (*mti->mti_uuid == '\0')
snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
"%s_UUID", mti->mti_svname);
- rc = record_attach(obd, llh, mti->mti_svname,
+ rc = record_attach(env, llh, mti->mti_svname,
"obdfilter"/*LUSTRE_OST_NAME*/, mti->mti_uuid);
- rc = record_setup(obd, llh, mti->mti_svname,
+ rc = record_setup(env, llh, mti->mti_svname,
"dev"/*ignored*/, "type"/*ignored*/,
failout ? "n" : "f", 0/*options*/);
- rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add ost");
- rc = record_end_log(obd, &llh);
+ rc = record_marker(env, llh, fsdb, CM_END, mti->mti_svname, "add ost");
+ rc = record_end_log(env, &llh);
/* We also have to update the other logs where this osc is part of
the lov */
name_create_mdt_and_lov(&logname, &lovname, fsdb, i);
sprintf(mdt_index, "-MDT%04x", i);
- mgs_write_log_osc_to_lov(obd, fsdb, mti, logname,
+ mgs_write_log_osc_to_lov(env, mgs, fsdb, mti, logname,
mdt_index, lovname,
LUSTRE_SP_MDT, flags);
name_destroy(&logname);
/* Append ost info to the client log */
name_create(&logname, mti->mti_fsname, "-client");
- if (mgs_log_is_empty(obd, logname)) {
+ if (mgs_log_is_empty(env, mgs, logname)) {
/* Start client log */
- rc = mgs_write_log_lov(obd, fsdb, mti, logname,
+ rc = mgs_write_log_lov(env, mgs, fsdb, mti, logname,
fsdb->fsdb_clilov);
- rc = mgs_write_log_lmv(obd, fsdb, mti, logname,
+ rc = mgs_write_log_lmv(env, mgs, fsdb, mti, logname,
fsdb->fsdb_clilmv);
}
- mgs_write_log_osc_to_lov(obd, fsdb, mti, logname, "",
+ mgs_write_log_osc_to_lov(env, mgs, fsdb, mti, logname, "",
fsdb->fsdb_clilov, LUSTRE_SP_CLI, flags);
name_destroy(&logname);
RETURN(rc);
return 0;
}
-static int mgs_write_log_failnid_internal(struct obd_device *obd,
+static int mgs_write_log_failnid_internal(const struct lu_env *env,
+ struct mgs_device *mgs,
struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *cliname)
if (mgs_param_empty(mti->mti_params)) {
/* Remove _all_ failnids */
- rc = mgs_modify(obd, fsdb, mti, logname,
+ rc = mgs_modify(env, mgs, fsdb, mti, logname,
mti->mti_svname, "add failnid", CM_SKIP);
return rc;
}
/* Otherwise failover nids are additive */
- rc = record_start_log(obd, &llh, logname);
+ rc = record_start_log(env, mgs, &llh, logname);
if (!rc) {
/* FIXME this should be a single journal transaction */
- rc = record_marker(obd, llh, fsdb, CM_START,
+ rc = record_marker(env, llh, fsdb, CM_START,
mti->mti_svname, "add failnid");
- rc = mgs_write_log_failnids(obd, mti, llh, cliname);
- rc = record_marker(obd, llh, fsdb, CM_END,
+ rc = mgs_write_log_failnids(env, mti, llh, cliname);
+ rc = record_marker(env, llh, fsdb, CM_END,
mti->mti_svname, "add failnid");
- rc = record_end_log(obd, &llh);
+ rc = record_end_log(env, &llh);
}
return rc;
The mdc/osc must have been added to logs first */
/* tcp nids must be in dotted-quad ascii -
we can't resolve hostnames from the kernel. */
-static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_add_failnid(const struct lu_env *env,
+ struct mgs_device *mgs,
+ struct fs_db *fsdb,
struct mgs_target_info *mti)
{
char *logname, *cliname;
* an "add uuid" stanza */
/* Verify that we know about this target */
- if (mgs_log_is_empty(obd, mti->mti_svname)) {
+ if (mgs_log_is_empty(env, mgs, mti->mti_svname)) {
LCONSOLE_ERROR_MSG(0x142, "The target %s has not registered "
"yet. It must be started before failnids "
"can be added.\n", mti->mti_svname);
/* Add failover nids to the client log */
name_create(&logname, mti->mti_fsname, "-client");
- rc = mgs_write_log_failnid_internal(obd, fsdb, mti, logname, cliname);
+ rc = mgs_write_log_failnid_internal(env, mgs, fsdb,mti,logname,cliname);
name_destroy(&logname);
name_destroy(&cliname);
continue;
name_create_mdt(&logname, mti->mti_fsname, i);
name_create_mdt_osc(&cliname, mti->mti_svname, fsdb, i);
- rc = mgs_write_log_failnid_internal(obd, fsdb, mti,
+ rc = mgs_write_log_failnid_internal(env, mgs, fsdb, mti,
logname, cliname);
name_destroy(&cliname);
name_destroy(&logname);
RETURN(rc);
}
-static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_wlp_lcfg(const struct lu_env *env,
+ struct mgs_device *mgs, struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, struct lustre_cfg_bufs *bufs,
char *tgtname, char *ptr)
if ((tmp = strchr(comment, '=')))
*tmp = 0;
/* FIXME we should skip settings that are the same as old values */
- rc = mgs_modify(obd, fsdb, mti, logname, tgtname, comment, CM_SKIP);
+ rc = mgs_modify(env, mgs, fsdb, mti, logname, tgtname, comment,CM_SKIP);
del = mgs_param_empty(ptr);
LCONSOLE_INFO("%sing parameter %s.%s in log %s\n", del ? "Disabl" : rc ?
lcfg = lustre_cfg_new(LCFG_PARAM, bufs);
if (!lcfg)
return -ENOMEM;
- rc = mgs_write_log_direct(obd, fsdb, logname, lcfg, tgtname, comment);
+ rc = mgs_write_log_direct(env, mgs, fsdb, logname,lcfg,tgtname,comment);
lustre_cfg_free(lcfg);
return rc;
}
/* write global variable settings into log */
-static int mgs_write_log_sys(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti, char *sys, char *ptr)
+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 lustre_cfg *lcfg;
sep = *ptr;
*ptr = '\0';
/* modify all servers and clients */
- rc = mgs_write_log_direct_all(obd, fsdb, mti,
+ rc = mgs_write_log_direct_all(env, mgs, fsdb, mti,
*tmp == '\0' ? NULL : lcfg,
mti->mti_fsname, sys, 0);
if (rc == 0 && *tmp != '\0') {
}
/* write quota settings into log */
-static int mgs_write_log_quota(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti, char *quota,
- char *ptr)
+static int mgs_write_log_quota(const struct lu_env *env, struct mgs_device *mgs,
+ struct fs_db *fsdb, struct mgs_target_info *mti,
+ char *quota, char *ptr)
{
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
* config logs, it should be moved to a separate config
* log once we cleanup the config log for global param. */
/* modify all servers */
- rc = mgs_write_log_direct_all(obd, fsdb, mti,
+ rc = mgs_write_log_direct_all(env, mgs, fsdb, mti,
*tmp == '\0' ? NULL : lcfg,
mti->mti_fsname, quota, 1);
*ptr = sep;
return rc;
}
-static int mgs_srpc_set_param_disk(struct obd_device *obd,
+static int mgs_srpc_set_param_disk(const struct lu_env *env,
+ struct mgs_device *mgs,
struct fs_db *fsdb,
struct mgs_target_info *mti,
char *param)
if (rc)
GOTO(out_lcfg, rc);
- if (mgs_log_is_empty(obd, logname)) {
- rc = record_start_log(obd, &llh, logname);
- record_end_log(obd, &llh);
+ if (mgs_log_is_empty(env, mgs, logname)) {
+ rc = record_start_log(env, mgs, &llh, logname);
+ record_end_log(env, &llh);
if (rc)
GOTO(out, rc);
}
/* obsolete old one */
- mgs_modify(obd, fsdb, mti, logname, mti->mti_svname, comment, CM_SKIP);
+ mgs_modify(env, mgs, fsdb, mti, logname, mti->mti_svname,
+ comment, CM_SKIP);
/* write the new one */
- rc = mgs_write_log_direct(obd, fsdb, logname, lcfg,
+ rc = mgs_write_log_direct(env, mgs, fsdb, logname, lcfg,
mti->mti_svname, comment);
if (rc)
CERROR("err %d writing log %s\n", rc, logname);
RETURN(rc);
}
-static int mgs_srpc_set_param(struct obd_device *obd,
+static int mgs_srpc_set_param(const struct lu_env *env,
+ struct mgs_device *mgs,
struct fs_db *fsdb,
struct mgs_target_info *mti,
char *param)
goto out_free;
/* previous steps guaranteed the syntax is correct */
- rc = mgs_srpc_set_param_disk(obd, fsdb, mti, copy);
+ rc = mgs_srpc_set_param_disk(env, mgs, fsdb, mti, copy);
if (rc)
goto out_free;
* for mgs rules, make them effective immediately.
*/
LASSERT(fsdb->fsdb_srpc_tgt == NULL);
- sptlrpc_target_update_exp_flavor(obd, &fsdb->fsdb_srpc_gen);
+ sptlrpc_target_update_exp_flavor(mgs->mgs_obd,
+ &fsdb->fsdb_srpc_gen);
}
out_free:
RETURN(0);
}
-int mgs_get_fsdb_srpc_from_llog(struct obd_device *obd,
+int mgs_get_fsdb_srpc_from_llog(const struct lu_env *env,
+ struct mgs_device *mgs,
struct fs_db *fsdb)
{
struct llog_handle *llh = NULL;
if (rc)
RETURN(rc);
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- if (mgs_log_is_empty(obd, logname))
+ if (mgs_log_is_empty(env, mgs, logname))
GOTO(out, rc = 0);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
rc = llog_open(NULL, ctxt, &llh, NULL, logname,
LLOG_OPEN_EXISTS);
out_close:
llog_close(NULL, llh);
out_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
out:
llog_ctxt_put(ctxt);
name_destroy(&logname);
* A parameter with null value ("<param>='\0'") means to erase it out of
* the logs.
*/
-static int mgs_write_log_param(struct obd_device *obd, struct fs_db *fsdb,
+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;
}
if (class_match_param(ptr, PARAM_SRPC, NULL) == 0) {
- rc = mgs_srpc_set_param(obd, fsdb, mti, ptr);
+ rc = mgs_srpc_set_param(env, mgs, fsdb, mti, ptr);
GOTO(end, rc);
}
targets in mgs_write_log_target */
if (mti->mti_flags & LDD_F_PARAM) {
CDEBUG(D_MGS, "Adding failnode\n");
- rc = mgs_write_log_add_failnid(obd, fsdb, mti);
+ rc = mgs_write_log_add_failnid(env, mgs, fsdb, mti);
}
GOTO(end, rc);
}
if (class_match_param(ptr, PARAM_SYS, &tmp) == 0) {
- rc = mgs_write_log_sys(obd, fsdb, mti, ptr, tmp);
+ rc = mgs_write_log_sys(env, mgs, fsdb, mti, ptr, tmp);
GOTO(end, rc);
}
if (class_match_param(ptr, PARAM_QUOTA, &tmp) == 0) {
- rc = mgs_write_log_quota(obd, fsdb, mti, ptr, tmp);
+ rc = mgs_write_log_quota(env, mgs, fsdb, mti, ptr, tmp);
GOTO(end, rc);
}
flag ? "de": "re", mti->mti_svname);
/* Modify clilov */
name_create(&logname, mti->mti_fsname, "-client");
- rc = mgs_modify(obd, fsdb, mti, logname,
+ rc = mgs_modify(env, mgs, fsdb, mti, logname,
mti->mti_svname, "add osc", flag);
name_destroy(&logname);
if (rc)
if (!cfs_test_bit(i, fsdb->fsdb_mdt_index_map))
continue;
name_create_mdt(&logname, mti->mti_fsname, i);
- rc = mgs_modify(obd, fsdb, mti, logname,
+ rc = mgs_modify(env, mgs, fsdb, mti, logname,
mti->mti_svname, "add osc", flag);
name_destroy(&logname);
if (rc)
}
/* Modify mdtlov */
- if (mgs_log_is_empty(obd, mti->mti_svname))
+ if (mgs_log_is_empty(env, mgs, mti->mti_svname))
GOTO(end, rc = -ENODEV);
name_create_mdt_and_lov(&logname, &mdtlovname, fsdb,
mti->mti_stripe_index);
- rc = mgs_wlp_lcfg(obd, fsdb, mti, mti->mti_svname,
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, mti->mti_svname,
&bufs, mdtlovname, ptr);
name_destroy(&logname);
name_destroy(&mdtlovname);
/* Modify clilov */
name_create(&logname, mti->mti_fsname, "-client");
- rc = mgs_wlp_lcfg(obd, fsdb, mti, logname, &bufs,
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &bufs,
fsdb->fsdb_clilov, ptr);
name_destroy(&logname);
GOTO(end, rc);
/* Modify client */
name_create(&logname, mti->mti_fsname, "-client");
- rc = mgs_wlp_lcfg(obd, fsdb, mti, logname, &bufs,
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, logname, &bufs,
cname, ptr);
/* osc params affect the MDT as well */
fsdb, i);
name_destroy(&logname);
name_create_mdt(&logname, mti->mti_fsname, i);
- if (!mgs_log_is_empty(obd, logname))
- rc = mgs_wlp_lcfg(obd, fsdb,mti,logname,
- &bufs, cname, ptr);
+ if (!mgs_log_is_empty(env, mgs, logname))
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
+ logname, &bufs, cname,
+ ptr);
if (rc)
break;
}
fsdb->fsdb_mdt_index_map))
continue;
name_create_mdt(&logname, mti->mti_fsname, i);
- rc = mgs_wlp_lcfg(obd, fsdb, mti,
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
logname, &bufs,
logname, ptr);
name_destroy(&logname);
goto active_err;
}
} else {
- rc = mgs_wlp_lcfg(obd, fsdb, mti,
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti,
mti->mti_svname, &bufs,
mti->mti_svname, ptr);
if (rc)
if ((class_match_param(ptr, PARAM_MDD, NULL) == 0) ||
(class_match_param(ptr, PARAM_OST, NULL) == 0)) {
CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4);
- if (mgs_log_is_empty(obd, mti->mti_svname))
+ if (mgs_log_is_empty(env, mgs, mti->mti_svname))
GOTO(end, rc = -ENODEV);
- rc = mgs_wlp_lcfg(obd, fsdb, mti, mti->mti_svname,
+ rc = mgs_wlp_lcfg(env, mgs, fsdb, mti, mti->mti_svname,
&bufs, mti->mti_svname, ptr);
GOTO(end, rc);
}
}
/* Not implementing automatic failover nid addition at this time. */
-int mgs_check_failnid(struct obd_device *obd, struct mgs_target_info *mti)
+int mgs_check_failnid(const struct lu_env *env, struct mgs_device *mgs,
+ struct mgs_target_info *mti)
{
#if 0
struct fs_db *fsdb;
return 0;
}
-int mgs_write_log_target(struct obd_device *obd,
+int mgs_write_log_target(const struct lu_env *env,
+ struct mgs_device *mgs,
struct mgs_target_info *mti,
struct fs_db *fsdb)
{
ENTRY;
/* set/check the new target index */
- rc = mgs_set_index(obd, mti);
+ rc = mgs_set_index(env, mgs, mti);
if (rc < 0) {
CERROR("Can't get index (%d)\n", rc);
RETURN(rc);
(LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
/* Generate a log from scratch */
if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
- rc = mgs_write_log_mdt(obd, fsdb, mti);
+ rc = mgs_write_log_mdt(env, mgs, fsdb, mti);
} else if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
- rc = mgs_write_log_ost(obd, fsdb, mti);
+ rc = mgs_write_log_ost(env, mgs, fsdb, mti);
} else {
CERROR("Unknown target type %#x, can't create log for "
"%s\n", mti->mti_flags, mti->mti_svname);
}
CDEBUG(D_MGS, "remaining string: '%s', param: '%s'\n",
params, buf);
- rc = mgs_write_log_param(obd, fsdb, mti, buf);
+ rc = mgs_write_log_param(env, mgs, fsdb, mti, buf);
if (rc)
break;
}
/* COMPAT_146 */
/* verify that we can handle the old config logs */
-int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti,
- struct fs_db *fsdb)
+int mgs_upgrade_sv_14(const struct lu_env *env, struct mgs_device *mgs,
+ struct mgs_target_info *mti, struct fs_db *fsdb)
{
int rc = 0;
ENTRY;
}
if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
- if (mgs_log_is_empty(obd, mti->mti_svname)) {
+ if (mgs_log_is_empty(env, mgs, mti->mti_svname)) {
LCONSOLE_ERROR_MSG(0x14b, "The old MDT log %s is "
"missing. Was tunefs.lustre "
"successful?\n",
}
/* end COMPAT_146 */
-int mgs_erase_log(struct obd_device *obd, char *name)
+int mgs_erase_log(const struct lu_env *env, struct mgs_device *mgs, char *name)
{
struct lvfs_run_ctxt saved;
struct llog_ctxt *ctxt;
int rc = 0;
+ struct obd_device *obd = mgs->mgs_obd;
ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
if (ctxt == NULL) {
}
/* erase all logs for the given fs */
-int mgs_erase_logs(struct obd_device *obd, char *fsname)
+int mgs_erase_logs(const struct lu_env *env, struct mgs_device *mgs, char *fsname)
{
- struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
cfs_list_t dentry_list;
struct l_linux_dirent *dirent, *n;
ENTRY;
/* Find all the logs in the CONFIGS directory */
- rc = class_dentry_readdir(obd, mgs->mgs_configs_dir,
- mgs->mgs_vfsmnt, &dentry_list);
+ rc = class_dentry_readdir(env, mgs, &dentry_list);
if (rc) {
CERROR("Can't read %s dir\n", MOUNT_CONFIGS_DIR);
RETURN(rc);
cfs_mutex_lock(&mgs->mgs_mutex);
/* Delete the fs db */
- fsdb = mgs_find_fsdb(obd, fsname);
+ fsdb = mgs_find_fsdb(mgs, fsname);
if (fsdb)
- mgs_free_fsdb(obd, fsdb);
+ mgs_free_fsdb(mgs, fsdb);
cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
cfs_list_del(&dirent->lld_list);
(strncmp(fsname, dirent->lld_name, len) == 0)) {
CDEBUG(D_MGS, "Removing log %s\n",
dirent->lld_name);
- mgs_erase_log(obd, dirent->lld_name);
+ mgs_erase_log(env, mgs, dirent->lld_name);
}
}
OBD_FREE(dirent, sizeof(*dirent));
* \param lcfg buf0 may contain the device (testfs-MDT0000) name
* buf1 contains the single parameter
*/
-int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
+int mgs_setparam(const struct lu_env *env, struct mgs_device *mgs,
+ struct lustre_cfg *lcfg, char *fsname)
{
struct fs_db *fsdb;
struct mgs_target_info *mti;
fsname[MTI_NAME_MAXLEN - 1] = 0;
CDEBUG(D_MGS, "setparam fs='%s' device='%s'\n", fsname, devname);
- rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
+ rc = mgs_find_or_make_fsdb(env, mgs, fsname, &fsdb);
if (rc)
RETURN(rc);
if (!cfs_test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags) &&
cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) {
CERROR("No filesystem targets for %s. cfg_device from lctl "
"is '%s'\n", fsname, devname);
- mgs_free_fsdb(obd, fsdb);
+ mgs_free_fsdb(mgs, fsdb);
RETURN(-EINVAL);
}
mti->mti_flags = rc | LDD_F_PARAM;
cfs_mutex_lock(&fsdb->fsdb_mutex);
- rc = mgs_write_log_param(obd, fsdb, mti, mti->mti_params);
+ rc = mgs_write_log_param(env, mgs, fsdb, mti, mti->mti_params);
cfs_mutex_unlock(&fsdb->fsdb_mutex);
/*
* so we don't really need to hold the lock while we're
* writing (above).
*/
- mgs_revoke_lock(obd, fsdb, CONFIG_T_CONFIG);
+ mgs_revoke_lock(mgs, fsdb, CONFIG_T_CONFIG);
out:
OBD_FREE_PTR(mti);
RETURN(rc);
}
-static int mgs_write_log_pool(struct obd_device *obd, char *logname,
+static int mgs_write_log_pool(const struct lu_env *env,
+ struct mgs_device *mgs, char *logname,
struct fs_db *fsdb, char *lovname,
enum lcfg_command_type cmd,
char *poolname, char *fsname,
struct llog_handle *llh = NULL;
int rc;
- rc = record_start_log(obd, &llh, logname);
+ rc = record_start_log(env, mgs, &llh, logname);
if (rc)
return rc;
- rc = record_marker(obd, llh, fsdb, CM_START, lovname, comment);
- record_base(obd, llh, lovname, 0, cmd, poolname, fsname, ostname, 0);
- rc = record_marker(obd, llh, fsdb, CM_END, lovname, comment);
- rc = record_end_log(obd, &llh);
+ rc = record_marker(env, llh, fsdb, CM_START, lovname, comment);
+ record_base(env, llh, lovname, 0, cmd, poolname, fsname, ostname, 0);
+ rc = record_marker(env, llh, fsdb, CM_END, lovname, comment);
+ rc = record_end_log(env, &llh);
return rc;
}
-int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
- char *fsname, char *poolname, char *ostname)
+int mgs_pool_cmd(const struct lu_env *env, struct mgs_device *mgs,
+ enum lcfg_command_type cmd, char *fsname,
+ char *poolname, char *ostname)
{
struct fs_db *fsdb;
char *lovname;
int rc, i;
ENTRY;
- rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
+ rc = mgs_find_or_make_fsdb(env, mgs, fsname, &fsdb);
if (rc) {
CERROR("Can't get db for %s\n", fsname);
RETURN(rc);
}
if (cfs_test_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags)) {
CERROR("%s is not defined\n", fsname);
- mgs_free_fsdb(obd, fsdb);
+ mgs_free_fsdb(mgs, fsdb);
RETURN(-EINVAL);
}
GOTO(out, rc = -ENOMEM);
switch(cmd) {
- case LCFG_POOL_NEW: {
+ case LCFG_POOL_NEW:
sprintf(label,
"new %s.%s", fsname, poolname);
break;
- }
- case LCFG_POOL_ADD: {
+ case LCFG_POOL_ADD:
sprintf(label,
"add %s.%s.%s", fsname, poolname, ostname);
break;
- }
- case LCFG_POOL_REM: {
+ case LCFG_POOL_REM:
OBD_ALLOC(canceled_label, label_sz);
if (canceled_label == NULL)
GOTO(out, rc = -ENOMEM);
sprintf(canceled_label,
"add %s.%s.%s", fsname, poolname, ostname);
break;
- }
- case LCFG_POOL_DEL: {
+ case LCFG_POOL_DEL:
OBD_ALLOC(canceled_label, label_sz);
if (canceled_label == NULL)
GOTO(out, rc = -ENOMEM);
sprintf(canceled_label,
"new %s.%s", fsname, poolname);
break;
- }
- default: {
+ default:
break;
}
- }
cfs_mutex_lock(&fsdb->fsdb_mutex);
if (canceled_label != NULL) {
strcpy(mti->mti_svname, "lov pool");
- mgs_modify(obd, fsdb, mti, logname, lovname,
- canceled_label, CM_SKIP);
+ mgs_modify(env, mgs, fsdb, mti, logname,
+ lovname, canceled_label,
+ CM_SKIP);
}
- mgs_write_log_pool(obd, logname, fsdb, lovname,
+ mgs_write_log_pool(env, mgs, logname, fsdb, lovname,
cmd, fsname, poolname, ostname,
label);
name_destroy(&logname);
name_create(&logname, fsname, "-client");
if (canceled_label != NULL)
- mgs_modify(obd, fsdb, mti, logname, fsdb->fsdb_clilov,
+ mgs_modify(env, mgs, fsdb, mti, logname, fsdb->fsdb_clilov,
canceled_label, CM_SKIP);
- mgs_write_log_pool(obd, logname, fsdb, fsdb->fsdb_clilov,
+ mgs_write_log_pool(env, mgs, logname, fsdb, fsdb->fsdb_clilov,
cmd, fsname, poolname, ostname, label);
name_destroy(&logname);
cfs_mutex_unlock(&fsdb->fsdb_mutex);
/* request for update */
- mgs_revoke_lock(obd, fsdb, CONFIG_T_CONFIG);
+ mgs_revoke_lock(mgs, fsdb, CONFIG_T_CONFIG);
EXIT;
out: