[sheepdog] [PATCH] dog/vdi: fix panic if number of nodes less than number of copies

Ruoyu liangry at ucweb.com
Mon Mar 2 13:06:29 CET 2015


Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 dog/vdi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/dog/vdi.c b/dog/vdi.c
index 6be3304..3a69505 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -1137,6 +1137,13 @@ static void print_expected_location(uint64_t oid, int copies)
 {
 	const struct sd_vnode *vnodes[SD_MAX_COPIES];
 
+	if (sd_nodes_nr < copies) {
+		printf("\nBecause number of nodes (%d) is less than "
+			"number of copies (%d), the object should be located "
+			"at every nodes.\n", sd_nodes_nr, copies);
+		return;
+	}
+
 	printf("\nAccording to sheepdog algorithm, "
 		   "the object should be located at:\n");
 	oid_to_vnodes(oid, &sd_vroot, copies, vnodes);
-- 
1.8.3.2





More information about the sheepdog mailing list