struct mdd_thread_info {
struct txn_param mti_param;
+ struct lu_fid mti_fid;
};
+const char *mdd_root_dir_name = "ROOT";
+
static struct mdd_thread_info *mdd_ctx_info(struct lu_context *ctx)
{
struct mdd_thread_info *info;
return seq_printf(f, LUSTRE_MDD0_NAME"-object@%p", o);
}
+static int mdd_dt_lookup(struct lu_context *ctx, struct mdd_device *mdd,
+ struct mdd_object *obj, const char *name,
+ struct lu_fid *fid)
+{
+ struct dt_object *dir = mdd_object_child(obj);
+ struct dt_rec *rec = (struct dt_rec *)fid;
+ const struct dt_key *key = (const struct dt_key *)name;
+ int result;
+
+ if (dir->do_index_ops != NULL)
+ result = dir->do_index_ops->dio_lookup(ctx, dir, rec, key);
+ else
+ result = -ENOTDIR;
+ return result;
+}
+
+static int mdd_mount(struct lu_context *ctx, struct mdd_device *mdd)
+{
+ int result;
+ struct mdd_thread_info *info = lu_context_key_get(ctx,
+ &mdd_thread_key);
+ struct lu_device *dev = &mdd->mdd_md_dev.md_lu_dev;
+
+ result = mdd_child_ops(mdd)->dt_root_get(ctx, mdd->mdd_child,
+ &info->mti_fid);
+ if (result == 0) {
+ struct lu_object *root;
+
+ root = lu_object_find(ctx, dev->ld_site, &info->mti_fid);
+ if (!IS_ERR(root)) {
+ struct mdd_object *obj;
+
+ obj = mdd_obj(lu_object_locate(root->lo_header,
+ dev->ld_type));
+ if (obj != NULL)
+ result = mdd_dt_lookup(ctx, mdd, obj,
+ mdd_root_dir_name ,
+ &mdd->mdd_root_fid);
+ else {
+ CERROR("No slice\n");
+ result = -EINVAL;
+ }
+ lu_object_put(ctx, root);
+ } else {
+ CERROR("No root\n");
+ result = PTR_ERR(root);
+ }
+ }
+ return result;
+}
+
static int mdd_fs_setup(struct lu_context *ctx, struct mdd_device *mdd)
{
return 0;
default:
err = next->ld_ops->ldo_process_config(ctx, next, cfg);
+ if (err == 0 && cfg->lcfg_command == LCFG_SETUP)
+ err = mdd_mount(ctx, m);
}
RETURN(err);
RETURN(rc);
}
-static void mdd_rename_lock(struct mdd_device *mdd, struct mdd_object *src_pobj,
- struct mdd_object *tgt_pobj, struct mdd_object *sobj,
+static void mdd_rename_lock(struct mdd_device *mdd,
+ struct mdd_object *src_pobj,
+ struct mdd_object *tgt_pobj,
+ struct mdd_object *sobj,
struct mdd_object *tobj)
{
return;
struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
ENTRY;
- RETURN(mdd_child_ops(mdd)->dt_root_get(ctx, mdd->mdd_child, f));
+ *f = mdd->mdd_root_fid;
+ RETURN(0);
}
static int mdd_config(struct lu_context *ctx, struct md_device *m,
{
struct osd_device *d = osd_dt_dev(dev);
- return osd_inode_get_fid(d, d->od_root_dir->d_inode, f);
+ return osd_inode_get_fid(d, osd_sb(d)->s_root->d_inode, f);
}
struct lu_object *l;
l = &mo->oo_dt.do_lu;
- lu_object_init(l, NULL, d);
+ dt_object_init(&mo->oo_dt, NULL, d);
mo->oo_dt.do_ops = &osd_obj_ops;
l->lo_ops = &osd_lu_obj_ops;
init_rwsem(&mo->oo_sem);
static void osd_object_free(struct lu_context *ctx, struct lu_object *l)
{
struct osd_object *obj = osd_obj(l);
+ dt_object_fini(&obj->oo_dt);
OBD_FREE_PTR(obj);
}
* Index operations.
*/
+#if OI_IN_MEMORY
+
+/*
+ * XXX fid for "real" root.
+ */
+static const struct lu_fid uber_fid = {
+ .f_seq = LUSTRE_ROOT_FID_SEQ,
+ .f_oid = LUSTRE_ROOT_FID_OID,
+ .f_ver = 0
+};
+
+extern void osd_oi_init0(struct osd_oi *oi, const struct lu_fid *fid,
+ __u64 root_ino, __u32 root_gen);
+extern int osd_oi_find_fid(struct osd_oi *oi,
+ __u64 ino, __u32 gen, struct lu_fid *fid);
+#endif
+
/*
* XXX This is temporary solution: inode operations are used until iam is
* ready.
/*
* XXX temporary solution.
*/
- struct dentry *dentry;
+ struct dentry *dentry;
+ struct dentry *parent;
LASSERT(osd_has_index(obj));
LASSERT(osd->od_obj_area != NULL);
dir = obj->oo_inode;
LASSERT(dir->i_op != NULL && dir->i_op->lookup != NULL);
- dentry = d_alloc(NULL, &info->oti_str);
+ parent = d_alloc_root(dir);
+ if (parent == NULL)
+ return -ENOMEM;
+
+ dentry = d_alloc(parent, &info->oti_str);
if (dentry != NULL) {
struct dentry *d;
*/
if (dentry->d_inode != NULL) {
struct lu_fid *fid = (struct lu_fid *)rec;
+ struct inode *inode = dentry->d_inode;
/*
* Build fid from inode.
*/
- fid->f_seq = 0; /* XXX hard-coded */
- fid->f_oid = dentry->d_inode->i_ino;
- fid->f_ver = dentry->d_inode->i_generation;
+ /* XXX hard-coded */
+ fid->f_seq = LUSTRE_ROOT_FID_SEQ + 1;
+ fid->f_oid = inode->i_ino;
+ fid->f_ver = inode->i_generation;
+ osd_oi_init0(&osd->od_oi, fid,
+ inode->i_ino, inode->i_generation);
result = 0;
} else
result = -ENOENT;
dput(dentry);
} else
result = -ENOMEM;
+ dput(parent);
return result;
}
return 0;
}
-extern void osd_oi_init0(struct osd_oi *oi, __u64 root_ino, __u32 root_gen);
-extern int osd_oi_find_fid(struct osd_oi *oi,
- __u64 ino, __u32 gen, struct lu_fid *fid);
-
static int osd_mount(struct lu_context *ctx,
struct osd_device *o, struct lustre_cfg *cfg)
{
struct lustre_mount_info *lmi;
- const char *dev = lustre_cfg_string(cfg, 0);
+ const char *dev = lustre_cfg_string(cfg, 0);
+ struct inode *inode;
int result;
ENTRY;
if (result == 0) {
struct dentry *d;
+ inode = osd_sb(o)->s_root->d_inode;
+ /*
+ * XXX temporary kludge: this should be done by mkfs.
+ */
+ osd_oi_init0(&o->od_oi, &uber_fid,
+ inode->i_ino, inode->i_generation);
+
d = simple_mkdir(osd_sb(o)->s_root, "*OBJ-TEMP*", 0777, 1);
if (!IS_ERR(d)) {
o->od_obj_area = d;
+ /*
+ * XXX temporary fix for mdd/fld: create root
+ * directory if not yet there, and insert it into fld.
+ */
d = simple_mkdir(osd_sb(o)->s_root, "ROOT", 0777, 1);
- if (!IS_ERR(d)) {
- osd_oi_init0(&o->od_oi, d->d_inode->i_ino,
- d->d_inode->i_generation);
- o->od_root_dir = d;
- } else
+ if (!IS_ERR(d))
+ dput(d);
+ else
result = PTR_ERR(d);
} else
result = PTR_ERR(d);
dput(o->od_obj_area);
o->od_obj_area = NULL;
}
- if (o->od_root_dir != NULL) {
- dput(o->od_root_dir);
- o->od_root_dir = NULL;
- }
osd_oi_fini(&o->od_oi);
if (o->od_mount)
return result;
}
-const struct lu_fid root_fid = {
- .f_seq = LUSTRE_ROOT_FID_SEQ,
- .f_oid = LUSTRE_ROOT_FID_OID,
- .f_ver = 0
-};
-
-void osd_oi_init0(struct osd_oi *oi, __u64 root_ino, __u32 root_gen)
+void osd_oi_init0(struct osd_oi *oi, const struct lu_fid *fid,
+ __u64 root_ino, __u32 root_gen)
{
int result;
const struct osd_inode_id root_id = {
.oii_gen = root_gen
};
- result = osd_oi_insert(NULL, oi, &root_fid, &root_id, NULL);
+ result = osd_oi_insert(NULL, oi, fid, &root_id, NULL);
LASSERT(result == 0);
}