[sheepdog] [PATCH] sheep: daemon should exit directly if there is no availabe disk

Liu Yuan namei.unix at gmail.com
Tue Dec 24 13:22:05 CET 2013


On Tue, Dec 24, 2013 at 04:16:07PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai at taobao.com>
> 
> Currently, the sheep daemon will only report "multi-disk support need xattr feature"
> and continue to run when all the data pathe are not support xattr.But if we create
> a vdi, it will report path is broken.
> So, we need to check the return code of md_add_disk() and exit if all the path is
> unavailabe.
> 
> This patch also fix some log level in source code.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  lib/net.c     |  4 ++--
>  sheep/md.c    |  3 ++-
>  sheep/sheep.c |  4 ++--
>  sheep/store.c | 15 ++++++++++++++-
>  4 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/net.c b/lib/net.c
> index 23c9e5d..b32e022 100644
> --- a/lib/net.c
> +++ b/lib/net.c
> @@ -516,12 +516,12 @@ int get_local_addr(uint8_t *bytes)
>  			memset(bytes, 0, 12);
>  			memcpy(bytes + 12, &sin->sin_addr, 4);
>  			memcpy(bytes + 12, &sin->sin_addr, 4);
> -			sd_err("found IPv4 address");
> +			sd_notice("found IPv4 address");
>  			goto out;
>  		case AF_INET6:
>  			sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
>  			memcpy(bytes, &sin6->sin6_addr, 16);
> -			sd_err("found IPv6 address");
> +			sd_notice("found IPv6 address");
>  			goto out;
>  		}
>  	}
> diff --git a/sheep/md.c b/sheep/md.c
> index e6d175c..6814c61 100644
> --- a/sheep/md.c
> +++ b/sheep/md.c
> @@ -240,7 +240,8 @@ static uint64_t init_path_space(const char *path, bool purge)
>  	char stale[PATH_MAX];
>  
>  	if (!is_xattr_enabled(path)) {
> -		sd_info("multi-disk support need xattr feature");
> +		sd_warn("multi-disk support need xattr feature for path: %s",
> +			path);
>  		goto broken_path;
>  	}
>  
> diff --git a/sheep/sheep.c b/sheep/sheep.c
> index e1d4a39..a87c49d 100644
> --- a/sheep/sheep.c
> +++ b/sheep/sheep.c
> @@ -470,8 +470,8 @@ static void check_host_env(void)
>  	 * dangerous to run Sheepdog cluster.
>  	 */
>  	else if (r.rlim_cur == 1024)
> -		sd_err("WARN: Allowed open files 1024 too small, suggested %u",
> -		       SD_RLIM_NOFILE);
> +		sd_warn("Allowed open files 1024 too small, suggested %u",
> +			SD_RLIM_NOFILE);
>  	else if (r.rlim_cur < SD_RLIM_NOFILE)
>  		sd_info("Allowed open files %lu, suggested %u", r.rlim_cur,
>  			SD_RLIM_NOFILE);
> diff --git a/sheep/store.c b/sheep/store.c
> index 4e6a6d4..6da9088 100644
> --- a/sheep/store.c
> +++ b/sheep/store.c
> @@ -203,7 +203,8 @@ static int is_meta_store(const char *path)
>  static int init_obj_path(const char *base_path, char *argp)
>  {
>  	char *p;
> -	int len;
> +	int len, ret;
> +	struct sd_md_info mdi;
>  
>  	if (check_path_len(base_path) < 0)
>  		return -1;
> @@ -232,6 +233,18 @@ static int init_obj_path(const char *base_path, char *argp)
>  			md_add_disk(p, false);
>  		} while ((p = strtok(NULL, ",")));
>  	}
> +
> +	ret = md_get_info(&mdi);
> +	if (ret != sizeof(mdi)) {
> +		sd_err("Can't get md info");
> +		return -1;
> +	}
> +	/* check the number of available disks */

Applied after removing this comment because sd_err already said it

Thanks
Yuan



More information about the sheepdog mailing list