fix layering in cmm.
struct md_object *md_child)
{
struct cmm_object *cmm_parent = md2cmm_obj(md_parent);
+ struct md_object *next = cmm2child_obj(cmm_parent);
- return md_parent->mo_ops->moo_mkdir(cmm2child_obj(cmm_parent),
- name, md_child);
+ return next->mo_ops->moo_mkdir(next, name, md_child);
}
static struct md_object_operations cmm_mo_ops = {
struct md_object *next = cmm2child_obj(md2cmm_obj(obj));
LASSERT((void *)obj->mo_ops > (void *)0x100);
- return obj->mo_ops->moo_attr_get(next, buf, size, name, ctxt);
+ return next->mo_ops->moo_attr_get(next, buf, size, name, ctxt);
}
* DT device interface. XXX Probably should go elsewhere.
*/
-struct dt_object {
- struct lu_object do_lu;
-};
+struct context;
+struct thandle;
+struct txn_param;
+struct dt_device;
+struct dt_object;
enum dt_lock_mode {
DT_WRITE_LOCK = 1,
DT_READ_LOCK = 2,
};
-struct context;
-struct thandle;
-struct txn_param;
-struct dt_device;
-
struct dt_device_operations {
/* method for getting/setting device wide back stored config data, like
* last used meta-sequence, etc. */
int (*dt_config) (struct dt_device *dev, const char *name,
void *buf, int size, int mode);
-
int (*dt_statfs)(struct dt_device *dev, struct kstatfs *sfs);
- void (*dt_object_lock)(struct dt_object *dt, enum dt_lock_mode mode);
- void (*dt_object_unlock)(struct dt_object *dt, enum dt_lock_mode mode);
struct thandle *(*dt_trans_start)(struct dt_device *dev,
struct txn_param *param);
void (*dt_trans_stop)(struct thandle *th);
- int (*dt_object_create)(struct dt_object *dt, struct dt_object *child,
+ int (*dt_root_get)(struct dt_device *dev, struct lu_fid *f);
+};
+
+struct dt_object_operations {
+ void (*do_object_lock)(struct dt_object *dt, enum dt_lock_mode mode);
+ void (*do_object_unlock)(struct dt_object *dt, enum dt_lock_mode mode);
+ int (*do_object_create)(struct dt_object *dt, struct dt_object *child,
struct context *context, struct thandle *th);
- int (*dt_object_destroy)(struct dt_object *dt, struct thandle *th);
- int (*dt_attr_get)(struct dt_object *dt, void *buf, int buf_len,
+ int (*do_object_destroy)(struct dt_object *dt, struct thandle *th);
+ int (*do_attr_get)(struct dt_object *dt, void *buf, int buf_len,
const char *name, struct context *context);
- int (*dt_attr_set)(struct dt_object *dt, void *buf, int buf_len,
+ int (*do_attr_set)(struct dt_object *dt, void *buf, int buf_len,
const char *name, struct context *context,
struct thandle *handle);
- int (*dt_index_insert)(struct dt_object *dt, struct lu_fid *fid,
+ int (*do_index_insert)(struct dt_object *dt, struct lu_fid *fid,
const char *name, struct context *uctxt,
void *handle);
- int (*dt_index_delete)(struct dt_object *dt, struct lu_fid *fid,
+ int (*do_index_delete)(struct dt_object *dt, struct lu_fid *fid,
const char *name, struct context *uctxt,
struct thandle *handle);
- int (*dt_root_get)(struct dt_device *dev, struct lu_fid *f);
};
struct dt_device {
struct lustre_mount_info *dd_lmi;
};
+struct dt_object {
+ struct lu_object do_lu;
+ struct dt_object_operations *do_ops;
+};
+
struct txn_param {
unsigned int tp_credits;
};
struct md_object_operations *mo_ops;
};
-static inline int lu_device_is_md(struct lu_device *d)
+static inline int lu_device_is_md(const struct lu_device *d)
{
return d->ld_type->ldt_tags & LU_DEVICE_MD;
}
-static inline struct md_device *lu2md_dev(struct lu_device *d)
+static inline struct md_device *lu2md_dev(const struct lu_device *d)
{
LASSERT(lu_device_is_md(d));
return container_of(d, struct md_device, md_lu_dev);
return &d->md_lu_dev;
}
-static inline struct md_object *lu2md(struct lu_object *o)
+static inline struct md_object *lu2md(const struct lu_object *o)
{
LASSERT(lu_device_is_md(o->lo_dev));
return container_of(o, struct md_object, mo_lu);
}
-static inline struct md_device *md_device_get(struct md_object *o)
+static inline struct md_object *md_object_next(const struct md_object *obj)
+{
+ return lu2md(lu_object_next(&obj->mo_lu));
+}
+
+static inline struct md_device *md_device_get(const struct md_object *o)
{
LASSERT(lu_device_is_md(o->mo_lu.lo_dev));
return container_of(o->mo_lu.lo_dev, struct md_device, md_lu_dev);
struct context *uctxt)
{
struct mdd_object *mdd_obj = mdo2mddo(obj);
- struct mdd_device *mdd = mdo2mdd(obj);
+ struct dt_object *next = mdd_object_child(mdd_obj);
int rc;
ENTRY;
- rc = mdd_child_ops(mdd)->dt_attr_get(mdd_object_child(mdd_obj),
- buf, buf_len, name, uctxt);
+ rc = next->do_ops->do_attr_get(next, buf, buf_len, name, uctxt);
RETURN(rc);
}
struct thandle *handle)
{
int rc = 0;
+ struct dt_object *next = mdd_object_child(obj);
- rc = mdd_child_ops(mdd)->dt_object_destroy(mdd_object_child(obj),
- handle);
+ rc = next->do_ops->do_object_destroy(next, handle);
RETURN(rc);
}
static void mdd_lock(struct mdd_object *obj, enum dt_lock_mode mode)
{
- struct mdd_device *dev = mdo2mdd(&obj->mod_obj);
+ struct dt_object *next = mdd_object_child(obj);
- mdd_child_ops(dev)->dt_object_lock(mdd_object_child(obj), mode);
+ next->do_ops->do_object_lock(next, mode);
}
static void mdd_unlock(struct mdd_object *obj, enum dt_lock_mode mode)
{
- struct mdd_device *dev = mdo2mdd(&obj->mod_obj);
+ struct dt_object *next = mdd_object_child(obj);
- mdd_child_ops(dev)->dt_object_unlock(mdd_object_child(obj), mode);
+ next->do_ops->do_object_unlock(next, mode);
}
static void mdd_lock2(struct mdd_object *o0, struct mdd_object *o1)
struct thandle *handle)
{
int rc;
+ struct dt_object *next = mdd_object_child(pobj);
ENTRY;
- rc = mdd_child_ops(mdd)->dt_object_create(mdd_object_child(pobj),
- mdd_object_child(child),
- uctxt, handle);
+ rc = next->do_ops->do_object_create(next, mdd_object_child(child),
+ uctxt, handle);
/*XXX increase the refcount of the object or not?*/
RETURN(rc);
}
int buf_len, const char *name, struct context *uc_context,
struct thandle *handle)
{
- return mdd_child_ops(mdd)->dt_attr_set(mdd_object_child(obj),
- buf, buf_len,
- name, uc_context,
- handle);
+ struct dt_object *next = mdd_object_child(obj);
+ return next->do_ops->do_attr_set(next, buf, buf_len,
+ name, uc_context, handle);
}
static int
struct context *uctxt, void *handle)
{
int rc;
+ struct dt_object *next = mdd_object_child(pobj);
ENTRY;
mdd_lock2(pobj, obj);
- rc = mdd_child_ops(mdd)->dt_index_insert(mdd_object_child(pobj),
- mdd_object_getfid(obj), name,
- uctxt, handle);
+ rc = next->do_ops->do_index_insert(next, mdd_object_getfid(obj), name,
+ uctxt, handle);
mdd_unlock2(pobj, obj);
RETURN(rc);
struct context *uctxt, struct thandle *handle)
{
int rc;
+ struct dt_object *next = mdd_object_child(pobj);
ENTRY;
mdd_lock2(pobj, obj);
- rc = mdd_child_ops(mdd)->dt_index_delete(mdd_object_child(pobj),
- mdd_object_getfid(obj), name,
- uctxt, handle);
+ rc = next->do_ops->do_index_delete(next, mdd_object_getfid(obj), name,
+ uctxt, handle);
mdd_unlock2(pobj, obj);
RETURN(rc);
child = mdt_object_find(d, cfid);
if (!IS_ERR(child)) {
- result = o->mot_obj.mo_ops->moo_mkdir(mdt_object_child(o), name,
- mdt_object_child(child));
+ struct md_object *next = mdt_object_child(o);
+
+ result = next->mo_ops->moo_mkdir(next, name,
+ mdt_object_child(child));
mdt_object_put(child);
} else
result = PTR_ERR(child);
{
struct mdt_device *d = info->mti_mdt;
struct mdt_object *o;
+ struct md_object *next;
struct iattr
int result;
if (IS_ERR(o))
return PTR_ERR(o);
- result = o->mot_obj.mo_ops->moo_attr_get(mdt_object_child(o), name,
- mdt_object_child(child));
+ next = mdt_object_child(o);
+ result = next->mo_ops->moo_attr_get(next, name,
+ mdt_object_child(child));
mdt_object_put(child);
} else
result = PTR_ERR(child);