X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fosp%2Fosp_md_object.c;h=6dec919463d09d7f2be64149646bbfeaa40504a7;hp=ea5ef0a13177fddc37b859f5a2de55db1ac16686;hb=b69b7de30c3977cb69a741099218bc4a81752717;hpb=17797975b27e1b5222fb75cac49d90066091486d diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index ea5ef0a..6dec919 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -397,13 +397,20 @@ static int osp_md_declare_insert(const struct lu_env *env, 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)) { @@ -413,14 +420,11 @@ static int osp_md_declare_insert(const struct lu_env *env, 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; @@ -515,14 +519,18 @@ again: 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, @@ -537,11 +545,33 @@ 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 = {