On 04/02/2014 02:56 AM, arei.gong...@huawei.com wrote:
> From: ChenLiang <chenlian...@huawei.com>
> 
> The cache_insert don't check whether the page has been in the cache.
> 
> Signed-off-by: ChenLiang <chenlian...@huawei.com>
> Signed-off-by: Gonglei <arei.gong...@huawei.com>
> ---
>  page_cache.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <ebl...@redhat.com>

> 
> diff --git a/page_cache.c b/page_cache.c
> index c78157b..78f7590 100644
> --- a/page_cache.c
> +++ b/page_cache.c
> @@ -171,7 +171,7 @@ int cache_insert(PageCache *cache, uint64_t addr, const 
> uint8_t *pdata,
>      /* actual update of entry */
>      it = cache_get_by_addr(cache, addr);
>  
> -    if (it->it_data &&
> +    if (it->it_data && it->it_addr != addr &&
>          it->it_age + CACHED_PAGE_LIFETIME > current_age) {
>          /* the cache page is fresh, don't replace it */
>          return -1;
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to