ceph: fix writeback congestion accounting
cover ceph: fix writeback congestion accounting
Two fixes for the writeback congestion accounting in ceph_process_folio_batch(), both found while reworking the writeback path for folios.
Patch 1 fixes a writeback_count leak when an fscrypt bounce page allocation fails, which can eventually leave the mount permanently congested. Patch 2 restores the set-only semantics for write_congested that the folio batch refactor lost.
---
Tal Zussman (2):
ceph: fix writeback_count leak when a bounce page allocation fails
ceph: don't clear write_congested when collecting folios
fs/ceph/addr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
---
base-commit: ef063f72b23420b2889a8f631887fe0adae4af12
change-id: 20260904-ceph-writeback-count-leak-2a577e8c15f9
Best regards,
Signature · 1 line
Tal Zussman <[email protected]>
PATCH 1/2 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.
--- fs/ceph/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ceph/addr.c +2 -2
@@ -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); }
Signature · 1 line
2.39.5
Re: [1/2] ceph: fix writeback_count leak when a bounce page allocation fails
Hi Tal,
Thanks for the patch.
Signature · 1 line
Alex Markuze
PATCH 2/2 ceph: don't clear write_congested when collecting folios
In reply to Tal Zussmanceph_process_folio_batch() assigns the result of is_write_congestion_happened() to fsc->write_congested for every folio it collects. The code it replaced only ever set write_congested to true here, leaving the decrement paths to clear it once writeback_count drops below CONGESTION_OFF_THRESH. The unconditional assignment means that a sync writeback that runs while the count sits between the off and on thresholds clears the flag on its first folio, and background writeback resumes early.
Only set the flag here, as before.
--- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/addr.c +2 -1
@@ -1469,7 +1469,8 @@ void ceph_process_folio_batch(struct address_space *mapping,break ; } - fsc->write_congested =is_write_congestion_happened (fsc); +if (is_write_congestion_happened (fsc)) + fsc->write_congested = true; ceph_wbc->fbatch.folios[i] =NULL ; ceph_wbc->len +=folio_size (folio);
Signature · 1 line
2.39.5