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

Liu Yuan namei.unix at gmail.com
Thu Jun 5 07:31:56 CEST 2014


On Thu, Jun 05, 2014 at 12:14:27PM +0800, Ruoyu wrote:
> 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     |  2 +-
>  tests/functional/029.out | 24 ++++++++++++++++++++++++
>  3 files changed, 41 insertions(+), 1 deletion(-)
> 
> 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 b/tests/functional/029
> index 2f3cfaa..f123fea 100755
> --- a/tests/functional/029
> +++ b/tests/functional/029
> @@ -23,7 +23,7 @@ $DOG vdi create -c 4:5 test8 20M -P
>  $DOG vdi create -c 16:7 test9 20M -P
>  $DOG vdi create -c 16:16 fail 20M -P
>  $DOG vdi snapshot -s tag test2
> -$DOG vdi clone -s 1 test2 clone -c 3
> +$DOG vdi clone -s 1 test2 clone
>  
>  for i in `seq 2 3`; do
>  	_kill_sheep $i;
> diff --git a/tests/functional/029.out b/tests/functional/029.out
> index a6d8716..23117f7 100644
> --- a/tests/functional/029.out
> +++ b/tests/functional/029.out
> @@ -40,6 +40,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 +68,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 +96,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 +124,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 +152,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 +180,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 +208,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 +236,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
> 
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog

Applied thanks

Yuan



More information about the sheepdog mailing list