summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDāvis Mosāns <davispuh@gmail.com>2022-02-02 23:44:54 +0200
committerDavid Sterba <dsterba@suse.com>2022-03-14 13:13:50 +0100
commitdc4a4bdb3f22f9a97a59cdf3c6a1257435ff3700 (patch)
treeb02cb7b0d353cee12c1199b16374c2345c9a6958
parent40e7efe057ae7446915dc9d95bbfe4c6c7329d89 (diff)
downloadlinux-dc4a4bdb3f22f9a97a59cdf3c6a1257435ff3700.tar.bz2
btrfs: add lzo workspace buffer length constants
It makes it more readable for length checking and is be used repeatedly. Signed-off-by: Dāvis Mosāns <davispuh@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/lzo.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index e6e28a9c7987..430ad36b8b08 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -55,6 +55,9 @@
* 0x1000 | SegHdr N+1| Data payload N+1 ... |
*/
+#define WORKSPACE_BUF_LENGTH (lzo1x_worst_compress(PAGE_SIZE))
+#define WORKSPACE_CBUF_LENGTH (lzo1x_worst_compress(PAGE_SIZE))
+
struct workspace {
void *mem;
void *buf; /* where decompressed data goes */
@@ -83,8 +86,8 @@ struct list_head *lzo_alloc_workspace(unsigned int level)
return ERR_PTR(-ENOMEM);
workspace->mem = kvmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
- workspace->buf = kvmalloc(lzo1x_worst_compress(PAGE_SIZE), GFP_KERNEL);
- workspace->cbuf = kvmalloc(lzo1x_worst_compress(PAGE_SIZE), GFP_KERNEL);
+ workspace->buf = kvmalloc(WORKSPACE_BUF_LENGTH, GFP_KERNEL);
+ workspace->cbuf = kvmalloc(WORKSPACE_CBUF_LENGTH, GFP_KERNEL);
if (!workspace->mem || !workspace->buf || !workspace->cbuf)
goto fail;
@@ -380,7 +383,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
kunmap(cur_page);
cur_in += LZO_LEN;
- if (seg_len > lzo1x_worst_compress(PAGE_SIZE)) {
+ if (seg_len > WORKSPACE_CBUF_LENGTH) {
/*
* seg_len shouldn't be larger than we have allocated
* for workspace->cbuf
@@ -433,7 +436,7 @@ int lzo_decompress(struct list_head *ws, unsigned char *data_in,
struct workspace *workspace = list_entry(ws, struct workspace, list);
size_t in_len;
size_t out_len;
- size_t max_segment_len = lzo1x_worst_compress(PAGE_SIZE);
+ size_t max_segment_len = WORKSPACE_BUF_LENGTH;
int ret = 0;
char *kaddr;
unsigned long bytes;