const struct dt_key *key,
struct thandle *th)
{
- struct dt_update_request *update;
- struct lu_fid *fid;
- struct lu_fid *rec_fid = (struct lu_fid *)rec;
- int size[2] = {strlen((char *)key) + 1,
- sizeof(*rec_fid)};
- const char *bufs[2] = {(char *)key, (char *)rec_fid};
- int rc;
+ struct osp_thread_info *info = osp_env_info(env);
+ struct dt_update_request *update;
+ struct dt_insert_rec *rec1 = (struct dt_insert_rec *)rec;
+ struct lu_fid *fid =
+ (struct lu_fid *)lu_object_fid(&dt->do_lu);
+ struct lu_fid *rec_fid = &info->osi_fid;
+ __u32 type = cpu_to_le32(rec1->rec_type);
+ int size[3] = { strlen((char *)key) + 1,
+ sizeof(*rec_fid),
+ sizeof(type) };
+ const char *bufs[3] = { (char *)key,
+ (char *)rec_fid,
+ (char *)&type };
+ int rc;
update = out_find_create_update_loc(th, dt);
if (IS_ERR(update)) {
return PTR_ERR(update);
}
- fid = (struct lu_fid *)lu_object_fid(&dt->do_lu);
-
- CDEBUG(D_INFO, "%s: insert index of "DFID" %s: "DFID"\n",
+ CDEBUG(D_INFO, "%s: insert index of "DFID" %s: "DFID", %u\n",
dt->do_lu.lo_dev->ld_obd->obd_name,
- PFID(fid), (char *)key, PFID(rec_fid));
-
- fid_cpu_to_le(rec_fid, rec_fid);
+ PFID(fid), (char *)key, PFID(rec1->rec_fid), rec1->rec_type);
+ fid_cpu_to_le(rec_fid, rec1->rec_fid);
rc = out_insert_update(env, update, OUT_INDEX_INSERT, fid,
ARRAY_SIZE(size), size, bufs);
return rc;
static struct dt_key *osp_it_key(const struct lu_env *env,
const struct dt_it *di)
{
- LBUG();
- return NULL;
+ struct osp_it *it = (struct osp_it *)di;
+ struct lu_dirent *ent = (struct lu_dirent *)it->ooi_ent;
+
+ return (struct dt_key *)ent->lde_name;
}
static int osp_it_key_size(const struct lu_env *env, const struct dt_it *di)
{
- LBUG();
- return 0;
+ struct osp_it *it = (struct osp_it *)di;
+ struct lu_dirent *ent = (struct lu_dirent *)it->ooi_ent;
+
+ return (int)le16_to_cpu(ent->lde_namelen);
}
static int osp_md_index_it_rec(const struct lu_env *env, const struct dt_it *di,
return 0;
}
+/**
+ * Locate the iteration cursor to the specified position (cookie).
+ *
+ * \param[in] env pointer to the thread context
+ * \param[in] di pointer to the iteration structure
+ * \param[in] hash the specified position
+ *
+ * \retval positive number for locating to the exactly position
+ * or the next
+ * \retval 0 for arriving at the end of the iteration
+ * \retval negative error number on failure
+ */
static int osp_it_load(const struct lu_env *env, const struct dt_it *di,
__u64 hash)
{
- LBUG();
- return 0;
+ struct osp_it *it = (struct osp_it *)di;
+ int rc;
+
+ it->ooi_next = hash;
+ rc = osp_md_index_it_next(env, (struct dt_it *)di);
+ if (rc == 1)
+ return 0;
+
+ if (rc == 0)
+ return 1;
+
+ return rc;
}
const struct dt_index_operations osp_md_index_ops = {