[sheepdog] [PATCH] sheep: fix vdi clone operation

Liu Yuan namei.unix at gmail.com
Wed Feb 5 14:17:28 CET 2014


- pass correct array size
- return FULL_VDI instead of wrong NO_BASE_VDI

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/vdi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sheep/vdi.c b/sheep/vdi.c
index 080bc82..1ae31ca 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -315,9 +315,9 @@ static int clone_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid,
 		goto out;
 	}
 
-	idx = find_free_idx(base->child_vdi_id, sizeof(base->child_vdi_id));
+	idx = find_free_idx(base->child_vdi_id, ARRAY_SIZE(base->child_vdi_id));
 	if (idx < 0) {
-		ret = SD_RES_NO_BASE_VDI;
+		ret = SD_RES_FULL_VDI;
 		goto out;
 	}
 
@@ -379,9 +379,9 @@ static int snapshot_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid,
 		goto out;
 	}
 
-	idx = find_free_idx(base->child_vdi_id, sizeof(base->child_vdi_id));
+	idx = find_free_idx(base->child_vdi_id, ARRAY_SIZE(base->child_vdi_id));
 	if (idx < 0) {
-		ret = SD_RES_NO_BASE_VDI;
+		ret = SD_RES_FULL_VDI;
 		goto out;
 	}
 
@@ -448,9 +448,9 @@ static int rebase_vdi(const struct vdi_iocb *iocb, uint32_t new_snapid,
 		goto out;
 	}
 
-	idx = find_free_idx(base->child_vdi_id, sizeof(base->child_vdi_id));
+	idx = find_free_idx(base->child_vdi_id, ARRAY_SIZE(base->child_vdi_id));
 	if (idx < 0) {
-		ret = SD_RES_NO_BASE_VDI;
+		ret = SD_RES_FULL_VDI;
 		goto out;
 	}
 
-- 
1.8.1.2




More information about the sheepdog mailing list