* [PATCH] erofs: fix memory leak on short-lived bounced pages
@ 2023-11-28 17:58 Gao Xiang
2023-11-28 18:04 ` [PATCH v2] " Gao Xiang
0 siblings, 1 reply; 4+ messages in thread
From: Gao Xiang @ 2023-11-28 17:58 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang
Both MicroLZMA and DEFLATE algorithms can use short-lived pages on
demand for overlap inplace I/O decompression.
However, those short-lived pages are actually added to
`be->decompressed_pages`. Thus, it should be checked instead of
`pcl->compressed_bvecs`.
The LZ4 algorithm doesn't work like this, so it won't be impacted.
Fixes: 67139e36d970 ("erofs: introduce `z_erofs_parse_in_bvecs'")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/zdata.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index a7e6847f6f8f..e5e44f926692 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1309,12 +1309,11 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
put_page(page);
} else {
for (i = 0; i < pclusterpages; ++i) {
- page = pcl->compressed_bvecs[i].page;
+ /* consider shortlived pages added when decompressing */
+ page = be->decompressed_pages[i];
if (erofs_page_is_managed(sbi, page))
continue;
-
- /* recycle all individual short-lived pages */
(void)z_erofs_put_shortlivedpage(be->pagepool, page);
WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);
}
--
2.39.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] erofs: fix memory leak on short-lived bounced pages
2023-11-28 17:58 [PATCH] erofs: fix memory leak on short-lived bounced pages Gao Xiang
@ 2023-11-28 18:04 ` Gao Xiang
2023-11-29 5:39 ` Yue Hu
2023-12-14 15:00 ` Chao Yu
0 siblings, 2 replies; 4+ messages in thread
From: Gao Xiang @ 2023-11-28 18:04 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang
Both MicroLZMA and DEFLATE algorithms can use short-lived pages on
demand for overlap inplace I/O decompression.
However, those short-lived pages are actually added to
`be->compressed_pages`. Thus, it should be checked instead of
`pcl->compressed_bvecs`.
The LZ4 algorithm doesn't work like this, so it won't be impacted.
Fixes: 67139e36d970 ("erofs: introduce `z_erofs_parse_in_bvecs'")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
v2:
- should be `be->compressed_pages`.
fs/erofs/zdata.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index a7e6847f6f8f..a33cd6757f98 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1309,12 +1309,11 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be,
put_page(page);
} else {
for (i = 0; i < pclusterpages; ++i) {
- page = pcl->compressed_bvecs[i].page;
+ /* consider shortlived pages added when decompressing */
+ page = be->compressed_pages[i];
if (erofs_page_is_managed(sbi, page))
continue;
-
- /* recycle all individual short-lived pages */
(void)z_erofs_put_shortlivedpage(be->pagepool, page);
WRITE_ONCE(pcl->compressed_bvecs[i].page, NULL);
}
--
2.39.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] erofs: fix memory leak on short-lived bounced pages
2023-11-28 18:04 ` [PATCH v2] " Gao Xiang
@ 2023-11-29 5:39 ` Yue Hu
2023-12-14 15:00 ` Chao Yu
1 sibling, 0 replies; 4+ messages in thread
From: Yue Hu @ 2023-11-29 5:39 UTC (permalink / raw)
To: Gao Xiang; +Cc: linux-erofs, LKML, huyue2
On Wed, 29 Nov 2023 02:04:31 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
> Both MicroLZMA and DEFLATE algorithms can use short-lived pages on
> demand for overlap inplace I/O decompression.
>
> However, those short-lived pages are actually added to
> `be->compressed_pages`. Thus, it should be checked instead of
> `pcl->compressed_bvecs`.
>
> The LZ4 algorithm doesn't work like this, so it won't be impacted.
>
> Fixes: 67139e36d970 ("erofs: introduce `z_erofs_parse_in_bvecs'")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Yue Hu <huyue2@coolpad.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] erofs: fix memory leak on short-lived bounced pages
2023-11-28 18:04 ` [PATCH v2] " Gao Xiang
2023-11-29 5:39 ` Yue Hu
@ 2023-12-14 15:00 ` Chao Yu
1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-12-14 15:00 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: LKML
On 2023/11/29 2:04, Gao Xiang wrote:
> Both MicroLZMA and DEFLATE algorithms can use short-lived pages on
> demand for overlap inplace I/O decompression.
>
> However, those short-lived pages are actually added to
> `be->compressed_pages`. Thus, it should be checked instead of
> `pcl->compressed_bvecs`.
>
> The LZ4 algorithm doesn't work like this, so it won't be impacted.
>
> Fixes: 67139e36d970 ("erofs: introduce `z_erofs_parse_in_bvecs'")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-14 15:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 17:58 [PATCH] erofs: fix memory leak on short-lived bounced pages Gao Xiang
2023-11-28 18:04 ` [PATCH v2] " Gao Xiang
2023-11-29 5:39 ` Yue Hu
2023-12-14 15:00 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox