[sheepdog] [PATCH] collie: clean up and fix 'vdi track'

MORITA Kazutaka morita.kazutaka at gmail.com
Sat Nov 24 19:58:10 CET 2012


At Fri, 23 Nov 2012 13:28:29 +0800,
Liu Yuan wrote:
>  
>  	nr_logs = rsp->data_length / sizeof(struct epoch_log);
>  	for (i = nr_logs - 1; i >= 0; i--) {
>  		printf("\nobj %"PRIx64" locations at epoch %d, copies = %d\n",
>  		       oid, logs[i].epoch, nr_copies);
>  		printf("---------------------------------------------------\n");
> +
> +		/*
> +		 * When # of nodes is less than nr_copies, we only print
> +		 * remaining nodes that holds all the remaining copies.
> +		 */
>  		if (logs[i].nr_nodes < nr_copies) {
>  			for (j = 0; j < logs[i].nr_nodes; j++) {
>  				addr_to_str(host, sizeof(host),
> @@ -919,9 +916,8 @@ again:
>  		}
>  		vnodes_nr = nodes_to_vnodes(logs[i].nodes,
>  					    logs[i].nr_nodes, vnodes);
> -		oid_to_vnodes(vnodes, vnodes_nr, oid, logs[i].nr_copies,
> -			      vnode_buf);
> -		for (j = 0; j < logs[i].nr_copies; j++) {
> +		oid_to_vnodes(vnodes, vnodes_nr, oid, nr_copies, vnode_buf);
> +		for (j = 0; j < nr_copies; j++) {
>  			addr_to_str(host, sizeof(host), vnode_buf[j]->nid.addr,
>  				    vnode_buf[j]->nid.port);
>  			printf("%s\n", host);

Instead of explicitly handling the case where # of nodes is less than
nr_copies, printing info from 0 to min(nr_copies,logs[i].nr_copies) is
simpler?

Thanks,

Kazutaka



More information about the sheepdog mailing list