Thread (3 messages) 3 messages, 3 authors, 2021-11-22

Re: [PATCH] btrfs: fix the memory leak caused in lzo_compress_pages()

From: Josef Bacik <josef@toxicpanda.com>
Date: 2021-11-20 22:11:21

On Sat, Nov 20, 2021 at 04:34:11PM +0800, Qu Wenruo wrote:
[BUG]
Fstests generic/027 is pretty easy to trigger a slow but steady memory
leak if run with "-o compress=lzo" mount option.

Normally one single run of generic/027 is enough to eat up at least 4G ram.

[CAUSE]
In commit d4088803f511 ("btrfs: subpage: make lzo_compress_pages()
compatible") we changed how @page_in is released.

But that refactor makes @page_in only released after all pages being
compressed.

This leaves error path not releasing @page_in. And by "error path"
things like incompressible data will also be treated as an error
(-E2BIG).

Thus it can leave btrfs to leak memory even there is nothing wrong
happened.

[FIX]
Add check under @out label to release @page_in when needed, so when we
hit any error, the input page is properly released.

Reported-by: Josef Bacik <josef@toxicpanda.com>
Fixes: d4088803f511 ("btrfs: subpage: make lzo_compress_pages() compatible")
Signed-off-by: Qu Wenruo <redacted>
Woo now we're making it all the way through the xfstests runs on the vm that has
-o compress=lzo.  You can add

Reviewed-and-tested-by: Josef Bacik [off-list ref]

Thanks for digging into this Qu,

Josef
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help