qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function


From: Gonglei (Arei)
Subject: [Qemu-devel] [PATCH 4/7] XBZRLE: rebuild the cache_is_cached function
Date: Fri, 28 Feb 2014 04:10:05 +0000

Rebuild the cache_is_cached function.

Signed-off-by: ChenLiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
 page_cache.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/page_cache.c b/page_cache.c
index fa58ab2..34ec933 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -121,24 +121,6 @@ static size_t cache_get_cache_pos(const PageCache *cache,
     return pos;
 }
 
-bool cache_is_cached(const PageCache *cache, uint64_t addr,
-                                             uint64_t current_age)
-{
-    size_t pos;
-
-    g_assert(cache);
-    g_assert(cache->page_cache);
-
-    pos = cache_get_cache_pos(cache, addr);
-
-    if (cache->page_cache[pos].it_addr == addr) {
-        /* updata the it_age when the cache hit */
-        cache->page_cache[pos].it_age = current_age;
-        return true;
-    }
-    return false;
-}
-
 static CacheItem *cache_get_by_addr(const PageCache *cache, uint64_t addr)
 {
     size_t pos;
@@ -156,6 +138,21 @@ uint8_t *get_cached_data(const PageCache *cache, uint64_t 
addr)
     return cache_get_by_addr(cache, addr)->it_data;
 }
 
+bool cache_is_cached(const PageCache *cache, uint64_t addr,
+                                             uint64_t current_age)
+{
+    CacheItem *it = NULL;
+
+    it = cache_get_by_addr(cache, addr);
+
+    if (it->it_addr == addr) {
+        /* updata the it_age when the cache hit */
+        it->it_age = current_age;
+        return true;
+    }
+    return false;
+}
+
 int cache_insert(PageCache *cache, uint64_t addr, const uint8_t *pdata,
                                                         uint64_t current_age)
 {
-- 
1.7.12.4

Best regards,
-Gonglei





reply via email to

[Prev in Thread] Current Thread [Next in Thread]