<div dir="ltr">Reviewed-by: Robin Dong <<a href="mailto:sanbai@taobao.com">sanbai@taobao.com</a>></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/20 Liu Yuan <span dir="ltr"><<a href="mailto:namei.unix@gmail.com" target="_blank">namei.unix@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Since we use delete-before-put model to implement overwrite semantics, this code<br>
patch will never bed triggered. So remove it.<br>
<br>
Signed-off-by: Liu Yuan <<a href="mailto:namei.unix@gmail.com">namei.unix@gmail.com</a>><br>
---<br>
sheep/http/kv.c | 64 +++++++++++++++------------------------------------------<br>
1 file changed, 16 insertions(+), 48 deletions(-)<br>
<br>
diff --git a/sheep/http/kv.c b/sheep/http/kv.c<br>
index 7a826f7..eda9124 100644<br>
--- a/sheep/http/kv.c<br>
+++ b/sheep/http/kv.c<br>
@@ -836,7 +836,7 @@ static bool kv_find_object(struct http_request *req, const char *account,<br>
#define KV_ONODE_INLINE_SIZE (SD_DATA_OBJ_SIZE - sizeof(struct kv_onode_hdr))<br>
<br>
static int kv_write_onode(struct sd_inode *inode, struct kv_onode *onode,<br>
- uint32_t vid, uint32_t idx, bool overwrite)<br>
+ uint32_t vid, uint32_t idx)<br>
{<br>
uint64_t oid = vid_to_data_oid(vid, idx), len;<br>
int ret;<br>
@@ -846,31 +846,19 @@ static int kv_write_onode(struct sd_inode *inode, struct kv_onode *onode,<br>
else<br>
len = sizeof(struct onode_extent) * onode->hdr.nr_extent;<br>
<br>
- if (overwrite) {<br>
- sd_info("overwrite object %s", onode-><a href="http://hdr.name" target="_blank">hdr.name</a>);<br>
- ret = sd_write_object(oid, (char *)onode,<br>
- sizeof(onode->hdr) + len,<br>
- 0, false);<br>
- if (ret != SD_RES_SUCCESS) {<br>
- sd_err("failed to write object, %" PRIx64, oid);<br>
- goto out;<br>
- }<br>
- } else {<br>
- ret = sd_write_object(oid, (char *)onode,<br>
- sizeof(onode->hdr) + len,<br>
- 0, true);<br>
- if (ret != SD_RES_SUCCESS) {<br>
- sd_err("failed to create object, %" PRIx64, oid);<br>
- goto out;<br>
- }<br>
- INODE_SET_VID(inode, idx, vid);<br>
- ret = sd_inode_write_vid(sheep_bnode_writer, inode, idx,<br>
- vid, vid, 0, false, false);<br>
- if (ret != SD_RES_SUCCESS) {<br>
- sd_err("failed to update inode, %" PRIx64,<br>
- vid_to_vdi_oid(vid));<br>
- goto out;<br>
- }<br>
+ ret = sd_write_object(oid, (char *)onode, sizeof(onode->hdr) + len,<br>
+ 0, true);<br>
+ if (ret != SD_RES_SUCCESS) {<br>
+ sd_err("failed to create object, %" PRIx64, oid);<br>
+ goto out;<br>
+ }<br>
+ INODE_SET_VID(inode, idx, vid);<br>
+ ret = sd_inode_write_vid(sheep_bnode_writer, inode, idx,<br>
+ vid, vid, 0, false, false);<br>
+ if (ret != SD_RES_SUCCESS) {<br>
+ sd_err("failed to update inode, %" PRIx64,<br>
+ vid_to_vdi_oid(vid));<br>
+ goto out;<br>
}<br>
out:<br>
return ret;<br>
@@ -880,14 +868,10 @@ out:<br>
* Create the object if the index isn't taken. Overwrite the object if it exists<br>
* Return SD_RES_OBJ_TAKEN if the index is taken by other object.<br>
*/<br>
-static int do_kv_create_object(struct http_request *req,<br>
- struct kv_onode *onode,<br>
+static int do_kv_create_object(struct http_request *req, struct kv_onode *onode,<br>
uint32_t vid, uint32_t idx)<br>
{<br>
struct sd_inode *inode = xmalloc(sizeof(struct sd_inode));<br>
- uint64_t oid = vid_to_data_oid(vid, idx);<br>
- struct kv_onode_hdr hdr;<br>
- uint32_t tmp_vid;<br>
int ret;<br>
<br>
ret = sd_read_object(vid_to_vdi_oid(vid), (char *)inode,<br>
@@ -897,23 +881,7 @@ static int do_kv_create_object(struct http_request *req,<br>
vid_to_vdi_oid(vid));<br>
goto out;<br>
}<br>
- tmp_vid = INODE_GET_VID(inode, idx);<br>
- if (tmp_vid) {<br>
- ret = sd_read_object(oid, (char *)&hdr, sizeof(hdr), 0);<br>
- if (ret != SD_RES_SUCCESS) {<br>
- sd_err("failed to read object, %" PRIx64, oid);<br>
- goto out;<br>
- }<br>
-<br>
- if (<a href="http://hdr.name" target="_blank">hdr.name</a>[0] != '\0' &&<br>
- strcmp(<a href="http://hdr.name" target="_blank">hdr.name</a>, onode-><a href="http://hdr.name" target="_blank">hdr.name</a>) != 0) {<br>
- sd_debug("index %d is already used", idx);<br>
- ret = SD_RES_OBJ_TAKEN;<br>
- goto out;<br>
- }<br>
- }<br>
-<br>
- ret = kv_write_onode(inode, onode, vid, idx, !!tmp_vid);<br>
+ ret = kv_write_onode(inode, onode, vid, idx);<br>
if (ret != SD_RES_SUCCESS)<br>
sd_err("Failed to write onode");<br>
out:<br>
--<br>
1.8.1.2<br>
<br>
--<br>
sheepdog mailing list<br>
<a href="mailto:sheepdog@lists.wpkg.org">sheepdog@lists.wpkg.org</a><br>
<a href="http://lists.wpkg.org/mailman/listinfo/sheepdog" target="_blank">http://lists.wpkg.org/mailman/listinfo/sheepdog</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>--<br>Best Regard<br>Robin Dong
</div>