On Sat, Aug 4, 2012 at 7:15 PM, Liu Yuan <[email protected]> wrote: > On 08/04/2012 06:17 PM, Yunkai Zhang wrote: >> -static inline void obj_to_sheeps(struct sd_vnode *entries, >> - int nr_entries, uint64_t oid, int nr_copies, int *idxs) >> +static inline int obj_to_sheep(struct sd_vnode *entries, int nr_entries, >> + uint64_t oid, int nth_idx) >> { >> - int pos = get_vnode_pos(entries, nr_entries, oid); >> - int idx; >> + return get_vnode_nth_idx(entries, nr_entries, oid, nth_idx); >> +} >> >> - for (idx = 0; idx < nr_copies; idx++) >> - idxs[idx] = get_nth_node(entries, nr_entries, >> - (pos + 1) % nr_entries, idx); >> +static inline void obj_to_sheeps(struct sd_vnode *entries, int nr_entries, >> + uint64_t oid, int nr_copies, int *idxs) >> +{ >> + int nr_idxs = 0; >> + >> + idxs[nr_idxs++] = get_vnode_first_idx(entries, nr_entries, oid); >> + >> + while (nr_idxs < nr_copies) { >> + idxs[nr_idxs] = get_vnode_next_idx(entries, nr_entries, >> + idxs, nr_idxs); >> + nr_idxs++; >> + } >> } > > Both obj_to_sheep and obj_to_sheeps would better be folded into their > callers and every one should rely on the oid_to_vnodes(), > oid_to_vnode(), which are much more descriptive, to map oid to vnode(s).
Good idea, I'll give V2. > > Thanks, > Yuan -- Yunkai Zhang Work at Taobao -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
