<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">2014-02-17 13:39 GMT+08:00 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">This will fix a bug that after deletion of clones, we fail to create clones<br>
with the snapshot that we previousy cloned.<br>
<br>
Signed-off-by: Liu Yuan <<a href="mailto:namei.unix@gmail.com">namei.unix@gmail.com</a>><br>
---<br>
sheep/vdi.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++<br>
1 file changed, 47 insertions(+)<br>
<br>
diff --git a/sheep/vdi.c b/sheep/vdi.c<br>
index f4c589a..2da82a2 100644<br>
--- a/sheep/vdi.c<br>
+++ b/sheep/vdi.c<br>
@@ -1028,6 +1028,51 @@ static uint64_t get_vdi_root(uint32_t vid, bool *cloned)<br>
return vid;<br>
}<br>
<br>
+static void clear_parent_child_vdi(uint32_t vid)<br>
+{<br>
+ struct sd_inode * inode = xmalloc(SD_INODE_HEADER_SIZE);<br>
+ uint32_t pvid, i;<br>
+ int ret;<br>
+<br>
+ ret = read_backend_object(vid_to_vdi_oid(vid), (char *)inode,<br>
+ SD_INODE_HEADER_SIZE, 0);<br>
+ if (ret != SD_RES_SUCCESS) {<br>
+ sd_err("failed to read inode %"PRIx32, vid);<br>
+ goto out;<br>
+ }<br>
+<br>
+ pvid = inode->parent_vdi_id;<br>
+ if (!pvid)<br>
+ goto out;<br>
+ ret = read_backend_object(vid_to_vdi_oid(pvid), (char *)inode,<br>
+ SD_INODE_HEADER_SIZE, 0);<br>
+ if (ret != SD_RES_SUCCESS) {<br>
+ sd_err("failed to read parent inode %"PRIx32, pvid);<br>
+ goto out;<br>
+ }<br>
+<br>
+ for (i = 0; i < MAX_CHILDREN; i++)<br>
+ if (inode->child_vdi_id[i] == vid) {<br>
+ inode->child_vdi_id[i] = 0;<br>
+ break;<br>
+ }<br>
+<br>
+ if (i == MAX_CHILDREN) {<br>
+ sd_info("failed to find child %"PRIx32, vid);<br>
+ goto out;<br>
+ }<br>
+<br>
+ ret = sd_write_object(vid_to_vdi_oid(pvid), (char *)inode,<br>
+ SD_INODE_HEADER_SIZE, 0, false);<br>
+ if (ret != SD_RES_SUCCESS) {<br>
+ sd_err("failed to update parent %"PRIx32, pvid);<br>
+ goto out;<br>
+ }<br>
+ sd_debug("parent %"PRIx32, pvid);<br>
+out:<br>
+ free(inode);<br>
+}<br>
+<br>
static int start_deletion(struct request *req, uint32_t vid)<br>
{<br>
struct deletion_work *dw = NULL;<br>
@@ -1052,6 +1097,8 @@ static int start_deletion(struct request *req, uint32_t vid)<br>
goto out;<br>
}<br>
<br>
+ clear_parent_child_vdi(vid);<br>
+<br>
ret = fill_delete_vid_array(dw, root_vid);<br>
if (ret < 0) {<br>
ret = SD_RES_EIO;<br>
<span class="HOEnZb"><font color="#888888">--<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>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--<br>Best Regard<br>Robin Dong
</div>