From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 118B036197E for ; Sat, 1 Aug 2026 22:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621671; cv=none; b=fw3pN5g64mPFluEFgOwe12ypHXEgmff43uPpjIFJleRaNyfRcpzgZG1cmaIjYvjFpSQ6mVBy0oB35KQGuIt1UeMf9nC6wsTpFJJuAs65HuRuDz1qK/j3ozhBvyo2NJSx3kDSt9xYy+Uvgl0QjEkJF4s1CV8e0k+rw9ju84JcKKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621671; c=relaxed/simple; bh=fQPgfXMhlq+1VG0MRuQEzdSC7q5vWTQFKVnCNqnuFvQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sur+xfrFKYP0Mm0zrmuXXDZ/A/t7QjXa8GvTbgk0YO63BgvIgo5Z90NBz1qx3afv0/lX2JuBai6D/FgVi5QB+WGIgwaWpmWTSZ7qGOuduE0YzIYcgMZdKhi6yEZ3JnX4QDxsjXHOxkCeZTJ/Jtn7LylGmCxYjp/uSEIJM1mpYeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QOCmht6G; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QOCmht6G" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-81f36179d72so31506187b3.2 for ; Sat, 01 Aug 2026 15:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621669; x=1786226469; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=boTJ4NLnnkEUxDYA6Ii16la58dxC2XdEwOIDbV8GTAs=; b=QOCmht6GN+gIAff33a6iQXQu2gFFYkEh8ROR8X66nLwsVhM3eANiFUbiKvLCjtanHB M73eFpJ9SDjG5EhyDZ5NO8AVXtN7Vt0gyCaJKXwagSHdPgzz1yYsHdP55rp7UUl6sgDo l4MfUcdMURX4bSTzSsDRAATt3Kwcpj2L/nQF2z3/2DWgoFRLXVo/p1sbbC6JPP6+/NBx CwVjbRWHr5/4OuA9Q6Ujbvy8j8uqW/boI9L+AHOzYqhrjWaJD8o6VHcYliDXSlYUGel9 5ouLtzhFQbzmbFtf4GF/oB6EImRtHPDX0bW6VA3En5HY16AinGjUcHp1KI933r4Q+SuY v8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621669; x=1786226469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=boTJ4NLnnkEUxDYA6Ii16la58dxC2XdEwOIDbV8GTAs=; b=rW3lFTjRIGE5oI+DpQE8wDlE5X7/1GK5CpFco8/n7LBN4R5kHUPejJVilltFW53KTA W5vZ29MAd2I6ULZAYmVVbvqMX6lsckiwWAgd362J+eSjaAzRqTVa2Lpdm5eGLcEpUyT/ 6NfZ7gWhdMq+WKUgRp/5zHJwk73oBecEWc6WleGR8pnH1abUWUJ33x0FCKrPB17tEgUh 9aVgc1WFDHbEpQ+kIOEsBMDbTwXQ8mtJD18ro3Bhd9fnOPuzoYnQOoEbQceXQajJ36YS 6BSX3qu8C/4iXhCGSykeWazr6sBhqwMETZXVHHzGgxWpU4M0qpkcXsQOVyyyKk6wzp2I ZvIw== X-Forwarded-Encrypted: i=1; AHgh+RrXIV9bcEjg80Vbe4447fHF9FfTgFO1mlQd0HdRYLMHYMMuc47yTv795CZ7Xsx1tp7Tltg7vLjTmlpScmU=@vger.kernel.org X-Gm-Message-State: AOJu0YwGC5QV6jPfE0tZDCwuddhz+b+JkLImZHOgzbevr650t+NdZ8IB Lp1UcfLHBsF0A7Dd23rHFRaNzeeqR7hWZAoeciqYLUOI63E3Cr8LY8oM X-Gm-Gg: AR+sD13ztFJannkIw8Vha0AEzwRyu33PfRaIbLRtjzw3RruZHpVEk98lrWhK+OPcIk7 hnnviUPcONG7j+PDx/AF4MBoE9Z5tFjIKVFJ2Xn1Z0xvjW14llXx9AUorFqEtIkC8E3XIcuKvzm SUAtT7hu6N4XhMeO84oXWxTFjy9uGnadKyGfrQZo52vyUlmiI0BvUvmYbFFwdvcn02R1h58rVhp pWoBppKQof1qbmeb9NqLdSpt5k+pxSm0VgAulKUGB9TnjGoKO3TPldeYshTkPFMO4Roo5zdUHJ1 82Kl6t/tBFSeIP7UrnrRsjGoQV7sv42HEIt5uSyr7oNoL2iaJpLTIm0Nhva9O+hzkZM/DnNKZF0 KA7bZckOGdgZylSCTIgMJx8dclavDGqbdy0R8NuRAIXobVezVtlBuEQHAKoM1NhVJo+vHzns1UH ZXnGZZM4/GrFPDXXhv9B9HPYvoQtSA4a392JAtBPRmTekfZIU/GHMfArTwTYKrtZlr1HwXK4520 jclL9U= X-Received: by 2002:a05:690c:688e:b0:81e:c998:9c9a with SMTP id 00721157ae682-81fd4bce906mr71495667b3.17.1785621668857; Sat, 01 Aug 2026 15:01:08 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:07 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 01/19] buffer_head: Remove b_page Date: Sat, 1 Aug 2026 18:00:45 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Matthew Wilcox (Oracle)" All users except bh_offset() have been converted to use b_folio instead. Convert bh_offset() and remove b_page. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- include/linux/buffer_head.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index fd2c7115c054..699970b4bbf2 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -59,10 +59,7 @@ struct address_space; struct buffer_head { unsigned long b_state; /* buffer state bitmap (see above) */ struct buffer_head *b_this_page;/* circular list of page's buffers */ - union { - struct page *b_page; /* the page this bh is mapped to */ - struct folio *b_folio; /* the folio this bh is mapped to */ - }; + struct folio *b_folio; /* the folio this bh is mapped to */ =20 sector_t b_blocknr; /* start block number */ size_t b_size; /* size of mapping */ @@ -172,7 +169,7 @@ static __always_inline int buffer_uptodate(const struct= buffer_head *bh) =20 static inline unsigned long bh_offset(const struct buffer_head *bh) { - return (unsigned long)(bh)->b_data & (page_size(bh->b_page) - 1); + return (unsigned long)(bh)->b_data & (folio_size(bh->b_folio) - 1); } =20 /* If we *know* page->private refers to buffer_heads */ --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CF16247291 for ; Sat, 1 Aug 2026 22:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621672; cv=none; b=GCqJh/hrkUrkHR7vAZ/62rZlThQSjCCz8aa9+jH1Hero8w+R2m7frcEG7el/DdszTRX3NPw4a7ttUKZ34siAyGBkToOlISbjykOddojXzIexNh6heDGKeP+6k/AtCuRetZ4kN8nXg7FHAlsgPKSsIBKFojeURKmmv3pYC9Ns0c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621672; c=relaxed/simple; bh=dHCSXwhqSp5ZYzPgeTI83J3l93w1hXqXrOBDQtAfTkk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdhNpLeUlyDAnhR0vtXX/FrIPpNdWlxdRL2FzlT/O2WKVlQXkK5qNfNbLBAU7JDcjwgBAKaUi6P008G/SyKdEPlEfEEeqC8fDqQtef1s9wK/rNbovnqlixLRpKoP3YxnABPTFgMieyYoZ20ZnXkfMp19leTZ47ZLjwG3yu9bGOw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rr/zyvdC; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rr/zyvdC" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-81f36179dd5so30874267b3.2 for ; Sat, 01 Aug 2026 15:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621670; x=1786226470; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=R/+4h8mFnc0QJGTHkSaUWdLQ44MjYcXD2X7Z3kRsV/c=; b=rr/zyvdCTTUD1h2ADJZFQyniubg/ygk1iHIqyBK4nLEnXoBsBusjzCjmNNhXFvB970 SjkpNJH6ZyKgVLdYEF1589AEsQsXJswezNwrHN4q+2S8xQsq9rHhEc8oA3DmCWFJVpwT 4I7bj9n9FgdU12Ud/vUks/qJwfM+2z2CAu3R3Tjh4loeZEWPkaAfz8DYGFS5Tn2VHFUw IVTqQxvgHU4CnJBcIgMjWXbfNe7sEzxBenigQ4xeBk7WfNdB46emCGxrlTfzAkYb4HA+ 1Kl/VtmbuVZ0DxFuJQzHKIgcD+4dkHXcykF69jid98GhvtXVNpoxHxepa7nmc10XyMiT fc2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621670; x=1786226470; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=R/+4h8mFnc0QJGTHkSaUWdLQ44MjYcXD2X7Z3kRsV/c=; b=I4l6MTfCkD/NuOjQMxhDrudD1Kef5JHneNzRErJHzGlsz2bse60/J413KT7Oq9btP/ 0Zoj/M382HjT6qRnY/9Iwb65Tz4JHj0iVHXkT9gIIzeeFi+S26j+o2CYeJ++5+zIT1B1 OzZfnC7XPBFVP9YqCyrarxa5bXqdAo+o2zu/hq3vAPiKGWZAq20NSVbhHOvuUbmzi5zF cb+uzSrE/OHzbG7Yzf+Kpzsi2xgL1eA4llLCeFdytLG/DuzrDFg6OC3l7AIrzagIINBQ ZhxadtunRTAiFQnRhPyaoJdB0eyh4LOaQ2LMd6koZJid8qCES6wdzoJ0c5qO5TMJPIsn ZKWw== X-Forwarded-Encrypted: i=1; AHgh+RqDoGDpWV/D4LwWvckUAQg85indyFYy6O+AI5jK+hglQZfZk6JgkBggS7ahyGRwP9KoHJur63ljuVXjwnI=@vger.kernel.org X-Gm-Message-State: AOJu0YzfEmGWa7xp8GWoNTa7Z2LSXTvZLu2R3MtdO2bN2KIQfCEuXwSm EgNFX5cpVp87AI1p9vzOOQFEqFQHoNEotRuCxgFYfU1P2dETfy+ae5IP X-Gm-Gg: AR+sD1024Fp0YwdtJYz56brasJCsrSKeqKgh4dSn32Wfa7MvGRkSo9D5wkt/PTpbl4r zvlHyS8BjNwT2aesCGZc0P9GNl7uJakHsQgX7zOFXQYlgxNdP3QLvH4xpN99Y4lvIkkpqEW/u98 JOUgVbAdX5oI92xqGc57U42Q5PMWQCNBShhxttqsz6+BRC2y2iaXIsrWyIu+KtoRYPp9nwBGZ0r IMLTMZAYy9ZPJjURL70qua3la17HnDWe3iPGA+wPCkICZ1H9HFwML0jtKZIxmo4JY7I08xpm2PB ZJJyphZapizTBF5etWmb/N/quSVY+xAk3gw/O9Ub4DhcEjUiLiq/EqYVUWCiqnbRppIAY8e1B21 DUX7fkuO0a4RSgBiTY/ub9azH+roRu3hAxpLcfqWdhetGmxv7/EmH9DEzodsd3XuHUn021EImga sxZX1JYqn7RAMulicvweqhFfA6T1FpGMvBifCu6Dxg18JMvKA/Pjfl0FssPtReNYZp+G0fLGLsx Rafo6OZ9clmZYmCqn5AGO8c2zz+Ew== X-Received: by 2002:a05:690c:6203:b0:80d:c2cc:f673 with SMTP id 00721157ae682-81fd4b72857mr77020067b3.20.1785621669974; Sat, 01 Aug 2026 15:01:09 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:09 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 02/19] buffer: allow a buffer_head to point at memory outside the page cache Date: Sat, 1 Aug 2026 18:00:46 -0400 Message-ID: <41c6fee66724e374d4682124a1eb80041e22efb9.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" jbd2 builds a temporary buffer_head to write out the frozen copy of a metadata block, and that copy lives in slab memory. Today jbd2 points the temporary buffer at the slab folio backing it. A slab folio's ->mapping is not an address_space, so anything that follows bh->b_folio->mapping there gets garbage rather than NULL; mark_buffer_write_io_error() does exactly that, and we are about to start calling it on this buffer. Rather than teach every such helper about slab folios, allow bh->b_folio to be NULL and let b_data point straight at the memory. Code that needs the folio has to check. There are two places in this file: - __bh_submit() adds the data by virtual address using bio_add_virt_nofail(), and skips the cgroup accounting: a buffer that is not in the page cache has no owning folio to attribute writeback to. - buffer_set_crypto_ctx() returns early. fscrypt has no interest in a buffer that is not part of a file mapping, which is why it already returns when folio_mapping() comes back NULL. Nothing sets b_folio to NULL yet, so this patch is a no-op on its own. This is deliberately not a general capability. Buffers over highmem have no permanent kernel virtual address, which is why folio_set_bh() records a folio and an offset instead of an address. A folio-less buffer_head is only valid over memory that is always mapped, and must not be passed to bh_offset(). Suggested-by: Matthew Wilcox (Oracle) Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/buffer.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index be8b57a635cd..04fcc34e4fa6 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1099,12 +1099,16 @@ EXPORT_SYMBOL(__bforget); static void buffer_set_crypto_ctx(struct bio *bio, const struct buffer_hea= d *bh, gfp_t gfp_mask) { - const struct address_space *mapping =3D folio_mapping(bh->b_folio); + const struct address_space *mapping; =20 /* * The ext4 journal (jbd2) can submit a buffer_head it directly created - * for a non-pagecache page. fscrypt doesn't care about these. + * for memory that is not in the page cache at all. fscrypt doesn't + * care about these. */ + if (!bh->b_folio) + return; + mapping =3D folio_mapping(bh->b_folio); if (!mapping) return; fscrypt_set_bio_crypt_ctx(bio, mapping->host, @@ -1142,7 +1146,11 @@ static void __bh_submit(struct buffer_head *bh, blk_= opf_t opf, bio->bi_iter.bi_sector =3D bh->b_blocknr * (bh->b_size >> 9); bio->bi_write_hint =3D write_hint; =20 - bio_add_folio_nofail(bio, bh->b_folio, bh->b_size, bh_offset(bh)); + if (bh->b_folio) + bio_add_folio_nofail(bio, bh->b_folio, bh->b_size, + bh_offset(bh)); + else + bio_add_virt_nofail(bio, bh->b_data, bh->b_size); =20 bio->bi_end_io =3D end_bio; bio->bi_private =3D bh; @@ -1152,7 +1160,8 @@ static void __bh_submit(struct buffer_head *bh, blk_o= pf_t opf, =20 if (wbc) { wbc_init_bio(wbc, bio); - wbc_account_cgroup_owner(wbc, bh->b_folio, bh->b_size); + if (bh->b_folio) + wbc_account_cgroup_owner(wbc, bh->b_folio, bh->b_size); } =20 blk_crypto_submit_bio(bio); --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4113239CD04 for ; Sat, 1 Aug 2026 22:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621675; cv=none; b=TZIRwA5/zAYnK2JJas6nKwnbf5w6OaWnR4X4vTkD1QRzY+/a6Rp95Pv2T3SHyKPgF3zaSTUbFyNo3ZOhGTPOhJB2rwAzKdQsu74MvNlewPYkS8gMbMRfED7I9oLmjQLX7n3IVJy23u4mPw5/YSCAiNjpyT2kFU3wXnVceDonJWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621675; c=relaxed/simple; bh=SjXMq5r8DMa+oHg54Pyb7CIIaYbycUjnXKa6wiUICzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nW1KgLkZF0gS7lnF1q8Siv531BgVQ8w3/kv0pOqF8OsR/wDkRNQkuZhd5s5APOYi8V7WYkPYycBWVqWYI3uGAbTM+6u+EKfdDaga1tPPQiV5l2EjFRtDARuMsGyZvZ7qaqDLglwBOpgwH4H7N7xmmdsHtE88PTO6oP/99zSSJ+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DtMZ09Sz; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DtMZ09Sz" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-81dfdbd86d1so22029627b3.1 for ; Sat, 01 Aug 2026 15:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621671; x=1786226471; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gohFf3fZxhqEtiFe2bU4t44nrD74JSO89+v5O5dAsXE=; b=DtMZ09SzKwXwbxYd2KN2PmXgv0auYOwp0rlbvJ9o7ApuOsr/yYZTu0NS0abPKqPwU6 xihWmnQ502ZHVL9De21Rbz6AcKrZoAjOS7TrIxJ923Wz1ETwHSsJvjo5jC1hSCkzWsO2 k2W1w1D9p6fWZ4EhBhXS516p5UNye3Wxm8JF0RoryVdh8eL1f88wh3w6RxdUZCq4gs5X RdSgoEHmU7WCpTcU9duOn5VYvKWD3r2bMFr/6J7fxE9IElbZCmz0ucaGy9gitclRC2NC NGlAilPCA4HsvUGw7UjArJ9Cc/EoJHbWWpe1bIrYz+zUePQBdEIEQUn2NQ2XAVUhRoh6 338A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621671; x=1786226471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gohFf3fZxhqEtiFe2bU4t44nrD74JSO89+v5O5dAsXE=; b=Acx/lSixPyc9Rs5ATRp8jtUxXSVk8kwg6GmbKGcD/6FS3KOKBh2HA+kcp9HWQ5nVA8 0THcbOcHTo1j9EwrlRZArJtxvNfsjfcN/ewvnKxoHcmLRzVoOGNGqZPF0JcJNW43EN1O ZGqsyzcVU2NI6rH7Kt2IWAMA9WKLEOqkWKVceeNLR386KvmO0UR7z4o0UQYqXMW+pd8B FSNTx9MzEif15R1Oh/qosgKaauiyRM4gvrlxAdtKckzLJaAexyvhAumTW7kEIJ53TMlp Fu6Nz+LEABUlHuOeojAw9pav4DEGzLn7127VfHDfpXy6JHnJzJ4rjpVH4KFZbPBkv2L6 yO0Q== X-Forwarded-Encrypted: i=1; AHgh+Rqn7BgCwPL5JPuffVqzq3+ZkwadwXK+zkTa9i9uuNK7icBFxU08l/AQxvm2hC9KiCpDCyxVrY3YIqSa4cM=@vger.kernel.org X-Gm-Message-State: AOJu0YybE76CJOA1W470dLI2uUQUqgxKBaTO5lP7/vb4Xb5nWGfhkxEc cHLC2tVOS/LWCs4S1qGnJ7Nh2lQsdS4JT8d8ij53GehkRFhwX+/ckRFF X-Gm-Gg: AR+sD13x5AWIaCX/swfFhrEcK77d4DmddWrC5OlGTw6c18rflzedajjjZBQqlgw3FfF g6yZy8sv7c7wnBVCuzawOzrW3X178cbwuRbthLpBuPBxqhfhwkISbImGVa1/FP6Thjt1poeWAtk aYbpcjWbe+YH9zYcYvd8/Nv7QUBjoclt/iRvgjjlLfGKLE1X4ptSv+IDlbkVJC0+tgHrDfNi7pI eCKjEQpWEat7SVDSKbGBUyEVn5CgEYkTyPLMz43+uUOj8AHvgB496hAXzk878AE5P/TuTzx6NFH 1UDKCXBq4Y4OeiUpQxRodoTiswutfL7sbzHQJRZhdeZvuSEtSbEY5S+Or28z3mYO1qA3Kfc4dUc dsAFXicyDUUNUhx0JVD+1IPIVqwLY5jxysV0GvRDLICzJv5IYP5dxfjqHve3aztnYjjUWcIbF6O 6nOtTqvHOhi7jL9qnkyxlh6tpIlyR4HSBEOQ56ifVWmfO8KTtuTNJ2lC5iPwyWgvGlgyw+5VqIa YYXCWGH+BFcgLTbIRo= X-Received: by 2002:a05:690c:6e12:b0:80d:66b2:82c with SMTP id 00721157ae682-81fd4a95542mr74278777b3.16.1785621671027; Sat, 01 Aug 2026 15:01:11 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:10 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 03/19] jbd2: point the shadow buffer at the frozen data directly Date: Sat, 1 Aug 2026 18:00:47 -0400 Message-ID: <2824f30bbc43e6a0b318564fa641228e9a096e37.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a metadata buffer has to be copied out before it can be journalled, jbd2_journal_write_metadata_buffer() writes jh->b_frozen_data rather than the page cache copy. b_frozen_data is kmalloc()ed, so folio_set_bh() makes the shadow buffer point at a slab folio. That is not something the buffer_head layer can reason about. A slab folio overloads ->mapping, so a shadow buffer looks like it belongs to an address_space when it does not. buffer_set_crypto_ctx() already has to use folio_mapping() to avoid tripping over this, and it is the reason mark_buffer_write_io_error() cannot be called on a shadow buffer today. Point the shadow buffer at the frozen data itself instead: leave b_folio NULL and set b_data. The previous patch taught fs/buffer.c to submit such a buffer. The two commit-path checksum helpers are the only other users of the shadow buffer's contents, and they take the data directly rather than kmapping a folio that is already mapped. Note that the shadow buffer must not be passed to bh_offset() while b_folio is NULL. All four callers that can see one are handled here and in the previous patch. Tested with ext4 mounted data=3Djournal,journal_checksum on a metadata_csum filesystem, writing files whose every block begins with the JBD2 magic so that escaping forces the copy-out, then crashing with sysrq-b without unmounting and replaying the journal on the next mount. Recovery completed, the file contents matched, e2fsck -fn was clean, and an instrumented build confirmed the b_folio =3D=3D NULL path was taken. Suggested-by: Matthew Wilcox (Oracle) Signed-off-by: Chao Shi --- fs/jbd2/commit.c | 12 +++++++++--- fs/jbd2/journal.c | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 3029cb6f6d64..60273cddf434 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -330,6 +330,8 @@ static __u32 jbd2_checksum_data(__u32 crc32_sum, struct= buffer_head *bh) char *addr; __u32 checksum; =20 + if (!bh->b_folio) + return crc32_be(crc32_sum, bh->b_data, bh->b_size); addr =3D kmap_local_folio(bh->b_folio, bh_offset(bh)); checksum =3D crc32_be(crc32_sum, addr, bh->b_size); kunmap_local(addr); @@ -357,10 +359,14 @@ static void jbd2_block_tag_csum_set(journal_t *j, jou= rnal_block_tag_t *tag, return; =20 seq =3D cpu_to_be32(sequence); - addr =3D kmap_local_folio(bh->b_folio, bh_offset(bh)); csum32 =3D jbd2_chksum(j->j_csum_seed, (__u8 *)&seq, sizeof(seq)); - csum32 =3D jbd2_chksum(csum32, addr, bh->b_size); - kunmap_local(addr); + if (!bh->b_folio) { + csum32 =3D jbd2_chksum(csum32, bh->b_data, bh->b_size); + } else { + addr =3D kmap_local_folio(bh->b_folio, bh_offset(bh)); + csum32 =3D jbd2_chksum(csum32, addr, bh->b_size); + kunmap_local(addr); + } =20 if (jbd2_has_feature_csum3(j)) tag3->t_checksum =3D cpu_to_be32(csum32); diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 09efa337649e..9e4cb04587b4 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -329,6 +329,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *t= ransaction, struct buffer_head *new_bh; struct folio *new_folio; unsigned int new_offset; + bool frozen =3D false; struct buffer_head *bh_in =3D jh2bh(jh_in); journal_t *journal =3D transaction->t_journal; =20 @@ -354,8 +355,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *t= ransaction, * we use that version of the data for the commit. */ if (jh_in->b_frozen_data) { - new_folio =3D virt_to_folio(jh_in->b_frozen_data); - new_offset =3D offset_in_folio(new_folio, jh_in->b_frozen_data); + frozen =3D true; do_escape =3D jbd2_data_needs_escaping(jh_in->b_frozen_data); if (do_escape) jbd2_data_do_escape(jh_in->b_frozen_data); @@ -400,13 +400,22 @@ int jbd2_journal_write_metadata_buffer(transaction_t = *transaction, jh_in->b_frozen_triggers =3D jh_in->b_triggers; =20 copy_done: - new_folio =3D virt_to_folio(jh_in->b_frozen_data); - new_offset =3D offset_in_folio(new_folio, jh_in->b_frozen_data); + frozen =3D true; jbd2_data_do_escape(jh_in->b_frozen_data); } =20 escape_done: - folio_set_bh(new_bh, new_folio, new_offset); + if (frozen) { + /* + * b_frozen_data is slab memory, not page cache. Point the + * buffer at it directly rather than at a slab folio, whose + * ->mapping is not an address_space. + */ + new_bh->b_folio =3D NULL; + new_bh->b_data =3D jh_in->b_frozen_data; + } else { + folio_set_bh(new_bh, new_folio, new_offset); + } new_bh->b_size =3D bh_in->b_size; new_bh->b_bdev =3D journal->j_dev; new_bh->b_blocknr =3D blocknr; --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4B713921DB for ; Sat, 1 Aug 2026 22:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621681; cv=none; b=Z0cKiHo63brCHD+UHGBggxR51TH2CXB6VGd5AACy6gLRF2rxcyV36a/FXTz6y60CCnPm5H6RRVBoT2lAY6DWfGRfjPPmhVs8kBmWgpFJ7JvkDT2QSPbxfTbX2OAANyyt60R4xzPF9H1mgIJ2ZwoKIkWx1L9hiyBaSL3GYjo9MEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621681; c=relaxed/simple; bh=0vTXRoH3hdLZk9GtOk2DqiSHrzqM0Eca0oDK4MAlmLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=trWPw4MqdCWJ8h2B0IaXzkf14Jmf/maPwyxdWcv4Z+3M3VmNFAm/lkSokibYsAOd4lM4hIBjLYI2wUHre8eo7VcPMc0SgucNkLD1ww2Kuj48Uhkx2AZa2DW1GZ+9SM2eo8R1YxnCYCznxeU1RhYIsBA4PJKBRETZirqSe2pYF5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pY4wVshl; arc=none smtp.client-ip=209.85.128.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pY4wVshl" Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-81fc442789cso32953447b3.3 for ; Sat, 01 Aug 2026 15:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621674; x=1786226474; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TKbaZIzhd+ZroWBcz7LzJbdFmiCbzToVe0S18iQ99Z0=; b=pY4wVshlZkkdWFCJqjaJcVP/epbFWkKWUHRSyLSN4aI7i1IyFUJv8sjGg7c6/tPv86 guMwyMDTwjrkhLZe1bY/StOX4aP2nkbWZEHe4XLU5MbsL5xqaiBx76A/sMlSwEbQldXG UX7+7TWBBf65gTlD1T+o1br2ChtsVUtTCuql22cWoyFIhFD5yr2J+4LOenoXvqXVigQ/ rT8iqYsLovFCn8j4oU9+nyw0gqmxTnBBbFMnDsOM2OSdellEjlNAwWben7kHwxqjrBWz G1WHdtfXl2UaU9du7/odkYLaYA40hWc7a8e1gAvieG47ybUuLgs/TaNXXzkC1XJIX7FM 65yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621674; x=1786226474; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TKbaZIzhd+ZroWBcz7LzJbdFmiCbzToVe0S18iQ99Z0=; b=UNVMSspIjWcXHbBaousihw5bjDYifydXhYziwewNdEY3Tl2LjLIRAhcTAp7r+9vl7b saosNBJAS8FFDvSsCSWrWnUKCJZJZhoNEk0hyIUneK3biOtl25EBgsgrEiFtjnRNRWQL 0r/3JJ6OpSaBaKNI6i9XfkpAg2/HHs8Qy3tGEpz2qVICQiuDKfda5QIFGJXz1EKSezOQ ZIjc5JgP2Afv3TahwzEOmU72B+iMeYtCs3vG3IW9AM3NJdhk+o4oO3Yr0SS2NEQasPdT P8Wa0kC4W4NfO8HLxxeiEs5jZGwuTQJAYHrIXt0YZ/qhC5xTRcfeA9UG6tH3iQzSnesi aetw== X-Forwarded-Encrypted: i=1; AHgh+Ro5SlWnlzcAut9fsKqMi1D+IpdRRYR2Ydbmz8XqGGJeC6RkH1nCkLc+QeXg350+ek05IKw7YXd0sAcI6oY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1vSPvY2zxRFxkVmp3MYxmcG7EF54zeqSserKcbu7StNyMxAu/ OmFUXFZ6Wp1J3RAGOXhjd67iE9ZlXdWwx/tp1W96A5mYRkosxqIt5A8A X-Gm-Gg: AR+sD10OI3ReK0hx9u0R15y+ghhabdFY+wYJDhklnoFnFnyoZ2DHl0y5SVGCZBTTyKj M82OQGpaNmtHJ7qTX1B4Akcub9FHOM/XHxxC5f6AKEHAL71uOsOm7UyHqQZyFXpgFc+FNouOhgb kuv7bN9CNfyHyCAcjmfVjW1IUNGfvKqK877mA/SejkM1NNXit8rUYPdnXehzf04e/qOT5TNN8We KMxAIHJQaUL24gOzzaB43q24z4OkxynMma3yGuPl/KGZObRR3BLyefStOxh70kDAex2bYhFivbp rvdmi8lyj2865pAj2G3QSnasqCvkdqnH6qROHrvPwbkmLTytEgIRnh9s8B38AQhkjtVgRi7vHIH if/WNWA6dzt8uhKTzfUeYLPTbfSyAomra38ZuTOlAlJZhiBjaXWavEraMbSkd8Jv6r1LNMx46al M0lZNy2J9Zr0khOlceOR/OBIFqvN7SASsQ9sfS2sYPGWKcOuoP9PKXne4TbcivtcnabSqkVQ05i ig8kxc= X-Received: by 2002:a05:690c:dc2:b0:81e:c7d2:f26 with SMTP id 00721157ae682-81fd49cae43mr67970467b3.6.1785621673554; Sat, 01 Aug 2026 15:01:13 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:12 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 04/19] buffer: clear BH_Write_EIO when a buffer is forgotten Date: Sat, 1 Aug 2026 18:00:48 -0400 Message-ID: <1bf058fd5867bceeede78d99844b49a26ed6f3c5.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" BH_Write_EIO records that the last write of this buffer failed. It is cleared when the buffer is submitted for write again - see the test_set_buffer_req() check in __bh_submit() - but a filesystem freeing a metadata block never submits it again. It calls bforget() and hands the block back to the allocator, so the flag outlives the block it refers to. That does not matter much today, because the write error is also recorded by clearing BH_Uptodate and the buffer is discarded soon after. It starts to matter in the rest of this series, which stops clearing BH_Uptodate on write error and makes BH_Write_EIO the way a failed metadata write is reported. bforget() is where a filesystem says it no longer cares about this buffer's contents, so clear the error there alongside the dirty flag. Suggested-by: Jan Kara Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/buffer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/buffer.c b/fs/buffer.c index 04fcc34e4fa6..7889c30d8715 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1091,6 +1091,7 @@ EXPORT_SYMBOL(__brelse); void __bforget(struct buffer_head *bh) { clear_buffer_dirty(bh); + clear_buffer_write_io_error(bh); remove_assoc_queue(bh); __brelse(bh); } --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D59AE36197E for ; Sat, 1 Aug 2026 22:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621680; cv=none; b=bEGynh6VvtiQUDwB1DlZoLfcW5dEB3NctEJSwOna1X3JmXltVTlG3tDc+/fIF9iieVfUppgg9hx7enpe+oE7FhTJkv/XyXxsKBiiXEun122a1geyGS2NCvbP9YN8Knb6JRmzZg19koPE0Ua72LbYowTF1WR33pmgfIZQ8W8K//0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621680; c=relaxed/simple; bh=C/EU16/I7KCMlmfQlOxCpDa7gi9I5VwIhNBsZBfHyYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gLjcUlhEUF13siLfYqis1vwhpqR6mQWDML7vrdgorEEKpdeH87u8T3+FIeFZ4iMYHhdvZmnU0qWXrlk87rTQobGuXgHHp3oP1Khn/SeXy5TIskX4OgfrXNrfqCQWq0oGfHHdHUSl1O3wtrgrfsghtY7uYSnPHPos0LVO9oFjo+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mVQsNMht; arc=none smtp.client-ip=209.85.128.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mVQsNMht" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-81ee41aaec1so29632417b3.3 for ; Sat, 01 Aug 2026 15:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621676; x=1786226476; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RmlziesBf0p1zLY+SBouFO3AuG9bJkIG3U4FWyI9lx8=; b=mVQsNMhtoyDJzr5v3i315Qh382bdVk1jK9+Q30pwlj/dcosHnql6LoueV3JP29yCRE YwUbHngWzXnUqkGWq2B+Km/mOooKzR70LjcCelSmVMpyvSIhcQZr6Vb0upleThF5jNH/ as5oJP5fJuwuYcnXVPHVNgUa5DUc8z2uvhqsTmWTHts9cG87AUX1wHT77hYM3LLEuMKV KOj3qT1t2+fiQ2SKDHK9npn0aF3mq7ZD0O8wrQC52tbY3ZexkcLsRWUqRCyrZBuPkNk7 2e/m43g0/s9wG3bMtzyIX2i2ZP8sCX890VJ3nlaed77ltCGWPoR0HYgbl1pK/Y8hgufs IjTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621676; x=1786226476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RmlziesBf0p1zLY+SBouFO3AuG9bJkIG3U4FWyI9lx8=; b=iuvGSziv3FdlpYyEfgI0nrphsGPab7LOktIY8Fpw1mI9jL1xaeLSh1AJ2Qllsmjadc OBCGahvqostIdmNtzlYZGfxOQ3uYHoCmOjr278FPZb1AmqogsBQhznUVj01Z1ejJxsvl yX2vFrvdM7dgdV9irUZrrs1bXp9Ne9j0UPRQHtvEFxMJUiqUaSCSR2S1S3oKySOb4wWD slW592kb8MlkKlrXpEQwyblGzZa2bb/Qis31rWD0+da40YTfS1YjFVPVlrb4rg4ZoiW8 GgPi1nlvNZQ4aoVb/M8HhetSh/IMtFnn0FJ8rajrtO9dECiGyeefHr80RyvWL8dBN18T s8uQ== X-Forwarded-Encrypted: i=1; AHgh+RqBjWwNB02/S7lt2f/pT7iR9c5YBtrw9JWaeMfoSCO1RSNOC8qGNdaHAuZIzTciL3d1sgXBOyRmICegWuo=@vger.kernel.org X-Gm-Message-State: AOJu0YxD3h0gdkuUSPGTx8P0XV/guo7+EHolHESuayEfa4pOy31TMAtV tXRySZHa+0JLhYH9lIBo4JqQI1QLDZuFl0kEaOHlMxAtkpGR5Mi3lTYq X-Gm-Gg: AR+sD13OiTgGFEk9r2LKWNFWjPn/cYUQ1uFglLNtYK/nbP/l2HBPiNhawQ+W8Jk5MDp lN65EijQN7Fg5XxDjNrN4yM7wWDarbQqAQBYzXlwkCrMb0t0C3zVmxk7EOvH0WXR7PJt/sDWQ9j TGHZJxBHBemYkMUO7KoXD6MS/ucq50blx+egWzI55JgSDStIcO6HqHEgAf8a7YAYy1YE4FSOEy6 LKmXjMQLo2B2wyAVEPjWsEyaHLvz07Xqu8A6EnIe53tU83wfTd2kY9DqCyUbeLR5vqlDUbS5nOT CSs1Ef5pBBJTgWULY3LIdcLaSdnLiGx/+Vt/5RDrGCOfB0wiz3kdUmk3819JUZKValz/+OIfVks sHPzli9EXAuJ4RkUa60lwyOhrm3rQkdnOBAnX0O+dA1c36hibBVzrPXij3uVk3hnFAeuvs+J/I4 eKaID8tIRYosK4XkFdIVycq8V52BM8MJnzY04o2Y9b5phwPLlH+vSwwlndAoGhKLyZhZtVlLl0b muGrsE= X-Received: by 2002:a05:690c:6286:b0:80c:8d09:3880 with SMTP id 00721157ae682-81fd4a86754mr73431087b3.15.1785621676098; Sat, 01 Aug 2026 15:01:16 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:15 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 05/19] buffer: discard BH_Write_EIO along with the rest of the buffer state Date: Sat, 1 Aug 2026 18:00:49 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" discard_buffer() strips the state that describes where a buffer lives and what has happened to it, because after an invalidate none of it applies any more. BH_Write_EIO belongs in that set for the same reason: it describes a write of the data that is being thrown away. Leaving it set means a buffer_head reused for a different block starts life carrying somebody else's write error. Like the bforget() change, this is mostly theoretical today and becomes load bearing once the rest of the series makes BH_Write_EIO the report of a failed metadata write. Suggested-by: Jan Kara Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 7889c30d8715..50a63d964815 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1518,7 +1518,7 @@ EXPORT_SYMBOL(folio_set_bh); /* Bits that are cleared during an invalidate */ #define BUFFER_FLAGS_DISCARD \ (1 << BH_Mapped | 1 << BH_New | 1 << BH_Req | \ - 1 << BH_Delay | 1 << BH_Unwritten) + 1 << BH_Delay | 1 << BH_Unwritten | 1 << BH_Write_EIO) =20 static void discard_buffer(struct buffer_head * bh) { --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EB552F8EB3 for ; Sat, 1 Aug 2026 22:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621681; cv=none; b=UM2zUsi7R20uZ11/IGEt39krOimoC73O6BUIjxHKd/CeTIX5cjiiv0FyHT6OQ2yfVewmhPFNn1Oej/EYourC7SHm25EBKuzkaSArTAmrg0EJZl5+IeAnpXzo1Vc2tDEzd9dbTr057gsT5oQxQbi5gQEHnV+FqET3+6m2QHWtqx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621681; c=relaxed/simple; bh=nTKqFaIO4eWueECCBUw01WYSenLBpxO8tTFhLp4DI8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jBQfu1cckFxHkISFIMBwS9+jshhve8ygftzhcL38rA/Cc2BI/xczd40ojRo6hiszJvHKx9bL32xtrC7Ymo68Cz4r6Xt3Wf8gm/A9TkKj+OFNpIp4SBFPMmxa9cvlKnJkr1fspMPWdvO9ePNB6veBq/RpRu/rih3FnqH0OCNkzC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mhZDp/RP; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mhZDp/RP" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-81f3b227a4aso33571647b3.1 for ; Sat, 01 Aug 2026 15:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621678; x=1786226478; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+Vy4j4aElKFiT0ILAbTnwQA9DPnzOxaRGdQq6jv8GAw=; b=mhZDp/RPeORtxayAJxHijgqC9qNm90l4P6i0Flu6B7+HSOSH9Agxm2V6wYLOoQTrxS TddmwBfvofGm3zZ83wrO+BuGkV51HHmPYQv+Gvbfp8vetuZqreaUE2SPC4Cjwt4MDuUX sYimmrLQBHLWYLIN1uL/WwC6+WlHx0JkxFef/66FFooATqEJUxAHq//26qs0cEoktsJi P3lirHZ5MpcYubzWfmwIMARnWO/BTaamaDt+UTffZUKqut3/LvaYvA/Nz+7YWDxiIooE 4NVEf7NPoH8VMlHeBcL8xlFuIvS7HCwrBohWIEB3edibmaVdm6fmYlgwEzhajtEaUTXV NkDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621678; x=1786226478; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+Vy4j4aElKFiT0ILAbTnwQA9DPnzOxaRGdQq6jv8GAw=; b=iEIURyTDBk/2HO0dpZMde5J1g1R3N/x4717wZ+mMwuYdwee7lBJ3acf0CRtEaspz/L UYR87QnWIAjdYbjPRFi5tFSKr1So2tueayYLnD78yTlmBYAqFulcfcZjVQtVAmYtGDMo 3xpZNsJ+EY/QKWbnVBD92gadueeKCRg2Y9Fa0XE6XREEyrDMtvWUEKQTnIT7GoGr4A0u hwCFE6+8pmLiGRc0qQ0twbGkdVZ2aD22qlo0s6Frj5xn+J8TZttJ3yfdTah3M+I65DVk t1MIGcdGupWSRc7G6rxTqQuoJoM7PllakuMjK+ik2K46Mjf+5Auf0kXqLFuSp7G+ZwnN auLQ== X-Forwarded-Encrypted: i=1; AHgh+Rqf8YLKzt+kTpi3zQdskcjKxkZBasj+TFS/YNcpkovdSoM6anQrEL1ppbetyohD699VlgUprapdtvZo4Rs=@vger.kernel.org X-Gm-Message-State: AOJu0YzM794Gl+IXF2URJpuVbjDF1p69q0/88yM0UhEbXU71oaNBCbPd uVwIYB2QSrZCAshy78HM8J0yqi6zxQSpK70OSTvYRhxZy+cEnjp+7pkD X-Gm-Gg: AR+sD11L/aJtKSEYkwoTCJolQHvAfB437ny0F/uf59DIEtjDB4bmBonbixzLXmCuwgI q4kRFHe2FMU3J3kSDU6o7B2DV2CFmTJSdgEEs9I0uhIp/7g5ArA/OVnp57vb8IF+Nn+W7e0caq/ +igfkBCXHk2hiUqNX6FQR/dywwTEA+zAlCb4iYIrSlOhkPm5M3kBdYY0tNxAKVYJoKCmTN6YTjk EJ/tDBIvznax0tXK/v28Q+/wNQiMgYOEVfLix5cAzA1/uUUnh82bu7euemvoryQUf7y5oZE2ebE jOii0wk2HTvVKDNDWqhfS2cjuvsWoWpZPpi/940D46NJ5sqSn+6MBKfw4jDtgYkfoDvudt19QmJ BONFhom00Jj5t3VqwLyFuyapTOEOnsxwgNAjE77wSYPdgS/zGd72lX3t50Ubu/CJeLqkR1zg2Ul BQaVaGRDeB16XoJThheACJbZ3rKiiNFD8PxhMWm7lP1vZFycApzXcHD+I8U86i5U3aMzU7WjRIS GHNqnU= X-Received: by 2002:a05:690c:4442:b0:81e:c972:e8c3 with SMTP id 00721157ae682-81fd4ba85d1mr75578147b3.29.1785621677847; Sat, 01 Aug 2026 15:01:17 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:16 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 06/19] buffer: detect metadata write errors with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:50 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Both places in this file that report a metadata write error to a caller do it by testing !buffer_uptodate() after waiting for the write. That works only because the write completion handlers clear BH_Uptodate when the write fails, which is what this series is removing: a buffer whose write failed still holds the correct data, and saying otherwise makes callers rewrite, re-read or WARN over a buffer that was never wrong. BH_Write_EIO is the flag that actually means "the last write of this buffer failed", and both handlers already set it via mark_buffer_write_io_error(). Test that instead. No behaviour change: today a failed write through bh_end_write() or bh_end_async_write() sets BH_Write_EIO and clears BH_Uptodate together, so the two tests agree. They stop agreeing at the end of the series, and this one stays right. In __sync_dirty_buffer() the flag also refers unambiguously to the write we just issued, because __bh_submit() clears it when it resubmits a buffer for write. Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 50a63d964815..ac978d9090c2 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -618,7 +618,7 @@ int mmb_sync(struct mapping_metadata_bhs *mmb) } spin_unlock(&mmb->lock); wait_on_buffer(bh); - if (!buffer_uptodate(bh)) + if (buffer_write_io_error(bh)) err =3D -EIO; brelse(bh); spin_lock(&mmb->lock); @@ -2743,7 +2743,7 @@ int __sync_dirty_buffer(struct buffer_head *bh, blk_o= pf_t op_flags) =20 bh_submit(bh, REQ_OP_WRITE | op_flags, bh_end_write); wait_on_buffer(bh); - if (!buffer_uptodate(bh)) + if (buffer_write_io_error(bh)) return -EIO; } else { unlock_buffer(bh); --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1AF638E8CC for ; Sat, 1 Aug 2026 22:01:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621683; cv=none; b=gfO2/f4p68JCgqAjNfLseAi1IPlN62mHiVSW/9hshXvKHDeZOEKFbkZIn18SvTrrDAq1eBrgBubpvtUH77tcVidrPaY1SuS1aamdTkUxZYdmq75Nq/DNbs0+0lIrbwMyiwBPyuyrbhqZeCG/eBfoe0KWKOYX6zzo9H2Yd4w9Gnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621683; c=relaxed/simple; bh=rmASDDjzyu7ORP+REJJAPqpbg4Lkmrb9SobBQ2fdR4s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GNy69yMLpoyax5DTFGRNrsw5XJpAxjpLoVJ0o5iJsy7zEM9xYwfAjh+iQ80C2x2ZkBgRqMx/LQGzj4DYoMYL8TJ2JAZPJzCZf0WNXSnDz2NVAm4+gKKIPGy27bogOpt/9MuIyO/jGB5XlxlXiEimC6di9D66NaIWChov3HXF8kA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZMnnxug9; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZMnnxug9" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-81ed2a06b9eso19525047b3.3 for ; Sat, 01 Aug 2026 15:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621680; x=1786226480; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CmPK9JWvOViXyoDvMWnuptWNftqO/5jbHBuyoy5p9Iw=; b=ZMnnxug9XdWQ0aXvQSPCN2jWf+hw2NGNaI9rsERvZSxtiKGb4zMc+oFGf51JQt0eTo ngmYksGG9+iDAue1aGPDPVXT/bdWSYFaOsCl0F9aT06Q4M1tTiK+WrswQRDxYqSYxmKG uDq4Q93W0SVAB8dXdzOhKahfz5q5/HDeabMMVjWPrJeKwU8Pvq8ctmeDz5nQU5f3MpxS 8rx0dnvWPfjc1b0j874DqBxATRVdprSV0tX3oNXEVkTinZLeC/hvKP+L3fdPq/EWLJhz Z6mmStYrX/1cmxkP+A3B2YudrR6I/nR0wKy07aHxBzn7OkqxqYi8Rb3ryVdAbEEXzaE+ 10gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621680; x=1786226480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CmPK9JWvOViXyoDvMWnuptWNftqO/5jbHBuyoy5p9Iw=; b=hiPXK5XDfHG1CjtoaJbo06msiTXCwbj8C8Ad8J5I6Q0yilJpRvqlXJHzreZE7XHYBf a8649k2tHK7T1Yhz9Swuyb0sh3UJn9TnI5gjOhr5w5NlnzcTN042wbewGHofeROfyOKr 3MvbGewtwhLPjh4yECI+JBGl+HJxId2VlrV52cQNFN2SFw/OlPVcnVhDWxeiD+8/e5jr yrb9VTMANHaKd5eadBxiKIRb/mle3WtRm+YzYLZXoBKEqwzQRoOHzfRAOK+XU58u87hM cTvV9mhyOpRPgULRnv1XhUBFOvG3ntNIocBIVSVUKtZ2jt9vUAFyscI88nxezN3b/Jqo dDeg== X-Forwarded-Encrypted: i=1; AHgh+RpPaki4CtVziydvHX62N5w4+r7EKbO0JnQDSOvC/Ipz3n7WhRgLET6bcSeyh2TulA76gG6ecu1NYS+20e4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0VSC22vlfVKpU0FHRSZdJ/OvAOL7bvJVv144gX/3dZ7ZlWOgb UZz1zQRM0qPvFqjOP+oeGhalzgYIBbhgPzIbOCM09p/tPkSlMxXdO39w X-Gm-Gg: AR+sD11NF2XQI5e0023yXT05lwZpkmr22AkVRgwuKXAa09kJjCBcQgwjfZUYgSPATUr 2SyulzAmaerWeoTDA7P1/Ld2RXTLF1b3xA+w94xvujqupMJfVPpYWdNBFR7Dxv90wRJ72GssLz4 VHm0AcSsni82bcCFYN6BtbSv9reKipqp+kzr8AFO+0GVsU/cOUNL2k3TP8w8MvSKNeobc98FgGk 6bdMAgWpSEQGM+KTpz+6GGObm0ZShGDSpAFPwEdRIwwRAB1iL3jMoXQnxgowk6vsY7etcsWbTaN RoG8CRmtRG22BEYzJgr1aWpl5283K+Ozd1E0VUh1x/gbXNcMYVg9LgAYhOsEcF2cAVz16NTh8qp 9rgsFHpijyw7IEZlqRdhYTbRArLetrXRGkV8Zco+GDctT2CwDovshEKSX5ZIfchdjS92FiRzKwh tP1n8bYkWmkKcKCyBGt4eO4bzR6gfGjR2NIVZif3FJI62WTw0sAyHiCuDSYarbZJorwBgXFBwkl Hyeng4= X-Received: by 2002:a05:690c:dcb:b0:81e:d009:1956 with SMTP id 00721157ae682-81fd4a21566mr79336867b3.12.1785621679620; Sat, 01 Aug 2026 15:01:19 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:19 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 07/19] adfs: check for a directory write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:51 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" adfs_dir_sync() spots a failed write by testing BH_Req together with !BH_Uptodate. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. BH_Write_EIO says exactly what this code wants to know, and it implies BH_Req, so the pair collapses into one test. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi --- fs/adfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c index 11afa9e157aa..b8cc6a697a05 100644 --- a/fs/adfs/dir.c +++ b/fs/adfs/dir.c @@ -191,7 +191,7 @@ static int adfs_dir_sync(struct adfs_dir *dir) for (i =3D dir->nr_buffers - 1; i >=3D 0; i--) { struct buffer_head *bh =3D dir->bhs[i]; sync_dirty_buffer(bh); - if (buffer_req(bh) && !buffer_uptodate(bh)) + if (buffer_write_io_error(bh)) err =3D -EIO; } =20 --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 780CC37F72C for ; Sat, 1 Aug 2026 22:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621685; cv=none; b=WdpjJ7mO3tYy0Ls/6zWUGBcdt/A1UEjYlHq68oGzHP3uy9Y7eodWKysC2LazOLQPJSFiZsL0Y5TvOo1f4jWYr4ELMJx0CG33bA7Cz7l1kD92qXq8PxNQOO+vmugFJK8ujxgLYyS3ZGUprcxyNXWTtMhoCZZTCbx05x5fBcWvTuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621685; c=relaxed/simple; bh=0GZwqUy172rmUBMrDMV2vQcxlGBw18Y+h2pa3/xDLGE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rgNG01n2r0UEAIRYoAzl4zp+yU0Fg8iVZsOpbd03zWrLOPl36uMYURx1e3Az4e/rwcum04JOx3BhxbzvXJdINYWD6V9aN97ocH6Th4q+5Fwd8jzxuJtFJBw9wuBGafgJmrOXKRxBdHkMl7KRGHH4fUb2HRCXwGzZ4cAVBx/SaCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BSZ8BYZc; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BSZ8BYZc" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-80bb41f7f3cso21508057b3.2 for ; Sat, 01 Aug 2026 15:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621681; x=1786226481; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZTD9K6oObS45hnhRjtGbn2SpngZimROJJDwLscvqzbo=; b=BSZ8BYZcRcxM3awTw2IR7SZiL43EtkPRP/HJP4UPaqugzYvhfLH137ZE2fnZ/yXFQo Bj6/x4uvRE2rZOtNaBO730T8RAOfYjuV6Dk5k3ywMABH++Kyeg6iAx701bEzkaxAijCd vklhSZJe346aVtPeUcqtK6v1X3c+q4a97+cCSwSYcQxHEL99Z6N+bHK0QmnAFcQjU0bA m1qWp4jkg0aC52mVVoCDl47RDlm8EfFS13z6UIoWvyopX9vJ9lF8GqmSQL8KWCktQnFK xRteSSXvUrUGEZWpk4iY5sXR0zGBZhnJjmgwG9TZcxuRYcxXHIgbaWWD7SgUkh/5tZ6W OIKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621681; x=1786226481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZTD9K6oObS45hnhRjtGbn2SpngZimROJJDwLscvqzbo=; b=LjmPZtDGwy3flLtWyo/dgKM8lBSkQd6dRkPEUTs88PNITg8Y9ULIwiF0g3X3l47eIh r/VfsUfMG/wOnwvvN0hme886t5XYmwxbfpJLUXL8Bj8EhVuNUAtr/XU5RrPkPm9IU+XV wLtDEHLH7CSIbaqXJFW4nd7FmaSjJKJS5NFnyzwIjtkOfAF77whKZxU7kem8x8JcXY8z zYBWK0s64B9bmGaeXVwZIP3jGltSZnhLWU5epDWBvQbuo2Stsdmjw2rubux/xQkgYEli C4nqdYN5CJxu1UtVq6sTsMDcnXjh8eUT4n+Jn56TBq9p43mHZLFnFeiMmdoHwDGUfXz+ wuVw== X-Forwarded-Encrypted: i=1; AHgh+Rqu8VMTUEAZdJ+CQAmzJJB3IHOuRjWAMrWiW+EKs4DYG7Ctaz0d0fAQAr9tGivHrF1pxby/f6q6r+f0Wrs=@vger.kernel.org X-Gm-Message-State: AOJu0YxpWscIYZAH4FhLHWtN9Yc0UR74LzaeMmUgti2HlKyl5AoXGP+U V+bfsMY/0yHhjRvhvMJISsNVQZlK39vIRwPtZzOyrc2CHjyZHfzlkYiw X-Gm-Gg: AR+sD13ls3kSSYYbb6xt3QHt4hHmsCnAXNI9ZbanxmlYAGFXwysd6y9yC7IO5CluEae 5a6vCxPIfpUOmnMseuigcUbRRSnNk7J9gKxfibqmzadZ78sskWXhm5Pv0mp5f/vdWzPuzUQijf+ 4limcz+bi+8gRWYrZMFK4uJyYEIodxoJbpAKizH8dXMq8UIBpfA1YUu/Ly029t6dl5SX3A+qVqx 3KIvZ8xZSnuwRbPZyu8dcMW2wvY4FCi/CCfR8DX3x5WA3FH0jEpJZX+0ufdOGCVxwJPkJTwaxpW 99GVj84dGRUbJ1V6MCcBtJO7MOmLRYEjEw3mFSQoyDUczWhqFvmjwm7ffs8h3KjJlIb/pIdgjX0 TmIJdhuV32m9B5KV1zGbiFF+ss2mCSzEe9CtQbrWJPpBSC1uIcfszp0cjhLObYGA/sPZOIMszI/ RZCgoI4sW1tFjuy72OV4xqscUZRLUKWoLmJUKJArYrO/r2qQb1/us7P27IUHwYKQnEnuH+iFCTX nRSVgY= X-Received: by 2002:a05:690c:6ac9:b0:81e:ae6d:caed with SMTP id 00721157ae682-81fd4bf66c7mr72228817b3.34.1785621680760; Sat, 01 Aug 2026 15:01:20 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:20 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 08/19] ext2: check for an xattr block write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:52 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ext2_xattr_set2() spots a failed synchronous write by testing BH_Req together with !BH_Uptodate. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. BH_Write_EIO says exactly what this code wants to know, and it implies BH_Req, so the pair collapses into one test. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/ext2/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index be63f89402a3..39005ec23fe5 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -769,7 +769,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head= *old_bh, if (IS_SYNC(inode)) { sync_dirty_buffer(new_bh); error =3D -EIO; - if (buffer_req(new_bh) && !buffer_uptodate(new_bh)) + if (buffer_write_io_error(new_bh)) goto cleanup; } } --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D964F364045 for ; Sat, 1 Aug 2026 22:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621695; cv=none; b=KDg8zbLT+YDcPRJGZno/Yq0ZntHPx+94XvdVQSppYpSv55w7JcuO4VHhfvSQugbgK2TlgJNAl5qmOYXnuzY30NiEQB3/jA3x/o/8IXp10JiswezTWqTTPAEIU/Oz9OtH4k71wTSPmJbL7SPdHZbK3kQl6ZayXCN1/jypCAymukA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621695; c=relaxed/simple; bh=k+XwpsvdR4lXnK8J7akvyHhiQeX6iOLIGH6lriW/zZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iR6MhiAZS8q8qCmG9S6gUuHZKaYfa7TtIuYeHPrzNwmW5Gg+v1Une9s1nPH5SuTkui8zyHD44fRnelhikijCrVEayTz1zqgWa1Pt4uaSy/PModN1UXTdKRaefR5XpiMIctx6uJwS+0yn2JIpNatGfweRVnuBCTvyA40KBIA78rY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LjF6511M; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LjF6511M" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-81ed2a00f12so31638357b3.2 for ; Sat, 01 Aug 2026 15:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621682; x=1786226482; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qR4j1ND7sU3DHEeB5SkE24JFiOq+gxamuNrGyu3FS3k=; b=LjF6511MD8nyx8OgsBaCVjrtAId5xfEyV9Mla+K1MgBFkCXjSOtDDh4FrzzGiIgCYG rg6ez4+UbzKcMgRNqTBV/vSr4vBOxenfTN7yvq377FOV49TEgxtoWpoyyCg6Nf9yWtOq yxhLAAE12uLnCLsNx6OFA9wIczk1fHp9PmTSOL8655l3xvJLKk9dqQO5YL9yeUGiI5r4 vFigq4zGJeymgJTrqEPeR6GUNaT8iTHSE5d7p3hBn1FCH8Fn821F4fD511QmILnQZfaR VEsI+Hjmibx7q+C6zbLrWdlm0gmRBoiz6r+K9Y8cA03955hqcrDcJJXROOFxlWZ5tpAi aNHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621682; x=1786226482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qR4j1ND7sU3DHEeB5SkE24JFiOq+gxamuNrGyu3FS3k=; b=PHP+zwPLYtDRUvpwvZ24At2TLPMyYiqJtFfX2RchToYs+d+ms6sArqcsHKbfHeUJE6 vHwSO1GjagxqPN8PzPSYVdC5bDSB9x6mkKiw9lBz0wyWF0UR4XgFMJVUKKCH/f+VuPj7 TNCxAjN6CSmcFjjhcPIFG8p8F4i9nqIJV6YZ1zz6eI4inq+skL2PYexW1PzxEhVNF+L0 vmBvv9UpwcJXKjMMh+TUiS8vj9tjXUPZlK/70BrdYoJX5EZ3QaRo2zkXkI1TVRYRuPM1 GkYQRXyc4pXVV5ewu0I5bic8G4Ov6nO4zqzB22JLDNfoMUHURULDzpjfWOVr7DQiyJ41 xSsw== X-Forwarded-Encrypted: i=1; AHgh+RphxRXVoV2xCPgLe+s/30zSnEW+upj06/70L83RtpjquEVwETSaDaP28g+BPSdtKR/Nk3r6234E8Nyf34A=@vger.kernel.org X-Gm-Message-State: AOJu0Yy00L0WabrQN7feGYCwzKMo9PN0Ikxd7rpqmkqNKmgFoVGKosNf wwus6fXfcJ99MM/djS7/JywlOOYIX/0v4YqDfYlQW0BZ6unoe18ku/0d X-Gm-Gg: AR+sD12I7JaahQvpXJ6AgsWMJEFrmGsXK/ubbpW2on/lTqjjT1TSil+coKnvm+eLeuG rhdt+G1lgac03MW1OKdgm/aFWrHKPcI3OdHg0p/HF6dZg8G/c9HDH+qEixi8wXU1EqyVIcDd+fw cBvVrDbV+KnLurYgcDxzMTK+2lH1MxN8KDx5/D1E/clw7CpWALU47NLyLfQxGX4KsNPzJNyKhaK Gg+5qOCz+1wttBiFqMq7rJr1hhdeAqs+Ynnale0i7Rz1JmjuCYqEAdugX9UwwzpK6JDmrgIZ//Q K6T+xtmkpkL6O7tpc3PTI//MiJSf7Maeacg8rrbJjmbkxwVj2GTqDEjvzu5JdkC661rN2N0F7U0 pPQ23IDubO9yhwgTbnVP8r/crnZaHYXopJfG28vzGszw8IU4OVw2x0678fiNXL0sVp156c/E8uL 3U2wjjMXPO1H8T+l1I8qGbClUvMKzqM/sYHbIXPpHKCvvnAyrJoYzb6jk5ODMsX22ZDEZWFeOnf hg3eS50 X-Received: by 2002:a05:690c:6d07:b0:81f:27f8:2de4 with SMTP id 00721157ae682-81fd4a04799mr74061547b3.8.1785621681823; Sat, 01 Aug 2026 15:01:21 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:21 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 09/19] omfs: check for an inode write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:53 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" __omfs_write_inode() spots a failed synchronous write, on both the primary block and each mirror, by testing BH_Req together with !BH_Uptodate. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. BH_Write_EIO says exactly what this code wants to know, and it implies BH_Req, so each pair collapses into one test. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi --- fs/omfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index 1d915ef72119..bc37029a4afb 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c @@ -145,7 +145,7 @@ static int __omfs_write_inode(struct inode *inode, int = wait) mark_buffer_dirty(bh); if (wait) { sync_dirty_buffer(bh); - if (buffer_req(bh) && !buffer_uptodate(bh)) + if (buffer_write_io_error(bh)) sync_failed =3D 1; } =20 @@ -159,7 +159,7 @@ static int __omfs_write_inode(struct inode *inode, int = wait) mark_buffer_dirty(bh2); if (wait) { sync_dirty_buffer(bh2); - if (buffer_req(bh2) && !buffer_uptodate(bh2)) + if (buffer_write_io_error(bh2)) sync_failed =3D 1; } brelse(bh2); --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0AC03B71B6 for ; Sat, 1 Aug 2026 22:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621691; cv=none; b=jqzFIXrVK82GmYtAkGvy/3FX1PX4RZ5C8GirhZwVSd9DSGMXwCIKC7Q519iARNqZ6I8IYCSNRyhhuKgrTBxUZ/ZcaW5uiotFLW3FEIsPH/JdbzUUMwudS1GSh7O/H8D+BKaoS00RDK33qF2kplzP+/CPXn2pmMoxXFg8zKn9Zyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621691; c=relaxed/simple; bh=B1aGoafSodbJHnZvQa4U88gzZAbdOk4anLe8al4k4+M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s3C37cEMKSM9o9x/ur+S52iM4Tpva4xQ7EuWb6EGn2/fbpLarZbizx9hALD3jlTS8nxRd3zFJNx4DSsNSUAl4hDQkrYzkCvlVukzQ+rGxK5PqI7NxKSNYrIhGwg6qvjRR2Xg+prZwXF2yQxva/GJFOHER1a+RCqQ3I9HKlVWCIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PNVHRsXU; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PNVHRsXU" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-8114a4542b2so33656787b3.1 for ; Sat, 01 Aug 2026 15:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621684; x=1786226484; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fFKjhKiLwW7000gY04FDp9HuhYK5pnv34+ERWpP83n8=; b=PNVHRsXUp0XCXnD8Q+OJb7MgdABLPwXgxvpcqQWg4VuxEPmBLymrH5x1rcy08o+/9t ZGNL91aWrTxK+/zmIESs8niMIAbrmnsJ8IdweXdnxfTINbPcwllz9HQzaDWZUf/lpUyG CG76ga41gnn4KB8Fp5Qfbb4MrLbyOft7dCNVuLy/jKpiqPKmywoBG3iJSi4pn0Ndk+MW Z9jHubiQBK9UUscfGZ5iX9eEoUMaASP7WwczxwGJyUQdAIZ7yErDlmdI7JpkNaFHzj0r gqJESLFvRnPXoH3zZPAy8K9Ue2PTHvhTBwBPpHDYQpMsDszYEefsqIvEQRkDBVRFKnVs Imdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621684; x=1786226484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=fFKjhKiLwW7000gY04FDp9HuhYK5pnv34+ERWpP83n8=; b=H/bVrGbl5sOHOXjG+SLoFCKp2GbAPFhQnU2pCDC71kxM0amQWHS2tCIUqwLs5wQOxG zSz4rHowRhCxke/zBeFV4XnwhxFFZYeQ1NYOkqqE2Vju+bIx2eIA8fAkTjwAbB+l3WiB BumKc5fIQE199fw6V/z5aO3ulw+/zR3hKK17W7tykAxV0zAr+foTSFezp5Dd/B7C6Imm zrOCX2Qzh0KbXC9BAADS4LzBXjwpt1lE+vzaymertkI/P+u4e05urh1jjrZLovN7Qnjq JS1tXmyWedSg7Ojcn9CiKv2EBMq9/WBxE67ctgxt8igkQ9s4dAL8fZ9wlptHNqm4cwJo ZnYQ== X-Forwarded-Encrypted: i=1; AHgh+RpjBnZgUAlNRB2xHxITXlVIiGpcIEvH0gCa3Dd32VbqR8bQBVV8805RZCZC9RCM9CkE6bJWZVjk7qcEgkw=@vger.kernel.org X-Gm-Message-State: AOJu0YxDUuR/bdXTq+igh9c8H98Uepai8uAJp1s+1Zmas5yJcTJ0LcXV bQC7wVwqBI34N3G+g6E6j/Efe6HPe01wdwpQSJlM8U5pqgYCKapZahrj X-Gm-Gg: AR+sD12+UXYrN3bk8S1ki116PNNAwdfJkwSaLvSj166x5jP6ngwGzybuyAqHTrwGIRP oMApYyb7tC2L2OiEHLwv+a3jdUTHW+war7acV3yDTy1PiEqxIX8erWUnfevsNZi0xO84+fLLF6+ v0lcdUq+zcxyjlPcKMSgjrJFk1n8v1xu7Fw7qVvT99m/gLCIkDWtjibsHVQL7O667et8UMyj4Ky bRzFEAXI6bi+lbQ9aP/4O6W5vhx8WqsTGRTwZn3Vwnh7H/rDIGbdqWZKUahFrqV1KhPduF/PZs7 e9QNe6+FTBrB3IaKjK1Nnc03qXdzexn+dTFSbPL3NTkgPYiYZ4+s155KBA6wnYCQh9Hbp+pZXwH /dkiwJGsPcNCBReoUYdzzUYUaZ4KFwAGouzWAvIsyPaHI8wiMT+PfLVns40Tz77suNkisTqj+KW pheyjg57M8OL++O1vzwJMQ1udXQCiWOxbBnbgLDoeaK+RKTQIuz3wT1CquukniAggPp+zL51hPB 7hNBdg= X-Received: by 2002:a05:690c:d8f:b0:80d:a249:4854 with SMTP id 00721157ae682-81fd4b59a06mr68933057b3.17.1785621683893; Sat, 01 Aug 2026 15:01:23 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:23 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 10/19] exfat: check for a directory write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:54 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" exfat_update_bhs() waits for the writes it issued and then tests !buffer_uptodate() to find the ones that failed. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. Test BH_Write_EIO, which is what the completion handler sets and what this code actually wants to know. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi --- fs/exfat/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c index 6f11a96a4ffa..dfd0bbf31c94 100644 --- a/fs/exfat/misc.c +++ b/fs/exfat/misc.c @@ -187,7 +187,7 @@ int exfat_update_bhs(struct buffer_head **bhs, int nr_b= hs, int sync) =20 for (i =3D 0; i < nr_bhs && sync; i++) { wait_on_buffer(bhs[i]); - if (!err && !buffer_uptodate(bhs[i])) + if (!err && buffer_write_io_error(bhs[i])) err =3D -EIO; } return err; --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4F553C061D for ; Sat, 1 Aug 2026 22:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621694; cv=none; b=fH9KonhHpMu3n0bWNwIQH3xxVMU1LcGYkM4PPL9X6S3ZkEkpinGeZbyzxxVNzWRtjWlyjIFcZaT23N8KqHsNuH5wwdlF1acatGtSQuXYt3L2o9SJlm9XfStBPVGJnL18Djmhp5um/kEovMtPJN2P1iRR66Y4w9eI92ekgMKMSSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621694; c=relaxed/simple; bh=8eaNHjlxdd2m/7vaM8HHzpWZ1ndxEHRbTTCO2KCwplQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XCl0n7WcJ3DgvZULxslO+Asf4rKdqU/DK4cqH0QKKX4GU4rN8lTO6/86hBb8HHd9luAkz08KcbN/ZVEkt4gTtKjBAxI94XbsKjnHZSjAoE/4eprZwWkOqddaJ0xiCGlKnUfLsGC4wrao9wrmucsnTfsUWxtA3uh9oYotvJzv1A4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Yun8d6rU; arc=none smtp.client-ip=209.85.128.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yun8d6rU" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-80cebd41372so32695827b3.3 for ; Sat, 01 Aug 2026 15:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621686; x=1786226486; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3pK8MlUvCqFzPv9m7RxaKBOJ8dELfs23G8cRNXDTowI=; b=Yun8d6rU0GoHZQcKyHCKysFS1cmF1+vOzb36IhO1iprimsJcB5E5iDw8v63y5vqL9b etNPkdTEm2nZfFCgJ9AIc+/vVJxP8roJGK9j2AXQilPM/2Cw2gDL2XdmBQtOUaV0sftj +rM0JHXCUz0P8wP2syNvzwrhjLipikksShz8Fo1f1Il703+AjjJAlQE8Dceo91k6cxbO QwKMnPaHb6dyxYmHOQVBOp2pwUEhHARdJroXbUAQ8UWKSSnj6IJihONCyXuBWozTaAxg bNWrQZjA+C+eEaOxdxtb8D8Aj+zV+DseLbs8obh7rIc6EsdLqJjFjnVQP8t583vhk8OZ Yx2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621686; x=1786226486; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3pK8MlUvCqFzPv9m7RxaKBOJ8dELfs23G8cRNXDTowI=; b=jtXFWRLdELzyGSL1LhtAeWFNUCs9DhrDe4+VDSOBf8FuWKZDx0BWmjvoe4MyfqaPQB 1whiRdZ10/Wx2rAE84C8YkZSaCXPTkUizi7ANosQxGKm5/F34TyXZtf7OKJjmRJV2hNQ hImV8BY3DN8NMg0B7UVbdR6wAESmp0kfFAakoroU4vpd/4sZTxRRZ4BEVSQW8Z1J0TKm Hc1OgLUGdKskoofpLHJexBpwXPOKXeGs8mrj7q7bhE/CBkTWyIMXu0r/npHvcdlmuXj6 I5C/8f3W/hMpzIWzkvq/upf4DklEyhIoxjCJnG0vZ4qQ38MshwAtgu6OIb+AS+T8w04K 80uQ== X-Forwarded-Encrypted: i=1; AHgh+RqcBkucE2P6DW06hnaJsgXedIGfjk9ZgoQfDTCqe2hvgcL7q2QBoOtnCnwYnDfXWb5xzZahkQlgoUgAmIk=@vger.kernel.org X-Gm-Message-State: AOJu0YwMBxngbBdJ2yiqhqgB7GyhwgRctEJ+/HGCh8k9zElv699jbar7 BUWnkYZkqfviQ9sy7bhIh3rodtXTLlTAPejDDf2BFZy6WqY8PgSP/10L X-Gm-Gg: AR+sD12XYQBYgVcDXlreolcx5lGPcVWn0P3t6f1IPOQ05hTLDGug7KDKRBxymRiJhgX 4kRdX/GLQvqPuAIbfoE1i5bSvXeApYo4XLQNGk7C2x+VOh27u2tWAMNQqvCg3m6zoihfVngwQSt Y6AiUEeWljpIb19zC1NDCC17vRXsjOVz/gGpst40oAnw5PUZ/AmgoWNjJixWg/UusjjmPGWYazK A3g/nT4TrZhiSTQeRy+kDYdMugNpol7ASPWazQVx2fLFxKfvGU1iJVwsv3+3kBkmSRTHcTG3Yf6 wsaMjRxQpPd0NG0i9ajrpnnIkLi7Tlw7WtEr6jXVbWCnWXCgJ01flVccvnzXGmEdnRI0B7WjY+5 U67tkj0duY/VPD0urh09YssDxnrmBrAQ0sfHEQzHZZrZLvn6cxS3ftfQB0PBaQYSLWahiMweuHj xhHKDA/Ak3WaTIA616HN78h2iO/f2zYCiZkr+WQBG8uKea1GiT2gfO6fX/6TLxkWZwZx9/i0rk8 Vc1elY= X-Received: by 2002:a05:690c:6f10:b0:80e:5236:b930 with SMTP id 00721157ae682-81fd4c9064cmr74857937b3.36.1785621685651; Sat, 01 Aug 2026 15:01:25 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:24 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 11/19] fat: check for a metadata write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:55 -0400 Message-ID: <202c109fe73ff6899235aab9dc19ba15eeda0d5d.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" fat_sync_bhs() waits for the writes it issued and then tests !buffer_uptodate() to find the ones that failed. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. Test BH_Write_EIO, which is what the completion handler sets and what this code actually wants to know. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi --- fs/fat/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/fat/misc.c b/fs/fat/misc.c index be18f6b5819b..4a4cd0111e47 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c @@ -356,7 +356,7 @@ int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs) =20 for (i =3D 0; i < nr_bhs; i++) { wait_on_buffer(bhs[i]); - if (!err && !buffer_uptodate(bhs[i])) + if (!err && buffer_write_io_error(bhs[i])) err =3D -EIO; } return err; --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6655339379 for ; Sat, 1 Aug 2026 22:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621691; cv=none; b=r6GU5bXAWQkjWZbqExSsJAx5kO374EK7WT9lopRvulig8maZ+IDiVZl+Vk5RmON+AjK3lDTR8bMShsaOGW4WKO8jVLxncXQvyvbFaUGtmr63Rx572WnClZnhZZSuQIdZTUbigT/HSoji6MHHFdnC+w0j2Wj1vQtphthNCfZrfc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621691; c=relaxed/simple; bh=tojfuYvzfAMfs0bsJ/hEKkMgCSJ1prAxAJ+lK0XKzIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sB9y1XCERTIX306bC/l1GGVQw1JLHZImojgq14O64cGb27Z59jMdtTVXBAk46ocFGuZ4aOexWMQfO9cupOq1xbvxEifLmwEkpLm+fvE/NfagOBlG7o/CQbHNjyiOOBKJkt71jRLW77oNR0mA+zSWcUPOVGbcpfny1wOxisl4F5g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TYuH/kaP; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TYuH/kaP" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-80cebd41372so32696007b3.3 for ; Sat, 01 Aug 2026 15:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621687; x=1786226487; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=S5d9GJjjHaj8KTJ0WAU1dmfHtrReZ7Fn8M10/pEoUFY=; b=TYuH/kaPqP7d3Q7Zz/nxr5ocNgCXUXsytaGpbw8XVlGTRRue8C5+ds4Pe7Tpr3sHIh Ezdxkj+G20pbV5xDuU60LWV7zhMUGZn3z0EnZhoVoLXXtQT7qj/b308VvG++6RsjEb2U whA8yDVvrOZzxlCZUQDDCV/rbn6w+clpklfhyn+XrjEVWJqu1xkps+7ncse+c+NjQC7s cU1iFfbfnVMW4EzHN562s7P0lFKwYphttpFHXtUywAzwB4hT3OnXwtWPrl4MwZnEPSyO QL9g51u6/yhB5U7T/7nJT2m+HMXX22Tzb6G1/Nh2GPn1yTtXlyTtUYas9n+bmaX9hq05 6Fow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621687; x=1786226487; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=S5d9GJjjHaj8KTJ0WAU1dmfHtrReZ7Fn8M10/pEoUFY=; b=Aa4GjvJVDjZpJpfybI2dkc28yX8n4VGao0hoIhHBxK8ZWsNJeI2upGYMm5C6aP3jQ9 DbcAf/NCEPiyF+IIPXml7RKt/f34+FRQfbKLHxofqWjz9RxOSZIPcPD2gEmTxNRvJsNd chzOBZg0g1UMclD+H5M0oIcaLPRwxh33VR91SumvnI2e6NxkZ1WSmdwz5QPSBOZLAtxF tbr+QFJ1BhEH1hsTZQnLTnU0MmPeYKhzeMFeZF5D31p9W8E9PS/ra3YgUL5uyQhPUmBY ar+IQvJRDOkZbLQu6jSqLdlqGO+jcYVaozBLPUeTlL0oR3Kk/O+0YocUw8sIu0auMczj wpHw== X-Forwarded-Encrypted: i=1; AHgh+RoUxZqX9djCdsQomba0FMnBE/+qZe3AgKS8mqQdTP1ypdOwKHfXKGhi6G/t4J7uHiRRfmg44Iu69csgUJI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw62fmji4KKEgRU3jEPAE00/GAWSqUy+UpAInnXtjzna9wzRtJ cqsXcaJgYGt8zmDkHkkw2rWI9juOfHfXB9rQvb4YKs/UN8XAnUJhN4uk X-Gm-Gg: AR+sD115+Hrp5LEqGFCZ9l+Peo8srEwOnYYqSi4Ctu71B4vur3iLpG2c92k3pAS9ORc S2/6VtNLGgpsj2Y5zhURlMsYTEBN6jpeBI+I7b5jlviDtqAxd5Jyl/Zgn62LvouJVXa+oV/BIaC CfDaq/KdA0m7tvfuD9Q2rtFalXFT9BHRHDdI00exmUG6jUFXuSAF2bDwIeVbb9M71XnqazQlFVb bl7IZCofm3iXnw9/IwKfr4k4mmF+fiUoudTijfyxDeq8NxZeL8MYlZAa5oxVkUM0u8sWUojdBRt Q4RlTVWMbi8CfLd2WLhP8vHbBVl5eqbes2ypfkNJZB0C8njvqN/NyC7p23UIwfI34YsodFG0/OT sDlfCWrZFaUmLVI66SieLZHJT4p1PjI0gHaaypg86yP/tfw6h7a+VSoDSwBjY7neTjm6lTWJ31O wSBursebo16ITWJkLK5UlTLZixz9i6hnOzULavkR+Rct5Kci5HvhNe/KLcBpIEX8DsT40QLKWCv q0daps= X-Received: by 2002:a05:690c:48c3:b0:81e:d792:a019 with SMTP id 00721157ae682-81fd4a64bcbmr74354127b3.6.1785621686736; Sat, 01 Aug 2026 15:01:26 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:26 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 12/19] ext4: check for a metadata write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:56 -0400 Message-ID: <844d01d43111830a299346d0f3c6fddd62f22cc4.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Two places detect a failed metadata write by testing !buffer_uptodate() after waiting for it. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. ext4 already does this correctly for the superblock - see ext4_commit_super(), which tests buffer_write_io_error() - so this brings the other two into line. In __ext4_handle_dirty_metadata() the old test also required BH_Req. BH_Write_EIO implies it, so the pair collapses into one test. The new test is also strictly stronger than consuming sync_dirty_buffer()'s return value, because it still fires when the buffer was written by background writeback and that write hit an error, which sync_dirty_buffer() does not report. Note that BH_Write_EIO stays set until the buffer is written again, forgotten or invalidated, so an unrepaired itable block now reports on every subsequent sync of that inode rather than only on the write that failed. That is the intended behaviour and matches what ocfs2 has always done with this flag. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/ext4/ext4_jbd2.c | 2 +- fs/ext4/mmp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index 02b066299164..f338d6e3c29f 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c @@ -413,7 +413,7 @@ int __ext4_handle_dirty_metadata(const char *where, uns= igned int line, } if (inode && inode_needs_sync(inode)) { sync_dirty_buffer(bh); - if (buffer_req(bh) && !buffer_uptodate(bh)) { + if (buffer_write_io_error(bh)) { ext4_error_inode_err(inode, where, line, bh->b_blocknr, EIO, "IO error syncing itable block"); diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 7ce361484b38..4b18ddef468d 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -49,7 +49,7 @@ static int write_mmp_block_thawed(struct super_block *sb, bh_submit(bh, REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PRIO, bh_end_write); wait_on_buffer(bh); - if (unlikely(!buffer_uptodate(bh))) + if (unlikely(buffer_write_io_error(bh))) return -EIO; return 0; } --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1022384CCA for ; Sat, 1 Aug 2026 22:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621694; cv=none; b=C2OBd76o3OxMNGb/oEHK19MOtnrRZRaSITabERicfIapkzvhdowlj+rCrh4luuQW9OGq1lHrlNSI+Kw9tk4xa7DSOI08KED2as4c/2wdkq+yvMrmJYh27AP4sEO4a0Xoj2dvQNm0TddhBgqggjVM6QRkkvvV+HctRIy1m5UMdu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621694; c=relaxed/simple; bh=3dsw1Zg8M5wNaCMh6F9jO6eXBuRivbQ5EiuJWZtmA2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EyAKJ0RWkOftR0nJvOjnuJSEgQujBjJzISwFlfgeESJ34C+RyDi8RzbQ4zfUOs/BCSfFLxJ4mLnsQ7d1ZeGdVYfT3zvl6IgvWK/bqjGbjvgCQIl/qf2NiiJOrgjplqjZMuKBbwS2KCA1OZS4HFcvKf3FIjIKGKQ8DR7PzJfDbAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jIdtbZ4O; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jIdtbZ4O" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-81ee41aaec1so29633547b3.3 for ; Sat, 01 Aug 2026 15:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621688; x=1786226488; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/DniCfidRbKUpj3g8JSrdbI5dITb8OPbOoquygm/08o=; b=jIdtbZ4OTSOT9OPvleuuFCF4Pc38X/ywxPMR3t6kTu5fvOjwuri3CWPIDleEi+yfTd jNjRjG1uU4gjKFa4m0dUa1vBYSNz1jrwx9qJTMdLMx1EQ3UYJ51GPPdgyzjVvOtevzmt 6UJhx2S1iWnz8BdBXkdKGdi1lb50HfS7boV7941Auh/IIbrBTOMNuSWbz5dE+aJOW+oG oKyznNI4+kb4B9WfmRt889vBo+GzDT5Ek5Zir6iOX8xJagkbiHQXlNFQdfgLJasR8FYK rTJsM/7wbLfAdvPU48ELbaRQt4tD+UVBk+43/CEbnMJyjdHZVFOh8PsqlwzZWdXFXgph F0Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621688; x=1786226488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/DniCfidRbKUpj3g8JSrdbI5dITb8OPbOoquygm/08o=; b=E59Woh359JFNGbo5LP3CpNfjYGoDSCcKm3jN/iD3BJDcI4JNEiM+G860zCOEDTSq1q hpaynSF8TenRr2BKT8UHTVfAOJ49TKh48PlYXA/uY+caxan/XHsAIEaOCJptt6poutUF Lh+ASXuC/I/O1k3dpWtoKfqkMnKEXK9t0MkJFMpTkB1+VF4l5nB87IKjIW5cdRmgP5KI 9yegrs/J61QTMG+N0ATYQ/37C93739yZRdRBt64UcOQZjqmxk83TFPA+ztbOxWx5xDtS l61gZM3dD3Lp/PFQTzhjecs2qKVRhrNVy2HUaug3n9Dlq0aOPXGG+Dmf/v20jYZouXA2 2f8g== X-Forwarded-Encrypted: i=1; AHgh+RqThp1BL+ngkuDdFTWbYbf4OCTnHEbEovaViWq8YCWJLQLVh6cNK4+mlk24EZuRR7XWHGagmRxuDPXMXHU=@vger.kernel.org X-Gm-Message-State: AOJu0YxWWtqgwFlrz37/zVVRMnc0IWMnwnh/DDnmimEd868l978SpxMu N8prVKU3n9UJ0o7RXwXWX1qA9Bn2EHR4/tY7tr++exMGgiuAvQtWQb+Q X-Gm-Gg: AR+sD10FMeck/KDx3qzITr61v/jSNHOMWS2NSMXgj7tK2OIfCuDIIFRTN3SXB0pgn7P YopzGX2ytUcOSuUiUAPAQer8b0Jh7h8yoUpbxcVZ9jau46nXKMGtrjtau9z7fhlAqUwAxUesS+o u7tEyuWa/nXJhymwCjfsMGxArLYzzc6pJRS92L4v8b6bTpNwcaVvfY380edTqCgsdcQvDEU2JiS 7H8tlSIpEpkWdd/SU+D53j1OBF7mLrSW56U9Nlku9sm5u8RisQDp/DUdnlFGpyfW7v84jcpqCYg Cpijv4ahS5iwxiio9sW40KC/WvyrnlXc9S2M5WF/lHq0HiNELJ81wPPpxpCwmhzOZJ5weQOf59w WXnjRaS/78Sv7/FhqnqKqbU2NhV508ZrGG56dtCn2b/45FyO+rm/klauoLoZ1Qwgfvw7ZGaG4Wr TrTch2I6S/DpbDc9SpvBKbgmo3YGZE143l/oMQzozUFz6r7GKVwVeyzOUZZHkTcsuw57FJBFtoL GHJlh8= X-Received: by 2002:a05:690c:c15:b0:809:6b62:2f7a with SMTP id 00721157ae682-81fd4b72864mr76660857b3.21.1785621688522; Sat, 01 Aug 2026 15:01:28 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:28 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 13/19] ocfs2: check for a metadata write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:57 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ocfs2_write_block() and ocfs2_write_super_or_backup() detect a failed write by looking at BH_Uptodate afterwards. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. Test BH_Write_EIO instead. Note that ocfs2_write_block()'s test is the positive one, so the sense has to be inverted rather than the flag simply swapped. The comment in ocfs2_write_block()'s error arm needs updating for the same reason. It said the clustered uptodate information did not have to be removed because the buffer was not marked locally uptodate; after this series it is, so the reason no longer holds. Not advertising the block to the cluster is still the right thing to do - the data is in memory but not on disk - so only the justification changes, not the behaviour. No behaviour change today - a failed write sets BH_Write_EIO and clears BH_Uptodate together. It stops being a no-op at the end of the series, where the new test is the one that still works. Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/ocfs2/buffer_head_io.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c index 7bfe377af2df..733ceda79ca1 100644 --- a/fs/ocfs2/buffer_head_io.c +++ b/fs/ocfs2/buffer_head_io.c @@ -66,12 +66,14 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct b= uffer_head *bh, =20 wait_on_buffer(bh); =20 - if (buffer_uptodate(bh)) { + if (!buffer_write_io_error(bh)) { ocfs2_set_buffer_uptodate(ci, bh); } else { - /* We don't need to remove the clustered uptodate - * information for this bh as it's not marked locally - * uptodate. */ + /* + * The buffer still holds what we tried to write, but it did + * not reach the disk, so don't advertise it to the cluster + * as up to date. + */ ret =3D -EIO; mlog_errno(ret); } @@ -446,7 +448,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, =20 wait_on_buffer(bh); =20 - if (!buffer_uptodate(bh)) { + if (buffer_write_io_error(bh)) { ret =3D -EIO; mlog_errno(ret); } --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C679E3C10AA for ; Sat, 1 Aug 2026 22:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621694; cv=none; b=Fr1My18QtWMpncki4FkXTkRLHP0Y62i9mjBy/Fl2vOQl70kbrxtd0hcc2fazBsNwtKBuu3Y1r7EvZMZJtSjnFvnnt1MpnVtuC2vmKVHgqJHS1iNIybtJ0r034Pc6w/ROPew4XLUQvknOURlU/Yr9HG3ExRjlZD3OkiQG10TU24E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621694; c=relaxed/simple; bh=njsuMFgQW9XgoUDzJC8DUF4aImr/QOgd49oen3uWUEs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uEc4kGix1G7bcUhYcNPh6bqSOZGB4Xxh3T7EKDEvIBL7iNNeazFrzn0wiMvHGvDvs9OrYCdtdDQRS/myEx0ox69j6sYWPEYv7qF0+YtiCZe0u4ssOiXvyXUdDE0ExG7IlZi7/J1BnXzVs3B27hjg9ZFphNwAojaBm3I/aDTgIys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GMURzrMd; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GMURzrMd" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-81e6f2ee60bso42983387b3.1 for ; Sat, 01 Aug 2026 15:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621689; x=1786226489; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nQgNx97XjQWdnRUlGoDKYUMjSoMBL5tDz0tOo1NQ/rc=; b=GMURzrMdQ+0fCw3lI2AlYxm2541TapXakDa4FRTLpuF9BBkzpyEeoJXFKdW6YwWTIX yFl2b5Ai4tPDsQWM1420067C7pIVz/ho5qyqdpyNZMHQMNhGUb+VGPIcjfLJgtGuW6i6 wFlKnOlTMQY1AX6TOHxlJWAPONXvwFfSMzL+Brx2S22U9Zdng1JIjq6wwkGuGiovpcC1 L1dCTBpUiSloYeMTRMPc236X34icQBnowXCsHv846XBzdnXCROvUnjoaJqsUwoklM3ym 7/AK1Ub/6dJ01t7/EqyswYFx1Ce3Q73CvXd38rVyZNmOOxnkZ3QHIox2onpR+o1GoEfA 7suQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621689; x=1786226489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=nQgNx97XjQWdnRUlGoDKYUMjSoMBL5tDz0tOo1NQ/rc=; b=B/l5W7fKwMTkifKl8/nCvDAcB9Z3rDqDncmZ4+O4Ae5jXOlFx2k49tPA1D7u8tlDWw i7wwG09SI2qxcQlakpfSX1bWpnxL1sTM35nMlSHfXsSbhGkv2U04lgl+ghY7geiEqH6K DQnXVrJxiYbOSgl6wyy+NEQNRAfjl6lx/K+d7s+1Eg/XntY/EIeUFzzhCibJcgu/vMXu w/DE/iu4bEqE/cF6j2tu5cTa8+xu0RhHgCIdXt0JEeJL8TLsTN3pCpDj1fBPe60sj8OO 3XlDPdmsoppwWfXnFAeF+arr62Ml4A9bzIxFdl7SZvfNvUnnu6n9sHFEevNTkuAMcbYe SaoA== X-Forwarded-Encrypted: i=1; AHgh+RowoYO9swwiK7SRUI+KMLX+77T/dQx7w8Dg9LSOavdd2fVtct2BUiUsWdGbc2VVMYY8xIV9h4ZAe83eoU8=@vger.kernel.org X-Gm-Message-State: AOJu0YzMmFq5nv3jepZn7+QI7urlCKIHh6OeA3a8eXjGEsQrlLOLSu3m FM98FDzgvXtIfNAUXb7kl9XjefDe+g/DoooqSe/gWkLbwL+BgDQBgw2Z X-Gm-Gg: AR+sD11tmd0m/bouNP7qOXQAQ+8eSeZ0C4eHlI6xdjXZ7/YtcpQE4czEY/gEnApGZDk XzYDcaK2JboGJIjmpA5JyW/ywL2qX6v2Cs0G9mrz2BCxJ0IqkGOibm/YFk/rTfVvnFPHmHHXpEJ 8dJLX2gdOoxsOQA/E1Maal4xxf7vQLxVDfRTcGxZSsUzrX8icAn2aIagO9T6VCm0FUnlXSV0vyu H6dTjAu/CEgQaA46eFuHCTcpl0MAr8XBlHYDEguMnvvwKiMZBZeTpCvb2nENOmVLYIDO0mUEL1G dVjHgmD9BBwSjBAfwS7FXX/qEmkmmEpq3Cp5OyHXViXak5AUH/7gFtJ9qSt73J9O6ITJ6bdM2tX u470v/DX6teIt5jgE0P1mNezzREVYtxfALgT8+O72XHFY4cddiCoBmVssvpQ/ZR7VU0ZVKS4mLM eQjvMdWd3Hrw3s+b9vSAvWAbMw/ynt0KbtmCTBcPOqf4PpOjj9XTwK17b0f11x2QFTze67sOHj0 IjiaPGBXKlOUkgvfw== X-Received: by 2002:a05:690c:e3c6:b0:81f:69a:3739 with SMTP id 00721157ae682-81fcbd4e504mr95002497b3.18.1785621689541; Sat, 01 Aug 2026 15:01:29 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:29 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 14/19] ocfs2: check for a stale write error before reusing a metadata buffer Date: Sat, 1 Aug 2026 18:00:58 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" __ocfs2_journal_access() refuses to journal a buffer whose previous write failed, and turns the filesystem read-only rather than risk metadata inconsistency. That check sits inside an if (!buffer_uptodate(bh)) block, because until now a failed write also cleared BH_Uptodate. This series stops clearing BH_Uptodate on write error, so that outer test would never fire again and ocfs2 would silently start reusing buffers whose last write failed. Hoist the check out of the debug block, where it does not depend on BH_Uptodate any more, and drop the now dead second half of its condition. The mlog() pair keeps its own !buffer_uptodate() guard: it is a separate "we can safely remove this assertion after testing" debug aid about being handed a buffer with no valid contents, which is a different question from whether the last write of that buffer failed. The unlocked test followed by a locked retest is deliberate. BH_Write_EIO is cleared under the buffer lock when the buffer is submitted for write again, so taking the lock and looking a second time avoids turning the filesystem read-only over an error that a concurrent rewrite has already cleared, while keeping the common case lock-free. The code in this patch is Jan's, from the review discussion linked in the cover letter. Suggested-by: Jan Kara Signed-off-by: Chao Shi Reviewed-by: Jan Kara --- fs/ocfs2/journal.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index d8afbc1a76bb..ea6802d894c2 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c @@ -676,19 +676,20 @@ static int __ocfs2_journal_access(handle_t *handle, mlog(ML_ERROR, "giving me a buffer that's not uptodate!\n"); mlog(ML_ERROR, "b_blocknr=3D%llu, b_state=3D0x%lx\n", (unsigned long long)bh->b_blocknr, bh->b_state); - + } + /* + * A previous transaction with a couple of buffer heads fail + * to checkpoint, so all the bhs are marked as BH_Write_EIO. + * For current transaction, the bh is just among those error + * bhs which previous transaction handle. We can't just clear + * its BH_Write_EIO and reuse directly, since other bhs are + * not written to disk yet and that will cause metadata + * inconsistency. So we should set fs read-only to avoid + * further damage. + */ + if (buffer_write_io_error(bh)) { lock_buffer(bh); - /* - * A previous transaction with a couple of buffer heads fail - * to checkpoint, so all the bhs are marked as BH_Write_EIO. - * For current transaction, the bh is just among those error - * bhs which previous transaction handle. We can't just clear - * its BH_Write_EIO and reuse directly, since other bhs are - * not written to disk yet and that will cause metadata - * inconsistency. So we should set fs read-only to avoid - * further damage. - */ - if (buffer_write_io_error(bh) && !buffer_uptodate(bh)) { + if (buffer_write_io_error(bh)) { unlock_buffer(bh); return ocfs2_error(osb->sb, "A previous attempt to " "write this buffer head failed\n"); --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BB053C5DDE for ; Sat, 1 Aug 2026 22:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621695; cv=none; b=gu7L6x7h4Ch6TLo7UnsdFDAhNEGPCPA7kYUZWfmDFUHOEyrElLi+IJWBT3JqBByCBgp2hxj6Kk26Pudr2C/za0EHupid+IFiEkOLq4RFsPQIfHNx8Zd0JDJoksN7PlzqGpofsBpJ+ekGGX5zLiUU0+PpeRaxGQGoB9a2bDrddXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621695; c=relaxed/simple; bh=luLrRtkts7duEn4/GPgzY7ldWmmHGqiqpJhG8wUqy44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SOhQGM92G3pTLzZ6drokTN9DTFxrFRdiLn0B9eaywGsk3uT1jwlq5tVswF0iH8LRGNmBzjwVadKuhUfrXIm0ZXo4ON+uRiMdgTZccHW56rUJwu2JgIEE9lRKwGvLCP3RzER+L5w3viHvSRoaluzLCLJ17C6wL7cYhI4ThCMIQqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Oc+AGHnl; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Oc+AGHnl" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-81ef8255cccso28404667b3.0 for ; Sat, 01 Aug 2026 15:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621691; x=1786226491; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0pFv0xCjYx7PImBsEcBITOWzdrDyUn6BmUrT79FEDLI=; b=Oc+AGHnl/V4vhp3rCBi8fFodk8742TYrmmsC+wKxDEE7AZLUIztaL/at/s7IkeKD4G 8M+waOopAK/TkbwXsoGidwiD8mhzej1mci1V4LuGwPIc/owXOaGk2HsLuut2N6ftXivG rd4jOCwHV/UHWIKneJisBK0bBKexvtlwuU4ilLrjbUCv7BL+TZz82G9odDL8SjNuRbZI np0cge2Sx9OhyZXDYxLV9QkfljWgU74K8MEjUVWyacHiTnQzKs4xm2dgFowg1SstuXvR 8yK0TN4xwnEVS6FNZhuOGeT1lvLRlJHheNPYHMBcHmI4Fwce4wjl+Ki2D+9W5QX49AHl fdNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621691; x=1786226491; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0pFv0xCjYx7PImBsEcBITOWzdrDyUn6BmUrT79FEDLI=; b=eylXhdbfa8jK7xyoWZLtPk8l9gIIh1eMMnAH/yylFLi9Nmn77iZK4Ta+GTQRuVkYfX X8UfUyBOi/0lDKqS4onj5OHg9R4O+xAKM3mFJ7qYmjTnLhj6qqFJDb4HhYyM8AhMc28R oljZzeQLJyvtO14H1/2lDwYCjwv73DiVykttJNoi1+sdKSI+GqEKGpq8JrdAnYPpmZ+8 dt1eGYn7nd/FnZgLYGPVXt1i+isKiXU/3IMvFaEljO3jLdOM6T7QDVOemvhKezxJLlNB Bxv0ucqEE/KfEK0mpYniRv+AMzC2/KVqyzFYaetBg6A1opzUBwUoPhrtwrb49RsKwd5Q yJ3g== X-Forwarded-Encrypted: i=1; AHgh+RruAdSjS0y7y9edyX8nVwVyqq92FAiMJ5OYL1e2I6AfUbZBRu6HQKSH348KnE21JQK1p9QPTEBhc8V9MkU=@vger.kernel.org X-Gm-Message-State: AOJu0YyFJnHF9LJ/zdCU651JVBPcvRhTbjaVqJWgFR6RuJNWljy1joNV bSIi8IYR4PMZVGQFxQ3LtACjRd65uLP9lFxnB38BA00GsFGahacqGWeT X-Gm-Gg: AR+sD11AkQitDAFK6u6/bar8U5lrGPZXOrnTuh0E4IreLdkD4kyLtazNFT/zwVxr6c/ 7Fn6VCdWh+LnoIQ3Z4VUIijd6OC9l296oAv1kVmGOpUyhzsUJHqRgvG/Mk//9zZgRJJp0gZODQT bsLMzKzBbtvbreBgvfaiKhxmXy0XWS7q+8ql0BG2LEeTNz3d02ZX8q61EuN5uCBt29HSblEQIC1 Csol0YaZ2c/Pll9i2QMXVfWCpo7eJT8mv2lD2lQXsrJdxI+TQgZWG148mQ79DkpOZCAB1bapVfo s/TepXyf4+GzG/7RLKG2qwmj775RQnUyz2m5SJeNV3GJqiR1yiWSUwPzJt0Gi+V+C376yK9q2Cy 7l8JPrd8N3fEVfagb+x5LASluBNbarPQb9V3BBcbeufuQ7GP6bcGNCozG7XasCcaH5yk3MxFqJ2 v+lonTrDrSg5ZA4hlAz+/Xeu+/A0i7u/oPDsbLSmLoFsqQTYO/8a/HcKAc6vWAaYvbxKrRpTZ0x LfIof8= X-Received: by 2002:a05:690c:368a:b0:81f:64e8:cac5 with SMTP id 00721157ae682-81fd49cbf8dmr71805897b3.7.1785621690658; Sat, 01 Aug 2026 15:01:30 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:30 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 15/19] gfs2: check for a metadata write error with buffer_write_io_error() Date: Sat, 1 Aug 2026 18:00:59 -0400 Message-ID: <2a0450b24c7e6c8d7a2648196f51852c45bfae33.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" gfs2_ail1_start_one() and gfs2_ail1_empty_one() decide whether a buffer on the ail reached the disk by looking at BH_Uptodate once it is no longer busy. That relies on the write completion handler clearing BH_Uptodate on error, which this series removes: a buffer whose write failed still holds the data the filesystem asked to be written, so declaring it not up to date is wrong and makes callers re-read it. Test BH_Write_EIO instead. In gfs2_ail1_start_one() the test is the positive one, so the sense has to be inverted rather than the flag simply swapped. This is not a pure conversion for gfs2, because gfs2 already has a private write completion handler that behaves the way this series is heading: gfs2_end_log_write_bh() calls mark_buffer_write_io_error() and leaves BH_Uptodate alone. Buffers completed through it are therefore invisible to both tests today, and start being caught once they look at BH_Write_EIO. That is a real behaviour change, and it is the one gfs2 wanted: a failed log write now withdraws the filesystem instead of passing silently. gfs2_pin() is a different case and gets a different treatment. Its !buffer_uptodate() test is not only a proxy for a failed write - a buffer with no valid contents at all is equally a reason to withdraw before pinning it into a transaction - so the write error test is added to it rather than replacing it. Left alone deliberately: the BUG_ON(!buffer_uptodate(bh)) in gfs2_unpin() and the two WARN_ON()s in fs/gfs2/rgrp.c. After this series they simply stop firing for write errors, which is correct; turning them into BUG_ON(buffer_write_io_error(bh)) would newly panic on an I/O error. Signed-off-by: Chao Shi --- fs/gfs2/log.c | 4 ++-- fs/gfs2/lops.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 78bba8cc10b8..e3e0dcb1f567 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -107,7 +107,7 @@ __acquires(&sdp->sd_ail_lock) gfs2_assert(sdp, bd->bd_tr =3D=3D tr); =20 if (!buffer_busy(bh)) { - if (buffer_uptodate(bh)) { + if (!buffer_write_io_error(bh)) { list_move(&bd->bd_ail_st_list, &tr->tr_ail2_list); continue; @@ -321,7 +321,7 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, st= ruct gfs2_trans *tr, active_count++; continue; } - if (!buffer_uptodate(bh) && + if (buffer_write_io_error(bh) && !cmpxchg(&sdp->sd_log_error, 0, -EIO)) gfs2_io_error_bh(sdp, bh); /* diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 6dabe73ad790..3df6e4b7e8b9 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -48,7 +48,7 @@ void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *b= h) clear_buffer_dirty(bh); if (test_set_buffer_pinned(bh)) gfs2_assert_withdraw(sdp, 0); - if (!buffer_uptodate(bh)) + if (!buffer_uptodate(bh) || buffer_write_io_error(bh)) gfs2_io_error_bh(sdp, bh); bd =3D bh->b_private; /* If this buffer is in the AIL and it has already been written --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2A453D3321 for ; Sat, 1 Aug 2026 22:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621697; cv=none; b=R2ikDLTl8dlfJxp7ZXAOlKGE5WlliVg+5kzUb9ejGTjAUZ9KELfOqfpl7KVCIsUlx4cMLRGu86DLt8Z1ZpkLSJ1CSRly+pFdDXUCeHW8iL0m+ZpAPEaE/YDviNgiK92CdcZR5sLhtcdur9FDJ/kwiicYymNY4vKTUMEXgQxUZ3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621697; c=relaxed/simple; bh=11/QTy2yfnrD1wjLL3sT4kKYG83gGCLz7L/Upg/VVro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oKD6P+9smg3co/9QZQfP34Q7LluFG1bRe/lKchIwYwRkc8z6TxcVEb3rM7uR3aZzaMr01te25APFfDRIop73ndcvycwg1WxIOKAhEFbKxmV7xrLfXuyPt1rCOQSm3nGKVjxh+A5d54+55ekgDK6gvJriDlswSrRSN5uv9Nuz548= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gJRresyN; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gJRresyN" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-8114a4542b2so33657727b3.1 for ; Sat, 01 Aug 2026 15:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621692; x=1786226492; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6crITnQf0AA10KnjmQzAxCPQHRm39qApxGuVVNfjYZs=; b=gJRresyNBALjoqKc/66TtEsPPXHMOZr6YmYOpBuzdFCjAAzBEgLs3U7EWB+I1s0Aa8 n3XBmFe7mzhsx/uPeDyrsWnzV2JQyUTeGQVrk4GSqWSKZHUx1MUNAM/gUyQJN83T1p5V fj95wBPSdAkeCSPbUciqxTx3tC1quKD96Fkg16T6T9Mw0PhriBz5fc2VQPwNnsN5L283 AoaDCNkyzB1dZOLbvFbX3uDQSe0jIhcDaCKlXP3+ETaPaA5eNiQWJCL9nQE56jaTiUNO Xt83RXZ3PzlNt9xepxiCf1dgsSKWwcEfNmUScdRApFFXNFRAA/+hMXxns2cu54quPikY AjyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621692; x=1786226492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6crITnQf0AA10KnjmQzAxCPQHRm39qApxGuVVNfjYZs=; b=hDQdEp3SFZXoWOM9yQeZuzwqzvQktVAaMCh6S4SqOXaZMTDwWsglHS07uIIV7PCcYg BI4/TO2+F87N9ZH6MZ4iwswzSAZ0pni79YjqVCnxPyVezzYPsTFkkB13rQpR1jWGVFCQ ur2o2x6jboWeW/FUBqBuq2xyxRtn0LbC2b+OvB4X7K+R0sARq5i/A+Pof+3ZIE+eeIZL Cp+lA2S95W4CovVOT04HHXRl0IJuUJbz6tS67IXyIUHDKcT5rTsrFqC1XdhJGZsX8dqs N+SffU3fspbbtLTz+HsGkf/6Bwz6s2gzkkyaJNzaG/SLZHtpI8jzk1ENwaG2UbbNRjUu S69Q== X-Forwarded-Encrypted: i=1; AHgh+RqDV5s0Z/G7S8rs3mnkOvSMJ8rrU3B/uanhON+/OARXvqos9SHmtaw3HfqpdZD68ntj8MBNpMKO7ClUm3k=@vger.kernel.org X-Gm-Message-State: AOJu0YznkmEODmz/Xl61i5APJXFdp2Fzpzh86dLo0852EjDLrZgNCVQL oDAonKTYKVG2wNNqi7dZ9Cff27sxLKIg+6euseNe0pK62VNd254csP+Y X-Gm-Gg: AR+sD12gF/ZoyZJqghqinfE//q+TLW6JtaHlJKrH/PEIAsxPyZUuUCkIijlm9GpqfkX ShQDy5bkEbCOvBw6sPp/oPPyPmAqwA9qQZ94DFW8EVKrqvjZ1G8SYyTVK+3sMhYKHeK0uAXjiEV 0zWqo+0RcqCcOhHgYUrOhSAWaQLS31MaWUn6eZZKTtCrOC8RY5QOyNdEjWRXvg6cNCRJwUrCQqF 81Z/Iuf3RNWDB1et00zcLbT8I0unsG4xtjqCDKNfg8GjTrybJWXKe/tBgUk2urYU3FQy9Wj+j7l s0PNWw2/7t90F/en0yLlB6x+ADcJdS5sXcMxhbyc/cZtB+OXAt145JmKnsN94jQV7tSuMZKTuE/ aTFzqy319y2uJVzm+OfpubAz1cQVsYWJ76Iaf2NKkBqiaMukJuD9fPK+GcrYf2+ySq2GK8td3IP 0ph1Ir9VD5GzTcEbCwfh08nnoB9OoD9QU69KqE4zRvAJY6oK24uxaL7dMYk378+D5o6HKnl8/sO wFSNkY= X-Received: by 2002:a05:690c:450a:b0:809:9422:8c47 with SMTP id 00721157ae682-81fd4b5a2e1mr70880997b3.22.1785621692499; Sat, 01 Aug 2026 15:01:32 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:31 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 16/19] jbd2: report journal write errors with BH_Write_EIO Date: Sat, 1 Aug 2026 18:01:00 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The journal's own write completion handler, journal_end_buffer_io_sync(), reports a failed write by clearing BH_Uptodate, and the three places that wait for journal writes look for that. This series is removing that convention: a buffer whose write failed still holds the data that was supposed to reach the disk, and saying it is not up to date makes callers rewrite, re-read or WARN over data that was never wrong. Set BH_Write_EIO instead, with mark_buffer_write_io_error(), and test it in journal_wait_on_commit_record() and in the two commit-phase waits. The two changes have to go together, because commit phase 4 waits on a mixed list: descriptor blocks are submitted with journal_end_buffer_io_sync(), while revoke blocks go through write_dirty_buffer() and land in bh_end_write(). bh_end_write() already sets BH_Write_EIO, so converting the consumer alone would keep working for revoke blocks and silently stop detecting failed descriptor writes. With the handler converted, both halves of the list report the same way. mark_buffer_write_io_error() is safe on all of these buffers. The shadow buffers from jbd2_journal_write_metadata_buffer() have no folio and no associated mapping, so it does nothing beyond setting the flag. Descriptor and commit blocks are ordinary buffers on the journal device, and marking the journal's mapping with the error is what write_dirty_buffer() already does for revoke blocks on the same device. Signed-off-by: Chao Shi --- fs/jbd2/commit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 60273cddf434..8912786ebebb 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -39,7 +39,7 @@ static void journal_end_buffer_io_sync(struct bio *bio) if (uptodate) set_buffer_uptodate(bh); else - clear_buffer_uptodate(bh); + mark_buffer_write_io_error(bh); if (orig_bh) { clear_and_wake_up_bit(BH_Shadow, &orig_bh->b_state); } @@ -169,7 +169,7 @@ static int journal_wait_on_commit_record(journal_t *jou= rnal, clear_buffer_dirty(bh); wait_on_buffer(bh); =20 - if (unlikely(!buffer_uptodate(bh))) + if (unlikely(buffer_write_io_error(bh))) ret =3D -EIO; put_bh(bh); /* One for getblk() */ =20 @@ -840,7 +840,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) wait_on_buffer(bh); cond_resched(); =20 - if (unlikely(!buffer_uptodate(bh))) + if (unlikely(buffer_write_io_error(bh))) err =3D -EIO; jbd2_unfile_log_bh(bh); stats.run.rs_blocks_logged++; @@ -883,7 +883,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) wait_on_buffer(bh); cond_resched(); =20 - if (unlikely(!buffer_uptodate(bh))) + if (unlikely(buffer_write_io_error(bh))) err =3D -EIO; =20 BUFFER_TRACE(bh, "ph5: control buffer writeout done: unfile"); --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8009E3D47D4 for ; Sat, 1 Aug 2026 22:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621699; cv=none; b=soHp5oVi2x1jMOoGh+RGGoFUCyzzprOzmHVeafDPrPuFp2ZNkcXdcz0KFEb/qhtWR+iwuwP7fcMNMC+jWJm1dgjx/WblZZyYjC52/y+cEGLxQXyOjja7dwTnFuMCF/XxHKpn9WtW/K5UUagIqyMlacWRvE7FwDT0/zksOoHMdQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621699; c=relaxed/simple; bh=2bZmsqZVVuc9CfGIc+LM2Z9Btw3Dvkpcm1xyNQyplYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o1pVpDvcGZ+xVvyLSjvEqlLfhVaExdoLltMH1NDuQjBQqDyGQlUQtby4vlsG3ehfCGh8dxsn+SBT18Hjw9J3R+p/tfolmty18/g+so65I8mpS1wLW2OcCMX8UdNwdF4ou0FomN9lst3vbFqI+LHse137/x9qmkiTTQikHlv4ymo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Z30IZIRH; arc=none smtp.client-ip=209.85.128.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z30IZIRH" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-7ff05e5d009so26780527b3.1 for ; Sat, 01 Aug 2026 15:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621695; x=1786226495; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qElo3yzh2qeHSY0scU/mBgdij9EIQBJHv2xpttY7cac=; b=Z30IZIRHurAGIj7N3745zgHKTG2pjmnNThmE9dNSZgam264BfRNFCm7OYh87fRHyIx w7z65QEIc5oZHERQx3nPRecefmfeZv6X+LT51z7X5iN1CXuiK8Yu0DmBkjPj42xHVwek 16Dfn4TKb1zsRMtDhFtBI203IfG8XUIy7F3M4kfTsXj8SenMb5E4zduiu8q7B1QgJRj0 KKvVklr1phauf9ope16nR8CqD6Ad27r6g5ufuKI7O1N075IewPYRbLVSQ3Tn3yv7lSd1 Bf87nG9xO4cCBJLUm8Qeya8fHtVPuwz97Qw9PD0figQ5iHfxai/ZUuEDJ5CD5Hthtv3d HXNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621695; x=1786226495; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qElo3yzh2qeHSY0scU/mBgdij9EIQBJHv2xpttY7cac=; b=oiv7z1ll/1rtg9uMSKjUQo7Ehmw8xLyKxxuLkmPws+AYFG1LXNgmD16D1e1FyPu2JY q2nZ7Zx2JSp1uzm1ipuwyoQJ881JkkzNTKZXkiYNImaHGoKIcWZ77ARAWyBDyjoLaTf6 dQj4XdM22Zk209MqXIVE1/wIS7nP0o83bkG9lTmGsGzNm0U/Ro8sCa6S8nCVhN34BIfG jEoJA8nZTFKSc1ztDOgLx5qi19HorRyvVZwcfyCId4VsIRfE5WplYqN6gNkvJd+h3Ph6 PIOxr+o5vhKjq2NT+jKqRR7fdNVT21AcbN1QmJnWq48p10dqE7NyOPQIejXtbXC3Y/iK DGVw== X-Forwarded-Encrypted: i=1; AHgh+Rq6yHpsXh/btQb9TqKaWTtwjlK3wRktviqJdf0D+1wqLNDcT5d/E3Dquh8Yzxp9Fzk8tUS4gmur8zeBqTE=@vger.kernel.org X-Gm-Message-State: AOJu0Yyl5/L/A1mDea+l6aYrj8nubwOolsZGhYcj2bmNhZYJ1fu6sccZ 776fP8C/SaIoGR6lKZG1+Or1HnBYB/3vNejM+vDaSq/bkEzcpmJxT0Iq X-Gm-Gg: AR+sD13X86jANIblxjeXUexJ6ckrdeaSgNWPdd2lK+ceQaqcGnd7pe6Xb66T6syeG2b OV47MtXxfHqawHK1zX8/R+pxsAFc+TBc1qd6rvIBk/WNTKYeoxhQ9kLeoCSperz0isSeNvqIWyX 2uh09oA2tEkjEfxWTswKzfDhVAW1W6SNcuIZSx8ryx4xO0WW028Cp0eGNw/EJPWPX4blSJCnhja 9NHlf6VCnn182RUnjpRER0QTeM1WIH/O1c7wpJWix3hL+OqiM0x9EhwElhPyKcdRigxr2K354ap Diu5mi2OtF+ZL8eehB497mIzKsg8MKkEbVmFrtyg0+8k4FOKHwwFj6cMeH02sN0LCObOHTXVwgV 2pEApZeob96dUqnmsTnLzZMzxWVsyi1NB2kE/kPHv3lWbyfSDXkyeYZkJoIuUI8AryeMolyFW0H 5IQTTBno6awOFx7tFMZrrUHQhqwfUrxtgQpmGU7Zlu82Uv2JVRTUY6LrzNKkDFWWjEX2dAiLdXW HssGEs= X-Received: by 2002:a05:690c:9981:b0:81e:a471:e8b0 with SMTP id 00721157ae682-81fd4b3e2d0mr70199667b3.21.1785621695043; Sat, 01 Aug 2026 15:01:35 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:33 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 17/19] jbd2: assert on a failed write, not on a buffer that is not up to date Date: Sat, 1 Aug 2026 18:01:01 -0400 Message-ID: <8aa2ee674d147d3630f73f7b53fef7781f2aeccc.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" jbd2_freeze_jh_data() asserts that the buffer it is about to copy out is up to date. Once this series stops clearing BH_Uptodate on write error, that assertion stops firing for the case it was written for, because a buffer whose write failed stays up to date - which is the point: the in-memory copy being frozen is still the data the filesystem wants written. Assert on the condition that still means something went wrong. The message loses its "Possible", because BH_Write_EIO is not a guess. Suggested-by: Jan Kara Signed-off-by: Chao Shi --- fs/jbd2/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 5cc7d097b2ac..fdabe34a7e22 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -920,7 +920,7 @@ static void jbd2_freeze_jh_data(struct journal_head *jh) char *source; struct buffer_head *bh =3D jh2bh(jh); =20 - J_EXPECT_JH(jh, buffer_uptodate(bh), "Possible IO failure.\n"); + J_EXPECT_JH(jh, !buffer_write_io_error(bh), "IO failure.\n"); source =3D kmap_local_folio(bh->b_folio, bh_offset(bh)); /* Fire data frozen trigger just before we copy the data */ jbd2_buffer_frozen_trigger(jh, source, jh->b_triggers); --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 444FD30DED5 for ; Sat, 1 Aug 2026 22:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621700; cv=none; b=sMmLvTVPYdKa02O31+t4YH1S6qJ4sj9GtFk9AYnCxCD6Jf5led398m33hVbyL3FDIAAIcTpNt+NJGCb+Ne4mqaXUTr3ycIvP756YFWrBPrTigWqoW6OHhJW/V+qMTQtvHyzYRgRpYRDb770+x+UKW0dbZI7dPEXFN1XpzDZYcrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621700; c=relaxed/simple; bh=/v7VBJbAb9aO5qRUONItTpWH4owbSyqDIsLqUgwMCt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=epLhpg/YvTOWrUdWtk7iQoFY6NxOdnIL38cdAXzFYGAZ6srStyWV1pJcb8jQrtAiMVxpGFnD5cj2IjsXqCtXsS84XfbXlwdUoBp6sAGIxCj/4U/6okDnzfjgZEuBsSWeY7wzDMOMAGEN4anQ05hNKthsWqzjrbdgepgvzhWEaNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cONoK9DE; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cONoK9DE" Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-81ee41aaec1so29634227b3.3 for ; Sat, 01 Aug 2026 15:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621696; x=1786226496; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XvLI01z2FUEK9ccgzSRudNIsKkvOOlfj4ulYih3+qTw=; b=cONoK9DEybQyse0MMTQ578SeX73NzsGajXVpScsaVCJ+Q1kArj6DfxOs2OefFKR2K5 uJMfUUjnbC/vVh4s+ij14YZW41ohWsko3lGk8C16Q6ICvWjdXbC/fZZupzXFfsJA+c6Z o7tCP54FlCsxzO1DWuiLIvDAhEKlnlsPKfJBYkbbvC9JeNHC/7QqAAYrMPtNJXY6GrMj CZOPk6hpy/Ujf3U+k72bjN9mHQ7hXN7Mjk1+9ky5SfnQ0dBAKQ+RAayPm09T6WRAoa6i TqqKi1B1w1iG8gWtbWmvBZcvS+rv5GfHCb92w0oSCPudhnQS3MGXHCr//Ng5XGCVnuhQ oBTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621696; x=1786226496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XvLI01z2FUEK9ccgzSRudNIsKkvOOlfj4ulYih3+qTw=; b=dAjXobGu9YbwSQBcYlEj2xZtX514tLvXZLVXtW7uDjvQ4GjT9AxRmba/rtkUOGuYi4 4FZqfuyKDGSkKm0kRRshS9jvIqD0Eu9y9k5yYMYmmdLwZ8wfo/BsTI/x6FIDAVa/4NX2 nzLSmHvF+aJ6H2VRr4JpQ88JZ1XWKPHWCv/p14lFsEnGB9UgRvY+4jY2v7NwLtSIr4hJ ZD/aW/efkVbSz7B3NZrOqyLPejcQenCvgE2RBofQHybqETB+SlUJwgSmvIhW7o9Ileh2 tCIM9XKYe0HGFoNA8K6dI/dsFoPhrywIH+lN0ZQV51GgmRhYIDrBbh0X23ftpkiRibBf A08g== X-Forwarded-Encrypted: i=1; AHgh+RpvgMgwDDSEqM65HSE21AC4EHqOETVL+S1eWvOeTvU8sildLYl63crM47q3f3GZI9VgjSWzTNDS6yBO4dU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzkg0CYUPIzkI5swzr6/8mhEOPZmhSFFdrRYFio/+D1JtJkVAly 3oMsbhy+V1takI8ZxC/nNVkarHdxKlChIg2DhPzKK9il0QYnPhq6iayv X-Gm-Gg: AR+sD12w/S8uQohBU7GVJmJxCIFTPRlpzT+vrmW7qLBg61Ss+ATSJhzJ2mTYlhmZtQk qknTCaZOwpwDlcWmPcfBUStORYpT8CPuUFxMd1JR6LTEhT06ajFmn5hE9uvm0Uj15ELJK5vrWRv OEvmhbtbNSprOlqwQHqqJE3O2F52QO7xrvhH5POUt28kO1uBS8GTVWC7g5JQll1yPIVp9GfQPUV zijLP1pKJSvCwGtbwen/31QSYnO7fiGdkNiCNkqUAeUVv6BVRQHi1I8IaXNen35DC5SI4kepsM1 /JAnPOovP1l0aSHTu1knwLvZT0wHgWcUkNpvbYiQpEeuZIhVIICS+kr1eiZVmrjbpE/x6aen4qO Y59gzFN8k/kQUfsiw/tTGFA5CLE2cjcUolHr3AKVUxmWVDBH5x91NMLe1+Ny+3quG+xLFBMDebx k5Qxnjc14Fup96PcC0WS2VGdkZqhQepcu49heN5lMkbn02GCFXNrjW3KfQzA1SZpLVJLjYKPsBk /AZPaiTfDz3O97rqeA= X-Received: by 2002:a05:690c:eca:b0:7ff:87e1:34d1 with SMTP id 00721157ae682-81fd4a5a892mr78630197b3.11.1785621696163; Sat, 01 Aug 2026 15:01:36 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:35 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 18/19] ext4, jbd2: report fast commit write errors with BH_Write_EIO Date: Sat, 1 Aug 2026 18:01:02 -0400 Message-ID: <7f988ec74b5d1135d5d67771240639e57ba9e0f4.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ext4_end_buffer_io_sync() is the third completion handler in this series that reports a failed write by clearing BH_Uptodate, and jbd2_fc_wait_bufs() is the only thing that looks at the result. Convert both. They have to move in the same patch. The handler lives in ext4 and the wait in jbd2, but neither is used by anything else: the buffers are ext4's fast commit blocks, submitted by ext4_fc_submit_bh() and waited for by jbd2_fc_wait_bufs(). Converting one without the other silently disables fast commit write error reporting. Signed-off-by: Chao Shi --- fs/ext4/fast_commit.c | 2 +- fs/jbd2/journal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 8e2259799614..8cd60c9f2272 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -213,7 +213,7 @@ static void ext4_end_buffer_io_sync(struct bio *bio) } else { ext4_debug("%s: Block %lld not up-to-date", __func__, bh->b_blocknr); - clear_buffer_uptodate(bh); + mark_buffer_write_io_error(bh); } =20 unlock_buffer(bh); diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 9e4cb04587b4..ffe7a22e6699 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -890,7 +890,7 @@ int jbd2_fc_wait_bufs(journal_t *journal, int num_blks) * Update j_fc_off so jbd2_fc_release_bufs can release remain * buffer head. */ - if (unlikely(!buffer_uptodate(bh))) { + if (unlikely(buffer_write_io_error(bh))) { journal->j_fc_off =3D i + 1; return -EIO; } --=20 2.43.0 From nobody Sat Oct 3 12:02:28 2026 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF8473D6CD7 for ; Sat, 1 Aug 2026 22:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621701; cv=none; b=VYrp/Dbo9wOdn2mb2OJSR0NBzlWLoIiaFn4DKScPhsRv9j5ZY9Dle4Rhk94rTczUpugHj08/N3GG0vgTSpy/SJAgVI9588Q/6USleYvgt5G3gqx5V2LE+g1OA36GgxryUYD03dx/ly4KIxQ3VG5pN77lcmeDlpOHaaiRFlIclBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785621701; c=relaxed/simple; bh=EXr243hgt49VO+NVV7qJVCHwNBqwGmV0A3daLRpsT44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2h5z3K2U46vbz9YrC5lBsm3ckcWpXSs3wtOF+nV+dyU9t442TC7um20XGjfBjiWE4Mm1YTCdAEoGpL5UYTfIh0b2O2Q20mo9NSPT3mqhRBFhRRwVBjgKzS4YMuSywnmRjBgPXxcBU0rrvvd7ovsrgb3YGrjRf6xVQFNyqYEl00= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FF28+Kuh; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FF28+Kuh" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-81dfdbd86d1so22032047b3.1 for ; Sat, 01 Aug 2026 15:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785621697; x=1786226497; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/eXvH9gfEzZ90R61WLxV17LvM97s4H8IYIhHdEQdhoQ=; b=FF28+KuhquhcwhUW1t3r3FnKppUtVxgbS1fAVBc40GkGsogkWB6f4tX2bJuPO7swj1 IBzsiWFMWtzYZvFGGE6IRe4WenwQnTr5AJ4fwrmKsTYgsj+tk/ndiNbOHj4pxTk2fong BzAiqRNqRaye0mpxyrRet+Xk2epn8o/uuqiver6FOMP/hzX21gdTUpq+qoXlMQcEE7wk MCD8I4HlrXQ5zqMKeoBxOlG21ndWHObySTDUTtgqKt4FpCvszBYDYCksD3pA1xSdVvKi XRQj9r1AypKIq3HIJgqFjYDOgEg/c1xEoOVeDENtrVyPo6YKV4t6L//7XlR9iSTgO9e2 EHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785621697; x=1786226497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/eXvH9gfEzZ90R61WLxV17LvM97s4H8IYIhHdEQdhoQ=; b=hggpY/3sDtOiWtJslSDww7n1oXs7UizJi+zjrPfUxPk6O+RFEb+uZaLxzBL8RbggJa amnhtUShldFd7WxeUFZz50d2b7UYzH0/D+S8kMtQ1WwFbjWV1uMmoCGyYWBaisHMU986 kbq1GJWyHe6Z8PH+Q3RxnUpeza8+MpFa1hPdz/9uDLfalgG93nLtV7fYlmhzMt+iff/9 8ryAM95+tBAH7fDALLYmI/B3xQfyMwhaGPItZRkSupkRZjupPbCwYYHxrZmrRTcyYjRa bO+ouht70bWXN4WJz5SaPnNe6EZsh/68SPg10LgBUYiie033NPR5NPo5flZ35UI0ArFF mYrQ== X-Forwarded-Encrypted: i=1; AHgh+RpGYHeSg7FvkADJ4/r6w23YRUZ4VkfgijNN5/xbaeyVbtzGi5xojLroZz+Sz4QzygPRF77eOjiT1DaX3Co=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8DsXjTqxSuhWtuETnDyYoqeOBXKvwSle25GP2OMS29He//GTG E9LiKIZ+qoOM4Up9irZCCTv1ZEzyEb8kneWz/uWVHBMMKTNB0kL9+Au1 X-Gm-Gg: AR+sD11Yjb4cYoi9OLl0n3zHDYAi2l3f8abQW/nkZ4fegrunVyFrSYrraV3r22uLgHT +6r/AQn5bUnkaexx7r/kn1VOFZkafD/GC6jqHS0NrD8bd8c2+PWIA7a4O3DZ99jgbS24omcVzJw pPm+UD4fftgdh3NP+uGIgPDcpK8mgDRzjok2bcsMfh0zjrthqATwIr52zxX6nJErZDguLMA6wDa XYkEjt9CgFnA3Kpa3tPpcAd+bb0eRwhbHcGWmlGlAuJbm0GNqIwHfSAWAFlishwGGqY/02rPVHw 4nOwjk11cJhQuANJTpg9uClQIxyypatb30MQmdRa7RRoTL1YGlm7mlOMhAIdDZ+Eskw1SMVO+Bf aR4ks1vqcWlX+psoxhQRzBhzcdTvthcoJNIgzkvEljB1HI1QZH/6YWmKNA0FkxfJBjkDdvO1alC 3n6aeobfHM96uDhzUvThvZsXoYzKMCA39zckafBaLP1ip28m1gRT3weGNUKYPhe4NGY9eDRGamP ccdd2nsfCTY/jiLRQ== X-Received: by 2002:a05:690c:6601:b0:81e:c7e5:df5d with SMTP id 00721157ae682-81fd4b51de3mr65716127b3.17.1785621697195; Sat, 01 Aug 2026 15:01:37 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81fcd0d6fbbsm29903767b3.25.2026.08.01.15.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 15:01:36 -0700 (PDT) From: Chao Shi To: Jan Kara , Christian Brauner , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , Andreas Dilger , Baokun Li , Ojaswin Mujoo , Ritesh Harjani , Zhang Yi , Bob Copeland , Namjae Jeon , Sungjong Seo , Yuezhang Mo , OGAWA Hirofumi , Mark Fasheh , Joel Becker , Joseph Qi , Andreas Gruenbacher , linux-ext4@vger.kernel.org, ocfs2-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Shi Subject: [PATCH 19/19] buffer: stop clearing BH_Uptodate when a write fails Date: Sat, 1 Aug 2026 18:01:03 -0400 Message-ID: <3aa278c3b75de2bca8a94ec0c0e40922b1170881.1785621505.git.coshi036@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A buffer whose write failed still holds exactly the data the filesystem asked to be written. It is the disk that is out of date, not the buffer. Clearing BH_Uptodate says the opposite, and callers act on it: - mark_buffer_dirty() has a WARN_ON_ONCE(!buffer_uptodate(bh)). A filesystem that dirties the buffer again after a failed write - which is the normal way to retry - trips it. That is the warning this series started from. - a buffer that is not up to date gets re-read from disk, which replaces the data the filesystem was trying to write with the stale on-disk copy, silently. - the window between the write completing and the buffer being marked not up to date is visible to anyone holding the folio lock, so the state is not even self consistent while it lasts. BH_Write_EIO already records the failure, and by now every place in the tree that needs to know about it tests that flag instead: the two core helpers in this file, adfs, exfat, ext2, ext4, fat, gfs2, jbd2, ocfs2 and omfs, converted one filesystem at a time in the preceding patches. The private completion handlers in jbd2 and ext4 fast commit were converted along with their waiters. Nothing is left that reads BH_Uptodate to find out whether a write failed, so the clears can go. Found by FuzzNvme. Signed-off-by: Chao Shi --- fs/buffer.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index ac978d9090c2..0002f0736398 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -207,7 +207,6 @@ void bh_end_write(struct bio *bio) } else { buffer_io_error(bh, ", lost sync page write"); mark_buffer_write_io_error(bh); - clear_buffer_uptodate(bh); } unlock_buffer(bh); } @@ -441,7 +440,6 @@ void bh_end_async_write(struct bio *bio) } else { buffer_io_error(bh, ", lost async page write"); mark_buffer_write_io_error(bh); - clear_buffer_uptodate(bh); } =20 first =3D folio_buffers(folio); --=20 2.43.0