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=1796385308; b=qzSa8E/nl0Zu/z/qSoKGpas9NP7fk1q53ngjm2fZPLnbpgjP/JSSJWrC9H2MJFE4l/+d FWgPixtANIbBc7S/qvASo0YlDcBNzHRKXT02kIlGmiTM/O5K6aeMmFSqNZ4ITi31LPrzX Azrxf8gzODi8tUjcUmCrpFbr8VzcHyxV9EJNNnNq3hDjo5zV51pUnVskEBdXfR2HjlCO/ o/wcVMsVwSFAGpDGxo5IX0SmlU4rTDL1vrXNEdKtqP08ASTUstkSU9XUTDpO+rtf7bw1P 4Zx1mUWo7nF5VUxN0eOwvOB5DO0FWkzZfZOFTO+DWTZmU5Ocp8e8cffMjHA1D34Hqbw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385308; 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=Ms/lDSRh1AMYqbMvZHIQuVOs+A9JxyZ8FfbqX3ZrCVs=; b=DvF5VrQZKMmW09kUSTaUnocjsMLSGrzGFLlVIPHE4yQu189cmduyih4zmGas9Bh8up5k ppwcFKTe4ljAIz+XnPtHUxlZPalXYKbLxhCp6GiTduLo34DkdMO1l1B4pkZvhvuYN/zdN XINr2b4R5VDsr2ONPPd+kLUlAKM2+wa8L495UtGvOTVCJKFRV8HdcXMZkQ8CKAtESJjya V3k8ST1m1wG7Es4jxhfGvCHDaV4wFmZENJyUL/h5+Z64iOZpO541X9EPi/6f5FWfyrK3B dthwYyAq2qYkEXkt/qH+I35g/OD7/EIzCep9Mhbp/B01bBcC51EZXr1C2AoNLpa7qaw== 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=We3MjYmU; 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 82263606A322; Fri, 4 Dec 2026 11:55:08 +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=We3MjYmU Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1A521F000CE; Fri, 4 Dec 2026 11:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385308; bh=Ms/lDSRh1AMYqbMvZHIQuVOs+A9JxyZ8FfbqX3ZrCVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=We3MjYmUrwIcwMJjxkjSiszbxV9VYCArE/5+S4fS57JToXz5V/22GBXKGRe6XyS9a FapTQZZB3CMP4jouQ6Zzko2DcYj0JP/mnTD/W8JsgLiKSt9uo4t+kxzArQ+tndD81D 3RkrP3GbOx0un2UbOkCyA+NV6JIHn0iONTHN5CEQ= 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.6 0462/1167] ceph: wait for pending fscache write in write_folio_nounlock() Date: Fri, 4 Dec 2026 18:58:09 +0900 Message-ID: <20261204100714.050288700@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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: Kept this tree's three-argument ceph_fscache_write_terminated() signature as context and applied the wait call in writepage_nounlock(), which is the older name for write_folio_nounlock(). ] 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 4957a40777821..63a4e6ffc8a76 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -543,6 +543,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; @@ -564,6 +569,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) { } @@ -737,6 +746,9 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) ceph_vinop(inode), page, page->index, page_off, wlen, 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