[PATCH 1/2] ceph: fix writeback_count leak when a bounce page allocation fails

From: Tal Zussman

Date: Fri Sep 04 2026 - 13:43:03 EST


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 <sashiko-bot@xxxxxxxxxx>
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 <tz2294@xxxxxxxxxxxx>
---
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 f1404664c97a..69f2c4c8498a 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1457,8 +1457,6 @@ void ceph_process_folio_batch(struct address_space *mapping,
boutc(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) {
@@ -1471,6 +1469,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);
}

--
2.39.5