From: Tal Zussman <tz2294@columbia.edu>
To: Ilya Dryomov <idryomov@gmail.com>,
Alex Markuze <amarkuze@redhat.com>,
Viacheslav Dubeyko <slava@dubeyko.com>,
Christian Brauner <brauner@kernel.org>,
Jeff Layton <jlayton@kernel.org>,
David Howells <dhowells@redhat.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Zi Yan <ziy@nvidia.com>
Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>,
Tal Zussman <tz2294@columbia.edu>
Subject: [PATCH v5 01/10] ceph: fix error handling when the OSD client is stopping in ceph_submit_write()
Date: Wed, 02 Sep 2026 12:11:25 -0400 [thread overview]
Message-ID: <20260902-remove-wait-on-page-writeback-v5-1-0b512e77e75b@columbia.edu> (raw)
In-Reply-To: <20260902-remove-wait-on-page-writeback-v5-0-0b512e77e75b@columbia.edu>
When ceph_inc_osd_stopping_blocker() fails, ceph_submit_write()
redirties and unlocks the folios remaining in ceph_wbc->fbatch.
However, none of those folios are locked at this point: locked folios
were moved to ceph_wbc->pages[] and removed from the fbatch by
ceph_process_folio_batch(). Unlocking them triggers
VM_BUG_ON_FOLIO(!folio_test_locked(folio)) in folio_unlock(), or
unlocks a folio locked by another task.
This error path also returns -EIO without fully cleaning up the folios in
ceph_wbc->pages[]: their references are never dropped, fscrypt bounce
pages are never freed, the writeback congestion count is never
decremented, and the pages array is leaked. ceph_wbc->locked_pages is
also left non-zero, so ceph_writepages_start() loops back around and
hits BUG_ON(ceph_wbc.locked_pages).
Leave the fbatch folios alone, as ceph_writepages_start() drops their
references when releasing the batch, and unwind ceph_wbc->pages[] the
same way writepages_finish() would have. Abort writeback in
ceph_writepages_start() instead of continuing, matching the handling
of ceph_inc_osd_stopping_blocker() failure on entry, as the OSD
client is being torn down and further writeback cannot make progress.
An LLM was used to verify that the cleanup was comprehensive, and
suggested aborting the writeback instead of continuing.
Fixes: 1551ec61dc55 ("ceph: introduce ceph_submit_write() method")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260804-remove-wait-on-page-writeback-v2-0-81f0ab065284%40columbia.edu?part=5
Assisted-by: Claude:fable-5
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/ceph/addr.c | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index f8844390f88d..28fb76ded32c 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1491,28 +1491,32 @@ int ceph_submit_write(struct address_space *mapping,
BUG_ON(len < ceph_fscrypt_page_offset(page) + thp_size(page) - offset);
if (!ceph_inc_osd_stopping_blocker(fsc->mdsc)) {
- for (i = 0; i < folio_batch_count(&ceph_wbc->fbatch); i++) {
- struct folio *folio = ceph_wbc->fbatch.folios[i];
-
- if (!folio)
- continue;
-
- page = &folio->page;
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
- }
-
for (i = 0; i < ceph_wbc->locked_pages; i++) {
- page = ceph_fscrypt_pagecache_page(ceph_wbc->pages[i]);
+ page = ceph_wbc->pages[i];
+ if (fscrypt_is_bounce_page(page)) {
+ page = fscrypt_pagecache_page(page);
+ fscrypt_free_bounce_page(ceph_wbc->pages[i]);
+ }
- if (!page)
- continue;
+ if (atomic_long_dec_return(&fsc->writeback_count) <
+ CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
+ fsc->write_congested = false;
ceph_undo_wrbuffer_claim(inode, page_folio(page));
redirty_page_for_writepage(wbc, page);
unlock_page(page);
+ put_page(page);
}
+ if (ceph_wbc->from_pool) {
+ mempool_free(ceph_wbc->pages, ceph_wb_pagevec_pool);
+ ceph_wbc->from_pool = false;
+ } else {
+ kfree(ceph_wbc->pages);
+ }
+ ceph_wbc->pages = NULL;
+ ceph_wbc->locked_pages = 0;
+
ceph_osdc_put_request(req);
return -EIO;
}
@@ -1745,8 +1749,11 @@ static int ceph_writepages_start(struct address_space *mapping,
}
rc = ceph_submit_write(mapping, wbc, &ceph_wbc);
- if (rc)
- goto release_folios;
+ if (rc) {
+ /* the OSD client is being torn down, don't retry */
+ folio_batch_release(&ceph_wbc.fbatch);
+ goto dec_osd_stopping_blocker;
+ }
ceph_wbc.locked_pages = 0;
ceph_wbc.strip_unit_end = 0;
--
2.39.5
next prev parent reply other threads:[~2026-09-02 16:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 16:11 [PATCH v5 00/10] ceph: convert writeback path to folios Tal Zussman
2026-09-02 16:11 ` Tal Zussman [this message]
2026-09-02 16:11 ` [PATCH v5 02/10] ceph: wait for pending fscache write in write_folio_nounlock() Tal Zussman
2026-09-02 16:11 ` [PATCH v5 03/10] ceph: add ceph_folio_snap_context() Tal Zussman
2026-09-02 16:11 ` [PATCH v5 04/10] ceph: convert ceph_wait_until_current_writes_complete() to folios Tal Zussman
2026-09-02 16:11 ` [PATCH v5 05/10] ceph: convert get_writepages_data_length() " Tal Zussman
2026-09-02 16:11 ` [PATCH v5 06/10] ceph: convert ceph_submit_write() " Tal Zussman
2026-09-02 16:11 ` [PATCH v5 07/10] ceph: remove page remnants from write_folio_nounlock() Tal Zussman
2026-09-02 16:11 ` [PATCH v5 08/10] ceph: convert page cleanup loop in writepages_finish() to folios Tal Zussman
2026-09-02 16:11 ` [PATCH v5 09/10] ceph: remove ceph_fscrypt_pagecache_page() and ceph_fscrypt_page_offset() Tal Zussman
2026-09-02 16:11 ` [PATCH v5 10/10] ceph: rename ceph_check_page_before_write() to ceph_check_folio_before_write() Tal Zussman
2026-10-08 16:00 ` [PATCH v5 00/10] ceph: convert writeback path to folios David Howells
2026-10-10 0:16 ` Tal Zussman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902-remove-wait-on-page-writeback-v5-1-0b512e77e75b@columbia.edu \
--to=tz2294@columbia.edu \
--cc=amarkuze@redhat.com \
--cc=brauner@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=slava@dubeyko.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®