* [PATCH v2] ceph: fix writeback_count leak in write_folio_nounlock()
@ 2026-06-02 9:07 Wentao Liang
2026-06-02 18:26 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-02 9:07 UTC (permalink / raw)
To: idryomov, amarkuze, slava; +Cc: ceph-devel, linux-kernel, Wentao Liang, stable
write_folio_nounlock() increments fsc->writeback_count to track
in-flight writeback operations. On several error paths where the
function returns early (folio lookup failure, snapshot context
allocation failure, and writepages submission failure), the function
returns without calling atomic_long_dec() to decrement the counter.
Each leaked increment keeps the counter above zero, which can prevent
the filesystem from cleanly unmounting or suspending writes.
Add atomic_long_dec() calls on all error paths that currently return
without decrementing the counter.
Fixes: d55207717ded ("ceph: add encryption support to writepage and writepages")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
Change in v2:
- Also clear write_congested flag when decrementing writeback_count
on error paths, as suggested by Viacheslav Dubeyko.
---
fs/ceph/addr.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index a606378649c3..7fab73874068 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -790,7 +790,9 @@ static int write_folio_nounlock(struct folio *folio,
ceph_wbc.truncate_size, true);
if (IS_ERR(req)) {
folio_redirty_for_writepage(wbc, folio);
- atomic_long_dec(&fsc->writeback_count);
+ if (atomic_long_dec_return(&fsc->writeback_count) <
+ CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
+ fsc->write_congested = false;
return PTR_ERR(req);
}
@@ -810,7 +812,9 @@ static int write_folio_nounlock(struct folio *folio,
folio_redirty_for_writepage(wbc, folio);
folio_end_writeback(folio);
ceph_osdc_put_request(req);
- atomic_long_dec(&fsc->writeback_count);
+ if (atomic_long_dec_return(&fsc->writeback_count) <
+ CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
+ fsc->write_congested = false;
return PTR_ERR(bounce_page);
}
}
@@ -849,7 +853,9 @@ static int write_folio_nounlock(struct folio *folio,
ceph_vinop(inode), folio);
folio_redirty_for_writepage(wbc, folio);
folio_end_writeback(folio);
- atomic_long_dec_return(&fsc->writeback_count);
+ if (atomic_long_dec_return(&fsc->writeback_count) <
+ CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
+ fsc->write_congested = false;
return err;
}
if (err == -EBLOCKLISTED)
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] ceph: fix writeback_count leak in write_folio_nounlock()
2026-06-02 9:07 [PATCH v2] ceph: fix writeback_count leak in write_folio_nounlock() Wentao Liang
@ 2026-06-02 18:26 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2026-06-02 18:26 UTC (permalink / raw)
To: vulab, ceph-devel, Alex Markuze, Ilya Dryomov, Viacheslav Dubeyko
Cc: stable, LKML
…
> Add atomic_long_dec() calls on all error paths that currently return
atomic_long_dec_return()?
> without decrementing the counter.
Can any duplicate source code be avoided in affected if branches
of the function implementation “write_folio_nounlock”?
https://elixir.bootlin.com/linux/v7.1-rc6/source/fs/ceph/addr.c#L717-L874
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-02 18:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-02 9:07 [PATCH v2] ceph: fix writeback_count leak in write_folio_nounlock() Wentao Liang
2026-06-02 18:26 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®