On 06/21/2012 12:24 PM, MORITA Kazutaka wrote: > 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. > Ah, yes. I'll do a new patch to address these issue. Thanks, Yuan |