struct lu_site *ls = info->mti_mdt->mdt_md_dev.md_lu_dev.ld_site;
struct md_fld mf, *p, *reply;
int size = sizeof(*reply);
- __u32 *opt;
+ __u32 *opt;
int rc;
ENTRY;
opt = lustre_swab_reqbuf(req, 0, sizeof(*opt), lustre_swab_generic_32s);
p = lustre_swab_reqbuf(req, 1, sizeof(mf), lustre_swab_md_fld);
mf = *p;
-
+
rc = fld_handle(ls->ls_fld, *opt, &mf);
if (rc)
- RETURN(rc);
+ RETURN(rc);
reply = lustre_msg_buf(req->rq_repmsg, 0, size);
*reply = mf;
ENTRY;
dt = md2_bottom_dev(m);
-
+
ls = m->mdt_md_dev.md_lu_dev.ld_site;
-
+
OBD_ALLOC_PTR(ls->ls_fld);
-
+
if (!ls->ls_fld)
RETURN(-ENOMEM);
-
+
rc = fld_server_init(ls->ls_fld, dt);
-
+
RETURN(rc);
}
{
struct lu_site *ls = m->mdt_md_dev.md_lu_dev.ld_site;
int rc = 0;
-
+
if (ls && ls->ls_fld) {
fld_server_fini(ls->ls_fld);
OBD_FREE_PTR(ls->ls_fld);
static void mdt_stack_fini(struct mdt_device *m)
{
- if (m->mdt_child) {
- struct lu_device *d = md2lu_dev(m->mdt_child);
- /* goes through all stack */
- while (d != NULL) {
- struct lu_device *n;
- struct obd_type *type;
- struct lu_device_type *ldt = d->ld_type;
-
- lu_device_put(d);
-
- /* each fini() returns next device in stack of layers
- * so we can avoid the recursion */
- n = d->ld_type->ldt_ops->ldto_device_fini(d);
- d->ld_type->ldt_ops->ldto_device_free(d);
-
- type = ldt->obd_type;
- type->typ_refcnt--;
- class_put_type(type);
- /* switch to the next device in the layer */
- d = n;
- }
+ struct lu_device *d = md2lu_dev(m->mdt_child);
+ /* goes through all stack */
+ while (d != NULL) {
+ struct lu_device *n;
+ struct obd_type *type;
+ struct lu_device_type *ldt = d->ld_type;
+
+ lu_device_put(d);
+
+ /* each fini() returns next device in stack of layers
+ * * so we can avoid the recursion */
+ n = ldt->ldt_ops->ldto_device_fini(d);
+ ldt->ldt_ops->ldto_device_free(d);
+
+ type = ldt->obd_type;
+ type->typ_refcnt--;
+ class_put_type(type);
+ /* switch to the next device in the layer */
+ d = n;
}
- return;
}
static struct lu_device *mdt_layer_setup(const char *typename,
CERROR("type: '%s'\n", typename);
GOTO(out_type, rc = -EINVAL);
}
-
+
d = ldt->ldt_ops->ldto_device_alloc(ldt, cfg);
if (IS_ERR(d)) {
CERROR("Cannot allocate device: '%s'\n", typename);
GOTO(out_type, rc = -ENODEV);
}
-
+
LASSERT(child->ld_site);
d->ld_site = child->ld_site;
RETURN(ERR_PTR(rc));
}
-static int mdt_stack_init(struct mdt_device *m, struct lustre_cfg *cfg)
+static int mdt_stack_init(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 */
- d = mdt_layer_setup(LUSTRE_OSD0_NAME, d, cfg);
- if (IS_ERR(d)) {
- GOTO(out, rc = PTR_ERR(d));
+ tmp = mdt_layer_setup(LUSTRE_OSD0_NAME, d, cfg);
+ if (IS_ERR(tmp)) {
+ RETURN (PTR_ERR(tmp));
}
-
- d = mdt_layer_setup(LUSTRE_MDD0_NAME, d, cfg);
- if (IS_ERR(d)) {
- GOTO(out, rc = PTR_ERR(d));
+ d = tmp;
+ tmp = mdt_layer_setup(LUSTRE_MDD0_NAME, d, cfg);
+ if (IS_ERR(tmp)) {
+ GOTO(out, rc = PTR_ERR(tmp));
}
-
- d = mdt_layer_setup(LUSTRE_CMM0_NAME, d, cfg);
- if (IS_ERR(d)) {
- GOTO(out, rc = PTR_ERR(d));
+ d = tmp;
+ tmp = mdt_layer_setup(LUSTRE_CMM0_NAME, d, cfg);
+ if (IS_ERR(tmp)) {
+ GOTO(out, rc = PTR_ERR(tmp));
}
-
+ d = tmp;
m->mdt_child = lu2md_dev(d);
- RETURN(0);
+ /* process setup config */
+ tmp = &m->mdt_md_dev.md_lu_dev;
+ rc = tmp->ld_ops->ldo_process_config(tmp, cfg);
+
out:
- mdt_stack_fini(m);
+ /* fini from last known good lu_device */
+ if (rc)
+ mdt_stack_fini(d);
+
return rc;
}
{
struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
+ ENTRY;
+
mdt_stop_ptlrpc_service(m);
+
+ /* finish the stack */
+ mdt_stack_fini(m);
+
if (d->ld_site != NULL) {
lu_site_fini(d->ld_site);
OBD_FREE_PTR(d->ld_site);
m->mdt_namespace = NULL;
}
- /* finish the stack */
- mdt_stack_fini(m);
-
if (m->mdt_seq_mgr) {
seq_mgr_fini(m->mdt_seq_mgr);
m->mdt_seq_mgr = NULL;
LASSERT(atomic_read(&d->ld_ref) == 0);
md_device_fini(&m->mdt_md_dev);
+ EXIT;
}
static int mdt_init0(struct mdt_device *m,
struct lu_site *s;
char ns_name[48];
struct lu_context ctx;
+
ENTRY;
OBD_ALLOC_PTR(s);
md_device_init(&m->mdt_md_dev, t);
m->mdt_md_dev.md_lu_dev.ld_ops = &mdt_lu_ops;
-
- rc = lu_site_init(s, &m->mdt_md_dev.md_lu_dev, cfg);
+
+ rc = lu_site_init(s, &m->mdt_md_dev.md_lu_dev);
if (rc) {
CERROR("can't init lu_site, rc %d\n", rc);
GOTO(err_fini_site, rc);
}
+
/* init the stack */
rc = mdt_stack_init(m, cfg);
if (rc) {
m->mdt_seq_mgr = NULL;
err_fini_stack:
mdt_stack_fini(m);
-
err_fini_site:
lu_site_fini(s);
OBD_FREE_PTR(s);
RETURN(rc);
}
+/* used by MGS to process specific configurations */
+static int mdt_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+{
+ struct lu_device *next = md2lu_dev(mdt_dev(d)->mdt_child);
+ int err;
+ ENTRY;
+ switch(cfg->lcfg_command) {
+ /* all MDT specific commands should be here */
+ default:
+ /* others are passed further */
+ err = next->ld_ops->ldo_process_config(next, cfg);
+ }
+out:
+ RETURN(err);
+}
static struct lu_object *mdt_object_alloc(struct lu_context *ctxt,
struct lu_device *d)
static void mdt_object_free(struct lu_context *ctxt, struct lu_object *o)
{
- struct mdt_object *mo = lu2mdt_obj(o);
+ struct mdt_object *mo = mdt_obj(o);
struct lu_object_header *h;
h = o->lo_header;
.ldo_object_init = mdt_object_init,
.ldo_object_free = mdt_object_free,
.ldo_object_release = mdt_object_release,
- .ldo_object_print = mdt_object_print
+ .ldo_object_print = mdt_object_print,
+ .ldo_process_config = mdt_process_config
};
/* mds_connect copy */
exp = class_conn2export(conn);
LASSERT(exp);
med = &exp->exp_mds_data;
-
+
OBD_ALLOC_PTR(mcd);
if (!mcd)
GOTO(out, rc = -ENOMEM);
spin_unlock(&svc->srv_lock);
}
spin_unlock_irqrestore(&exp->exp_lock, irqflags);
-
+
OBD_FREE_PTR(med->med_mcd);
class_export_put(exp);