From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.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 4484E36DA04 for ; Thu, 6 Aug 2026 16:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035598; cv=none; b=kN2NdF/eZ5Ep4QnYzr/heI2PTPkcacSkU9J05qTNLETPAuvE8v5XOu55ncnd2KnuC8ysqJ2oRqUQXg+LxKA/YER2oOAGNQZfQ6/lTsJYfcTjOh2tp4wTSI2uZMSZD+Q3SvNydbH+Ha1Cv3hEmbeJlgYUglGqFEZqhQvwUif3Fkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035598; c=relaxed/simple; bh=0neISYJFH5vf1iYeHnX8wDVudHaEvy72ntuqHszFLec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BNQKO6LFFfm85+xnzpiFptwgbROoJZLzndXnSYXjy14PQ6nhZcZP347CtCjcHW8fXtkR8WPsyqaRqMy/7kJ/CiYYEJhYdZEkB1BwQC1SpxZztmos8aisXDFD6goJvlz++jCKUPyq9UGHstmkkTqTx32MqxD1QCx8rcoEt5V36JM= 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.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="J3fTBh0R" Received: by mail-vk1-f177.google.com with SMTP id 71dfb90a1353d-5bf5370d38fso785720e0c.2 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=Rr9hT4DiheMd+ntEwUpX+6ePVYpZ+VRWCO+rh1DLZt6xTYAeHVJRJADYEQaLO6Ay6B euxgeaM0OaiOyGa++P/2OtEwhdDsriNeNwp/YrCcah8uD5SVkTyMeAlMBL7kZPiE5npy WHhiH6cuHs8nUn/jFSHKYFaaLP2Fv9REmaLYleSjVuvsAHmT4980/hhkxUrlXJTR6eBY rAQhiW9TMRg2gTTgTEhkX9D4VKon45y0j/SDZ+9S+tlex8ihnMIylT6NH//QCYg/wu7B xF58VUzLxR9SCFM+cPtDbIq/xEg4XzJj/17OopxgvuQhOvRqu5iGUUQmfb+4Aj96jIW2 aNEA== X-Forwarded-Encrypted: i=1; AHgh+RrQ0FprrOc2qQmQNzpqQgUezX77EBDydaxlPeWIIn7UxFdljXtfWQBJlDxmXAU8bQEnGWdARXMOZI16OZbt@vger.kernel.org X-Gm-Message-State: AOJu0Ywb/vw1CbZkbew3eaaBhPR14IuwYv/aJ0PP/glx2/IE7ddRM85/ VUOGxeLiZlSIRF0oH46XAliljnvnaoy0Gl/Ytr0PDo3iCrj/8q4QduOz X-Gm-Gg: AR+sD10pAWVJ8okvkyCsJQ2Oyurzv/AYhG+T7/DSodh2FfxQp+7QxxqSWRD+rHuXO6E dEVoYnOY+wBfwif6lMOd6TtjBx7k9E44g4ssg0bwItDNHJsrvczeFrRsYs/2/sZt1Q+9iGIcJTe KNEPNeGf7CujGrZWAwa2m2LTYucOHqlEl+wBygLjh5/Ds1VSZj/A9bHycXkVMBAZ639NTAGoOA2 Lt3/FHRyzZEnIGTT4eYaaDdls+Q8fNUjo2ZrE+YLjBvNZlYsMjoFA9ocOlF2w76GsCcqBeU6dSB QMlOdfuGMfQ/mKIaSGsUv5mMUFquiDCqMrYJw+Qc0zadUfXQfFccsYhGgCl3LY4EN5LwLqiboVK voegudOGYC3y6lRgfqgrLU0AmEPX8ac0rHnhc1yOIVDq/fgPe0Wvt2zOzeIUkfDQxbog87sMyPu 4tB6wwHf90cytVpM9kRp+PY1HMXt3LWFWLIsuQXXaPx7dSup8ALZ4P/p4izFCJpDExtzvw/ls2+ VAYzes= 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-fsdevel@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