[sheepdog] [PATCH v1] sheep/http: fix error in bucket_delete
Liu Yuan
namei.unix at gmail.com
Wed Aug 6 12:49:02 CEST 2014
On Wed, Aug 06, 2014 at 04:38:51PM +0800, 朱炳鹏 wrote:
> Sorry, I'm confused and I can't agree with you. You said that bnode_lookup() will check every objects, but the code doesn't seem like it.
> Here is the code of bnode_lookup() that I taken from the master branch.
> static int bnode_lookup(struct kv_bnode *bnode, uint32_t vid, const char *name)
> {
> uint64_t hval, i;
> int ret;
>
>
> hval = sd_hash(name, strlen(name));
> for (i = 0; i < MAX_DATA_OBJS; i++) {
> uint32_t idx = (hval + i) % MAX_DATA_OBJS;
> uint64_t oid = vid_to_data_oid(vid, idx);
>
>
> ret = sd_read_object(oid, (char *)bnode, sizeof(*bnode), 0);
> if (ret != SD_RES_SUCCESS)
> goto out;
> if (strcmp(bnode->name, name) == 0)
> break;
> }
>
>
> if (i == MAX_DATA_OBJS)
> ret = SD_RES_NO_OBJ;
> out:
> return ret;
> }
>
> Suppose container A and B has the same sd_hash() value, their bnodes will be stored in adjacent data objects. Then,
> we delete container A and its bnode. When we call bnode_lookup() for container B, sd_read_object() will return error.
> I have read your another replied email.
By rereading the code, seems you are right.
> Do you mean we should just ignore the hash collision since it is really rare in practical use?
No, we should fix it, this is a bug.
Thanks
Yuan
More information about the sheepdog
mailing list