[sheepdog] [PATCH] sheep: push dirty bits correctly for successive FLUSH req

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Aug 6 16:59:42 CEST 2013


At Tue,  6 Aug 2013 17:21:42 +0800,
Liu Yuan wrote:
> 
> This will fix a bug that 'qemu-img convert' fail to convert images intact with
> default unsafe mode.
> 
> Signed-off-by: Liu Yuan <namei.unix at gmail.com>
> ---
>  sheep/object_cache.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/sheep/object_cache.c b/sheep/object_cache.c
> index c267a1f..7f03f52 100644
> --- a/sheep/object_cache.c
> +++ b/sheep/object_cache.c
> @@ -1219,10 +1219,13 @@ int object_cache_flush_vdi(uint32_t vid)
>  	}
>  
>  	if (!uatomic_set_true(&cache->in_push)) {
> -		/* Guest expects synchronous flush, busy-wait for simplicity */
> +		/*
> +		 * We have to wait for last pusher finishing and push again so
> +		 * that dirty bits produced while it is waiting are guaranteed
> +		 * to be pushed back
> +		 */
>  		while (uatomic_is_true(&cache->in_push))
>  			usleep(100000);
> -		return SD_RES_SUCCESS;
>  	}

IIUC, It seems that the above branch can be a simple loop like this:

while (!uatomic_set_true(&cache->in_push))
      usleep(100000);

The above branch let cache->in_push be false if the condition
!uatomic_set_true(&cache->in_push) is true.

Thanks,
Hitoshi



More information about the sheepdog mailing list