From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387986; b=zhjbobUBW2Q3jH+UnTHhRDfqdSpIqBq0bqxkwB2jAYLIL4xpnzX37ke+7ya7hqnIqxGQ 5GmL9ZJY8RcYEg1K4VhUTyRj3t7qCYiZ5oo/61RwdTIs82hFDcZfy0o9+0EYPWGT1BKCK 3MxmxKJs8pIDqJF27kfdBIa2Hq6orYgLfjlgMd6T6n4p80AFBi5M2SPwu5YtKmUQi+z6G hfiDgOz6Ziir0GjrezJF8+itrlco2/mDDTRqcl+fMeY/QBbYYPTf5DzgVMSgyNZkKwDPm ubeLPyRiIAlQ8HJedrVszaNO9NwoK9YF+mofhzINUE7rDWQcHAetifIn/X9pMmVE1EQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387986; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=KKzD65plpkGo6T0WflucIyqrmDTaGrbstrTlcLwcmlo=; b=CFl4KtVR2WgCO7/3AoKrqhBWPBFMQ/tHpykhakOxuZYWMEnH9HaqAML02mdGZWasAjyj EpaAuQUovOLJnnmaOdLjSsmS61BFPN2zyd72IAo/CDnHb1JwOGpkqvmwwmbJVkCfidAMK GupeQ7tLl+EAJdFn4nGj/ebs3CxkTlnD3IMYD/Rm9+gPGqFMrS5qGdMYu1j6kFp1CA7fN riUmc0g8UJFFkBSOiPjiyNcbrys3F6u8t8DwefLQsxKzdlU8S2RkjWzeOW2CLYYRxophQ WTRXJz6Lur3GsLlA6MTiCaUg29JyN+NB5EfjKIqc2ZM6MYKTUdFlMu3rrtfx5IJI1Xw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="B5nw/QFt"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C85EB606A322; Fri, 4 Dec 2026 12:39:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=B5nw/QFt Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AE31F000CE; Fri, 4 Dec 2026 12:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387986; bh=KKzD65plpkGo6T0WflucIyqrmDTaGrbstrTlcLwcmlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=B5nw/QFt7kMh7RuAgoybT/jchHeTIeqSUgis8Rrv12H8MC7GtBS4l1Q3lPV8sAv0z 4t/M3X73ZSd5SzLWBROmWXWSq+mZU2nxNJylvc6xvobm0TjBEcNuGPi4wIy81cLBp0 xAINDYPAiH0omqEMW1PFwQJg40wYqKyiRORgUamQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Tal Zussman , Alex Markuze , Ilya Dryomov , Sasha Levin Subject: [PATCH 6.1 0439/1059] ceph: wait for pending fscache write in write_folio_nounlock() Date: Fri, 4 Dec 2026 18:59:30 +0900 Message-ID: <20261204100655.687544041@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tal Zussman [ Upstream commit 3f7655f0d9186656c6f1cbc012a39c866d4aaabf ] write_folio_nounlock() marks the folio with PG_private_2 via ceph_set_page_fscache() and starts an async write to the cache via ceph_fscache_write_to_cache(). PG_private_2 is only cleared once that write completes. If the OSD write fails, the error paths return without waiting for the cache write. On retry, ceph_find_incompatible() would wait for writeback, but not for PG_private_2, before calling write_folio_nounlock() again, which would trip the VM_BUG_ON_FOLIO() in folio_start_private_2(). Wait for any pending cache write before starting writeback on the folio. Do so before bumping the writeback congestion count and allocating the possibly mempool-backed OSD request, so that a thread sleeping on the cache I/O does not hold either while it waits. Add ceph_folio_wait_fscache(), a wrapper for folio_wait_private_2(), and use it. Fixes: 1702e7973410 ("ceph: add fscache writeback support") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260804-remove-wait-on-page-writeback-v2-0-81f0ab065284%40columbia.edu?part=7 Signed-off-by: Tal Zussman Reviewed-by: Alex Markuze Signed-off-by: Ilya Dryomov [ sashal: Added a ceph_folio_wait_fscache() wrapper and stub, and placed the call in the older writepage_nounlock() with dout() macros, keeping the extra was_async argument in ceph_fscache_write_terminated(). ] Signed-off-by: Sasha Levin --- fs/ceph/addr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 11bbcda371124..0e5fa2617c6cc 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -479,6 +479,11 @@ static void ceph_set_page_fscache(struct page *page) set_page_fscache(page); } +static void ceph_folio_wait_fscache(struct folio *folio) +{ + folio_wait_private_2(folio); /* [DEPRECATED] */ +} + static void ceph_fscache_write_terminated(void *priv, ssize_t error, bool was_async) { struct inode *inode = priv; @@ -500,6 +505,10 @@ static inline void ceph_set_page_fscache(struct page *page) { } +static inline void ceph_folio_wait_fscache(struct folio *folio) +{ +} + static inline void ceph_fscache_write_to_cache(struct inode *inode, u64 off, u64 len, bool caching) { } @@ -660,6 +669,9 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) dout("writepage %p page %p index %lu on %llu~%llu snapc %p seq %lld\n", inode, page, page->index, page_off, len, snapc, snapc->seq); + /* wait for a cache write left pending by a previously failed attempt */ + ceph_folio_wait_fscache(folio); + if (atomic_long_inc_return(&fsc->writeback_count) > CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb)) fsc->write_congested = true; -- 2.53.0