[Sheepdog] [PATCH v2] store: set correct path for farm in store_remove_obj

Liu Yuan namei.unix at gmail.com
Fri Apr 13 05:35:45 CEST 2012


On 04/12/2012 05:57 PM, zituan at taobao.com wrote:

> From: Yibin Shen <zituan at taobao.com>
> 
> Signed-off-by: Yibin Shen <zituan at taobao.com>
> ---
>  sheep/store.c |   23 +++++++++++++----------
>  1 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/sheep/store.c b/sheep/store.c
> index 739862c..b50ce22 100644
> --- a/sheep/store.c
> +++ b/sheep/store.c
> @@ -587,19 +587,22 @@ int store_remove_obj(const struct sd_req *req, struct sd_rsp *rsp, void *data)
>  {
>  	struct sd_obj_req *hdr = (struct sd_obj_req *)req;
>  	uint32_t epoch = hdr->epoch;
> -	char path[1024];
> -
> -	snprintf(path, sizeof(path), "%s%08u/%016" PRIx64, obj_path,
> -		 epoch, hdr->oid);
> +	struct strbuf buf = STRBUF_INIT;
> +	int ret = SD_RES_SUCCESS;
>  
> -	if (unlink(path) < 0) {
> -		if (errno == ENOENT)
> -			return SD_RES_NO_OBJ;
> +	get_store_dir(&buf, epoch);
> +	strbuf_addf(&buf, "%016" PRIx64, hdr->oid);
> +	if (unlink(buf.buf) < 0) {
> +		if (errno == ENOENT) {
> +			ret = SD_RES_NO_OBJ;
> +			goto out;
> +		}
>  		eprintf("%m\n");
> -		return SD_RES_EIO;
> +		ret =  SD_RES_EIO;
>  	}
> -
> -	return SD_RES_SUCCESS;
> + out:
> +	strbuf_release(&buf);
> +	return ret;
>  }
>  
>  int store_read_obj(const struct sd_req *req, struct sd_rsp *rsp, void *data)


Applied, thanks.

Yuan



More information about the sheepdog mailing list