cmm_dev->cmm_child, fid);
}
-static int cmm_config(const struct lu_context *ctxt, struct md_device *md,
- const char *name, void *buf, int size, int mode)
-{
- struct cmm_device *cmm_dev = md2cmm_dev(md);
- int rc;
- ENTRY;
- rc = cmm_child_ops(cmm_dev)->mdo_config(ctxt, cmm_dev->cmm_child,
- name, buf, size, mode);
- RETURN(rc);
-}
-
static int cmm_statfs(const struct lu_context *ctxt, struct md_device *md,
struct kstatfs *sfs) {
struct cmm_device *cmm_dev = md2cmm_dev(md);
static struct md_device_operations cmm_md_ops = {
.mdo_root_get = cmm_root_get,
- .mdo_config = cmm_config,
.mdo_statfs = cmm_statfs,
};
struct lu_device_type *ldt = &mdc_device_type;
struct lu_device *ld;
struct mdc_device *mc;
-#ifdef CMM_CODE
struct mdc_device *tmp;
__u32 mdc_num;
-#endif
int rc;
ENTRY;
-#ifdef CMM_CODE
/* find out that there is no such mdc */
LASSERT(lustre_cfg_string(cfg, 2));
mdc_num = simple_strtol(lustre_cfg_string(cfg, 2), NULL, 10);
RETURN(-EEXIST);
}
spin_unlock(&cm->cmm_tgt_guard);
-#endif
ld = ldt->ldt_ops->ldto_device_alloc(ctx, ldt, cfg);
ld->ld_site = cmm2lu_dev(cm)->ld_site;
rc = ld->ld_ops->ldo_process_config(ctx, ld, cfg);
if (rc == 0) {
mc = lu2mdc_dev(ld);
-#ifdef CMM_CODE
spin_lock(&cm->cmm_tgt_guard);
-#endif
list_add_tail(&mc->mc_linkage, &cm->cmm_targets);
cm->cmm_tgt_count++;
-#ifdef CMM_CODE
spin_unlock(&cm->cmm_tgt_guard);
-#endif
+
lu_device_get(cmm2lu_dev(cm));
fld_client_add_export(&cm->cmm_fld,
ENTRY;
-#ifdef CMM_CODE
spin_lock_init(&m->cmm_tgt_guard);
-#endif
INIT_LIST_HEAD(&m->cmm_targets);
m->cmm_tgt_count = 0;
m->cmm_child = lu2md_dev(next);
err = fld_client_init(&m->cmm_fld, LUSTRE_CLI_FLD_HASH_RRB);
if (err) {
- CERROR("can't init FLD, err %d\n",
- err);
+ CERROR("can't init FLD, err %d\n", err);
}
-
RETURN(err);
}
struct cmm_device *cm = lu2cmm_dev(ld);
struct mdc_device *mc, *tmp;
ENTRY;
-
- fld_client_fini(&cm->cmm_fld);
+ fld_client_fini(&cm->cmm_fld);
/* finish all mdc devices */
list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) {
struct lu_device *ld_m = mdc2lu_dev(mc);
#include <lustre_fld.h>
#include <md_object.h>
-#ifdef CMM_CODE
struct cmm_device {
struct md_device cmm_md_dev;
/* underlaying device in MDS stack, usually MDD */
struct cmm_object {
struct md_object cmo_obj;
+ int cmo_local;
};
/* local CMM objec */
struct cmm_object cmm_obj;
/* mds number where object is placed */
__u32 cmo_num;
-}
+};
static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
{
static inline int cmm_is_local_obj(struct cmm_object *c)
{
- return (c->cmo_num == cmm_obj2dev(c)->cmm_local_num);
+ return (c->cmo_local);
}
const struct lu_object_header *hdr,
struct lu_device *);
-#else
-
-struct cmm_device {
- struct md_device cmm_md_dev;
- /* underlaying device in MDS stack, usually MDD */
- struct md_device *cmm_child;
- /* other MD servers in cluster */
- __u32 cmm_local_num;
- __u32 cmm_tgt_count;
- struct list_head cmm_targets;
- /* client FLD interface */
- struct lu_client_fld cmm_fld;
-};
-
-static inline struct md_device_operations *cmm_child_ops(struct cmm_device *d)
-{
- return (d->cmm_child->md_ops);
-}
-
-static inline struct cmm_device *md2cmm_dev(struct md_device *m)
-{
- return container_of0(m, struct cmm_device, cmm_md_dev);
-}
-
-static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
-{
- //LASSERT(lu_device_is_cmm(d));
- return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
-}
-
-static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
-{
- return (&d->cmm_md_dev.md_lu_dev);
-}
-
-struct cmm_object {
- struct md_object cmo_obj;
- /* mds number where object is placed */
- __u32 cmo_num;
-};
-
-static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
-{
- return (md2cmm_dev(md_device_get(&c->cmo_obj)));
-}
-
-static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
-{
- //LASSERT(lu_device_is_cmm(o->lo_dev));
- return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
-}
-
-static inline int cmm_is_local_obj(struct cmm_object *c)
-{
- return (c->cmo_num == cmm_obj2dev(c)->cmm_local_num);
-}
-
-/* get cmm object from md_object */
-static inline struct cmm_object *md2cmm_obj(struct md_object *o)
-{
- return container_of0(o, struct cmm_object, cmo_obj);
-}
-/* get lower-layer object */
-static inline struct md_object *cmm2child_obj(struct cmm_object *o)
-{
- return lu2md(lu_object_next(&o->cmo_obj.mo_lu));
-}
-
-/* cmm_object.c */
-struct lu_object *cmm_object_alloc(const struct lu_context *ctx,
- const struct lu_object_header *hdr,
- struct lu_device *);
-#endif
#endif /* __KERNEL__ */
#endif /* _CMM_INTERNAL_H */
return 0;
}
-#ifdef CMM_CODE
static int cmm_fld_lookup(struct cmm_device *cm,
const struct lu_fid *fid)
{
__u64 mds;
int rc;
ENTRY;
-
+ return 0;
LASSERT(fid_is_sane(fid));
- rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), &mds);
- if (rc) {
- CERROR("can't find mds by seq "LPU64", rc %d\n",
- fid_seq(fid), rc);
- RETURN(rc);
+
+ /* XXX: is this correct? We need this to prevent FLD lookups while CMM
+ * did not initialized yet all MDCs. */
+ if (cmm_special_fid(fid))
+ mds = 0;
+ else {
+ rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), &mds);
+ if (rc) {
+ CERROR("can't find mds by seq "LPU64", rc %d\n",
+ fid_seq(fid), rc);
+ RETURN(rc);
+ }
}
CWARN("CMM: got MDS "LPU64" for sequence: "LPU64"\n",
mds, fid_seq(fid));
+
RETURN((int)mds);
}
struct lu_device *ld)
{
struct lu_object *lo = NULL;
- const struct lu_fid *fid = loh->loh_fid;
- int mdsnum, rc;
+ const struct lu_fid *fid = &loh->loh_fid;
+ int mdsnum;
ENTRY;
- /* XXX: is this correct? We need this to prevent FLD lookups while CMM
- * did not initialized yet all MDCs. */
- if (cmm_special_fid(fid))
- mdsnum = 0;
- else
- /* get object location */
- mdsnum = cmm_fld_lookup(lu2cmm_dev(ld), fid);
+ /* get object location */
+ mdsnum = cmm_fld_lookup(lu2cmm_dev(ld), fid);
/* select the proper set of operations based on object location */
if (mdsnum == lu2cmm_dev(ld)->cmm_local_num) {
clo->cmm_obj.cmo_obj.mo_ops = &cml_mo_ops;
clo->cmm_obj.cmo_obj.mo_dir_ops = &cml_dir_ops;
lo->lo_ops = &cml_obj_ops;
+ clo->cmm_obj.cmo_local = 1;
}
} else {
struct cmr_object *cro;
cro->cmm_obj.cmo_obj.mo_dir_ops = &cmr_dir_ops;
lo->lo_ops = &cmr_obj_ops;
cro->cmo_num = mdsnum;
+ cro->cmm_obj.cmo_local = 0;
}
}
RETURN(lo);
/* get local child device */
static struct lu_device *cml_child_dev(struct cmm_device *d)
{
- return next = &d->cmm_child->md_lu_dev;
+ return &d->cmm_child->md_lu_dev;
}
/* lu_object operations */
if (mo_t && !cmm_is_local_obj(md2cmm_obj(mo_t))) {
/* remote object */
- rc = moo_ref_del(ctx, cmm2child_obj(md2cmm_obj(mo_t)));
+ rc = mo_ref_del(ctx, cmm2child_obj(md2cmm_obj(mo_t)));
if (rc)
RETURN(rc);
mo_t = NULL;
int rc;
ENTRY;
- rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_po)),
+ rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_p)),
cmm2child_obj(md2cmm_obj(mo_t)), lf, name);
RETURN(rc);
}
-static struct md_dir_operations cmm_dir_ops = {
+static struct md_dir_operations cml_dir_ops = {
.mdo_lookup = cml_lookup,
.mdo_create = cml_create,
.mdo_link = cml_link,
struct cmm_device *cd = lu2cmm_dev(lo->lo_dev);
struct lu_device *c_dev;
struct lu_object *c_obj;
- const struct lu_fid *fid = lu_object_fid(lo);
int rc;
ENTRY;
RETURN(rc);
}
-
static int cmr_object_exists(const struct lu_context *ctx,
struct lu_object *lo)
{
return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", lo);
}
-static struct lu_object_operations cml_obj_ops = {
+static struct lu_object_operations cmr_obj_ops = {
.loo_object_init = cmr_object_init,
.loo_object_free = cmr_object_free,
.loo_object_print = cmr_object_print,
RETURN(-EFAULT);
}
-static struct md_object_operations cml_mo_ops = {
+static struct md_object_operations cmr_mo_ops = {
.moo_attr_get = cmr_attr_get,
.moo_attr_set = cmr_attr_set,
.moo_xattr_get = cmr_xattr_get,
rc = mo_ref_del(ctx, cmm2child_obj(md2cmm_obj(mo_c)));
if (rc == 0) {
rc = mdo_name_remove(ctx, cmm2child_obj(md2cmm_obj(mo_p)),
- name, lu_object_fid(&mo_c->mo_lu));
+ name);
}
RETURN(rc);
* lookup and process this further */
LASSERT(mo_t == NULL);
- rc = mdo_rename_tgt(ctx, c_pn, NULL/* mo_t */, lf, t_name);
+ rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_pn)), NULL/* mo_t */,
+ lf, t_name);
/* only old name is removed localy */
if (rc == 0)
- rc = mdo_name_remove(ctx, c_po, s_name);
+ rc = mdo_name_remove(ctx, cmm2child_obj(md2cmm_obj(mo_po)),
+ s_name);
RETURN(rc);
}
/* target object is remote one */
rc = mo_ref_del(ctx, cmm2child_obj(md2cmm_obj(mo_t)));
/* continue locally with name handling only */
- rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_po)),
- NULL, lf, name);
+ if (rc == 0)
+ rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_p)),
+ NULL, lf, name);
RETURN(rc);
}
-static struct md_dir_operations cmm_dir_ops = {
+static struct md_dir_operations cmr_dir_ops = {
.mdo_lookup = cmr_lookup,
.mdo_create = cmr_create,
.mdo_link = cmr_link,
.mdo_rename_tgt = cmr_rename_tgt,
};
-#else /* CMM_CODE */
-static struct md_object_operations cmm_mo_ops;
-static struct md_dir_operations cmm_dir_ops;
-static struct lu_object_operations cmm_obj_ops;
-
-static int cmm_fld_lookup(struct cmm_device *cm,
- const struct lu_fid *fid)
-{
- __u64 mds;
- int rc;
- ENTRY;
-
- LASSERT(fid_is_sane(fid));
- rc = fld_client_lookup(&cm->cmm_fld, fid_seq(fid), &mds);
- if (rc) {
- CERROR("can't find mds by seq "LPU64", rc %d\n",
- fid_seq(fid), rc);
- RETURN(rc);
- }
- CWARN("CMM: got MDS "LPU64" for sequence: "LPU64"\n",
- mds, fid_seq(fid));
- RETURN((int)mds);
-}
-
-/* get child device by mdsnum */
-static struct lu_device *cmm_get_child(struct cmm_device *d, __u32 num)
-{
- struct lu_device *next = NULL;
- ENTRY;
- if (likely(num == d->cmm_local_num)) {
- next = &d->cmm_child->md_lu_dev;
- } else {
- struct mdc_device *mdc;
- list_for_each_entry(mdc, &d->cmm_targets, mc_linkage) {
- if (mdc->mc_num == num) {
- next = mdc2lu_dev(mdc);
- break;
- }
- }
- }
- RETURN(next);
-}
-
-struct lu_object *cmm_object_alloc(const struct lu_context *ctx,
- const struct lu_object_header *hdr,
- struct lu_device *ld)
-{
- struct cmm_object *co;
- struct lu_object *lo;
- ENTRY;
-
- OBD_ALLOC_PTR(co);
- if (co != NULL) {
- lo = &co->cmo_obj.mo_lu;
- lu_object_init(lo, NULL, ld);
- co->cmo_obj.mo_ops = &cmm_mo_ops;
- co->cmo_obj.mo_dir_ops = &cmm_dir_ops;
- lo->lo_ops = &cmm_obj_ops;
- } else
- lo = NULL;
-
- RETURN(lo);
-}
-
-static void cmm_object_free(const struct lu_context *ctx, struct lu_object *lo)
-{
- struct cmm_object *co = lu2cmm_obj(lo);
- lu_object_fini(lo);
- OBD_FREE_PTR(co);
-}
-
-static int cmm_object_init(const struct lu_context *ctx, struct lu_object *lo)
-{
- struct cmm_device *cd = lu2cmm_dev(lo->lo_dev);
- struct lu_device *c_dev;
- struct lu_object *c_obj;
- const struct lu_fid *fid = lu_object_fid(lo);
- int mdsnum, rc;
-
- ENTRY;
-
- /* XXX: is this correct? We need this to prevent FLD lookups while CMM
- * did not initialized yet all MDCs. */
- if (cmm_special_fid(fid))
- mdsnum = 0;
- else
- mdsnum = cmm_fld_lookup(cd, fid);
-
- /* under device can be MDD or MDC */
- c_dev = cmm_get_child(cd, mdsnum);
- if (c_dev == NULL) {
- rc = -ENOENT;
- } else {
- c_obj = c_dev->ld_ops->ldo_object_alloc(ctx,
- lo->lo_header, c_dev);
- if (c_obj != NULL) {
- struct cmm_object *co = lu2cmm_obj(lo);
-
- lu_object_add(lo, c_obj);
- co->cmo_num = mdsnum;
- rc = 0;
- } else {
- rc = -ENOMEM;
- }
- }
-
- RETURN(rc);
-}
-
-static int cmm_object_exists(const struct lu_context *ctx, struct lu_object *lo)
-{
- return lu_object_exists(ctx, lu_object_next(lo));
-}
-
-static int cmm_object_print(const struct lu_context *ctx,
- struct seq_file *f, const struct lu_object *lo)
-{
- return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", lo);
-}
-
-static struct lu_object_operations cmm_obj_ops = {
- .loo_object_init = cmm_object_init,
- .loo_object_free = cmm_object_free,
- .loo_object_print = cmm_object_print,
- .loo_object_exists = cmm_object_exists
-};
-
-/* md_object operations */
-static int cmm_object_create(const struct lu_context *ctx, struct md_object *mo,
- struct lu_attr *attr)
-{
- struct md_object *ch = cmm2child_obj(md2cmm_obj(mo));
- int rc;
-
- ENTRY;
-
- LASSERT (cmm_is_local_obj(md2cmm_obj(mo)));
-
- rc = mo_object_create(ctx, ch, attr);
-
- RETURN(rc);
-}
-
-static int cmm_attr_get(const struct lu_context *ctx, struct md_object *mo,
- struct lu_attr *attr)
-{
- struct md_object *ch = cmm2child_obj(md2cmm_obj(mo));
- int rc;
-
- ENTRY;
-
- LASSERT (cmm_is_local_obj(md2cmm_obj(mo)));
-
- rc = mo_attr_get(ctx, ch, attr);
-
- RETURN(rc);
-}
-
-static struct md_object_operations cmm_mo_ops = {
- .moo_attr_get = cmm_attr_get,
- .moo_object_create = cmm_object_create,
-};
-
-static int cmm_lookup(const struct lu_context *ctx, struct md_object *mo_p,
- const char *name, struct lu_fid *lf)
-{
- struct md_object *ch_p = cmm2child_obj(md2cmm_obj(mo_p));
- int rc;
-
- ENTRY;
-
- LASSERT(cmm_is_local_obj(md2cmm_obj(mo_p)));
-
- rc = mdo_lookup(ctx, ch_p, name, lf);
-
- RETURN(rc);
-
-}
-
-static int cmm_create(const struct lu_context *ctx,
- struct md_object *mo_p, const char *name,
- struct md_object *mo_c, struct lu_attr *attr)
-{
- struct md_object *ch_c = cmm2child_obj(md2cmm_obj(mo_c));
- struct md_object *ch_p = cmm2child_obj(md2cmm_obj(mo_p));
- int rc;
-
- ENTRY;
-
- if (cmm_is_local_obj(md2cmm_obj(mo_c))) {
- rc = mdo_create(ctx, ch_p, name, ch_c, attr);
- } else {
- const struct lu_fid *lf = lu_object_fid(&mo_c->mo_lu);
-
- /* remote object creation and local name insert */
- rc = mo_object_create(ctx, ch_c, attr);
- if (rc == 0) {
- rc = mdo_name_insert(ctx, ch_p, name, lf);
- }
- }
-
- RETURN(rc);
-}
-
-static int cmm_mkdir(const struct lu_context *ctx, struct lu_attr *attr,
- struct md_object *mo_p, const char *name,
- struct md_object *mo_c)
-{
- struct md_object *ch_c = cmm2child_obj(md2cmm_obj(mo_c));
- struct md_object *ch_p = cmm2child_obj(md2cmm_obj(mo_p));
- int rc;
-
- ENTRY;
-
- if (cmm_is_local_obj(md2cmm_obj(mo_c))) {
- /* fully local mkdir */
- rc = mdo_mkdir(ctx, attr, ch_p, name, ch_c);
- } else {
- const struct lu_fid *lf = lu_object_fid(&mo_c->mo_lu);
-
- /* remote object creation and local name insert */
- rc = mo_object_create(ctx, ch_c, attr);
- if (rc == 0) {
- rc = mdo_name_insert(ctx, ch_p, name, lf);
- }
- }
-
- RETURN(rc);
-}
-
-static struct md_dir_operations cmm_dir_ops = {
- .mdo_lookup = cmm_lookup,
- .mdo_mkdir = cmm_mkdir,
- .mdo_create = cmm_create
-};
-#endif /* CMM_CODE */
-
ld->ld_ops == &mdc_lu_ops);
}
-#ifdef CMM_CODE
static struct md_device_operations mdc_md_ops = { 0 };
static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg)
CERROR("No such OBD %s\n", srv);
LBUG();
}
- obd_str2uuid(&desc->mc_cli_uuid, uuid_str);
- mdc = class_find_client_obd(&desc->mc_cli_uuid, LUSTRE_MDC_NAME,
+ obd_str2uuid(&desc->cl_cli_uuid, uuid_str);
+ mdc = class_find_client_obd(&desc->cl_cli_uuid, LUSTRE_MDC_NAME,
&mdt->obd_uuid);
if (!mdc) {
CERROR("Cannot find MDC OBD connected to %s\n", uuid_str);
ENTRY;
CDEBUG(D_CONFIG, "disconnect from %s(%s)\n",
- mdc->obd_name, mdc->obd_uuid.uuid);
+ class_exp2obd(desc->cl_exp)->obd_name, desc->cl_cli_uuid.uuid);
- rc = obd_disconnect(desc->cli_exp);
+ rc = obd_disconnect(desc->cl_exp);
if (rc) {
CERROR("target %s disconnect error %d\n",
class_exp2obd(desc->cl_exp)->obd_name, rc);
/* context key constructor/destructor */
-static void *mdÓ_thread_init(const struct lu_context *ctx,
+static void *mdc_thread_init(const struct lu_context *ctx,
struct lu_context_key *key)
{
- struct mdÓ_thread_info *info;
+ struct mdc_thread_info *info;
CLASSERT(CFS_PAGE_SIZE >= sizeof *info);
OBD_ALLOC_PTR(info);
void mdc_type_fini(struct lu_device_type *ldt)
{
- lu_context_key_deregister(&mdc_thread_key);
+ lu_context_key_degister(&mdc_thread_key);
}
static struct lu_device_type_operations mdc_device_type_ops = {
.ldt_name = LUSTRE_MDC0_NAME,
.ldt_ops = &mdc_device_type_ops
};
-#else
-static int mdc_root_get(const struct lu_context *ctx, struct md_device *md,
- struct lu_fid *fid)
-{
- //struct mdc_device *mdc_dev = md2mdc_dev(md);
-
- return -EOPNOTSUPP;
-}
-
-static int mdc_config(const struct lu_context *ctx,
- struct md_device *md, const char *name,
- void *buf, int size, int mode)
-{
- //struct mdc_device *mdc_dev = md2mdc_dev(md);
- int rc;
- ENTRY;
- rc = -EOPNOTSUPP;
- RETURN(rc);
-}
-
-static int mdc_statfs(const struct lu_context *ctx,
- struct md_device *md, struct kstatfs *sfs) {
- //struct mdc_device *mdc_dev = md2mdc_dev(md);
- int rc;
-
- ENTRY;
- rc = -EOPNOTSUPP;
- RETURN (rc);
-}
-
-static struct md_device_operations mdc_md_ops = {
- .mdo_root_get = mdc_root_get,
- .mdo_config = mdc_config,
- .mdo_statfs = mdc_statfs,
-};
-
-static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg)
-{
- struct mdc_cli_desc *desc = &mc->mc_desc;
- struct obd_device *mdc, *mdt;
- const char *srv = lustre_cfg_string(cfg, 0);
- const char *uuid_str = lustre_cfg_string(cfg, 1);
- const char *index = lustre_cfg_string(cfg, 2);
- struct obd_uuid uuid;
- int rc = 0;
-
- //find mdt obd to get group uuid
- mdt = class_name2obd(srv);
- if (mdt == NULL) {
- CERROR("No such OBD %s\n", srv);
- LBUG();
- }
- obd_str2uuid(&uuid, uuid_str);
- mdc = class_find_client_obd(&uuid, LUSTRE_MDC_NAME, &mdt->obd_uuid);
- if (!mdc) {
- CERROR("Cannot find MDC OBD connected to %s\n", uuid_str);
- rc = -ENOENT;
- } else if (!mdc->obd_set_up) {
- CERROR("target %s not set up\n", mdc->obd_name);
- rc = -EINVAL;
- } else {
- struct lustre_handle conn = {0, };
-
- 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) {
- CERROR("target %s connect error %d\n",
- mdc->obd_name, rc);
- } else {
- desc->cl_exp = class_conn2export(&conn);
- mc->mc_num = simple_strtol(index, NULL, 10);
- }
- }
-
- RETURN(rc);
-}
-
-static int mdc_process_config(const struct lu_context *ctx,
- struct lu_device *ld, struct lustre_cfg *cfg)
-{
- struct mdc_device *mc = lu2mdc_dev(ld);
- int rc;
-
- ENTRY;
- switch (cfg->lcfg_command) {
- case LCFG_ADD_MDC:
- rc = mdc_add_obd(mc, cfg);
- break;
- default:
- rc = -EOPNOTSUPP;
- }
- RETURN(rc);
-}
-
-static struct lu_device_operations mdc_lu_ops = {
- .ldo_object_alloc = mdc_object_alloc,
- .ldo_process_config = mdc_process_config
-};
-
-static int mdc_device_init(const struct lu_context *ctx,
- struct lu_device *ld, struct lu_device *next)
-{
- /* struct mdc_device *mc = lu2mdc_dev(ld); */
- int rc = 0;
-
- ENTRY;
-
- RETURN(rc);
-}
-
-static struct lu_device *mdc_device_fini(const struct lu_context *ctx,
- struct lu_device *ld)
-{
- /* struct mdc_device *mc = lu2mdc_dev(ld); */
-
- ENTRY;
-
- RETURN (NULL);
-}
-
-struct lu_device *mdc_device_alloc(const struct lu_context *ctx,
- struct lu_device_type *ldt,
- struct lustre_cfg *cfg)
-{
- struct lu_device *ld;
- struct mdc_device *mc;
-
- ENTRY;
-
- OBD_ALLOC_PTR(mc);
- if (mc == NULL) {
- ld = ERR_PTR(-ENOMEM);
- } else {
- md_device_init(&mc->mc_md_dev, ldt);
- mc->mc_md_dev.md_ops = &mdc_md_ops;
- ld = mdc2lu_dev(mc);
- ld->ld_ops = &mdc_lu_ops;
- }
-
- RETURN (ld);
-}
-void mdc_device_free(const struct lu_context *ctx, struct lu_device *ld)
-{
- struct mdc_device *mc = lu2mdc_dev(ld);
-
- LASSERT(atomic_read(&ld->ld_ref) == 0);
- md_device_fini(&mc->mc_md_dev);
- OBD_FREE_PTR(mc);
-}
-
-int mdc_type_init(struct lu_device_type *ldt)
-{
- return 0;
-}
-
-void mdc_type_fini(struct lu_device_type *ldt)
-{
- return;
-}
-
-static struct lu_device_type_operations mdc_device_type_ops = {
- .ldto_init = mdc_type_init,
- .ldto_fini = mdc_type_fini,
-
- .ldto_device_alloc = mdc_device_alloc,
- .ldto_device_free = mdc_device_free,
-
- .ldto_device_init = mdc_device_init,
- .ldto_device_fini = mdc_device_fini
-};
-
-struct lu_device_type mdc_device_type = {
- .ldt_tags = LU_DEVICE_MD,
- .ldt_name = LUSTRE_MDC0_NAME,
- .ldt_ops = &mdc_device_type_ops
-};
-#endif /* CMM_CODE */
#include <lustre_net.h>
#include <obd.h>
#include <md_object.h>
-
struct mdc_cli_desc {
struct obd_connect_data cl_conn_data;
struct obd_uuid cl_cli_uuid;
struct mdc_cli_desc mc_desc;
};
-#ifdef CMM_CODE
struct mdc_thread_info {
const struct lu_context *mci_ctxt;
struct md_op_data mci_opdata;
struct ptlrpc_request *mci_req;
};
-#endif
struct mdc_object {
struct md_object mco_obj;
static struct md_dir_operations mdc_dir_ops;
static struct lu_object_operations mdc_obj_ops;
-#ifdef CMM_CODE
extern struct lu_context_key mdc_thread_key;
struct lu_object *mdc_object_alloc(const struct lu_context *ctx,
int rc;
ENTRY;
- mci = lu_context_get_key(ctx, &mdc_thread_key);
+ mci = lu_context_key_get(ctx, &mdc_thread_key);
LASSERT(mci);
mci->mci_opdata.fid1 = *lu_object_fid(&mo->mo_lu);
- mci->mci_opdata.fid2 = { 0 };
mci->mci_opdata.mod_time = attr->la_mtime;
mci->mci_opdata.name = NULL;
mci->mci_opdata.namelen = 0;
RETURN(rc);
}
+
static int mdc_ref_add(const struct lu_context *ctx, struct md_object *mo)
{
struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
int rc;
ENTRY;
- mci = lu_context_get_key(ctx, &mdc_thread_key);
+ mci = lu_context_key_get(ctx, &mdc_thread_key);
LASSERT(mci);
mci->mci_opdata.fid1 = *lu_object_fid(&mo->mo_lu);
- mci->mci_opdata.fid2 = { 0 };
- mci->mci_opdata.mod_time = attr->la_mtime;
mci->mci_opdata.name = NULL;
mci->mci_opdata.namelen = 0;
int rc;
ENTRY;
- mci = lu_context_get_key(ctx, &mdc_thread_key);
+ mci = lu_context_key_get(ctx, &mdc_thread_key);
LASSERT(mci);
mci->mci_opdata.fid1 = *lu_object_fid(&mo->mo_lu);
- mci->mci_opdata.fid2 = { 0 };
- mci->mci_opdata.mod_time = attr->la_mtime;
mci->mci_opdata.name = NULL;
mci->mci_opdata.namelen = 0;
struct md_object *mo_p, struct md_object *mo_t,
const struct lu_fid *lf, const char *name)
{
- struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
+ struct mdc_device *mc = md2mdc_dev(md_device_get(mo_p));
struct mdc_thread_info *mci;
int rc;
ENTRY;
- mci = lu_context_get_key(ctx, &mdc_thread_key);
+ mci = lu_context_key_get(ctx, &mdc_thread_key);
LASSERT(mci);
mci->mci_opdata.fid1 = *lu_object_fid(&mo_p->mo_lu);
mci->mci_opdata.fid2 = *lf;
- mci->mci_opdata.mod_time = attr->la_mtime;
rc = md_rename(mc->mc_desc.cl_exp, &mci->mci_opdata, NULL, 0,
name, strlen(name), &mci->mci_req);
.mdo_rename_tgt = mdc_rename_tgt,
};
-#else /* CMM_CODE */
-struct lu_object *mdc_object_alloc(const struct lu_context *ctx,
- const struct lu_object_header *hdr,
- struct lu_device *ld)
-{
- struct mdc_object *mco;
- ENTRY;
-
- OBD_ALLOC_PTR(mco);
- if (mco != NULL) {
- struct lu_object *lo;
-
- lo = &mco->mco_obj.mo_lu;
- lu_object_init(lo, NULL, ld);
- mco->mco_obj.mo_ops = &mdc_mo_ops;
- mco->mco_obj.mo_dir_ops = &mdc_dir_ops;
- lo->lo_ops = &mdc_obj_ops;
- RETURN(lo);
- } else
- RETURN(NULL);
-}
-
-static int mdc_object_init(const struct lu_context *ctx, struct lu_object *lo)
-{
- //struct mdc_device *d = lu2mdc_dev(o->lo_dev);
- //struct lu_device *under;
- //const struct lu_fid *fid = lu_object_fid(o);
-
- ENTRY;
-
- RETURN(0);
-}
-
-static void mdc_object_free(const struct lu_context *ctx, struct lu_object *lo)
-{
- struct mdc_object *mco = lu2mdc_obj(lo);
- lu_object_fini(lo);
- OBD_FREE_PTR(mco);
-}
-
-static void mdc_object_release(const struct lu_context *ctx,
- struct lu_object *lo)
-{
- return;
-}
-
-static int mdc_object_exists(const struct lu_context *ctx, struct lu_object *lo)
-{
- return 0;
-}
-
-static int mdc_object_print(const struct lu_context *ctx,
- struct seq_file *f, const struct lu_object *lo)
-{
- return seq_printf(f, LUSTRE_MDC0_NAME"-object@%p", lo);
-}
-
-static int mdc_object_create(const struct lu_context *ctx,
- struct md_object *mo, struct lu_attr *attr)
-{
- struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
- struct obd_export *exp = mc->mc_desc.cl_exp;
- struct ptlrpc_request *req;
- struct md_op_data op_data = {
- .fid1 = mo->mo_lu.lo_header->loh_fid,
- .fid2 = { 0 },
- .mod_time = attr->la_mtime,
- .name = NULL,
- .namelen = 0,
- };
- int rc;
-
- rc = md_create(exp, &op_data, NULL, 0, attr->la_mode, attr->la_uid,
- attr->la_gid, 0, 0, &req);
- RETURN(rc);
-}
-
-static struct md_dir_operations mdc_dir_ops = {
-};
-
-static struct md_object_operations mdc_mo_ops = {
- .moo_object_create = mdc_object_create
-};
-
-static struct lu_object_operations mdc_obj_ops = {
- .loo_object_init = mdc_object_init,
- .loo_object_release = mdc_object_release,
- .loo_object_free = mdc_object_free,
- .loo_object_print = mdc_object_print,
- .loo_object_exists = mdc_object_exists
-};
-#endif /* CMM_CODE */