[sheepdog] [PATCH] sheep: refactor get_nth_node() and get_vnode_pos()
Yunkai Zhang
yunkai.me at gmail.com
Sat Aug 4 14:09:07 CEST 2012
On Sat, Aug 4, 2012 at 7:25 PM, Yunkai Zhang <yunkai.me at gmail.com> wrote:
> On Sat, Aug 4, 2012 at 7:15 PM, Liu Yuan <namei.unix at gmail.com> 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).
I found that there are several places calls obj_to_sheeps, and if I do
all these changes in one patch, it'll make this patch too big.
I'll give a new patch to delete these two functions.
>
> Good idea, I'll give V2.
>
>>
>> Thanks,
>> Yuan
>
>
>
> --
> Yunkai Zhang
> Work at Taobao
--
Yunkai Zhang
Work at Taobao
More information about the sheepdog
mailing list