[sheepdog] [PATCH] dog/vdi: add expected location for vdi object location command
Ruoyu
liangry at ucweb.com
Fri May 30 11:49: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
Signed-off-by: Ruoyu <liangry at ucweb.com>
---
dog/vdi.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/dog/vdi.c b/dog/vdi.c
index 866cb36..4c371e7 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("%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",
--
1.8.3.2
More information about the sheepdog
mailing list