[sheepdog-users] n copies > n nodes

MORITA Kazutaka morita.kazutaka at gmail.com
Mon Mar 18 00:57:55 CET 2013


At Fri, 15 Mar 2013 15:58:58 +0800,
Liu Yuan wrote:
> 
> On 03/15/2013 02:56 PM, MORITA Kazutaka wrote:
> > Then other functions that call write_object() have the same problem.
> > I wonder if we should change get_req_copy_number() so that it returns
> > a smaller number only when cluster mode is unsafe.
> 
> get_req_copy_number just tries hard to get the correct copies to work on. I think we shouldn't rely on the failure of write to backend to check if this operation is valid. If we are failed, we can't easily remove the objects that are partially written to backend store. This is two deep in the write path, we'd better exclude this write as early as possible.
> 
> The point of nohalt or quorum is to let cluster keep running for a short period for the crash events that make the number of nodes in the cluster is less than nr_copies. Allow creating VDI with required copies larger than alive nodes is nonsense. How about following patch:
> 
> f8770d90579f026c7881f974a5f8 Mon Sep 17 00:00:00 2001
> From: Liu Yuan <tailai.ly at taobao.com>
> Date: Fri, 15 Mar 2013 15:57:53 +0800
> Subject: [PATCH v2] collie: don't create VDI when there are not enough nodes
> 
> If we have less nodes than required copies, just error return.
> 
> Reported-by: Valerio Pachera <sirio81 at gmail.com>
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  collie/vdi.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/collie/vdi.c b/collie/vdi.c
> index 94acca9..d06c29c 100644
> --- a/collie/vdi.c
> +++ b/collie/vdi.c
> @@ -514,7 +514,7 @@ static int vdi_create(int argc, char **argv)
>  	uint64_t size;
>  	uint32_t vid;
>  	uint64_t oid;
> -	int idx, max_idx, ret;
> +	int idx, max_idx, ret, nr_copies = vdi_cmd_data.nr_copies;
>  	struct sheepdog_inode *inode = NULL;
>  
>  	if (!argv[optind]) {
> @@ -529,6 +529,12 @@ static int vdi_create(int argc, char **argv)
>  		return EXIT_USAGE;
>  	}
>  
> +	if (nr_copies > sd_nodes_nr) {
> +		fprintf(stderr, "There are not enough nodes(%d) to hold "
> +			"the copies(%d)\n", sd_nodes_nr, nr_copies);
> +		return EXIT_USAGE;
> +	}
> +

Do we need the same check in vdi_delete() and vdi_setattr() since
those functions also invoke write_object() in the sheep side?

Thanks,

Kazutaka



More information about the sheepdog-users mailing list