From: MORITA Kazutaka <morita.kazut...@lab.ntt.co.jp>

Sheepdog vdi snapshot works as follows:

 1. Update the inode header of the current working vdi.
 2. Create a new working vdi as a child of the previous one.

If QEMU reads the vdi object between 1 and 2, sheep returns
SD_RES_NO_VDI.  To avoid this problem, SD_OP_GET_INFO must be ordered
with other vdi operations.

Signed-off-by: MORITA Kazutaka <morita.kazut...@lab.ntt.co.jp>
---
 sheep/ops.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/sheep/ops.c b/sheep/ops.c
index 7f27bc3..64dad68 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -196,7 +196,15 @@ static int post_cluster_del_vdi(const struct sd_req *req, 
struct sd_rsp *rsp,
        return ret;
 }
 
-static int local_get_vdi_info(struct request *req)
+/*
+ * Look up vid and copy number from vdi name
+ *
+ * This must be a cluster operation.  If QEMU reads the vdi object
+ * while sheep snapshots the vdi, sheep can return SD_RES_NO_VDI.  To
+ * avoid this problem, SD_OP_GET_INFO must be ordered with
+ * SD_OP_NEW_VDI.
+ */
+static int cluster_get_vdi_info(struct request *req)
 {
        const struct sd_req *hdr = &req->rq;
        struct sd_rsp *rsp = &req->rp;
@@ -1092,19 +1100,19 @@ static struct sd_op_template sd_ops[] = {
                .process_main = cluster_recovery_completion,
        },
 
-       /* local operations */
        [SD_OP_GET_VDI_INFO] = {
                .name = "GET_VDI_INFO",
-               .type = SD_OP_TYPE_LOCAL,
-               .process_work = local_get_vdi_info,
+               .type = SD_OP_TYPE_CLUSTER,
+               .process_work = cluster_get_vdi_info,
        },
 
        [SD_OP_LOCK_VDI] = {
                .name = "LOCK_VDI",
-               .type = SD_OP_TYPE_LOCAL,
-               .process_work = local_get_vdi_info,
+               .type = SD_OP_TYPE_CLUSTER,
+               .process_work = cluster_get_vdi_info,
        },
 
+       /* local operations */
        [SD_OP_RELEASE_VDI] = {
                .name = "RELEASE_VDI",
                .type = SD_OP_TYPE_LOCAL,
-- 
1.7.9.5

-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to