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 204A7486E77 for ; Thu, 6 Aug 2026 17:00:02 +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=1786035603; cv=none; b=liZFsAre1TqwOvu4Pcz2ZL0yaQiuEKGGxXnSUZtV8xFmUa7tqstb1qew/IFQxYlRcs3nWQP9VQ+6DUs1aHtEPjUgiWwGzX1gVEPu3kXAbahbyIVsbGw+MO1cMrN+ja3HqUhkF+VcowrcPTTETfNAcLvVHp9xA1oqQpnkT4dhTbU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786035603; c=relaxed/simple; bh=MXEWU902YGIdYxhsplvnnMAlAsOIW5B35iOVcX+SwuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p//QKl8FKMNcLeYqZEBS7Tv2u5QRKbDRE1tz2Bb4kZp60BW6HiNSpy8vrnqPYa4Kv6iagAI4I8bkAQFDxiVN/62C83urZuKJ2M/rs18+XC96e0aThxPEb7JwcH+mZTYxvpR/0rgSJQFxh7EIEkMAFfmAwlB4tE43XmXqXMDdmYM= 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=fU3IdtY9; 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="fU3IdtY9" Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-5c375a9e76cso1469003e0c.0 for ; Thu, 06 Aug 2026 10:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786035601; x=1786640401; darn=lists.linux.dev; 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=dTojca6QcAoa5sJYmeZWsS9cCWtcJ0fPl4l3Xf8SOVQ=; b=fU3IdtY9few0ydXC16/8Q98a9uxbjMEiyb4qi4KfdQHxluSK7H7XDCYR+Y5XVw7zEM XMUUWxM81X4naUaXWSE9MqZ6PGg3wi0TP7iUSfxPALP8870d3yX3bn9Nf9Ojkb4skQm6 XwArEAL0MT43kkFg6Tdoby8Ml/C/6En8JAukYHeiM4PzkoZlLV6jvf7qKAj3kIrGhs6Y i8hqy3Nd3gDT+tdOfQtkJOlsCUk1h4Mjf7yvxzTU0iLCEAzNKpm1PWuK443LYpko7ZfL LBrZD41XmvfpoOuoXh7jH5TNhX+49UARMNZ3w49eXXo6pEs6SOQNl6lV6dTdEEkinV89 ZqLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786035601; x=1786640401; 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=dTojca6QcAoa5sJYmeZWsS9cCWtcJ0fPl4l3Xf8SOVQ=; b=PRSiPTZKfOEknRHyMWIS5J+QJAU4bXPZTSC1iAttSjg5k5EguQ2oHpl8oJbj/1/RdJ CrydmejKjKawQivkKZPPb73Lm5dqg879xfETmDPV+uz3lGtj8KOnKAwnIG9iucIYMJ3g CLWHVeDHcp4Rnqs1WfAlZNWmAvqA1fW04T1kKGrXutSaakPPD2T1lJeoSMl2sc+QWJiL txrfivquSQl4/F5/s0+6rJ9en/6VHj2uM8ubrGSsuznZo+IwwYYUxMo9E3swydB1UBgj x7qqOMBmE7fqBV/MWYgKCya9X/eKBf93IzvL96sxdWFUSy/me7cAp/b70LhA+duUOgmp Q+ow== X-Forwarded-Encrypted: i=1; AHgh+Rr9Bqg9e8BlzeRvtJ6gbnPk6cPbDlkvQtVXjY7IodRZJjY/+P0h9rJhCCuZuJnUSEZXOv5a@lists.linux.dev X-Gm-Message-State: AOJu0Yx8WxO5WWR/OdvW4fXiapArTx2oZimtoM97Zt/ll0olxQmej/Vu 46MHznROxKyIITkIgPCB3+TwIcBpI593yH5CFKJC+A5nkO6MnBH6aEQF X-Gm-Gg: AR+sD12kATUH34ocGxJ9uM3QjbmTv7wFmT1UINwiG+XNxBpBwGc9Rdy27tzHQMoDnk5 SNsAonyBxxnUUnjOEtT00zTEFQwgfQs3XKZR9BJ3lizrJGmacKl3YgifVxMVuynuRv5iQvYyYsd GJPnEuKLfsvM7sEMe+BJAk+0MbI47KE7IUJCKyOeDu9YnNvbS1G4xZX8gFl+i4BV5O93WqoqtDp D4PI1JR7Yphbycv6O4Zgkti7QSUrpozc6Co+lliMGCvT83ddJdFySqO0p9GQq4YGnFszNOJyv6+ bYv1QUxEBXSNhcPe1w5BRwy2KDQ5wARiwv+IqLaYE43K8i0+Ntf9+TjLgTxRXcDVq0UMxOVBYCN Lk/grOTMouAP5+q6cT8kBKWVM6rEkfXsMy4lVVWhM3XjrKNcPDZ6FFrdBuwnVcW21of4Xe3oNvC 4DAyKbIJhWnKg6+WOID7zMrfagMtPgOv1HsXzg2l/i6Pi2Lq8PMqmCpZFiw46vp1YzN9ug8E1lV Gu+uLY= X-Received: by 2002:a05:6122:178d:b0:5bd:9c71:11e with SMTP id 71dfb90a1353d-5c3f9eb0727mr555265e0c.4.1786035600948; Thu, 06 Aug 2026 10:00:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 10:00:00 -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 16/21] gfs2: check for a metadata write error with buffer_write_io_error() Date: Thu, 6 Aug 2026 12:58:39 -0400 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: gfs2@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Acked-by: Weidong Zhu 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 == tr); 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, struct 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 *bh) 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 = bh->b_private; /* If this buffer is in the AIL and it has already been written -- 2.43.0