[sheepdog] [PATCH v1] sheep/http: fix error in bucket_delete
朱炳鹏
nkuzbp at foxmail.com
Wed Aug 6 10:38:51 CEST 2014
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. Do you mean we should just ignore the hash collision since it is really rare in practical use?
------------------ Original ------------------
From: "Liu Yuan";<namei.unix at gmail.com>;
Date: Wed, Aug 6, 2014 04:17 PM
To: "朱炳鹏"<nkuzbp at foxmail.com>;
Cc: "sheepdog"<sheepdog at lists.wpkg.org>; "Yu Fang"<bingpeng.zbp at alibaba-inc.com>;
Subject: Re: [sheepdog] [PATCH v1] sheep/http: fix error in bucket_delete
On Tue, Aug 05, 2014 at 08:33:46PM +0800, Bingpeng Zhu wrote:
> From: NankaiZBP <nkuzbp at foxmail.com>
>
> In current implementation, When we create a bucket, we decide
> the bnode's location in account VDI using sd_hash(bucket_name)
> as key. We handle hash conflict by linear probing hash table.
> Here is the bug:
> When we delete a bucket, we can't discard its bnode. Because
> bnode_lookup() need it to find if some bucket exists or not
> by checking adjacent bnodes. Therefore, we just zero its
> bnode.name when client want to delete a bucket. When we create
> a bucket later, we can reuse the deleted bnode if they hash to
> the same location in account VDI.
No, bnode_lookup() will check every objects. What your said just applied to
onode_lookup(). There is no bug as your described for bnode_lookup().
Thanks
Yuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20140806/5b3843bb/attachment-0004.html>
More information about the sheepdog
mailing list