The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] erofs: skip sufficiently large global buffers when resizing
@ 2026-08-22 14:00 Nikhil Gurudasani
  2026-08-23 12:59 ` Gao Xiang
  2026-08-24  0:57 ` Chao Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Nikhil Gurudasani @ 2026-08-22 14:00 UTC (permalink / raw)
  To: xiang, chao
  Cc: zbestahu, jefflexu, dhavale, hongbohbli, guochunhai, linux-erofs,
	linux-kernel, stable

z_erofs_gbuf_nrpages is advanced only after every global buffer has been
grown. If a resize fails after some buffers were enlarged, a retry
revisits those enlarged buffers.

Retrying the same size then returns -ENOMEM because alloc_pages_bulk()
has no pages to add and the unchanged return value is treated as a
failure. Retrying an intermediate size allocates a temporary pointer
array smaller than gbuf->nrpages and copies more existing pointers than
the array can hold.

Skip buffers that already satisfy the request. Once all remaining
buffers have caught up, advancing z_erofs_gbuf_nrpages again describes
the guaranteed minimum size across the pool.

Fixes: d6db47e571dc ("erofs: do not use pagepool in z_erofs_gbuf_growsize()")
Cc: stable@vger.kernel.org # 6.10+
Signed-off-by: Nikhil Gurudasani <nikhilgurudasani314@gmail.com>
---
 fs/erofs/zutil.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/erofs/zutil.c b/fs/erofs/zutil.c
index a0ce9226b..6b9bfa2ef 100644
--- a/fs/erofs/zutil.c
+++ b/fs/erofs/zutil.c
@@ -79,6 +79,8 @@ int z_erofs_gbuf_growsize(unsigned int nrpages)
 
 	for (i = 0; i < z_erofs_gbuf_count; ++i) {
 		gbuf = &z_erofs_gbufpool[i];
+		if (gbuf->nrpages >= nrpages)
+			continue;
 		tmp_pages = kzalloc_objs(*tmp_pages, nrpages);
 		if (!tmp_pages)
 			goto out;

base-commit: 075b74841bd0065a3bda3440873c747938e69b68
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-24  0:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-22 14:00 [PATCH] erofs: skip sufficiently large global buffers when resizing Nikhil Gurudasani
2026-08-23 12:59 ` Gao Xiang
2026-08-24  0:57 ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox