* precondition: lu_object_exists(ctxt, &dt->do_lu);
*/
int (*do_xattr_set)(const struct lu_context *ctxt,
- struct dt_object *dt,
+ struct dt_object *dt,
const void *buf, int buf_len,
const char *name, struct thandle *handle);
/*
int dt_txn_hook_commit(const struct lu_context *ctx,
struct dt_device *dev, struct thandle *txn);
+int dt_is_dir(const struct lu_context *ctx, struct dt_object *obj);
struct dt_object *dt_store_open(const struct lu_context *ctx,
struct dt_device *dt, const char *name,
struct lu_fid *fid);
static struct lu_context_key mdd_thread_key;
-const char *mdd_root_dir_name = "ROOT";
+const char *mdd_root_dir_name = "root";
struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx)
{
struct dt_object *next = mdd_object_child(pobj);
ENTRY;
- if (next->do_index_ops != NULL)
+ if (dt_is_dir(ctxt, next))
rc = next->do_index_ops->dio_insert(ctxt, next,
(struct dt_rec *)lf,
(struct dt_key *)name, handle);
struct dt_object *next = mdd_object_child(pobj);
ENTRY;
- if (next->do_index_ops != NULL)
+ if (dt_is_dir(ctxt, next))
rc = next->do_index_ops->dio_delete(ctxt, next,
(struct dt_key *)name, handle);
else
static int mdd_lookup(const struct lu_context *ctxt, struct md_object *pobj,
const char *name, struct lu_fid* fid)
{
- struct dt_object *dir = mdd_object_child(md2mdd_obj(pobj));
- struct dt_rec *rec = (struct dt_rec *)fid;
+ struct dt_object *dir = mdd_object_child(md2mdd_obj(pobj));
+ struct dt_rec *rec = (struct dt_rec *)fid;
const struct dt_key *key = (const struct dt_key *)name;
int result;
ENTRY;
- if (dir->do_index_ops != NULL)
+ if (dt_is_dir(ctxt, dir))
result = dir->do_index_ops->dio_lookup(ctxt, dir, rec, key);
else
result = -ENOTDIR;
LASSERT(atomic_read(&lu->ld_ref) == 0);
md_device_fini(&m->mdd_md_dev);
- class_put_type(dt_lov->dd_lu_dev.ld_type->ldt_obd_type);
+ if (dt_lov->dd_lu_dev.ld_type != NULL)
+ class_put_type(dt_lov->dd_lu_dev.ld_type->ldt_obd_type);
OBD_FREE_PTR(m);
}
}
EXPORT_SYMBOL(dt_object_fini);
+int dt_is_dir(const struct lu_context *ctx, struct dt_object *obj)
+{
+ if (obj->do_index_ops == NULL)
+ obj->do_ops->do_object_index_try(ctx, obj,
+ &dt_directory_features);
+ return obj->do_index_ops != NULL;
+}
+EXPORT_SYMBOL(dt_is_dir);
+
static int dt_lookup(const struct lu_context *ctx, struct dt_object *dir,
const char *name, struct lu_fid *fid)
{
const struct dt_key *key = (const struct dt_key *)name;
int result;
- if (dir->do_index_ops != NULL)
+ if (dt_is_dir(ctx, dir))
result = dir->do_index_ops->dio_lookup(ctx, dir, rec, key);
else
result = -ENOTDIR;