[sheepdog] [PATCH v3] dog/vdi: add expected location for vdi object location command

Ruoyu liangry at ucweb.com
Thu Jun 5 06:06:22 CEST 2014


Current dog vdi object location command only print the actual
location of specified object. I think it is necessary to print
the expected location for diagnosis. Suppose that a temporary
object file ended with ".tmp" is existed in obj directory due to
some error, dog vdi check command shows the object is missing
and fixed. However, actually it is not fixed.

This example helps us to troubleshoot the problem is located at
node 10.1.48.167:7009, not at other nodes.

$ dog vdi object location -i 409 rh54t
Looking for the object 0xbfa2f600000199
(vid 0xbfa2f6 idx 409, 2 copies) with 10 nodes

10.1.48.167:7000 doesn't have the object
10.1.48.167:7001 doesn't have the object
10.1.48.167:7002 has the object
10.1.48.167:7003 doesn't have the object
10.1.48.167:7004 doesn't have the object
10.1.48.167:7005 doesn't have the object
10.1.48.167:7006 doesn't have the object
10.1.48.167:7007 doesn't have the object
10.1.48.167:7008 doesn't have the object
10.1.48.167:7009 doesn't have the object

According to sheepdog algorithm, the object should be located at:
10.1.48.167:7002 10.1.48.167:7009

Output of functional test case 029 is also updated.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 dog/vdi.c                | 16 ++++++++++++++++
 tests/functional/029.out | 28 ++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/dog/vdi.c b/dog/vdi.c
index 866cb36..52a1047 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -824,6 +824,20 @@ static int vdi_object_map(int argc, char **argv)
 	return EXIT_SUCCESS;
 }
 
+static void print_expected_location(uint64_t oid, int copies)
+{
+	const struct sd_vnode *vnodes[SD_MAX_COPIES];
+
+	printf("\nAccording to sheepdog algorithm, "
+		   "the object should be located at:\n");
+	oid_to_vnodes(oid, &sd_vroot, copies, vnodes);
+	for (int i = 0; i < copies; i++)
+		printf((i < copies - 1) ? "%s " : "%s",
+			addr_to_str(vnodes[i]->node->nid.addr,
+				vnodes[i]->node->nid.port));
+	printf("\n");
+}
+
 static int vdi_object_location(int argc, char **argv)
 {
 	const char *vdiname = argv[optind];
@@ -846,6 +860,7 @@ static int vdi_object_location(int argc, char **argv)
 		       " nodes\n\n",
 		       vid, sd_nodes_nr);
 		for_each_node_print(vid_to_vdi_oid(vid));
+		print_expected_location(vid_to_vdi_oid(vid), inode->nr_copies);
 		ret = EXIT_SUCCESS;
 		goto out;
 	}
@@ -865,6 +880,7 @@ static int vdi_object_location(int argc, char **argv)
 			oid, vid, idx, inode->nr_copies, sd_nodes_nr);
 
 		for_each_node_print(oid);
+		print_expected_location(oid, inode->nr_copies);
 	} else
 		printf("The inode object 0x%" PRIx32 " idx"
 		       " %"PRIu64" is not allocated\n",
diff --git a/tests/functional/029.out b/tests/functional/029.out
index a6d8716..5434aad 100644
--- a/tests/functional/029.out
+++ b/tests/functional/029.out
@@ -6,6 +6,10 @@ To create replicated vdi, set -c x
 To create erasure coded vdi, set -c x:y
   x(2,4,8,16)  - number of data strips
   y(1 to 15)   - number of parity strips
+../../dog/dog: invalid option -- 'c'
+Try 'dog --help' for more information.
+Cannot get VDI info for clone 0 : No VDI found
+Failed to open VDI clone
   Name        Id    Size    Used  Shared    Creation time   VDI id  Copies  Tag
   test5        0   20 MB   20 MB  0.0 MB DATE   fd2c30    4:2              
   test4        0   20 MB   20 MB  0.0 MB DATE   fd2de3      4              
@@ -40,6 +44,9 @@ Looking for the object 0xfd381500000001 (vid 0xfd3816 idx 1, 2 copies) with 23 n
 127.0.0.1:7022 has the object
 127.0.0.1:7023 doesn't have the object
 127.0.0.1:7024 doesn't have the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7016 127.0.0.1:7022
 Looking for the object 0xfd366200000001 (vid 0xfd3662 idx 1, 3 copies) with 23 nodes
 
 127.0.0.1:7000 doesn't have the object
@@ -65,6 +72,9 @@ Looking for the object 0xfd366200000001 (vid 0xfd3662 idx 1, 3 copies) with 23 n
 127.0.0.1:7022 doesn't have the object
 127.0.0.1:7023 doesn't have the object
 127.0.0.1:7024 doesn't have the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7007 127.0.0.1:7012 127.0.0.1:7001
 Looking for the object 0xfd2de300000001 (vid 0xfd2de3 idx 1, 4 copies) with 23 nodes
 
 127.0.0.1:7000 doesn't have the object
@@ -90,6 +100,9 @@ Looking for the object 0xfd2de300000001 (vid 0xfd2de3 idx 1, 4 copies) with 23 n
 127.0.0.1:7022 doesn't have the object
 127.0.0.1:7023 doesn't have the object
 127.0.0.1:7024 doesn't have the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7005 127.0.0.1:7001 127.0.0.1:7014 127.0.0.1:7019
 Looking for the object 0xfd2c3000000001 (vid 0xfd2c30 idx 1, 6 copies) with 23 nodes
 
 127.0.0.1:7000 has the object
@@ -115,6 +128,9 @@ Looking for the object 0xfd2c3000000001 (vid 0xfd2c30 idx 1, 6 copies) with 23 n
 127.0.0.1:7022 doesn't have the object
 127.0.0.1:7023 has the object
 127.0.0.1:7024 doesn't have the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7021 127.0.0.1:7000 127.0.0.1:7009 127.0.0.1:7001 127.0.0.1:7023 127.0.0.1:7011
 Looking for the object 0xfd314900000001 (vid 0xfd3149 idx 1, 7 copies) with 23 nodes
 
 127.0.0.1:7000 doesn't have the object
@@ -140,6 +156,9 @@ Looking for the object 0xfd314900000001 (vid 0xfd3149 idx 1, 7 copies) with 23 n
 127.0.0.1:7022 has the object
 127.0.0.1:7023 doesn't have the object
 127.0.0.1:7024 has the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7024 127.0.0.1:7022 127.0.0.1:7011 127.0.0.1:7008 127.0.0.1:7019 127.0.0.1:7012 127.0.0.1:7001
 Looking for the object 0xfd2f9600000001 (vid 0xfd2f96 idx 1, 8 copies) with 23 nodes
 
 127.0.0.1:7000 doesn't have the object
@@ -165,6 +184,9 @@ Looking for the object 0xfd2f9600000001 (vid 0xfd2f96 idx 1, 8 copies) with 23 n
 127.0.0.1:7022 doesn't have the object
 127.0.0.1:7023 doesn't have the object
 127.0.0.1:7024 doesn't have the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7004 127.0.0.1:7019 127.0.0.1:7012 127.0.0.1:7013 127.0.0.1:7014 127.0.0.1:7008 127.0.0.1:7001 127.0.0.1:7006
 Looking for the object 0xfd424700000001 (vid 0xfd4247 idx 1, 9 copies) with 23 nodes
 
 127.0.0.1:7000 doesn't have the object
@@ -190,6 +212,9 @@ Looking for the object 0xfd424700000001 (vid 0xfd4247 idx 1, 9 copies) with 23 n
 127.0.0.1:7022 has the object
 127.0.0.1:7023 has the object
 127.0.0.1:7024 has the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7006 127.0.0.1:7024 127.0.0.1:7023 127.0.0.1:7004 127.0.0.1:7022 127.0.0.1:7015 127.0.0.1:7011 127.0.0.1:7014 127.0.0.1:7010
 Looking for the object 0xfd409400000001 (vid 0xfd4094 idx 1, 23 copies) with 23 nodes
 
 127.0.0.1:7000 has the object
@@ -215,3 +240,6 @@ Looking for the object 0xfd409400000001 (vid 0xfd4094 idx 1, 23 copies) with 23
 127.0.0.1:7022 has the object
 127.0.0.1:7023 has the object
 127.0.0.1:7024 has the object
+
+According to sheepdog algorithm, the object should be located at:
+127.0.0.1:7018 127.0.0.1:7020 127.0.0.1:7019 127.0.0.1:7015 127.0.0.1:7000 127.0.0.1:7021 127.0.0.1:7023 127.0.0.1:7005 127.0.0.1:7017 127.0.0.1:7004 127.0.0.1:7008 127.0.0.1:7007 127.0.0.1:7022 127.0.0.1:7014 127.0.0.1:7001 127.0.0.1:7006 127.0.0.1:7016 127.0.0.1:7009 127.0.0.1:7012 127.0.0.1:7024 127.0.0.1:7010 127.0.0.1:7011 127.0.0.1:7013
-- 
1.8.3.2





More information about the sheepdog mailing list