[sheepdog] [PATCH v2] sheep: fix default_link on EEXIST of link

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Jun 20 05:45:24 CEST 2013


At Thu, 20 Jun 2013 10:53:45 +0800,
Liu Yuan wrote:
> 
> This is observed by the following bug:
> 
> Jun 18 21:55:11 [rw] default_link(377) failed to link from
> /mnt/ST2000DM001-1CH164_W1E2N5GM/obj/.stale/0002e519000054f1.21 to
> /mnt/ST2000DM001-1CH164_W1E2N5GM/obj/0002e519000054f1, File exists
> Jun 18 21:55:11 [rw] err_to_sderr(96) oid=2e519000054f1, File exists
> Jun 18 21:55:11 [main] remove_disk(319) /mnt/ST2000DM001-1CH164_W1E2N5GM/obj from multi-disk array
> 
> Reported-by: Valerio Pachera <sirio81 at gmail.com>
> Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> ---
>  sheep/plain_store.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/sheep/plain_store.c b/sheep/plain_store.c
> index 272a402..8e80a1f 100644
> --- a/sheep/plain_store.c
> +++ b/sheep/plain_store.c
> @@ -374,11 +374,18 @@ int default_link(uint64_t oid, uint32_t tgt_epoch)
>  	get_stale_obj_path(oid, tgt_epoch, stale_path);
>  
>  	if (link(stale_path, path) < 0) {
> +		/*
> +		 * Recovery thread and main thread might try to recover the
> +		 * same object and we might get EEXIST in such case.

Which function recovers the object in the main thread?

Thanks,

Kazutaka


> +		 */
> +		if (errno == EEXIST)
> +			goto out;
> +
>  		sd_eprintf("failed to link from %s to %s, %m", stale_path,
>  			   path);
>  		return err_to_sderr(path, oid, errno);
>  	}
> -
> +out:
>  	return SD_RES_SUCCESS;
>  }
>  
> -- 
> 1.7.9.5
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list