On Mon, Jun 30, 2014 at 08:53:36PM +0800, Ruoyu wrote:
> If using md, it is easy to re-produce the error when sheepdog is
> doing recovery. The error message is just like as below.
> 
> ERROR [io 30895] md_move_object(630) failed to create
>                  /mnt/sheepdog/obj2/0082aba600000056
> ERROR [io 30895] md_check_and_move(661) move old
>                  /mnt/sheepdog/obj/0082aba600000056 to new
>                  /mnt/sheepdog/obj2/0082aba600000056 failed
> 
> If the above target object is being written unfortunately by other
> thread at that time, atomic_create_and_write return -1, and then,
> md_exist return false so that guest file system catch it.
> 
> Therefore, I think we should check errno if atomic_create_and_write
> is failure. If the temp file exist, in another word, someone is
> writting it, just return success to avoid the error.
> 
> Signed-off-by: Ruoyu <lian...@ucweb.com>
> ---
>  sheep/md.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/sheep/md.c b/sheep/md.c
> index 538f696..a1c950e 100644
> --- a/sheep/md.c
> +++ b/sheep/md.c
> @@ -627,9 +627,11 @@ static int md_move_object(uint64_t oid, const char *old, 
> const char *new)
>       }
>  
>       if (atomic_create_and_write(new, buf.buf, buf.len, false) < 0) {
> -             sd_err("failed to create %s", new);
> -             ret = -1;
> -             goto out_close;
> +             if (errno != EEXIST) {
> +                     sd_err("failed to create %s", new);
> +                     ret = -1;
> +                     goto out_close;
> +             }
>       }
>       unlink(old);
>       ret = 0;
> -- 
> 1.8.3.2
> 
> 
> -- 
> sheepdog mailing list
> sheepdog@lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog

Applied thanks

Yuan
-- 
sheepdog mailing list
sheepdog@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to