From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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 --- 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 = -EIO; brelse(bh); spin_lock(&mmb->lock); @@ -2743,7 +2743,7 @@ int __sync_dirty_buffer(struct buffer_head *bh, blk_opf_t op_flags) 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); -- 2.43.0