Message ID | 1396428990-2516-1-git-send-email-arei.gonglei@huawei.com |
---|---|
State | New |
Headers | show |
On 04/02/2014 02:56 AM, arei.gonglei@huawei.com wrote: > From: ChenLiang <chenliang88@huawei.com> > > The cache_insert don't check whether the page has been in the cache. > > Signed-off-by: ChenLiang <chenliang88@huawei.com> > Signed-off-by: Gonglei <arei.gonglei@huawei.com> > --- > page_cache.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Reviewed-by: Eric Blake <eblake@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; >
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;