.loo_object_exists = mdd_object_exists,
};
-static struct dt_object* mdd_object_child(struct mdd_object *o)
-{
- return container_of0(lu_object_next(&o->mod_obj.mo_lu),
- struct dt_object, do_lu);
-}
static void mdd_lock(const struct lu_context *ctxt,
struct mdd_object *obj, enum dt_lock_mode mode)
handle);
}
-static int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
- const void *buf, int buf_len, const char *name)
+int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
+ const void *buf, int buf_len, const char *name)
{
struct mdd_device *mdd = mdo2mdd(obj);
struct thandle *handle;
rc = __mdd_ref_add(ctxt, mdd_sobj, handle);
exit:
mdd_unlock2(ctxt, mdd_tobj, mdd_sobj);
-
mdd_trans_stop(ctxt, mdd, handle);
RETURN(rc);
}
if (rc)
GOTO(cleanup, rc);
cleanup:
- /*FIXME: error handling?*/
mdd_lock2(ctxt, mdd_pobj, mdd_cobj);
mdd_trans_stop(ctxt, mdd, handle);
RETURN(rc);
struct mdd_object *mdo = md2mdd_obj(pobj);
struct mdd_object *son = md2mdd_obj(child);
struct thandle *handle;
- int rc = 0;
+ int rc = 0, created = 0, inserted = 0;
ENTRY;
mdd_txn_param_build(ctxt, &MDD_TXN_MKDIR);
if (rc)
GOTO(cleanup, rc);
+ created = 1;
rc = __mdd_index_insert(ctxt, mdo, lu_object_fid(&child->mo_lu),
name, handle);
+
+ inserted = 1;
+ rc = mdd_lov_set_md(ctxt, pobj, child);
if (rc) {
- int rc2;
-
- rc2 = __mdd_object_destroy(ctxt, son, handle);
- if (rc2)
- CERROR("Cannot cleanup insertion failure: %d/%d\n",
- rc, rc2);
+ CERROR("error on stripe info copy %d \n", rc);
}
-
cleanup:
+ if (rc && created) {
+ int rc1 = 0, rc2 = 0;
+
+ rc1 = __mdd_object_destroy(ctxt, son, handle);
+ if (inserted)
+ rc2 = __mdd_index_delete(ctxt, mdo, name, handle);
+ if (rc1 || rc2)
+ CERROR("error can not cleanup destory %d insert %d \n",
+ rc1, rc2);
+ }
+
mdd_unlock(ctxt, mdo, DT_WRITE_LOCK);
mdd_trans_stop(ctxt, mdd, handle);
RETURN(rc);
struct lu_fid mti_fid;
struct lu_attr mti_attr;
struct lov_desc mti_ld;
+ struct lov_mds_md mti_lmm;
};
int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd,
struct obd_device *watched, enum obd_notify_event ev,
void *data);
+int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
+ const void *buf, int buf_len, const char *name);
+int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
+ struct md_object *child);
struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx);
extern struct lu_device_operations mdd_lu_ops;
static inline int lu_device_is_mdd(struct lu_device *d)
{
return d->mdd_child->dd_ops;
}
+
+static inline struct dt_object* mdd_object_child(struct mdd_object *o)
+{
+ return container_of0(lu_object_next(&o->mod_obj.mo_lu),
+ struct dt_object, do_lu);
+}
+
#endif
!(ev == OBD_NOTIFY_SYNC));
RETURN(rc);
}
+
+static int mdd_get_md(const struct lu_context *ctxt, struct md_object *obj,
+ void *md, int *md_size, int lock)
+{
+ struct dt_object *next;
+ int rc = 0;
+ int lmm_size;
+
+ next = mdd_object_child(md2mdd_obj(obj));
+ rc = next->do_ops->do_xattr_get(ctxt, next, md, *md_size,
+ "lov");
+ if (rc < 0) {
+ CERROR("Error %d reading eadata \n", rc);
+ } else if (rc > 0) {
+ lmm_size = rc;
+ /*FIXME convert lov EA necessary for this version?*/
+ *md_size = lmm_size;
+ rc = lmm_size;
+ } else {
+ *md_size = 0;
+ }
+
+ RETURN (rc);
+}
+
+int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
+ struct md_object *child)
+{
+ struct dt_object *next = mdd_object_child(md2mdd_obj(child));
+ int rc = 0;
+ ENTRY;
+
+ if (dt_is_dir(ctxt, next)) {
+ struct lov_mds_md *lmm = &mdd_ctx_info(ctxt)->mti_lmm;
+ int lmm_size = sizeof(lmm);
+ rc = mdd_get_md(ctxt, pobj, &lmm, &lmm_size, 1);
+ if (rc > 0) {
+ rc = mdd_xattr_set(ctxt, child, lmm, lmm_size, "lov");
+ if (rc)
+ CERROR("error on copy stripe info: rc = %d\n", rc);
+ }
+ }
+ RETURN(rc);
+}
return 0;
}
+int osd_xattr_get(const struct lu_context *ctxt, struct dt_object *dt,
+ void *buf, int buf_len, const char *name)
+{
+ return 0;
+}
+
+int osd_xattr_set(const struct lu_context *ctxt, struct dt_object *dt,
+ const void *buf, int buf_len, const char *name,
+ struct thandle *handle)
+{
+ return 0;
+}
+
static struct dt_object_operations osd_obj_ops = {
.do_object_lock = osd_object_lock,
.do_object_unlock = osd_object_unlock,
.do_object_destroy = osd_object_destroy,
.do_object_index_try = osd_index_try,
.do_object_ref_add = osd_object_ref_add,
- .do_object_ref_del = osd_object_ref_del
+ .do_object_ref_del = osd_object_ref_del,
+ .do_xattr_get = osd_xattr_get,
+ .do_xattr_set = osd_xattr_set
};
static struct dt_body_operations osd_body_ops = {