From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.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 4821E485CCA for ; Thu, 6 Aug 2026 16:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035599; cv=none; b=fuqWt9EdFSfS8WQNXusFtX+x5nxtFCh+c0RcAbAfE/ZKVvCm27zXlDftBZHXlc0nlJgSOdMb5FnINCvyGBgFd6AJO45//7LtXOwXcJrdvM7eyGXq6c9gzc6XB14ftbOsWQmE223JtQt4TjjADYodkJw6dCoI4gnPEkteL9houoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035599; c=relaxed/simple; bh=0neISYJFH5vf1iYeHnX8wDVudHaEvy72ntuqHszFLec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q9ctOMrkAuWaIH/zlZgpjEGHMY/Pg9EgQtv/qPZImDWz653orYks3ZIuXidvGvYQHoE9kI/R6HBL+tjLAZyG0ZQ7dCr8bNWrW+mH+GMCWt0BlstWsklWKVg/w/ucHmwM4pVx20upwdQXoEJo3wIHCH0tDRH/vcTlkgQBgmwZ95o= 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=J3fTBh0R; arc=none smtp.client-ip=209.85.221.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="J3fTBh0R" Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-5c38568d9e1so883634e0c.3 for ; Thu, 06 Aug 2026 09:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786035596; x=1786640396; 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=DRJjTotyJT+hr0WWdtFL/ctkn8lHZ3M1r+YQr9eg6EA=; b=J3fTBh0RFlRULbxcBAkmHv7k0HwAUDpVGxIh0ib6BjHpitYK/lQlhSFW4kA2A/zl1s yY/4XLTCHApnP4f0DpfgswegGLdz1Jyp6O2iTiXt91o9fEKa4ru9slUyB9Zj+NTcNUg2 pPaObPPMVj7bBxcGrMhNMENPt3WOD6iQnlqmVhF4jcF+5SmQOJwiDndOpiqn3zUvY+OS e2oJN0tNk3sWBLeXJEj29tnf88O4CPXNIH1iATv4TJnh3wkOocV7kYeC5cidRsQuGf42 SDfeqLRexGlN6OPfaU8hie7YLbDCdztdNO2xgG0QsyLkO7luIv0L6sZXyPWc/3eUBwBm hCaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786035596; x=1786640396; 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=DRJjTotyJT+hr0WWdtFL/ctkn8lHZ3M1r+YQr9eg6EA=; b=UHi9i/WHuOHhjyvKzULf+kwgSRoBk//1E+3hC96JsRVskl4+h4fHIM6oC2ayOrL7vd 4z1ICrklFcIXSn5NlGfhb2rzD1n2jOeZ3W0oLXPJbsUgJon6ZgB64hk9l9k4ZJBJ7Ii2 Lr+3KPDecnwLC1+kJ2mO8WNazellxJygUftM0KUbvs40mNjcojURyGoyjt3jFhhJaWmp eXaJNOyrEbvgw6ebu1G6w4923ivIE2hiLH7Y0+yHZ/Od8EMtY+PMvULxnabtj/M7l0ON fM0hKNMmqjFO7f6oY7HDETXwEdnE3umTqQguPDJ8llUj3V/v8khxlwYEADSXcdHXaKdX rEkA== X-Forwarded-Encrypted: i=1; AHgh+RoQ7+MK6soziqfFi4SZVfGoMSQbKldbg3eszLSdlv29G/c/dzAzLgFLiXc7b++98i3jzpD1TZOCfTL4GB8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+wu42d43+Z7ZI0XBa/5rz1akqFsp0Bj6rFf3BMZMwVAR8y3vG ntI2a6EM4dc5fipesUJsbCCtCSbzX6g6X1J3xZHwZJSaV7P1nRvr9lmU X-Gm-Gg: AR+sD11csq09zXaO+gG4T4TbxwJ0u7I2dufhWEgSM9QQpSlwgbJvdT9lAuEfrtoXCec k4uU33jn3VsQ1PsS/NTP/NS6TxS69V0DLlGU0u9EF+MLptd2V7dPiaoV3czvGJvPBeZMF9I3pIn 2wtjy6YkzL2PnbfBYM3A9MGSu1AyRAd3o7mMo/+Nvl+kJg0vXMSha4rXt9ppqcaQy2Khjl1xw4N cVG8XBM5AkweAyeO6Nrs3ouuAWQ2a3G7UlhhGrcHFxA9wOYa7816eKMkLcq0DS1u3GcUD3BJJP+ WQEFgpr+kOHpvYKQLP57ySLhaEqP0ZtyQghLqIr7ymWLjiIdrnwsEe6lvV3leRtNUoyWt+QheE1 gTevN7MXxMjYNjGfsJvbNCVn5Ka58b1qj40gXnIbcAEMYSCVI8kQYoL0KIbSVIn3WKRDJ2LrlH6 W26LsC0Q84LjIudXb3D68HeuxWWh2HjEJSwxMclY60sxktJ4BlFDTG/QjjXGpuf/kCAb1E3R9jQ 4szf7Q= X-Received: by 2002:a05:6122:678b:b0:5c3:cbde:1bcf with SMTP id 71dfb90a1353d-5c3fe48e12dmr170712e0c.9.1786035596101; Thu, 06 Aug 2026 09:59:56 -0700 (PDT) Received: from syssplab.cs.fiu.edu (nat1.cs.fiu.edu. [131.94.134.89]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5c3d05c594fsm3706321e0c.8.2026.08.06.09.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 09:59:55 -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 , 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-kernel@vger.kernel.org, Chao Shi , Weidong Zhu Subject: [PATCH v2 14/21] ocfs2: check for a metadata write error with buffer_write_io_error() Date: Thu, 6 Aug 2026 12:58:37 -0400 Message-ID: <05cd3c34f2dc69b542db7baaef058cd75005d4cb.1785951556.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: 8bit 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. Acked-by: Weidong Zhu 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 buffer_head *bh, wait_on_buffer(bh); - 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 = -EIO; mlog_errno(ret); } @@ -446,7 +448,7 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, wait_on_buffer(bh); - if (!buffer_uptodate(bh)) { + if (buffer_write_io_error(bh)) { ret = -EIO; mlog_errno(ret); } -- 2.43.0