[sheepdog] [PATCH 1/8] raid: add dummy raid proper
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Mon Mar 11 02:07:25 CET 2013
At Sun, 10 Mar 2013 22:19:22 +0800,
Liu Yuan wrote:
> +
> +static struct vdisk *oid_to_vdisk_from(struct vdisk *vds, int nr, uint64_t oid)
> +{
> + uint64_t id = fnv_64a_buf(&oid, sizeof(oid), FNV1A_64_INIT);
> + int start, end, pos;
> +
> + start = 0;
> + end = nr - 1;
> +
> + if (id > vds[end].id || id < vds[start].id)
> + return &vds[start];
> +
> + for (;;) {
> + pos = (end - start) / 2 + start;
> + if (vds[pos].id < id) {
> + if (vds[pos + 1].id >= id)
> + return &vds[pos + 1];
> + start = pos;
> + } else
> + end = pos;
> + }
> +}
Can we add primitives for consistent hashing and use them to share the
similar codes with the functions in sheep.h?
Thanks,
Kazutaka
More information about the sheepdog
mailing list