[Sheepdog] [PATCH 1/2] add oid_to_vnodes() and obj_to_sheeps() to avoid too much vnodes traverse
levin li
levin108 at gmail.com
Tue May 15 09:52:04 CEST 2012
On 05/15/2012 03:09 PM, Christoph Hellwig wrote:
> On Tue, May 15, 2012 at 11:18:13AM +0800, levin li wrote:
>> I've noticed oid_to_vnode, I just keep it in case of future use,
> Please don't. Dead code bitrots, nevermind that people should use your
> more optimal version for just about any use case.
>
I've removed it in my latest version.
>> as for collie, I think I just ignored it, I'd like to replace it
>> with obj_to_sheeps,
>> but I don't think we should kill obj_to_sheep in recovery path, if we
>> use obj_to_sheeps there, it means we need more calling to get_nth_node,
>> I prefer to keep it.
> obj_to_sheeps with nr_copies = 1 only calls get_nth_node once and also
> is otherwise equivalent. If you don't feel with adding nr_copies = 1
> in recovery, maybe rewrite obj_to_sheep as:
>
> static inline int obj_to_sheep(struct sd_vnode *entries, int nr_entries,
> uint64_t oid, int idx)
> {
> int idx;
>
> obj_to_sheeps(entries, nr_entries, oid, 1,&idx);
> return idx;
> }
>
> to keep the implementation common.
>
I don't think we can just call obj_to_sheeps with nr_copies=1,
see this code:
for (idx = 0; idx < nr_copies; idx++)
idxs[idx] = get_nth_node(entries, nr_entries,
(pos + 1) % nr_entries, idx);
when nr_copies=1, idx is always zero, which is not what we want.
More information about the sheepdog
mailing list