extern struct lu_device_type mdc_device_type;
/* add new MDC to the CMM, create MDC lu_device and connect it to mdc_obd */
-static int cmm_add_mdc(struct cmm_device * cm, struct lustre_cfg *cfg)
+static int cmm_add_mdc(struct lu_context *ctx,
+ struct cmm_device * cm, struct lustre_cfg *cfg)
{
struct lu_device_type *ldt = &mdc_device_type;
struct lu_device *ld;
int rc;
ENTRY;
-
+
/*TODO check this MDC exists already */
ld = ldt->ldt_ops->ldto_device_alloc(ldt, cfg);
-
+
ld->ld_site = cmm2lu_dev(cm)->ld_site;
- rc = ldt->ldt_ops->ldto_device_init(ld, NULL);
+ rc = ldt->ldt_ops->ldto_device_init(ctx, ld, NULL);
if (rc)
ldt->ldt_ops->ldto_device_free(ld);
/* pass config to the just created MDC */
- rc = ld->ld_ops->ldo_process_config(ld, cfg);
+ rc = ld->ld_ops->ldo_process_config(ctx, ld, cfg);
if (rc == 0) {
struct mdc_device *mc = lu2mdc_dev(ld);
list_add_tail(&mc->mc_linkage, &cm->cmm_targets);
}
-static int cmm_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int cmm_process_config(struct lu_context *ctx,
+ struct lu_device *d, struct lustre_cfg *cfg)
{
struct cmm_device *m = lu2cmm_dev(d);
struct lu_device *next = md2lu_dev(m->cmm_child);
switch(cfg->lcfg_command) {
case LCFG_ADD_MDC:
- err = cmm_add_mdc(m, cfg);
+ err = cmm_add_mdc(ctx, m, cfg);
break;
- case LCFG_SETUP:
+ case LCFG_SETUP:
{
const char *index = lustre_cfg_string(cfg, 2);
LASSERT(index);
/* no break; to pass cfg further */
}
default:
- err = next->ld_ops->ldo_process_config(next, cfg);
+ err = next->ld_ops->ldo_process_config(ctx, next, cfg);
}
RETURN(err);
}
return;
}
-static int cmm_device_init(struct lu_device *d, struct lu_device *next)
+static int cmm_device_init(struct lu_context *ctx,
+ struct lu_device *d, struct lu_device *next)
{
struct cmm_device *m = lu2cmm_dev(d);
int err = 0;
RETURN(err);
}
-static struct lu_device *cmm_device_fini(struct lu_device *ld)
+static struct lu_device *cmm_device_fini(struct lu_context *ctx,
+ struct lu_device *ld)
{
struct cmm_device *cm = lu2cmm_dev(ld);
struct mdc_device *mc, *tmp;
ENTRY;
-
+
/* finish all mdc devices */
list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) {
struct lu_device *ld_m = mdc2lu_dev(mc);
list_del(&mc->mc_linkage);
lu_device_put(cmm2lu_dev(cm));
- ld->ld_type->ldt_ops->ldto_device_fini(ld_m);
+ ld->ld_type->ldt_ops->ldto_device_fini(ctx, ld_m);
ld->ld_type->ldt_ops->ldto_device_free(ld_m);
}
CDEBUG(D_CONFIG, "connect to %s(%s)\n",
mdc->obd_name, mdc->obd_uuid.uuid);
-
+
rc = obd_connect(&conn, mdc, &mdt->obd_uuid, NULL);
if (rc) {
mc->mc_num = simple_strtol(index, NULL, 10);
}
}
-
+
RETURN(rc);
}
-static int mdc_process_config(struct lu_device *ld, struct lustre_cfg *cfg)
+static int mdc_process_config(struct lu_context *ctx,
+ struct lu_device *ld, struct lustre_cfg *cfg)
{
struct mdc_device *mc = lu2mdc_dev(ld);
int rc;
rc = ptlrpc_init_import(imp);
if (rc != 0)
RETURN(rc);
-
+
rc = ptlrpc_connect_import(imp, NULL);
if (rc != 0) {
LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
RETURN(rc);
}
-
+
ptlrpc_pinger_add_import(imp);
//TODO other initializations
LASSERT(imp->imp_connection);
RETURN(0);
}
-static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
+static int mdc_device_init(struct lu_context *ctx,
+ struct lu_device *ld, struct lu_device *next)
{
struct mdc_device *mc = lu2mdc_dev(ld);
struct mdc_cli_desc *desc = &mc->mc_desc;
sema_init(&cli->cl_sem, 1);
cli->cl_conn_count = 0;
-
+
rc = ldlm_get_ref();
if (rc != 0) {
CERROR("ldlm_get_ref failed: %d\n", rc);
ptlrpc_init_client(rq_portal, rp_portal, obd->obd_type->typ_name,
&desc->cl_ldlm_client);
-
+
imp = class_new_import(obd);
if (imp == NULL)
GOTO(err_ldlm, rc = -ENOENT);
-
+
imp->imp_client = &desc->cl_ldlm_client;
imp->imp_connect_op = connect_op;
imp->imp_initial_recov = 1;
desc->cl_import = imp;
cli->cl_import = imp;
-
+
rc = mdc_device_connect(mc);
-
+
RETURN(0);
-
+
err_import:
class_destroy_import(imp);
err_ldlm:
RETURN(rc);
}
-static struct lu_device *mdc_device_fini(struct lu_device *ld)
+static struct lu_device *mdc_device_fini(struct lu_context *ctx,
+ struct lu_device *ld)
{
struct mdc_device *mc = lu2mdc_dev(ld);
struct mdc_cli_desc *desc = &mc->mc_desc;
-
+
ENTRY;
class_destroy_import(desc->cl_import);
RETURN (ld);
}
#endif
-static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
+static int mdc_device_init(struct lu_context *ctx,
+ struct lu_device *ld, struct lu_device *next)
{
/* struct mdc_device *mc = lu2mdc_dev(ld); */
int rc = 0;
RETURN(rc);
}
-static struct lu_device *mdc_device_fini(struct lu_device *ld)
+static struct lu_device *mdc_device_fini(struct lu_context *ctx,
+ struct lu_device *ld)
{
/* struct mdc_device *mc = lu2mdc_dev(ld); */
-
+
ENTRY;
RETURN (NULL);
* Features, required from index to support file system directories (mapping
* names to fids).
*/
-extern struct dt_index_features dt_directory_features;
+extern const struct dt_index_features dt_directory_features;
/*
* Per-dt-object operations on object as index.
/*
* process config specific for device
*/
- int (*ldo_process_config)(struct lu_device *, struct lustre_cfg *);
+ int (*ldo_process_config)(struct lu_context *ctx,
+ struct lu_device *, struct lustre_cfg *);
};
/*
/*
* Initialize the devices after allocation
*/
- int (*ldto_device_init)(struct lu_device *, struct lu_device *);
+ int (*ldto_device_init)(struct lu_context *ctx,
+ struct lu_device *, struct lu_device *);
/*
* Finalize device. Dual to ->ldto_device_init(). Returns pointer to
* the next device in the stack.
*/
- struct lu_device *(*ldto_device_fini)(struct lu_device *);
+ struct lu_device *(*ldto_device_fini)(struct lu_context *ctx,
+ struct lu_device *);
/*
* Initialize device type. This is called on module load.
ldt = obd->obd_type->typ_lu;
d = obd->obd_lu_dev;
if (ldt != NULL && d != NULL) {
- rc = d->ld_ops->ldo_process_config(d,
- (struct lustre_cfg *)data);
+ struct lu_context ctx;
+
+ rc = lu_context_init(&ctx);
+ if (rc == 0) {
+ lu_context_enter(&ctx);
+ rc = d->ld_ops->ldo_process_config(&ctx, d, data);
+ lu_context_exit(&ctx);
+ lu_context_fini(&ctx);
+ }
} else {
OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP);
rc = OBP(obd, process_config)(obd, datalen, data);
static struct md_dir_operations mdd_dir_ops;
static struct lu_object_operations mdd_lu_obj_ops;
+static struct lu_context_key mdd_thread_key;
+
+struct mdd_thread_info {
+ struct txn_param mti_param;
+};
+
+static struct mdd_thread_info *mdd_ctx_info(struct lu_context *ctx)
+{
+ struct mdd_thread_info *info;
+
+ info = lu_context_key_get(ctx, &mdd_thread_key);
+ LASSERT(info != NULL);
+ return info;
+}
+
static int lu_device_is_mdd(struct lu_device *d)
{
/*
return seq_printf(f, LUSTRE_MDD0_NAME"-object@%p", o);
}
-static int mdd_fs_setup(struct mdd_device *mdd)
+static int mdd_fs_setup(struct lu_context *ctx, struct mdd_device *mdd)
{
return 0;
}
return 0;
}
-static int mdd_device_init(struct lu_device *d, struct lu_device *next)
+static int mdd_device_init(struct lu_context *ctx,
+ struct lu_device *d, struct lu_device *next)
{
struct mdd_device *mdd = lu2mdd_dev(d);
int rc = -EFAULT;
mdd->mdd_child = lu2dt_dev(next);
- rc = mdd_fs_setup(mdd);
+ rc = mdd_fs_setup(ctx, mdd);
if (rc)
GOTO(err, rc);
RETURN(rc);
}
-static struct lu_device *mdd_device_fini(struct lu_device *d)
+static struct lu_device *mdd_device_fini(struct lu_context *ctx,
+ struct lu_device *d)
{
struct mdd_device *m = lu2mdd_dev(d);
struct lu_device *next = &m->mdd_child->dd_lu_dev;
return next;
}
-static int mdd_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int mdd_process_config(struct lu_context *ctx,
+ struct lu_device *d, struct lustre_cfg *cfg)
{
struct mdd_device *m = lu2mdd_dev(d);
struct lu_device *next = &m->mdd_child->dd_lu_dev;
switch(cfg->lcfg_command) {
default:
- err = next->ld_ops->ldo_process_config(next, cfg);
+ err = next->ld_ops->ldo_process_config(ctx, next, cfg);
}
RETURN(err);
int rc;
struct dt_object *next = mdd_object_child(pobj);
- rc = next->do_index_ops->dio_insert(ctxt, next, lf, name, handle);
+ rc = next->do_index_ops->dio_insert(ctxt, next, (struct dt_rec *)lf,
+ (struct dt_key *)name, handle);
return rc;
}
mdd_lock2(ctxt, pobj, obj);
- rc = next->do_index_ops->dio_delete(ctxt, next, mdd_object_getfid(obj),
- name, handle);
+ rc = next->do_index_ops->dio_delete(ctxt, next,
+ (const struct dt_rec *)mdd_object_getfid(obj),
+ (struct dt_key *)name, handle);
mdd_unlock2(ctxt, pobj, obj);
RETURN(rc);
return l;
}
-void mdd_device_free(struct lu_device *lu)
+static void mdd_device_free(struct lu_device *lu)
{
struct mdd_device *m = lu2mdd_dev(lu);
OBD_FREE_PTR(m);
}
-int mdd_type_init(struct lu_device_type *t)
+static int mdd_type_init(struct lu_device_type *t)
{
- return 0;
+ return lu_context_key_register(&mdd_thread_key);
}
-void mdd_type_fini(struct lu_device_type *t)
+static void mdd_type_fini(struct lu_device_type *t)
{
+ lu_context_key_degister(&mdd_thread_key);
}
static struct lu_device_type_operations mdd_device_type_ops = {
.ldt_ops = &mdd_device_type_ops
};
+static void *mdd_key_init(struct lu_context *ctx)
+{
+ struct mdd_thread_info *info;
+
+ OBD_ALLOC_PTR(info);
+ if (info == NULL)
+ info = ERR_PTR(-ENOMEM);
+ return info;
+}
+
+static void mdd_key_fini(struct lu_context *ctx, void *data)
+{
+ struct mdd_thread_info *info = data;
+ OBD_FREE_PTR(info);
+}
+
+static struct lu_context_key mdd_thread_key = {
+ .lct_init = mdd_key_init,
+ .lct_fini = mdd_key_fini
+};
+
struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
{ 0 }
};
int mdd_max_mddize;
int mdd_max_cookiesize;
struct file *mdd_rcvd_filp;
+ struct lu_fid mdd_root_fid;
spinlock_t mdd_transno_lock;
__u64 mdd_last_transno;
__u64 mdd_mount_count;
int offset = MDS_REQ_INTENT_REC_OFF;
int rc;
struct mdt_thread_info *info;
-
+
ENTRY;
LASSERT(req != NULL);
RETURN(rc);
}
-static void mdt_stack_fini(struct mdt_device *m, struct lu_device *d)
+static void mdt_stack_fini(struct lu_context *ctx,
+ struct mdt_device *m, struct lu_device *d)
{
/* goes through all stack */
while (d != NULL) {
/* each fini() returns next device in stack of layers
* * so we can avoid the recursion */
- n = ldt->ldt_ops->ldto_device_fini(d);
+ n = ldt->ldt_ops->ldto_device_fini(ctx, d);
ldt->ldt_ops->ldto_device_free(d);
type = ldt->ldt_obd_type;
m->mdt_child = NULL;
}
-static struct lu_device *mdt_layer_setup(const char *typename,
+static struct lu_device *mdt_layer_setup(struct lu_context *ctx,
+ const char *typename,
struct lu_device *child,
struct lustre_cfg *cfg)
{
d->ld_site = child->ld_site;
type->typ_refcnt++;
- rc = ldt->ldt_ops->ldto_device_init(d, child);
+ rc = ldt->ldt_ops->ldto_device_init(ctx, d, child);
if (rc) {
CERROR("can't init device '%s', rc %d\n", typename, rc);
GOTO(out_alloc, rc);
RETURN(ERR_PTR(rc));
}
-static int mdt_stack_init(struct mdt_device *m, struct lustre_cfg *cfg)
+static int mdt_stack_init(struct lu_context *ctx,
+ struct mdt_device *m, struct lustre_cfg *cfg)
{
struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
struct lu_device *tmp;
int rc;
/* init the stack */
- tmp = mdt_layer_setup(LUSTRE_OSD0_NAME, d, cfg);
+ tmp = mdt_layer_setup(ctx, LUSTRE_OSD0_NAME, d, cfg);
if (IS_ERR(tmp)) {
RETURN (PTR_ERR(tmp));
}
m->mdt_bottom = lu2dt_dev(tmp);
d = tmp;
- tmp = mdt_layer_setup(LUSTRE_MDD0_NAME, d, cfg);
+ tmp = mdt_layer_setup(ctx, LUSTRE_MDD0_NAME, d, cfg);
if (IS_ERR(tmp)) {
GOTO(out, rc = PTR_ERR(tmp));
}
d = tmp;
- tmp = mdt_layer_setup(LUSTRE_CMM0_NAME, d, cfg);
+ tmp = mdt_layer_setup(ctx, LUSTRE_CMM0_NAME, d, cfg);
if (IS_ERR(tmp)) {
GOTO(out, rc = PTR_ERR(tmp));
}
/* process setup config */
tmp = &m->mdt_md_dev.md_lu_dev;
- rc = tmp->ld_ops->ldo_process_config(tmp, cfg);
+ rc = tmp->ld_ops->ldo_process_config(ctx, tmp, cfg);
out:
/* fini from last known good lu_device */
if (rc)
- mdt_stack_fini(m, d);
+ mdt_stack_fini(ctx, m, d);
return rc;
}
static void mdt_fini(struct mdt_device *m)
{
struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
+ struct lu_context ctx;
+ int rc;
ENTRY;
+ rc = lu_context_init(&ctx);
+ if (rc != 0) {
+ CERROR("Cannot initialize context: %d\n", rc);
+ EXIT;
+ }
+
+ lu_context_enter(&ctx);
+
mdt_stop_ptlrpc_service(m);
/* finish the stack */
- mdt_stack_fini(m, md2lu_dev(m->mdt_child));
+ mdt_stack_fini(&ctx, m, md2lu_dev(m->mdt_child));
mdt_fld_fini(m);
-
+
LASSERT(atomic_read(&d->ld_ref) == 0);
md_device_fini(&m->mdt_md_dev);
d->ld_site = NULL;
}
+ lu_context_exit(&ctx);
+ lu_context_fini(&ctx);
+
EXIT;
}
GOTO(err_fini_site, rc);
}
+ rc = lu_context_init(&ctx);
+ if (rc != 0)
+ GOTO(err_fini_site, rc);
+
+ lu_context_enter(&ctx);
+
/* init the stack */
- rc = mdt_stack_init(m, cfg);
+ rc = mdt_stack_init(&ctx, m, cfg);
if (rc) {
CERROR("can't init device stack, rc %d\n", rc);
- GOTO(err_fini_site, rc);
+ GOTO(err_fini_ctx, rc);
}
/* set server index */
LASSERT(num);
s->ls_node_id = simple_strtol(num, NULL, 10);
-
+
m->mdt_seq_mgr = seq_mgr_init(&seq_mgr_ops, m);
if (!m->mdt_seq_mgr) {
CERROR("can't initialize sequence manager\n");
}
/* set initial sequence by mds index */
m->mdt_seq_mgr->m_seq = s->ls_node_id * LUSTRE_SEQ_RANGE;
-
- rc = lu_context_init(&ctx);
- if (rc != 0)
- GOTO(err_fini_mgr, rc);
- lu_context_enter(&ctx);
/* init sequence info after device stack is initialized. */
rc = seq_mgr_setup(&ctx, m->mdt_seq_mgr);
- lu_context_exit(&ctx);
if (rc)
- GOTO(err_fini_ctx, rc);
-
- lu_context_fini(&ctx);
+ GOTO(err_fini_mgr, rc);
snprintf(ns_name, sizeof ns_name, LUSTRE_MDT0_NAME"-%p", m);
m->mdt_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER);
if (rc)
GOTO(err_free_fld, rc);
+ lu_context_exit(&ctx);
+ lu_context_fini(&ctx);
+
RETURN(0);
err_free_fld:
err_free_ns:
ldlm_namespace_free(m->mdt_namespace, 0);
m->mdt_namespace = NULL;
-err_fini_ctx:
- lu_context_fini(&ctx);
err_fini_mgr:
seq_mgr_fini(m->mdt_seq_mgr);
m->mdt_seq_mgr = NULL;
err_fini_stack:
- mdt_stack_fini(m, md2lu_dev(m->mdt_child));
+ mdt_stack_fini(&ctx, m, md2lu_dev(m->mdt_child));
+err_fini_ctx:
+ lu_context_exit(&ctx);
+ lu_context_fini(&ctx);
err_fini_site:
lu_site_fini(s);
OBD_FREE_PTR(s);
}
/* used by MGS to process specific configurations */
-static int mdt_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int mdt_process_config(struct lu_context *ctx,
+ struct lu_device *d, struct lustre_cfg *cfg)
{
struct lu_device *next = md2lu_dev(mdt_dev(d)->mdt_child);
int err;
/* all MDT specific commands should be here */
default:
/* others are passed further */
- err = next->ld_ops->ldo_process_config(next, cfg);
+ err = next->ld_ops->ldo_process_config(ctx, next, cfg);
}
RETURN(err);
}
static int osd_object_print (struct lu_context *ctx,
struct seq_file *f, const struct lu_object *o);
static void osd_device_free (struct lu_device *m);
-static int osd_device_init (struct lu_device *d, struct lu_device *);
static void *osd_key_init (struct lu_context *ctx);
static void osd_key_fini (struct lu_context *ctx, void *data);
static int osd_has_index (struct osd_object *obj);
static void osd_object_init0 (struct osd_object *obj);
+static int osd_device_init (struct lu_context *ctx,
+ struct lu_device *d, struct lu_device *);
static int osd_fid_lookup (struct lu_context *ctx, struct osd_object *obj,
const struct lu_fid *fid);
static int osd_inode_getattr (struct lu_context *ctx,
static struct osd_device *osd_dt_dev (const struct dt_device *d);
static struct osd_object *osd_dt_obj (const struct dt_object *d);
static struct osd_device *osd_obj2dev (struct osd_object *o);
-static struct lu_device *osd_device_fini (struct lu_device *d);
static struct lu_device *osd2lu_dev (struct osd_device * osd);
+static struct lu_device *osd_device_fini (struct lu_context *ctx,
+ struct lu_device *d);
static struct lu_device *osd_device_alloc (struct lu_device_type *t,
struct lustre_cfg *cfg);
static struct lu_object *osd_object_alloc (struct lu_context *ctx,
return 0;
}
-struct dt_index_features dt_directory_features;
+const struct dt_index_features dt_directory_features;
static int osd_index_probe(struct lu_context *ctxt, struct dt_object *dt,
const struct dt_index_features *feat)
OBD_FREE_PTR(info);
}
-static int osd_device_init(struct lu_device *d, struct lu_device *next)
+static int osd_device_init(struct lu_context *ctx,
+ struct lu_device *d, struct lu_device *next)
{
return 0;
}
extern int osd_oi_find_fid(struct osd_oi *oi,
__u64 ino, __u32 gen, struct lu_fid *fid);
-static int osd_mount(struct osd_device *o, struct lustre_cfg *cfg)
+static int osd_mount(struct lu_context *ctx,
+ struct osd_device *o, struct lustre_cfg *cfg)
{
struct lustre_mount_info *lmi;
const char *dev = lustre_cfg_string(cfg, 0);
result = PTR_ERR(d);
}
if (result != 0)
- osd_device_fini(osd2lu_dev(o));
+ osd_device_fini(ctx, osd2lu_dev(o));
RETURN(result);
}
-static struct lu_device *osd_device_fini(struct lu_device *d)
+static struct lu_device *osd_device_fini(struct lu_context *ctx,
+ struct lu_device *d)
{
struct osd_device *o = osd_dev(d);
OBD_FREE_PTR(o);
}
-static int osd_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int osd_process_config(struct lu_context *ctx,
+ struct lu_device *d, struct lustre_cfg *cfg)
{
struct osd_device *o = osd_dev(d);
int err;
switch(cfg->lcfg_command) {
case LCFG_SETUP:
- err = osd_mount(o, cfg);
+ err = osd_mount(ctx, o, cfg);
break;
default:
err = -ENOTTY;
struct rw_semaphore oo_sem;
};
+/*
+ * osd device.
+ */
struct osd_device {
+ /* super-class */
struct dt_device od_dt_dev;
+ /* information about underlying file system */
struct lustre_mount_info *od_mount;
+ /* object index */
struct osd_oi od_oi;
+ /* root directory */
struct dentry *od_root_dir;
+ /*
+ * XXX temporary stuff for object index: directory where every object
+ * is named by its fid.
+ */
struct dentry *od_obj_area;
};
struct dentry *osd_lookup(struct dentry *parent, const char *name);
struct dentry *osd_open(struct dentry *parent, const char *name, mode_t mode);
-
struct osd_thread_info {
struct lu_fid oti_fid;
struct osd_inode_id oti_id;