[sheepdog] [PATCH 4/4] dog: add a new subcommand "dog vdi object dump-inode" for diagnosing inode object

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue May 6 17:25:55 CEST 2014


This patch adds a tool for diagnosing inode object.

How to use:
$ dog vdi object dump-inode <path of inode file>

Sample of output:
name: test
tag:
create_time: 5368f57a0a96d0c0
snap_ctime: 0
vm_clock_nsec: 0
copy_policy: 0
store_policy: 0
nr_copies: 3
block_size_shift: 22
snap_id: 1
vdi_id: 7c2b25
parent_vdi_id: 0
btree_counter: 0
data_vdi_id:

Cc: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Cc: Valerio Pachera <sirio81 at gmail.com>
Cc: Alessandro Bolgia <alessandro at extensys.it>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 dog/vdi.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/dog/vdi.c b/dog/vdi.c
index 552b483..82f301e 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -2269,11 +2269,55 @@ out:
 	return ret;
 }
 
+static int vdi_object_dump_inode(int argc, char **argv)
+{
+	struct sd_inode *inode = xzalloc(sizeof(*inode));
+	int fd, ret;
+
+	fd = open(argv[optind], O_RDONLY);
+	if (fd < 0) {
+		sd_err("fialed to open inode object file: %m");
+		return EXIT_FAILURE;
+	}
+
+	ret = xread(fd, inode, sizeof(*inode));
+	if (ret != sizeof(*inode)) {
+		sd_err("fialed to read inode object file: %m");
+		return EXIT_FAILURE;
+	}
+
+	printf("name: %s\n", inode->name);
+	printf("tag: %s\n", inode->tag);
+	printf("create_time: %"PRIx64"\n", inode->create_time);
+	printf("snap_ctime: %"PRIx64"\n", inode->snap_ctime);
+	printf("vm_clock_nsec: %"PRIx64"\n", inode->vm_clock_nsec);
+	printf("copy_policy: %d\n", inode->copy_policy);
+	printf("store_policy: %d\n", inode->store_policy);
+	printf("nr_copies: %d\n", inode->nr_copies);
+	printf("block_size_shift: %d\n", inode->block_size_shift);
+	printf("snap_id: %"PRIu32"\n", inode->snap_id);
+	printf("vdi_id: %"PRIx32"\n", inode->vdi_id);
+	printf("parent_vdi_id: %"PRIx32"\n", inode->parent_vdi_id);
+	printf("btree_counter: %"PRIu32"\n", inode->btree_counter);
+
+	printf("data_vdi_id:");
+	for (int i = 0; i < SD_INODE_DATA_INDEX; i++) {
+		if (!inode->data_vdi_id[i])
+			continue;
+
+		printf("%d: %"PRIu32"\n", i, inode->data_vdi_id[i]);
+	}
+
+	return EXIT_SUCCESS;
+}
+
 static struct subcommand vdi_object_cmd[] = {
 	{"location", NULL, NULL, "show object location information",
 	 NULL, CMD_NEED_NODELIST|CMD_NEED_ARG, vdi_object_location},
 	{"map", NULL, NULL, "show object map information",
 	 NULL, CMD_NEED_ARG, vdi_object_map},
+	{"dump-inode", NULL, NULL, "dump inode information",
+	 NULL, CMD_NEED_ARG, vdi_object_dump_inode},
 	{NULL},
 };
 
-- 
1.9.1




More information about the sheepdog mailing list