struct zpool *zpool;
gfp_t gfp;
u8 *dst;
+ bool mapped = false;
acomp_ctx = acomp_ctx_get_cpu_lock(pool);
dst = acomp_ctx->buffer;
* only adds metadata overhead. swap_writeout() will put the page back
* to the active LRU list in the case.
*/
- if (comp_ret || !dlen)
+ if (comp_ret || !dlen || dlen >= PAGE_SIZE) {
dlen = PAGE_SIZE;
- if (dlen >= PAGE_SIZE) {
if (!mem_cgroup_zswap_writeback_enabled(
folio_memcg(page_folio(page)))) {
comp_ret = comp_ret ? comp_ret : -EINVAL;
comp_ret = 0;
dlen = PAGE_SIZE;
dst = kmap_local_page(page);
+ mapped = true;
}
zpool = pool->zpool;
entry->length = dlen;
unlock:
- if (dst != acomp_ctx->buffer)
+ if (mapped)
kunmap_local(dst);
if (comp_ret == -ENOSPC || alloc_ret == -ENOSPC)
zswap_reject_compress_poor++;
struct zpool *zpool = entry->pool->zpool;
struct scatterlist input, output;
struct crypto_acomp_ctx *acomp_ctx;
- int decomp_ret, dlen;
+ int decomp_ret = 0, dlen = PAGE_SIZE;
u8 *src, *obj;
acomp_ctx = acomp_ctx_get_cpu_lock(entry->pool);
/* zswap entries of length PAGE_SIZE are not compressed. */
if (entry->length == PAGE_SIZE) {
memcpy_to_folio(folio, 0, obj, entry->length);
- zpool_obj_read_end(zpool, entry->handle, obj);
- acomp_ctx_put_unlock(acomp_ctx);
- return true;
+ goto read_done;
}
/*
decomp_ret = crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait);
dlen = acomp_ctx->req->dlen;
+read_done:
zpool_obj_read_end(zpool, entry->handle, obj);
acomp_ctx_put_unlock(acomp_ctx);