RETURN (rc);
}
+static int cmm_get_maxsize(const struct lu_context *ctxt, struct md_device *md,
+ int *md_size, int *cookie_size)
+{
+ struct cmm_device *cmm_dev = md2cmm_dev(md);
+ int rc;
+ ENTRY;
+ rc = cmm_child_ops(cmm_dev)->mdo_get_maxsize(ctxt,
+ cmm_dev->cmm_child, md_size, cookie_size);
+ RETURN(rc);
+}
+
static struct md_device_operations cmm_md_ops = {
.mdo_root_get = cmm_root_get,
.mdo_statfs = cmm_statfs,
+ .mdo_get_maxsize = cmm_get_maxsize,
};
extern struct lu_device_type mdc_device_type;
};
/* --- lu_device_type operations --- */
+static int cmm_upcall(const struct lu_context *ctxt, struct md_device *md,
+ enum md_upcall_event ev)
+{
+ struct md_device *upcall_dev;
+ int rc;
+ ENTRY;
+
+ upcall_dev = md->md_upcall.mu_upcall_dev;
+
+ LASSERT(upcall_dev);
+ rc = upcall_dev->md_upcall.mu_upcall(ctxt, md->md_upcall.mu_upcall_dev, ev);
+
+ RETURN(rc);
+}
static struct lu_device *cmm_device_alloc(const struct lu_context *ctx,
struct lu_device_type *t,
} else {
md_device_init(&m->cmm_md_dev, t);
m->cmm_md_dev.md_ops = &cmm_md_ops;
+ m->cmm_md_dev.md_upcall.mu_upcall = cmm_upcall;
l = cmm2lu_dev(m);
l->ld_ops = &cmm_lu_ops;
}
struct md_device *m, struct lu_fid *f);
int (*mdo_statfs)(const struct lu_context *ctx,
struct md_device *m, struct kstatfs *sfs);
+ int (*mdo_get_maxsize)(const struct lu_context *ctx,
+ struct md_device *m, int *md_size,
+ int *cookie_size);
+};
+
+enum md_upcall_event {
+ /*sync the md layer*/
+ MD_LOV_SYNC
+};
+
+struct md_upcall {
+ struct md_device *mu_upcall_dev;
+ int (*mu_upcall)(const struct lu_context *ctxt, struct md_device *md,
+ enum md_upcall_event ev);
};
struct md_device {
struct lu_device md_lu_dev;
struct md_device_operations *md_ops;
+ struct md_upcall md_upcall;
};
struct md_object {
return p->mo_dir_ops->mdo_rename_tgt(cx, p, t, lf, name);
}
}
+
#endif /* _LINUX_MD_OBJECT_H */
}
static int mdd_statfs(const struct lu_context *ctx,
- struct md_device *m, struct kstatfs *sfs) {
+ struct md_device *m, struct kstatfs *sfs)
+{
struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
int rc;
RETURN(rc);
}
+static int mdd_get_maxsize(const struct lu_context *ctx,
+ struct md_device *m, int *md_size,
+ int *cookie_size)
+{
+ struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
+ int rc;
+
+ ENTRY;
+
+ rc = mdd_lov_mdsize(ctx, mdd, md_size);
+ if (rc)
+ RETURN(rc);
+ rc = mdd_lov_cookiesize(ctx, mdd, cookie_size);
+
+ RETURN(rc);
+}
+
static void __mdd_ref_add(const struct lu_context *ctxt, struct mdd_object *obj,
struct thandle *handle)
{
struct md_device_operations mdd_ops = {
.mdo_root_get = mdd_root_get,
.mdo_statfs = mdd_statfs,
+ .mdo_get_maxsize = mdd_get_maxsize,
};
static struct md_dir_operations mdd_dir_ops = {
{
return mdd->mdd_md_dev.md_lu_dev.ld_obd;
}
+
+int mdd_lov_mdsize(const struct lu_context *ctxt, struct mdd_device *mdd,
+ int *md_size);
+int mdd_lov_cookiesize(const struct lu_context *ctxt, struct mdd_device *mdd,
+ int *cookie_size);
#endif
.ml_write_catlist = mdd_lov_write_catlist
};
+static int mdd_lov_update(struct obd_device *host,
+ struct obd_device *watched,
+ enum obd_notify_event ev, void *owner)
+{
+ struct mdd_device *mdd = owner;
+ struct obd_device *obd;
+ struct md_device *upcall_dev;
+ int rc;
+ ENTRY;
+
+ LASSERT(owner != NULL);
+ obd = mdd2_obd(mdd);
+
+ upcall_dev = mdd->mdd_md_dev.md_upcall.mu_upcall_dev;
+
+ rc = upcall_dev->md_upcall.mu_upcall(NULL, upcall_dev, MD_LOV_SYNC);
+
+ RETURN(rc);
+}
+
/*The obd is created for handling data stack for mdd*/
int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
char *dev)
rc = class_setup(obd, lcfg);
if (rc)
GOTO(class_detach, rc);
+ /*Add here for obd notify mechiasm,
+ *when adding a new ost, the mds will notify this mdd*/
+ obd->obd_upcall.onu_owner = mdd;
+ obd->obd_upcall.onu_upcall = mdd_lov_update;
mdd->mdd_md_dev.md_lu_dev.ld_obd = obd;
class_detach:
if (rc)
}
return 0;
}
+
+int mdd_lov_mdsize(const struct lu_context *ctxt, struct mdd_device *mdd,
+ int *md_size)
+{
+ struct obd_device *obd = mdd2_obd(mdd);
+ *md_size = obd->u.mds.mds_max_mdsize;
+ RETURN(0);
+}
+
+int mdd_lov_cookiesize(const struct lu_context *ctxt, struct mdd_device *mdd,
+ int *cookie_size)
+{
+ struct obd_device *obd = mdd2_obd(mdd);
+ *cookie_size = obd->u.mds.mds_max_cookiesize;
+ RETURN(0);
+}
+
obd->obd_name, rc);
GOTO(out, rc);
}
-
+ if (obd->obd_upcall.onu_owner) {
+ /*This is an hack for mds_notify->mdd_notify,
+ *When the mds obd in mdd is removed,
+ *This hack should be removed*/
+ LASSERT(obd->obd_upcall.onu_upcall != NULL);
+ obd->obd_upcall.onu_upcall(NULL, NULL, 0,
+ obd->obd_upcall.onu_owner);
+ }
out:
class_decref(obd);
RETURN(rc);
opc = mdt_reint_opcode(info, reint_fmts);
if (opc >= 0) {
OBD_FAIL_RETURN(OBD_FAIL_MDS_REINT_NET, 0);
-
+
rc = req_capsule_pack(&info->mti_pill);
if (rc == 0)
rc = mdt_reint_internal(info, opc);
GOTO(out_alloc, rc);
}
lu_device_get(d);
-
+
RETURN(d);
out_alloc:
ldt->ldt_ops->ldto_device_free(ctx, d);
{
struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
struct lu_device *tmp;
+ struct md_device *md;
int rc;
ENTRY;
GOTO(out, rc = PTR_ERR(tmp));
}
d = tmp;
+ md = lu2md_dev(d);
+
tmp = mdt_layer_setup(ctx, LUSTRE_CMM0_NAME, d, cfg);
if (IS_ERR(tmp)) {
GOTO(out, rc = PTR_ERR(tmp));
}
d = tmp;
+ /*set mdd upcall device*/
+ md->md_upcall.mu_upcall_dev = lu2md_dev(d);
+
+ md = lu2md_dev(d);
+ /*set cmm upcall device*/
+ md->md_upcall.mu_upcall_dev = &m->mdt_md_dev;
+
m->mdt_child = lu2md_dev(d);
/* process setup config */
static int mdt_process_config(const struct lu_context *ctx,
struct lu_device *d, struct lustre_cfg *cfg)
{
- struct lu_device *next = md2lu_dev(mdt_dev(d)->mdt_child);
+ struct mdt_device *m = mdt_dev(d);
+ struct md_device *md_next = m->mdt_child;
+ struct lu_device *next = md2lu_dev(md_next);
int err;
ENTRY;
CERROR("can't initialize controller export, "
"rc %d\n", err);
}
- /* all MDT specific commands should be here */
default:
/* others are passed further */
err = next->ld_ops->ldo_process_config(ctx, next, cfg);
+ break;
}
RETURN(err);
}
RETURN(rc);
}
+static int mdt_upcall(const struct lu_context *ctx, struct md_device *md,
+ enum md_upcall_event ev)
+{
+ struct mdt_device *m = mdt_dev(&md->md_lu_dev);
+ struct md_device *next = m->mdt_child;
+ int rc = 0;
+ ENTRY;
+
+ switch (ev) {
+ case MD_LOV_SYNC:
+ rc = next->md_ops->mdo_get_maxsize(ctx, next,
+ &m->mdt_max_mdsize, &m->mdt_max_cookiesize);
+ CDEBUG(D_INFO, "get max mdsize %d max cookiesize %d \n",
+ m->mdt_max_mdsize, m->mdt_max_cookiesize);
+ break;
+ default:
+ CERROR("invalid event\n");
+ rc = -EINVAL;
+ break;
+ }
+ RETURN(rc);
+}
+
+
static struct obd_ops mdt_obd_device_ops = {
.o_owner = THIS_MODULE,
.o_connect = mdt_obd_connect,
OBD_FREE_PTR(m);
l = ERR_PTR(result);
}
+ m->mdt_md_dev.md_upcall.mu_upcall = mdt_upcall;
} else
l = ERR_PTR(-ENOMEM);
return l;