- llog over OSD in MGS. Switch llog_test to work over OSD too.
- local_oid_store_init() don't create names for llog because all
llogs have names in O/d/n
- Enable all llog tests functionality
Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Change-Id: I60cc5ec7094a2640d7fc0a0d87519c56b1383557
Reviewed-on: http://review.whamcloud.com/4104
Tested-by: Hudson
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
int cfg_last_idx; /* for partial llog processing */
int cfg_flags;
};
-int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg);
-int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg);
+int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
+ char *name, struct config_llog_instance *cfg);
+int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
+ char *name, struct config_llog_instance *cfg);
enum {
CONFIG_T_CONFIG = 0,
ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
cfg->cfg_flags |= CFG_F_COMPAT146;
- rc = class_config_parse_llog(ctxt, profile, cfg);
+ rc = class_config_parse_llog(NULL, ctxt, profile, cfg);
llog_ctxt_put(ctxt);
if (rc) {
CERROR("class_config_parse_llog failed: rc = %d\n", rc);
void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
struct lvfs_ucred *uc)
{
+ /* if there is underlaying dt_device then push_ctxt is not needed */
+ if (new_ctx->dt != NULL)
+ return;
+
//ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n");
ASSERT_CTXT_MAGIC(new_ctx->magic);
OBD_SET_CTXT_MAGIC(save);
void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
struct lvfs_ucred *uc)
{
+ /* if there is underlaying dt_device then pop_ctxt is not needed */
+ if (new_ctx->dt != NULL)
+ return;
+
ASSERT_CTXT_MAGIC(saved->magic);
ASSERT_KERNEL_CTXT("popping non-kernel context!\n");
GOTO(out, rc);
case OBD_IOC_PARSE: {
ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
- rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL);
+ rc = class_config_parse_llog(NULL, ctxt, data->ioc_inlbuf1,
+ NULL);
llog_ctxt_put(ctxt);
GOTO(out, rc);
}
/* logname and instance info should be the same, so use our
copy of the instance for the update. The cfg_last_idx will
be updated here. */
- rc = class_config_parse_llog(ctxt, cld->cld_logname, &cld->cld_cfg);
+ rc = class_config_parse_llog(NULL, ctxt, cld->cld_logname,
+ &cld->cld_cfg);
EXIT;
out_pop:
#define DEBUG_SUBSYSTEM S_MGS
-#include <linux/module.h>
-#include <linux/kmod.h>
-#include <linux/version.h>
-#include <linux/sched.h>
-#include <linux/mount.h>
-#include <obd_class.h>
-#include <obd_support.h>
-#include <lustre_disk.h>
-#include <lustre_lib.h>
-#include <lustre_fsfilt.h>
-#include <libcfs/list.h>
#include <lustre_fid.h>
#include "mgs_internal.h"
return 0;
}
-/* Same as mds_lvfs_fid2dentry */
-/* Look up an entry by inode number. */
-/* this function ONLY returns valid dget'd dentries with an initialized inode
- or errors */
-static struct dentry *mgs_lvfs_fid2dentry(__u64 id, __u32 gen,
- __u64 gr, void *data)
-{
- struct fsfilt_fid fid;
- struct obd_device *obd = (struct obd_device *)data;
- struct mgs_device *mgs = lu2mgs_dev(obd->obd_lu_dev);
- ENTRY;
-
- CDEBUG(D_DENTRY, "--> mgs_fid2dentry: ino/gen %lu/%u, sb %p\n",
- (unsigned long)id, gen, mgs->mgs_sb);
-
- if (id == 0)
- RETURN(ERR_PTR(-ESTALE));
-
- fid.ino = id;
- fid.gen = gen;
-
- RETURN(fsfilt_fid2dentry(obd, mgs->mgs_vfsmnt, &fid, 0));
-}
-
-struct lvfs_callback_ops mgs_lvfs_ops = {
- l_fid2dentry: mgs_lvfs_fid2dentry,
-};
-
-int mgs_fs_setup_old(const struct lu_env *env, struct mgs_device *mgs)
-{
- struct obd_device *obd = mgs->mgs_obd;
- struct dt_device_param p;
- struct vfsmount *mnt;
- struct lvfs_run_ctxt saved;
- struct dentry *dentry;
- int rc;
- ENTRY;
-
- dt_conf_get(env, mgs->mgs_bottom, &p);
- mnt = p.ddp_mnt;
- if (mnt == NULL) {
- CERROR("%s: no proper support for OSD yet\n", obd->obd_name);
- RETURN(-ENODEV);
- }
-
- /* FIXME what's this? Do I need it? */
- rc = cfs_cleanup_group_info();
- if (rc)
- RETURN(rc);
-
- mgs->mgs_vfsmnt = mnt;
- mgs->mgs_sb = mnt->mnt_root->d_inode->i_sb;
-
- obd->obd_fsops = fsfilt_get_ops(mt_str(p.ddp_mount_type));
- if (IS_ERR(obd->obd_fsops))
- RETURN(PTR_ERR(obd->obd_fsops));
-
- rc = fsfilt_setup(obd, mgs->mgs_sb);
- if (rc)
- RETURN(rc);
-
- OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
- obd->obd_lvfs_ctxt.pwdmnt = mnt;
- obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
- obd->obd_lvfs_ctxt.fs = get_ds();
- obd->obd_lvfs_ctxt.cb_ops = mgs_lvfs_ops;
-
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
- /* Setup the configs dir */
- dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, MOUNT_CONFIGS_DIR, 0777, 1);
- if (IS_ERR(dentry)) {
- rc = PTR_ERR(dentry);
- CERROR("cannot create %s directory: rc = %d\n",
- MOUNT_CONFIGS_DIR, rc);
- GOTO(err_pop, rc);
- }
- mgs->mgs_configs_dir_old = dentry;
-
- /* create directory to store nid table versions */
- dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, MGS_NIDTBL_DIR,
- 0777, 1);
- if (IS_ERR(dentry)) {
- rc = PTR_ERR(dentry);
- CERROR("cannot create %s directory: rc = %d\n",
- MOUNT_CONFIGS_DIR, rc);
- GOTO(err_pop, rc);
- } else {
- dput(dentry);
- }
-
-err_pop:
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- return rc;
-}
-
-int mgs_fs_cleanup_old(const struct lu_env *env, struct mgs_device *mgs)
-{
- struct obd_device *obd = mgs->mgs_obd;
- struct lvfs_run_ctxt saved;
- int rc = 0;
-
- class_disconnect_exports(obd); /* cleans up client info too */
-
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
- if (mgs->mgs_configs_dir_old) {
- l_dput(mgs->mgs_configs_dir_old);
- mgs->mgs_configs_dir_old = NULL;
- }
-
- shrink_dcache_sb(mgs->mgs_sb);
-
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
- if (obd->obd_fsops)
- fsfilt_put_ops(obd->obd_fsops);
-
- return rc;
-}
-
int mgs_fs_setup(const struct lu_env *env, struct mgs_device *mgs)
{
- struct lu_fid fid;
- struct dt_object *o;
- struct lu_fid rfid;
- struct dt_object *root;
- int rc;
+ struct lu_fid fid;
+ struct dt_object *o;
+ struct lu_fid rfid;
+ struct dt_object *root;
+ int rc;
+
ENTRY;
/* FIXME what's this? Do I need it? */
if (rc)
RETURN(rc);
+ OBD_SET_CTXT_MAGIC(&mgs->mgs_obd->obd_lvfs_ctxt);
+ mgs->mgs_obd->obd_lvfs_ctxt.dt = mgs->mgs_bottom;
+
/* XXX: fix when support for N:1 layering is implemented */
LASSERT(mgs->mgs_dt_dev.dd_lu_dev.ld_site);
mgs->mgs_dt_dev.dd_lu_dev.ld_site->ls_top_dev =
out:
mgs->mgs_dt_dev.dd_lu_dev.ld_site->ls_top_dev = NULL;
- if (rc == 0) {
- rc = mgs_fs_setup_old(env, mgs);
- if (rc)
- mgs_fs_cleanup(env, mgs);
- }
-
return rc;
}
int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *mgs)
{
- mgs_fs_cleanup_old(env, mgs);
-
class_disconnect_exports(mgs->mgs_obd); /* cleans up client info too */
if (mgs->mgs_configs_dir) {
#define DEBUG_SUBSYSTEM S_MGS
#define D_MGS D_CONFIG
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/pagemap.h>
-# include <linux/miscdevice.h>
-# include <linux/init.h>
-#else
-# include <liblustre.h>
-#endif
-
#include <obd_class.h>
-#include <lustre_dlm.h>
#include <lprocfs_status.h>
-#include <lustre_fsfilt.h>
-#include <lustre_disk.h>
#include <lustre_param.h>
-#include <lustre_log.h>
#include "mgs_internal.h"
static int mgs_handle(struct ptlrpc_request *req);
-static int mgs_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
- struct obd_device *tgt, int *index)
-{
- int rc;
-
- ENTRY;
-
- LASSERT(olg == &obd->obd_olg);
- rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_ORIG_CTXT, obd,
- &llog_lvfs_ops);
- RETURN(rc);
-}
-
-static int mgs_llog_finish(struct obd_device *obd, int count)
-{
- struct llog_ctxt *ctxt;
-
- ENTRY;
-
- ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
- if (ctxt)
- llog_cleanup(NULL, ctxt);
-
- RETURN(0);
-}
-
static int mgs_completion_ast_config(struct ldlm_lock *lock, int flags,
void *cbdata)
{
if (rc <= 0)
/* Nothing wrong, or fatal error */
GOTO(out_nolock, rc);
- } else {
- if (!(mti->mti_flags & LDD_F_NO_PRIMNODE)
- && (rc = mgs_check_failover_reg(mti)))
- GOTO(out_nolock, rc);
+ } else if (!(mti->mti_flags & LDD_F_NO_PRIMNODE)) {
+ rc = mgs_check_failover_reg(mti);
+ if (rc)
+ GOTO(out_nolock, rc);
}
OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_PAUSE_TARGET_REG, 10);
struct mgs_thread_info *mgi = mgs_env_info(env);
int rc;
struct lustre_cfg *lcfg = NULL;
- struct llog_rec_hdr rec;
char *poolname = NULL;
ENTRY;
OBD_ALLOC(poolname, LOV_MAXPOOLNAME + 1);
if (poolname == NULL)
RETURN(-ENOMEM);
- rec.lrh_len = llog_data_len(data->ioc_plen1);
- if (data->ioc_type == LUSTRE_CFG_TYPE) {
- rec.lrh_type = OBD_CFG_REC;
- } else {
- CERROR("unknown cfg record type:%d \n", data->ioc_type);
+ if (data->ioc_type != LUSTRE_CFG_TYPE) {
+ CERROR("%s: unknown cfg record type: %d\n",
+ mgs->mgs_obd->obd_name, data->ioc_type);
GOTO(out_pool, rc = -EINVAL);
}
{
struct mgs_device *mgs = exp2mgs_dev(exp);
struct obd_ioctl_data *data = karg;
- struct lvfs_run_ctxt saved;
struct lu_env env;
int rc = 0;
case OBD_IOC_PARAM: {
struct mgs_thread_info *mgi = mgs_env_info(&env);
struct lustre_cfg *lcfg;
- struct llog_rec_hdr rec;
-
- rec.lrh_len = llog_data_len(data->ioc_plen1);
- if (data->ioc_type == LUSTRE_CFG_TYPE) {
- rec.lrh_type = OBD_CFG_REC;
- } else {
- CERROR("unknown cfg record type:%d \n", data->ioc_type);
+ if (data->ioc_type != LUSTRE_CFG_TYPE) {
+ CERROR("%s: unknown cfg record type: %d\n",
+ mgs->mgs_obd->obd_name, data->ioc_type);
GOTO(out, rc = -EINVAL);
}
case OBD_IOC_DUMP_LOG: {
struct llog_ctxt *ctxt;
+
ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
- push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
- rc = class_config_dump_llog(ctxt, data->ioc_inlbuf1, NULL);
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
+ rc = class_config_dump_llog(&env, ctxt, data->ioc_inlbuf1,
+ NULL);
llog_ctxt_put(ctxt);
break;
}
+ case OBD_IOC_LLOG_CANCEL:
+ case OBD_IOC_LLOG_REMOVE:
case OBD_IOC_LLOG_CHECK:
case OBD_IOC_LLOG_INFO:
case OBD_IOC_LLOG_PRINT: {
struct llog_ctxt *ctxt;
ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
- push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
- rc = llog_ioctl(NULL, ctxt, cmd, data);
- pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
+ rc = llog_ioctl(&env, ctxt, cmd, data);
llog_ctxt_put(ctxt);
break;
}
default:
- CDEBUG(D_INFO, "unknown command %x\n", cmd);
- rc = -EINVAL;
+ CERROR("%s: unknown command %#x\n",
+ mgs->mgs_obd->obd_name, cmd);
+ rc = -ENOTTY;
break;
}
out:
static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs,
struct lu_device_type *ldt, struct lustre_cfg *lcfg)
{
- static struct ptlrpc_service_conf conf;
- struct lprocfs_static_vars lvars = { 0 };
- struct obd_device *obd;
- struct lustre_mount_info *lmi;
- int rc;
+ static struct ptlrpc_service_conf conf;
+ struct lprocfs_static_vars lvars = { 0 };
+ struct obd_device *obd;
+ struct lustre_mount_info *lmi;
+ struct llog_ctxt *ctxt;
+ int rc;
+
ENTRY;
lmi = server_get_mount(lustre_cfg_string(lcfg, 0));
GOTO(err_ns, rc);
}
- rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
+ rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT,
+ obd, &llog_osd_ops);
if (rc)
GOTO(err_fs, rc);
+ /* XXX: we need this trick till N:1 stack is supported
+ * set "current" directory for named llogs */
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
+ LASSERT(ctxt);
+ ctxt->loc_dir = mgs->mgs_configs_dir;
+ llog_ctxt_put(ctxt);
+
/* No recovery for MGC's */
obd->obd_replayable = 0;
err_lproc:
lproc_mgs_cleanup(mgs);
err_llog:
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
+ if (ctxt) {
+ ctxt->loc_dir = NULL;
+ llog_cleanup(env, ctxt);
+ }
err_fs:
/* No extra cleanup needed for llog_init_commit_thread() */
mgs_fs_cleanup(env, mgs);
static struct lu_device *mgs_device_fini(const struct lu_env *env,
struct lu_device *d)
{
- struct mgs_device *mgs = lu2mgs_dev(d);
- struct obd_device *obd = mgs->mgs_obd;
+ struct mgs_device *mgs = lu2mgs_dev(d);
+ struct obd_device *obd = mgs->mgs_obd;
+ struct llog_ctxt *ctxt;
+
ENTRY;
LASSERT(mgs->mgs_bottom);
mgs_cleanup_fsdb_list(mgs);
lproc_mgs_cleanup(mgs);
- obd_llog_finish(obd, 0);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
+ if (ctxt) {
+ ctxt->loc_dir = NULL;
+ llog_cleanup(env, ctxt);
+ }
mgs_fs_cleanup(env, mgs);
.o_init_export = mgs_init_export,
.o_destroy_export = mgs_destroy_export,
.o_iocontrol = mgs_iocontrol,
- .o_llog_init = mgs_llog_init,
- .o_llog_finish = mgs_llog_finish
};
static int __init mgs_init(void)
#define _MGS_INTERNAL_H
#include <libcfs/libcfs.h>
+#include <lustre_log.h>
#include <lustre_export.h>
+#include <dt_object.h>
#define MGSSELF_NAME "_mgs"
struct mgs_nidtbl fsdb_nidtbl;
/* async thread to notify clients */
- struct obd_device *fsdb_obd;
struct mgs_device *fsdb_mgs;
cfs_waitq_t fsdb_notify_waitq;
cfs_completion_t fsdb_notify_comp;
unsigned int fsdb_notify_count;
};
-/* mgs_llog.c */
-int class_dentry_readdir(const struct lu_env *env,
- struct mgs_device *mgs, cfs_list_t *list);
-
struct mgs_device {
struct dt_device mgs_dt_dev;
struct ptlrpc_service *mgs_service;
struct dt_device *mgs_bottom;
struct obd_export *mgs_bottom_exp;
struct dt_object *mgs_configs_dir;
- struct dentry *mgs_configs_dir_old;
struct dt_object *mgs_nidtbl_dir;
cfs_list_t mgs_fs_db_list;
cfs_spinlock_t mgs_lock; /* covers mgs_fs_db_list */
cfs_time_t mgs_start_time;
struct obd_device *mgs_obd;
struct local_oid_storage *mgs_los;
- struct vfsmount *mgs_vfsmnt;
- struct super_block *mgs_sb;
cfs_mutex_t mgs_mutex;
};
int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb);
void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars);
#else
-static inline int lproc_mgs_setup(struct obd_device *dev)
+static inline int lproc_mgs_setup(struct mgs_device *mgs)
{return 0;}
-static inline int lproc_mgs_cleanup(struct obd_device *obd)
+static inline int lproc_mgs_cleanup(struct mgs_device *mgs)
{return 0;}
-static inline int lproc_mgs_add_live(struct mgs_device *obd, struct fs_db *fsdb)
+static inline int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb)
{return 0;}
-static inline int lproc_mgs_del_live(struct mgs_device *obd, struct fs_db *fsdb)
+static inline int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
{return 0;}
static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
{
void mgs_counter_incr(struct obd_export *exp, int opcode);
void mgs_stats_counter_init(struct lprocfs_stats *stats);
-struct temp_comp
-{
+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 obd_device *comp_obd;
};
struct mgs_thread_info {
return de;
}
+/* mgs_llog.c */
+int class_dentry_readdir(const struct lu_env *env, struct mgs_device *mgs,
+ cfs_list_t *list);
+
#endif /* _MGS_INTERNAL_H */
#include <lustre_param.h>
#include <lustre_sec.h>
#include <lquota.h>
-#include <lustre_log.h>
#include "mgs_internal.h"
/********************** Class functions ********************/
-/* Caller must list_del and mgs_dirent_free() each dentry from the list */
int class_dentry_readdir(const struct lu_env *env,
struct mgs_device *mgs, cfs_list_t *list)
{
struct mgs_device *mgs,
struct fs_db *fsdb)
{
- char *logname;
- struct llog_handle *loghandle;
- struct lvfs_run_ctxt saved;
- struct llog_ctxt *ctxt;
- struct mgs_fsdb_handler_data d = { fsdb, 0 };
- int rc, rc2;
- ENTRY;
+ char *logname;
+ struct llog_handle *loghandle;
+ struct llog_ctxt *ctxt;
+ struct mgs_fsdb_handler_data d = { fsdb, 0 };
+ int rc;
+
+ ENTRY;
ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
if (rc)
GOTO(out_put, rc);
cfs_mutex_lock(&fsdb->fsdb_mutex);
- push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
- rc = llog_open_create(NULL, ctxt, &loghandle, NULL, logname);
+ rc = llog_open_create(env, ctxt, &loghandle, NULL, logname);
if (rc)
GOTO(out_pop, rc);
- rc = llog_init_handle(NULL, loghandle, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
if (llog_get_size(loghandle) <= 1)
cfs_set_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags);
- rc = llog_process_or_fork(env, loghandle, mgs_fsdb_handler, (void *)&d,
- NULL, false);
+ rc = llog_process(env, loghandle, mgs_fsdb_handler, (void *)&d, NULL);
CDEBUG(D_INFO, "get_db = %d\n", rc);
out_close:
- rc2 = llog_close(NULL, loghandle);
- if (!rc)
- rc = rc2;
+ llog_close(env, loghandle);
out_pop:
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
cfs_mutex_unlock(&fsdb->fsdb_mutex);
name_destroy(&logname);
out_put:
/* Header and tail are added back to lrh_len in
llog_lvfs_write_rec */
rec->lrh_len = cfg_len;
- rc = llog_write(NULL, llh, rec, NULL, 0, (void *)lcfg,
+ rc = llog_write(env, llh, rec, NULL, 0, (void *)lcfg,
rec->lrh_index);
if (!rc)
mml->mml_modified++;
RETURN(rc);
}
-/* Modify an existing config log record (for CM_SKIP or CM_EXCLUDE) */
+/**
+ * Modify an existing config log record (for CM_SKIP or CM_EXCLUDE)
+ * Return code:
+ * 0 - modified successfully,
+ * 1 - no modification was done
+ * negative - error
+ */
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;
struct llog_ctxt *ctxt;
struct mgs_modify_lookup *mml;
- int rc, rc2;
+ int rc;
+
ENTRY;
- CDEBUG(D_MGS, "modify %s/%s/%s fl=%x\n", logname, devname, comment,
- flags);
+ LASSERT(cfs_mutex_is_locked(&fsdb->fsdb_mutex));
+ CDEBUG(D_MGS, "modify %s/%s/%s fl=%x\n", logname, devname, comment,
+ flags);
ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
- rc = llog_open(NULL, ctxt, &loghandle, NULL, logname,
- LLOG_OPEN_EXISTS);
+ rc = llog_open(env, ctxt, &loghandle, NULL, logname, LLOG_OPEN_EXISTS);
if (rc < 0) {
if (rc == -ENOENT)
rc = 0;
GOTO(out_pop, rc);
}
- rc = llog_init_handle(NULL, loghandle, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
mml->mml_marker.cm_flags = flags;
mml->mml_marker.cm_canceltime = flags ? cfs_time_current_sec() : 0;
mml->mml_modified = 0;
- rc = llog_process_or_fork(env, loghandle, mgs_modify_handler,
- (void *)mml, NULL, false);
- if (!rc && !mml->mml_modified)
+ rc = llog_process(env, loghandle, mgs_modify_handler, (void *)mml,
+ NULL);
+ if (!rc && !mml->mml_modified)
rc = 1;
OBD_FREE_PTR(mml);
out_close:
- rc2 = llog_close(NULL, loghandle);
- if (!rc)
- rc = rc2;
+ llog_close(env, loghandle);
out_pop:
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
if (rc < 0)
- CERROR("modify %s/%s failed %d\n",
- mti->mti_svname, comment, rc);
+ CERROR("%s: modify %s/%s failed: rc = %d\n",
+ mgs->mgs_obd->obd_name, mti->mti_svname, comment, rc);
llog_ctxt_put(ctxt);
RETURN(rc);
}
/******************** config log recording functions *********************/
static int record_lcfg(const struct lu_env *env, struct llog_handle *llh,
- struct lustre_cfg *lcfg)
+ 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;
+ struct llog_rec_hdr rec;
+ int buflen, rc;
if (!lcfg || !llh)
return -ENOMEM;
rec.lrh_len = llog_data_len(buflen);
rec.lrh_type = OBD_CFG_REC;
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
/* idx = -1 means append */
- rc = llog_write(NULL, llh, &rec, NULL, 0, (void *)lcfg, -1);
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+ rc = llog_write(env, llh, &rec, NULL, 0, (void *)lcfg, -1);
if (rc)
CERROR("failed %d\n", rc);
return rc;
return rc;
}
-static int record_start_log(const struct lu_env *env,
- struct mgs_device *mgs,
- struct llog_handle **llh, char *name)
+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" };
- struct lvfs_run_ctxt saved;
- struct llog_ctxt *ctxt;
- int rc = 0;
+ static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" };
+ struct llog_ctxt *ctxt;
+ int rc = 0;
- if (*llh)
- GOTO(out, rc = -EBUSY);
+ if (*llh)
+ GOTO(out, rc = -EBUSY);
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, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
- rc = llog_open_create(NULL, ctxt, llh, NULL, name);
+ rc = llog_open_create(env, ctxt, llh, NULL, name);
if (rc)
GOTO(out_ctxt, rc);
- rc = llog_init_handle(NULL, *llh, LLOG_F_IS_PLAIN, &cfg_uuid);
- if (rc) {
- llog_close(NULL, *llh);
- *llh = NULL;
- }
+ rc = llog_init_handle(env, *llh, LLOG_F_IS_PLAIN, &cfg_uuid);
+ if (rc)
+ llog_close(env, *llh);
out_ctxt:
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
out:
- if (rc)
- CERROR("Can't start log %s: %d\n", name, rc);
+ if (rc) {
+ CERROR("%s: can't start log %s: rc = %d\n",
+ mgs->mgs_obd->obd_name, name, rc);
+ *llh = NULL;
+ }
RETURN(rc);
}
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);
+ int rc;
- rc = llog_close(NULL, *llh);
- *llh = NULL;
+ rc = llog_close(env, *llh);
+ *llh = NULL;
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- RETURN(rc);
+ return rc;
}
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(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
- rc = llog_open(NULL, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
+ rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
if (rc < 0) {
if (rc == -ENOENT)
rc = 0;
GOTO(out_ctxt, rc);
}
- llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
+ llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
rc = llog_get_size(llh);
out_close:
- llog_close(NULL, llh);
+ llog_close(env, llh);
out_ctxt:
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
/* header is record 1 */
return (rc <= 1);
struct llog_rec_hdr *rec, void *data)
{
struct mgs_device *mgs;
+ struct obd_device *obd;
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;
- mgs = ((struct temp_comp*)data)->comp_mgs;
+ obd = ((struct temp_comp *)data)->comp_obd;
+ mgs = lu2mgs_dev(obd->obd_lu_dev);
+ LASSERT(mgs);
if (rec->lrh_type != OBD_CFG_REC) {
CERROR("unhandled lrh_type: %#x\n", rec->lrh_type);
struct temp_comp* comp)
{
struct llog_handle *loghandle;
- struct lvfs_run_ctxt saved;
struct mgs_target_info *tmti;
struct llog_ctxt *ctxt;
int rc;
GOTO(out_ctxt, rc = -ENOMEM);
comp->comp_tmti = tmti;
- comp->comp_mgs = mgs;
-
- push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
+ comp->comp_obd = mgs->mgs_obd;
- rc = llog_open(NULL, ctxt, &loghandle, NULL, client_name,
+ rc = llog_open(env, ctxt, &loghandle, NULL, client_name,
LLOG_OPEN_EXISTS);
if (rc < 0) {
if (rc == -ENOENT)
GOTO(out_pop, rc);
}
- rc = llog_init_handle(NULL, loghandle, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
(void *)comp, NULL, false);
CDEBUG(D_MGS, "steal llog re = %d\n", rc);
out_close:
- llog_close(NULL, loghandle);
+ llog_close(env, loghandle);
out_pop:
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
OBD_FREE_PTR(tmti);
out_ctxt:
llog_ctxt_put(ctxt);
struct fs_db *fsdb)
{
struct llog_handle *llh = NULL;
- struct lvfs_run_ctxt saved;
struct llog_ctxt *ctxt;
char *logname;
struct mgs_srpc_read_data msrd;
if (mgs_log_is_empty(env, mgs, logname))
GOTO(out, rc = 0);
- push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
-
- rc = llog_open(NULL, ctxt, &llh, NULL, logname,
+ rc = llog_open(env, ctxt, &llh, NULL, logname,
LLOG_OPEN_EXISTS);
if (rc < 0) {
if (rc == -ENOENT)
rc = 0;
- GOTO(out_pop, rc);
+ GOTO(out, rc);
}
- rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
msrd.msrd_fsdb = fsdb;
msrd.msrd_skip = 0;
- rc = llog_process_or_fork(env, llh, mgs_srpc_read_handler,
- (void *)&msrd, NULL, false);
+ rc = llog_process(env, llh, mgs_srpc_read_handler, (void *)&msrd,
+ NULL);
out_close:
- llog_close(NULL, llh);
-out_pop:
- pop_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL);
+ llog_close(env, llh);
out:
llog_ctxt_put(ctxt);
name_destroy(&logname);
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);
+ ctxt = llog_get_context(mgs->mgs_obd, LLOG_CONFIG_ORIG_CTXT);
if (ctxt == NULL) {
CERROR("%s: MGS config context doesn't exist\n",
- obd->obd_name);
+ mgs->mgs_obd->obd_name);
rc = -ENODEV;
} else {
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_erase(NULL, ctxt, NULL, name);
+ rc = llog_erase(env, ctxt, NULL, name);
/* llog may not exist */
if (rc == -ENOENT)
rc = 0;
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
}
if (rc)
- CERROR("%s: failed to clear log %s: %d\n", obd->obd_name,
- name, rc);
+ CERROR("%s: failed to clear log %s: %d\n",
+ mgs->mgs_obd->obd_name, name, rc);
return rc;
}
#define MGS_NIDTBL_VERSION_INIT 2
static int nidtbl_read_version(const struct lu_env *env,
- struct mgs_device *mgs, struct mgs_nidtbl *tbl)
+ struct mgs_device *mgs, struct mgs_nidtbl *tbl,
+ u64 *version)
{
struct dt_object *fsdb;
struct lu_fid fid;
LASSERT(mgs->mgs_nidtbl_dir);
rc = dt_lookup_dir(env, mgs->mgs_nidtbl_dir, tbl->mn_fsdb->fsdb_name,
&fid);
- if (rc == -ENOENT)
- RETURN(MGS_NIDTBL_VERSION_INIT);
- else if (rc < 0)
+ if (rc == -ENOENT) {
+ *version = MGS_NIDTBL_VERSION_INIT;
+ RETURN(0);
+ } else if (rc < 0) {
RETURN(rc);
+ }
fsdb = dt_locate_at(env, mgs->mgs_bottom, &fid,
&mgs->mgs_dt_dev.dd_lu_dev);
RETURN(PTR_ERR(fsdb));
rc = dt_read(env, fsdb, &buf, &off);
- if (rc == buf.lb_len)
- rc = le64_to_cpu(tmpver);
- else if (rc == 0)
- rc = MGS_NIDTBL_VERSION_INIT;
- else
+ if (rc == buf.lb_len) {
+ *version = le64_to_cpu(tmpver);
+ rc = 0;
+ } else if (rc == 0) {
+ *version = MGS_NIDTBL_VERSION_INIT;
+ } else {
CERROR("%s: read version file %s error %d\n",
mgs->mgs_obd->obd_name, tbl->mn_fsdb->fsdb_name, rc);
+ }
lu_object_put(env, &fsdb->do_lu);
RETURN(rc);
}
static int mgs_nidtbl_init_fs(const struct lu_env *env, struct fs_db *fsdb)
{
struct mgs_nidtbl *tbl = &fsdb->fsdb_nidtbl;
+ int rc;
CFS_INIT_LIST_HEAD(&tbl->mn_targets);
cfs_mutex_init(&tbl->mn_lock);
tbl->mn_nr_targets = 0;
tbl->mn_fsdb = fsdb;
cfs_mutex_lock(&tbl->mn_lock);
- tbl->mn_version = nidtbl_read_version(env, fsdb->fsdb_mgs, tbl);
+ rc = nidtbl_read_version(env, fsdb->fsdb_mgs, tbl, &tbl->mn_version);
cfs_mutex_unlock(&tbl->mn_lock);
- CDEBUG(D_MGS, "IR: current version is %llu\n", tbl->mn_version);
+ if (rc < 0)
+ CERROR("%s: IR: failed to read current version, rc = %d\n",
+ fsdb->fsdb_mgs->mgs_obd->obd_name, rc);
+ else
+ CDEBUG(D_MGS, "IR: current version is %llu\n",
+ tbl->mn_version);
- return 0;
+ return rc;
}
/* --------- Imperative Recovery relies on nidtbl stuff ------- */
CFS_INIT_LIST_HEAD(&fsdb->fsdb_clients);
/* start notify thread */
- fsdb->fsdb_obd = mgs->mgs_obd;
fsdb->fsdb_mgs = mgs;
cfs_atomic_set(&fsdb->fsdb_notify_phase, 0);
cfs_waitq_init(&fsdb->fsdb_notify_waitq);
ptlrpc_free_bulk(desc);
out:
- if (pages) {
- for (i = 0; i < nrpages; i++) {
- if (pages[i] == NULL)
- break;
- cfs_free_page(pages[i]);
- }
- OBD_FREE(pages, sizeof(*pages) * nrpages);
- }
- return rc;
+ for (i = 0; i < nrpages; i++) {
+ if (pages[i] == NULL)
+ break;
+ cfs_free_page(pages[i]);
+ }
+ OBD_FREE(pages, sizeof(*pages) * nrpages);
+ return rc;
}
static int lprocfs_ir_set_state(struct fs_db *fsdb, const char *buf)
GOTO(out_put, rc);
}
- llog_init_handle(env, *llh, LLOG_F_IS_PLAIN, &uuid);
+ rc = llog_init_handle(env, *llh, LLOG_F_IS_PLAIN, &uuid);
if (rc) {
CERROR("2a: can't init llog handle: %d\n", rc);
GOTO(out_close_llh, rc);
CERROR("4a: llog_create with name %s failed: %d\n", name, rc);
GOTO(ctxt_release, rc);
}
- llog_init_handle(env, cath, LLOG_F_IS_CAT, &uuid);
+ rc = llog_init_handle(env, cath, LLOG_F_IS_CAT, &uuid);
if (rc) {
CERROR("4a: can't init llog handle: %d\n", rc);
GOTO(out, rc);
num_recs++;
cat_logid = cath->lgh_id;
- /* XXX: there is known issue with tests 4b, MGS is not able to add
- * anonymous plain llog, si we exit now to allow following tests run.
- * It is fixed in upcoming llog over OSD code */
- GOTO(out, rc);
-
CWARN("4b: write 1 record into the catalog\n");
rc = llog_cat_add(env, cath, &lmr.lmr_hdr, &cookie, NULL);
if (rc != 1) {
struct llog_rec_hdr *rec, void *data)
{
struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
+ struct lu_fid fid;
if (rec->lrh_type != LLOG_LOGID_MAGIC) {
CERROR("invalid record in catalog\n");
RETURN(-EINVAL);
}
- CWARN("seeing record at index %d - "LPX64":%x in log "LPX64"\n",
- rec->lrh_index, lir->lid_id.lgl_oid,
- lir->lid_id.lgl_ogen, llh->lgh_id.lgl_oid);
+ logid_to_fid(&lir->lid_id, &fid);
+
+ CWARN("seeing record at index %d - "DFID" in log "DFID"\n",
+ rec->lrh_index, PFID(&fid),
+ PFID(lu_object_fid(&llh->lgh_obj->do_lu)));
cat_counter++;
static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh,
struct llog_rec_hdr *rec, void *data)
{
+ struct lu_fid fid;
+
if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
CERROR("log is not plain\n");
RETURN(-EINVAL);
}
- CDEBUG(D_INFO, "seeing record at index %d in log "LPX64"\n",
- rec->lrh_index, llh->lgh_id.lgl_oid);
+ logid_to_fid(&llh->lgh_id, &fid);
+
+ CDEBUG(D_INFO, "seeing record at index %d in log "DFID"\n",
+ rec->lrh_index, PFID(&fid));
plain_counter++;
GOTO(out_put, rc);
}
- llog_init_handle(env, llh, LLOG_F_IS_CAT, &uuid);
+ rc = llog_init_handle(env, llh, LLOG_F_IS_CAT, &uuid);
if (rc) {
CERROR("5a: can't init llog handle: %d\n", rc);
GOTO(out, rc);
}
- /* XXX: depends on tests 4 which is not working yet */
- GOTO(out, rc);
-
CWARN("5b: print the catalog entries.. we expect 2\n");
cat_counter = 0;
rc = llog_process(env, llh, cat_print_cb, "test 5", NULL);
rc = obd_connect(NULL, &exp, mgc_obd, &uuid,
NULL /* obd_connect_data */, NULL);
if (rc != -EALREADY) {
- CERROR("6a: connect on connected MDC (%s) failed to return"
+ CERROR("6a: connect on connected MGC (%s) failed to return"
" -EALREADY", mgc_obd->obd_name);
if (rc == 0)
obd_disconnect(exp);
ENTRY;
- rc = llog_open_create(env, ctxt, &llh, NULL, "llt_test7");
+ rc = llog_open_create(env, ctxt, &llh, NULL, NULL);
if (rc) {
CERROR("7_sub: create log failed\n");
RETURN(rc);
static int llog_run_tests(const struct lu_env *env, struct obd_device *obd)
{
struct llog_handle *llh = NULL;
- struct lvfs_run_ctxt saved;
struct llog_ctxt *ctxt;
int rc, err;
char name[10];
LASSERT(ctxt);
sprintf(name, "%x", llog_test_rand);
- push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
rc = llog_test_1(env, obd, name);
if (rc)
if (rc == 0)
rc = err;
cleanup_ctxt:
- pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
return rc;
}
static int llog_test_cleanup(struct obd_device *obd)
{
- int rc;
+ struct obd_device *tgt;
+ struct lu_env env;
+ int rc;
+
+ ENTRY;
+
+ rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
+ if (rc)
+ RETURN(rc);
- rc = llog_cleanup(NULL, llog_get_context(obd, LLOG_TEST_ORIG_CTXT));
+ tgt = obd->obd_lvfs_ctxt.dt->dd_lu_dev.ld_obd;
+ rc = llog_cleanup(&env, llog_get_context(tgt, LLOG_TEST_ORIG_CTXT));
if (rc)
CERROR("failed to llog_test_llog_finish: %d\n", rc);
- return rc;
+ lu_env_fini(&env);
+ RETURN(rc);
}
static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
- struct obd_device *tgt;
- struct lu_env env;
- int rc;
+ struct obd_device *tgt;
+ struct llog_ctxt *ctxt;
+ struct dt_object *o;
+ struct lu_env env;
+ struct lu_context test_session;
+ int rc;
ENTRY;
if (rc)
RETURN(rc);
+ rc = lu_context_init(&test_session, LCT_SESSION);
+ if (rc)
+ GOTO(cleanup_env, rc);
+ test_session.lc_thread = (struct ptlrpc_thread *)cfs_current();
+ lu_context_enter(&test_session);
+ env.le_ses = &test_session;
+
CWARN("Setup llog-test device over %s device\n",
lustre_cfg_string(lcfg, 1));
- rc = llog_setup(&env, obd, &obd->obd_olg, LLOG_TEST_ORIG_CTXT, tgt,
- &llog_lvfs_ops);
+ OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
+ obd->obd_lvfs_ctxt.dt = lu2dt_dev(tgt->obd_lu_dev);
+
+ rc = llog_setup(&env, tgt, &tgt->obd_olg, LLOG_TEST_ORIG_CTXT, tgt,
+ &llog_osd_ops);
if (rc)
- GOTO(cleanup_env, rc);
+ GOTO(cleanup_session, rc);
+
+ /* use MGS llog dir for tests */
+ ctxt = llog_get_context(tgt, LLOG_CONFIG_ORIG_CTXT);
+ LASSERT(ctxt);
+ o = ctxt->loc_dir;
+ llog_ctxt_put(ctxt);
+
+ ctxt = llog_get_context(tgt, LLOG_TEST_ORIG_CTXT);
+ LASSERT(ctxt);
+ ctxt->loc_dir = o;
+ llog_ctxt_put(ctxt);
llog_test_rand = cfs_rand();
- rc = llog_run_tests(&env, obd);
+ rc = llog_run_tests(&env, tgt);
if (rc)
llog_test_cleanup(obd);
+cleanup_session:
+ lu_context_exit(&test_session);
+ lu_context_fini(&test_session);
cleanup_env:
lu_env_fini(&env);
RETURN(rc);
rc = dt_record_write(env, o, &dti->dti_lb, &dti->dti_off, th);
if (rc)
GOTO(out_trans, rc);
- rc = dt_insert(env, root,
- (const struct dt_rec *)lu_object_fid(&o->do_lu),
- (const struct dt_key *)dti->dti_buf, th,
- BYPASS_CAPA, 1);
- if (rc)
- GOTO(out_trans, rc);
+#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 3, 90, 0)
+#error "fix this before release"
+#endif
+ /*
+ * there is one technical debt left in Orion:
+ * proper hanlding of named vs no-name objects.
+ * Llog objects have name always as they are placed in O/d/...
+ */
+ if (fid_seq(lu_object_fid(&o->do_lu)) != FID_SEQ_LLOG) {
+ rc = dt_insert(env, root,
+ (const struct dt_rec *)first_fid,
+ (const struct dt_key *)dti->dti_buf,
+ th, BYPASS_CAPA, 1);
+ if (rc)
+ GOTO(out_trans, rc);
+ }
out_trans:
dt_trans_stop(env, dev, th);
} else {
RETURN(rc);
}
-int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg)
+int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
+ char *name, struct config_llog_instance *cfg)
{
- struct llog_process_cat_data cd = {0, 0};
- struct llog_handle *llh;
- int rc, rc2;
- ENTRY;
+ struct llog_process_cat_data cd = {0, 0};
+ struct llog_handle *llh;
+ int rc;
- CDEBUG(D_INFO, "looking up llog %s\n", name);
- rc = llog_open(NULL, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
- if (rc)
- RETURN(rc);
+ ENTRY;
- rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
- if (rc)
- GOTO(parse_out, rc);
+ CDEBUG(D_INFO, "looking up llog %s\n", name);
+ rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
+ if (rc)
+ RETURN(rc);
- /* continue processing from where we last stopped to end-of-log */
- if (cfg)
- cd.lpcd_first_idx = cfg->cfg_last_idx;
- cd.lpcd_last_idx = 0;
+ rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
+ if (rc)
+ GOTO(parse_out, rc);
- rc = llog_process(NULL, llh, class_config_llog_handler, cfg, &cd);
+ /* continue processing from where we last stopped to end-of-log */
+ if (cfg)
+ cd.lpcd_first_idx = cfg->cfg_last_idx;
+ cd.lpcd_last_idx = 0;
- CDEBUG(D_CONFIG, "Processed log %s gen %d-%d (rc=%d)\n", name,
- cd.lpcd_first_idx + 1, cd.lpcd_last_idx, rc);
+ rc = llog_process(env, llh, class_config_llog_handler, cfg, &cd);
- if (cfg)
- cfg->cfg_last_idx = cd.lpcd_last_idx;
+ CDEBUG(D_CONFIG, "Processed log %s gen %d-%d (rc=%d)\n", name,
+ cd.lpcd_first_idx + 1, cd.lpcd_last_idx, rc);
+ if (cfg)
+ cfg->cfg_last_idx = cd.lpcd_last_idx;
parse_out:
- rc2 = llog_close(NULL, llh);
- if (rc == 0)
- rc = rc2;
-
+ llog_close(env, llh);
RETURN(rc);
}
EXPORT_SYMBOL(class_config_parse_llog);
RETURN(rc);
}
-int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
- struct config_llog_instance *cfg)
+int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
+ char *name, struct config_llog_instance *cfg)
{
- struct llog_handle *llh;
- int rc, rc2;
- ENTRY;
+ struct llog_handle *llh;
+ int rc;
+
+ ENTRY;
- LCONSOLE_INFO("Dumping config log %s\n", name);
+ LCONSOLE_INFO("Dumping config log %s\n", name);
- rc = llog_open(NULL, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
+ rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
if (rc)
RETURN(rc);
- rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(parse_out, rc);
- rc = llog_process(NULL, llh, class_config_dump_handler, cfg, NULL);
+ rc = llog_process(env, llh, class_config_dump_handler, cfg, NULL);
parse_out:
- rc2 = llog_close(NULL, llh);
- if (rc == 0)
- rc = rc2;
-
- LCONSOLE_INFO("End config log %s\n", name);
- RETURN(rc);
+ llog_close(env, llh);
+ LCONSOLE_INFO("End config log %s\n", name);
+ RETURN(rc);
}
EXPORT_SYMBOL(class_config_dump_llog);
strncpy(o->od_svname, lustre_cfg_string(cfg, 4),
sizeof(o->od_svname) - 1);
- if (strstr(o->od_svname, "-OST")) {
- rc = osd_compat_init(o);
- if (rc != 0)
- GOTO(out_mnt, rc);
- }
+ rc = osd_compat_init(o);
+ if (rc != 0)
+ GOTO(out_scrub, rc);
rc = lu_site_init(&o->od_site, l);
if (rc)
rc = lu_site_init_finish(&o->od_site);
if (rc)
- GOTO(out_compat, rc);
+ GOTO(out_site, rc);
rc = osd_procfs_init(o, o->od_svname);
if (rc != 0) {
CERROR("%s: can't initialize procfs: rc = %d\n",
o->od_svname, rc);
- GOTO(out_compat, rc);
+ GOTO(out_site, rc);
}
LASSERT(l->ld_site->ls_linkage.next && l->ld_site->ls_linkage.prev);
RETURN(0);
+out_site:
+ lu_site_fini(&o->od_site);
out_compat:
osd_compat_fini(o);
+out_scrub:
+ osd_scrub_cleanup(env, o);
out_mnt:
osd_oi_fini(info, o);
osd_shutdown(env, o);