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=1796123333; b=SEF5vbpVopGcS2nwHQHSFtWYmkY6KL19e2ISaUaOWaTth3UzHgc99IPoMGqUIRNF4YSx ruL8lBAQSnggrxCQYotwLF7oKBsq0kntKNYY1n6tFqoWVL+eQIsgQzW34bRwElP0KwFWQ C6f/aedTVgvG7LujuWEIDiJ22M+D7E732qFYOUf9NATu6FJnE95rjNX/9wlJKj2wm4o5/ K92w/RVwkLEq/H4icIn0U4dJ6Q0LDJ4FymuSmRFSVFCl15iJZ7MVG1pRGYSTPnUx0DU0g 6U9lv9nPkiuxAqM7BbFT7cEh5on/pYplM8qIWxjnMS93F0tkhyLZUJC+/F36ujrd4QA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796123333; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=fuW/u2y/MfpSDmxCt+GktdLSfcLRK+BRlM81wTl4WUE=; b=SVVHaTJ+JlqxMjAn/2evfywhYt5080nFagwQIwBPgwXgyWivLWK8W0sZqyEQ3MMBjOdI Hs6t3nrI0p5pP5gpfoo2fBE+EU5EEOrUffvVPdNXaQF0Vj8JfeThLRpCUoPoa1NJL7+vt VuXqw+yZDwgp4MhVgtxddMFqwS0Y+XnoLf/xmvyz2vmD0qfkvdaciJ3D8GNTrJuFceUdW WA/5NCdnC9bvh4wzsQibCm/DlEn4QdNSb02ks0kF8hsy9nX5WJZ1XpuCIXVjh4RJfw15u 8v1Tnk/br8wcGpGr3d8Xzik5/iBaaB57leoUA9UWhhiYxmZ4MzIKjdFmMTPYrY9EJOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aSBRDbnn; 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 ACEA6606A32C; Tue, 1 Dec 2026 11:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aSBRDbnn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B2A71F00897; Tue, 1 Dec 2026 11:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796123333; bh=fuW/u2y/MfpSDmxCt+GktdLSfcLRK+BRlM81wTl4WUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aSBRDbnnib0ePywijRc88ig2AtlZmUPE6zYGKPqPlllyRkQKXBy1jEvA60snTWQxK 3Vyn6JY0jx/IoNNJN5iWZ0XHHzoklmQY2SgzP59BG+7Vfm4Xko/Ek7OfGiaI4Oob7H +05o1LLFwKU16YxM7TtDZdEZxtrWMC7PUcjDlLo4cji3y1MZ25BqRSbkS0CFNCqnkc WFLwIh2ESvksL0rrXXbk6j+JDqoa6V+zqJ5C1iWUqd4vvzAnoisi/5ivPl0m/V0AQT sc0488KJrC+xwXP4mTFZeAzjn6L3b2agxFdfp96gQxw7wdsI1p2SUfCxiD8wK3O2ur 7xuqGOMbIcWnw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu , stable@vger.kernel.org Subject: [PATCH 3/6] f2fs: cache: fix to submit cached DATA bio when waiting writeback of meta cache Date: Tue, 1 Dec 2026 11:08:45 +0000 Message-ID: <20261201110842.1825797-9-chao@kernel.org> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog In-Reply-To: <20261201110842.1825797-7-chao@kernel.org> References: <20261201110842.1825797-7-chao@kernel.org> 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 From: Chao Yu GC migrates data blocks of post-read and atomic files via meta cache entries, and writes them w/ DATA bios in move_data_block(), however, f2fs_cache_wait_writeback() only submits cached META bio for a meta cache entry, so it may wait forever for a DATA bio which GC has not submitted yet, e.g. an ABBA deadlock found by consistency test w/ atomic write workers and gc_urgent: - lock A: writeback state (F2FS_BLOCK_WRITEBACK) of the meta cache entry of new block B, it's cleared only after the DATA bio cached by GC is submitted and completed - lock B: lock of node cache entry N GC thread atomic commit - do_garbage_collect - gc_data_segment (phase 4) - move_data_block - f2fs_start_cache_writeback(B) (set WRITEBACK of B: lock A) - f2fs_submit_cache_write : B's DATA bio is cached, not submitted until the end of do_garbage_collect - f2fs_commit_atomic_write - __replace_atomic_write_block - f2fs_get_dnode_of_data (lock N: lock B) - f2fs_truncate_data_blocks_range - f2fs_invalidate_blocks(B) - f2fs_truncate_meta_caches - f2fs_cache_wait_writeback - ..._wait_writeback_cond(META) : submits META bio only - wait_on_bit_io(WRITEBACK) (wait for lock A, held by GC) - is_alive (next block) - f2fs_get_node_cache(N) (wait for lock B, held by commit) Then checkpoint, writeback and all syncs hang behind them. Before commit 7a1cf2a76b71 ("f2fs: cache: use meta cache"), GC staged such blocks in META_MAPPING folios, and f2fs_truncate_meta_inode_pages() submitted cached DATA bio of meta inode before waiting on their writeback, the conversion to f2fs_truncate_meta_caches() lost it. Let's submit cached DATA bio as well in f2fs_cache_wait_writeback_cond() when waiting writeback of a meta cache entry w/ META type. Cc: stable@vger.kernel.org Fixes: 7a1cf2a76b71 ("f2fs: cache: use meta cache") Signed-off-by: Chao Yu --- fs/f2fs/cache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c index 6cac7662fc1a..f22acf3e51ff 100644 --- a/fs/f2fs/cache.c +++ b/fs/f2fs/cache.c @@ -32,6 +32,12 @@ void f2fs_cache_wait_writeback_cond(struct f2fs_cached_block *entry, /* submit cached bio */ f2fs_submit_merged_write_cache(entry->cache->sbi, entry, 0, type); + /* + * GC writes meta cache entries w/ DATA bio in move_data_block(), + * submit it as well, or we may wait for a bio cached by GC forever. + */ + if (type == META) + f2fs_submit_merged_write_cache(entry->cache->sbi, entry, 0, DATA); wait_on_bit_io(&entry->state, F2FS_BLOCK_WRITEBACK, TASK_UNINTERRUPTIBLE); -- 2.49.0