Commit b71f3bcc authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Greg Kroah-Hartman

staging: zcache: cleanup zcache_do_preload and zcache_put_page

Cleanup the code for zcache_do_preload and zcache_put_page
Acked-by: default avatarSeth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Acked-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 79c0d92c
...@@ -1045,28 +1045,23 @@ static int zcache_do_preload(struct tmem_pool *pool) ...@@ -1045,28 +1045,23 @@ static int zcache_do_preload(struct tmem_pool *pool)
kp->objnodes[kp->nr++] = objnode; kp->objnodes[kp->nr++] = objnode;
} }
if (!kp->obj) {
obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
if (unlikely(obj == NULL)) { if (unlikely(obj == NULL)) {
zcache_failed_alloc++; zcache_failed_alloc++;
goto out; goto out;
} }
kp->obj = obj;
}
if (!kp->page) {
page = (void *)__get_free_page(ZCACHE_GFP_MASK); page = (void *)__get_free_page(ZCACHE_GFP_MASK);
if (unlikely(page == NULL)) { if (unlikely(page == NULL)) {
zcache_failed_get_free_pages++; zcache_failed_get_free_pages++;
kmem_cache_free(zcache_obj_cache, obj);
goto out; goto out;
} }
if (kp->obj == NULL)
kp->obj = obj;
else
kmem_cache_free(zcache_obj_cache, obj);
if (kp->page == NULL)
kp->page = page; kp->page = page;
else }
free_page((unsigned long)page);
ret = 0; ret = 0;
out: out:
...@@ -1577,14 +1572,14 @@ static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp, ...@@ -1577,14 +1572,14 @@ static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
else else
zcache_failed_pers_puts++; zcache_failed_pers_puts++;
} }
zcache_put_pool(pool);
} else { } else {
zcache_put_to_flush++; zcache_put_to_flush++;
if (atomic_read(&pool->obj_count) > 0) if (atomic_read(&pool->obj_count) > 0)
/* the put fails whether the flush succeeds or not */ /* the put fails whether the flush succeeds or not */
(void)tmem_flush_page(pool, oidp, index); (void)tmem_flush_page(pool, oidp, index);
zcache_put_pool(pool);
} }
zcache_put_pool(pool);
out: out:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment