diff options
author | Sergey Senozhatsky <senozhatsky@chromium.org> | 2024-09-02 19:56:06 +0900 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-09-09 16:39:10 -0700 |
commit | 6a81bdfeb35094c3097650306a5fda9a990d8a97 (patch) | |
tree | dffab6dabed1741ba4e9401114dabd916468fbcb /drivers/block/zram/backend_lzo.c | |
parent | 52c7b4e2ba508a924c991e681db534e66a851adf (diff) |
zram: introduce zcomp_ctx structure
Keep run-time driver data (scratch buffers, etc.) in zcomp_ctx structure.
This structure is allocated per-CPU because drivers (backends) need to
modify its content during requests execution.
We will split mutable and immutable driver data, this is a preparation
path.
Link: https://lkml.kernel.org/r/20240902105656.1383858-19-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nick Terrell <terrelln@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram/backend_lzo.c')
-rw-r--r-- | drivers/block/zram/backend_lzo.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/block/zram/backend_lzo.c b/drivers/block/zram/backend_lzo.c index 88f1aa5683f3..81fbad286092 100644 --- a/drivers/block/zram/backend_lzo.c +++ b/drivers/block/zram/backend_lzo.c @@ -6,26 +6,29 @@ #include "backend_lzo.h" -static void *lzo_create(struct zcomp_params *params) +static int lzo_create(struct zcomp_params *params, struct zcomp_ctx *ctx) { - return kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); + ctx->context = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); + if (!ctx->context) + return -ENOMEM; + return 0; } -static void lzo_destroy(void *ctx) +static void lzo_destroy(struct zcomp_ctx *ctx) { - kfree(ctx); + kfree(ctx->context); } -static int lzo_compress(void *ctx, struct zcomp_req *req) +static int lzo_compress(struct zcomp_ctx *ctx, struct zcomp_req *req) { int ret; ret = lzo1x_1_compress(req->src, req->src_len, req->dst, - &req->dst_len, ctx); + &req->dst_len, ctx->context); return ret == LZO_E_OK ? 0 : ret; } -static int lzo_decompress(void *ctx, struct zcomp_req *req) +static int lzo_decompress(struct zcomp_ctx *ctx, struct zcomp_req *req) { int ret; |