[sheepdog] [PATCH 3/5] sheep: make stale object erasure aware

MORITA Kazutaka morita.kazutaka at gmail.com
Tue Oct 15 19:46:05 CEST 2013


At Fri, 11 Oct 2013 17:17:13 +0800,
Liu Yuan wrote:
> 
> Replica with different ec_index should be considered stale.
> 
> Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> ---
>  sheep/plain_store.c |   24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/sheep/plain_store.c b/sheep/plain_store.c
> index 40a7aaf..c788b07 100644
> --- a/sheep/plain_store.c
> +++ b/sheep/plain_store.c
> @@ -311,6 +311,15 @@ static int set_erasure_index(const char *path, uint8_t idx)
>  	return 0;
>  }
>  
> +static int get_erasure_index(const char *path, uint8_t *idx)
> +{
> +	if (getxattr(path, ECNAME, idx, ECSIZE) < 0) {
> +		sd_err("failed to getxattr %s, %m", path);
> +		return -1;
> +	}
> +	return 0;
> +}
> +
>  int default_create_and_write(uint64_t oid, const struct siocb *iocb)
>  {
>  	char path[PATH_MAX], tmp_path[PATH_MAX];
> @@ -408,7 +417,7 @@ out:
>  
>  static bool oid_stale(uint64_t oid)
>  {
> -	int i, nr_copies;
> +	uint32_t i, nr_copies;
>  	struct vnode_info *vinfo;
>  	const struct sd_vnode *v;
>  	bool ret = true;
> @@ -421,7 +430,18 @@ static bool oid_stale(uint64_t oid)
>  	for (i = 0; i < nr_copies; i++) {
>  		v = obj_vnodes[i];
>  		if (vnode_is_local(v)) {
> -			ret = false;
> +			if (is_erasure_oid(oid)) {
> +				char path[PATH_MAX];
> +				uint8_t idx;
> +
> +				get_obj_path(oid, path, sizeof(path));
> +				if (get_erasure_index(path, &idx) < 0)
> +					break;
> +				if (idx == i)
> +					ret = false;

I guess we need a comment about when the erasure indexes will be
different.

Thanks,

Kazutaka



More information about the sheepdog mailing list