From: "Dāvis Mosāns" <davispuh@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: "Chris Mason" <clm@fb.com>, "Josef Bacik" <josef@toxicpanda.com>,
"David Sterba" <dsterba@suse.com>,
linux-kernel@vger.kernel.org, "Dāvis Mosāns" <davispuh@gmail.com>
Subject: [PATCH 1/2] btrfs: add lzo workspace buffer length constants
Date: Wed, 2 Feb 2022 23:44:54 +0200 [thread overview]
Message-ID: <20220202214455.15753-1-davispuh@gmail.com> (raw)
It makes it more readable for length checking
Signed-off-by: Dāvis Mosāns <davispuh@gmail.com>
---
fs/btrfs/lzo.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 0fb90cbe7669..31319dfcc9fb 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;
@@ -422,7 +425,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;
--
2.35.1
next reply other threads:[~2022-02-02 21:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 21:44 Dāvis Mosāns [this message]
2022-02-02 21:44 ` [PATCH 2/2] btrfs: prevent copying too big compressed lzo segment Dāvis Mosāns
2022-02-03 13:26 ` Su Yue
2022-02-03 16:04 ` Dāvis Mosāns
2022-02-04 0:48 ` Omar Sandoval
2022-02-07 1:01 ` Dāvis Mosāns
2022-02-10 14:05 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220202214455.15753-1-davispuh@gmail.com \
--to=davispuh@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox