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(-)

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;
-- 
1.7.12.4



Reply via email to