From 7807710d88ad03e7ca9b5f79f518f040db2a4e09 Mon Sep 17 00:00:00 2001 From: Tal Zussman Date: Mon, 7 Sep 2026 15:38:19 +0000 Subject: [PATCH] ceph: fix writeback_count leak when a bounce page allocation fails ceph_process_folio_batch() calls is_write_congestion_happened(), which increments fsc->writeback_count, before calling move_dirty_folio_in_page_array(). If the fscrypt bounce page allocation there fails, the folio is redirtied and never makes it into the page array, but the count is never dropped. write_congested is only cleared when a decrement falls below CONGESTION_OFF_THRESH, so the leaked counts set congestion early and eventually leave write_congested set for good. Every WB_SYNC_NONE writeback then returns 0 and background writeback stops entirely. Bump the count only once the folio is in the page array. Fixes: d55207717ded ("ceph: add encryption support to writepage and writepages") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260902-remove-wait-on-page-writeback-v5-0-0b512e77e75b%40columbia.edu?part=1 Assisted-by: Claude:fable-5.1 Signed-off-by: Tal Zussman Reviewed-by: Alex Markuze Signed-off-by: Ilya Dryomov --- fs/ceph/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 334e41a7c2f2..b1b947d005ce 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1414,8 +1414,6 @@ void ceph_process_folio_batch(struct address_space *mapping, doutc(cl, "%llx.%llx will write folio %p idx %lu\n", ceph_vinop(inode), folio, folio->index); - fsc->write_congested = is_write_congestion_happened(fsc); - rc = move_dirty_folio_in_page_array(mapping, wbc, ceph_wbc, folio); if (rc) { @@ -1428,6 +1426,8 @@ void ceph_process_folio_batch(struct address_space *mapping, break; } + fsc->write_congested = is_write_congestion_happened(fsc); + ceph_wbc->fbatch.folios[i] = NULL; ceph_wbc->len += folio_size(folio); }