[sheepdog] [PATCH 2/2] collie: add a check&repair command
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Thu Jun 21 06:24:22 CEST 2012
At Wed, 20 Jun 2012 18:16:02 +0800,
Liu Yuan wrote:
> +
> +static void do_check_repair(uint64_t oid, int nr_copies)
> +{
> + struct sd_vnode *tgt_vnodes[nr_copies];
> + unsigned char sha1[nr_copies][SHA1_LEN];
> + void *buf;
> + int i;
> +
> + collie_oid_to_vnodes(vnode_list_entries, nr_vnodes,
> + oid, nr_copies, tgt_vnodes);
> + for (i = 0; i < nr_copies; i++) {
> + buf = read_object_from(tgt_vnodes[i], oid);
> + SHA1(buf, SD_DATA_OBJ_SIZE, sha1[i]);
memcmp against contents of the object directly looks simpler than
calculating their hash values.
> + free(buf);
> + }
> +
> + if (!memcmp(sha1[0], sha1[1], SHA1_LEN) &&
> + !memcmp(sha1[0], sha1[2], SHA1_LEN))
> + return; /* All replica consistent */
This will fail if the number of replica is not three.
Kazutaka
More information about the sheepdog
mailing list