[sheepdog] [PATCH v2 2/4] sheep: don't allow it to plug new disk for pure gateway

Liu Yuan namei.unix at gmail.com
Fri Jun 20 10:53:49 CEST 2014


On Fri, Jun 20, 2014 at 04:21:28PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai at taobao.com>
> 
> A sheep daemon which is lauched as pure gateway can't (and also don't need)
> to add data path.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> Cc: Hitoshi Mitake <mitake.hitoshi at gmail.com>
> ---
> v1-->v2:
>   1. change result to 'SD_RES_INVALID_PARMS' and add log
> 
>  sheep/md.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sheep/md.c b/sheep/md.c
> index 29f263f..e213ff6 100644
> --- a/sheep/md.c
> +++ b/sheep/md.c
> @@ -802,6 +802,12 @@ static int do_plug_unplug(char *disks, bool plug)
>  	path = strtok(disks, ",");
>  	do {
>  		if (plug) {
> +			/* Not allowed to plug disk for pure gateway */
> +			if (md.nr_disks == 0 || sys->this_node.nr_vnodes == 0) {
> +				sd_err("Can't plug disk for pure gateway");
> +				ret = SD_RES_INVALID_PARMS;
> +				goto out;
> +			}

This is wrong. We should allow plug disks into 0 disk sheep. Suppose you have
1 disk for sheep and it is near broken then you want to replace it. Firstly you
unplug it and then replace the disk, at last you plug it. With your patch, we
can't do this.

You should only disallow plugging if sys->this_node.nr_vnodes == 0.

Thanks
Yuan

>  			if (!md_add_disk(path, true))
>  				sd_err("failed to add %s", path);
>  		} else {
> -- 
> 1.7.12.4
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list