{"id":2215744,"url":"http://patchwork.ozlabs.org/api/patches/2215744/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260325093349.630193-2-diangangli@gmail.com/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260325093349.630193-2-diangangli@gmail.com>","list_archive_url":null,"date":"2026-03-25T09:33:49","name":"[RFC,1/1] ext4: fail fast on repeated metadata reads after IO failure","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"006feecb6c5f31c0d8f1a942abe294d512ffb9f6","submitter":{"id":92966,"url":"http://patchwork.ozlabs.org/api/people/92966/?format=json","name":"Diangang Li","email":"diangangli@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260325093349.630193-2-diangangli@gmail.com/mbox/","series":[{"id":497401,"url":"http://patchwork.ozlabs.org/api/series/497401/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=497401","date":"2026-03-25T09:33:49","name":"ext4: fail fast on repeated metadata reads after IO failure","version":1,"mbox":"http://patchwork.ozlabs.org/series/497401/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215744/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215744/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=eYzt=BZ=vger.kernel.org=linux-ext4+bounces-15359-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=jrSRf3WT;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=eyzt=bz=vger.kernel.org=linux-ext4+bounces-15359-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.232.135.74 arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","gandalf.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=jrSRf3WT;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15359-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"jrSRf3WT\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.214.178","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1 raw public key)\n server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fghZn2HG9z1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 20:34:57 +1100 (AEDT)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fghZn1CnXz4w9T\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 20:34:57 +1100 (AEDT)","by gandalf.ozlabs.org (Postfix)\n\tid 4fghZn15WQz4wF0; Wed, 25 Mar 2026 20:34:57 +1100 (AEDT)","from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4fghZj3YHKz4w9T\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 25 Mar 2026 20:34:53 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 2C9B4305971E\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 25 Mar 2026 09:34:49 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 412C2358D14;\n\tWed, 25 Mar 2026 09:34:46 +0000 (UTC)","from mail-pl1-f178.google.com (mail-pl1-f178.google.com\n [209.85.214.178])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 17F4A34A77D\n\tfor <linux-ext4@vger.kernel.org>; Wed, 25 Mar 2026 09:34:43 +0000 (UTC)","by mail-pl1-f178.google.com with SMTP id\n d9443c01a7336-2b06c43e6a7so25705765ad.2\n        for <linux-ext4@vger.kernel.org>;\n Wed, 25 Mar 2026 02:34:43 -0700 (PDT)","from n37-098-250.byted.org ([115.190.40.15])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b083516ae1sm164266245ad.13.2026.03.25.02.34.40\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Wed, 25 Mar 2026 02:34:42 -0700 (PDT)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1774431297; cv=pass;\n\tb=yo8pYcNikb3Lp3ldjepBzJirUpVPKi8PgnByUXW6TKv/ATEkhh9MP1PJY9bh9YQMySV30eCO8jS1unsj51flSBly2CgiNW+Iu12unpgWrSombL+qYK4sBsFpkg1N/pigISc/0cG32aY+yPz9E0ww0PtnFg80EiFqaQd+QDZv405e5hDWkS+/w8g5GdUPW4spceYgbAymrifKh1aU9WEcZOe4ZZq5zwxgwPCA54viq5oJ0THtuLYwUToslrItS/do/EMHecTcSpba0+dagK3NXPCcDa6lBgor8fT4yW7ZMNpgKYoK2BIPAo3f3qxuS0jTx9x8HrlpgyHm92WpraONzw==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774431286; cv=none;\n b=mornlXUCbGRSOsGp4wf0BotdNzHnhJlCnQ6UmxHQV5gnbkGNue92txosVMrb91iqfBs6f0GMcVRpLOM6MyBIu8vRbUQnzJGCB/2c/gwag8kRtTPE/p1xy9HyXjuxBUss2FDYBwc/uL3FXew97/GiOEwU/FUke1VTHELhdCFPnZM="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1774431297; c=relaxed/relaxed;\n\tbh=C2kZEGfm9VSl1YrM5qslWXevfM/VbQjjSaf7BnkuDjI=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=jZxuiYdSHhDynYmsV1EOnPMg8nG3g7xEpxMLEkBO50f5Fc96T3DGbUof143FAA73OZBDqwusBT0JyYUewxtjIXDR6D+Pv2W3fxbPQp3flTAG/UFgdSauEDOZyb7IBwKdIgw66UId4Vnpi7jdS//lb43DOvyqI9/kKeeUpgW2c7DSze6R/A8+GSyjpnIG+G9LiN+IMwMx9npqR9XJnwrjcwsYMJYjSffUEhJv/fEvEk1o3/CGDt6eOZaMpSZAwgNQYXUzIeFy2OuHuHI89U1Va94jdV2TOp2TnPSBX/IVMpeK5PCP4tRlJn0d0uXBEh3ZfnWUb5EgRy3DOq9e+nFQaA==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774431286; c=relaxed/simple;\n\tbh=au2v8Zj1g2gTa/qYyAEVaRCf5QQU9rUKjFNpk5w+uaE=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=ELSC4CbCAz/JsTXyT0GIADy4wxZ3QEvuy19SYLCKDJJPABAlO8tSjiH/UqYYJMK15LeCcJo3d3b+PpREYsM1wWx5j1wJcnY40vBE6NtqnjUqGzNwFS7xOUIkzIJO54baTTuIYmSu0KYNQlNc3Is9RwlWj4dQGBnxGXqv1Pj+e7M="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=jrSRf3WT; dkim-atps=neutral;\n spf=pass (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15359-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=jrSRf3WT; arc=none smtp.client-ip=209.85.214.178"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1774431283; x=1775036083;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=C2kZEGfm9VSl1YrM5qslWXevfM/VbQjjSaf7BnkuDjI=;\n        b=jrSRf3WT+DDpx5fcz/kXm0Rlfo6tOWG+ws6WM6zZyV9qNq1yST4Vp+Bnuo9vOUXpTX\n         2RugBghwntS/dHehzmGENwhYSXibhDqLqij594StYHIYH5DMfPF5spuBU2ueFf4rk5RZ\n         hYJN/gzKPPG1a5WVogL2HjfflGJSiR/MB3r1ik83ndLqxLe8HzG3CtjAC9V2muS6sNZ4\n         HGp7CxldlQzBeVfiaa72B+I4LOSvJZFlMaClNmDa6qNEoXTU1ztVVPynAsaPU3vJWBra\n         9MquIfkEfEx5Gq7br4SJYlmrH/cyHLi1h4UoX9IsZZ68435r6S3Qa6M8Abv9Tf0yZFJC\n         SWnA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1774431283; x=1775036083;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=C2kZEGfm9VSl1YrM5qslWXevfM/VbQjjSaf7BnkuDjI=;\n        b=qQyNPwwvBSsoAioGjp7Ll2JU+GqT98ZpXEIOMx/7X4tVuHx4F7UjPtkuDHg987pd0n\n         va0pDMPlAoh2xiY3bltuTLnepWpfAierWa3gSdIvLV58+dEgF+blS25xApJIDVrQwpTd\n         THQ6v1RLfJ/m1l8httglITjsROTkKiShAO47eeRFE/W+o3VECC2C/UyFY2hb3meYVKrF\n         FgM83MvlO6+WZfgoNKrdQ/sJmOvRWROF+Xo9BlupLh6efuCfg3Dx2qF8I8/lUtsXwqLE\n         IPp4pmll68QaTKsXrWhz1o3BRim3AAjNMQqygJd/0Nu37E0BBimhOZ5q1mC7UcebSrnO\n         p+eQ==","X-Gm-Message-State":"AOJu0YwiZFozReuCJMnBOt04jt8Ge5fHEly+34vSgQ0B1DE+qETl/Ybf\n\tfBIrYFQBtiPsOB1JBaGfvE7mGlthGt1IzhJsbvbfSICU234je1+diq6UTj618gtwacw=","X-Gm-Gg":"ATEYQzzfyq0ThZhc/A7iAhC+ET4L7SgVjNSeDFjrGzZ1qIQ3FTWkUnX+gYLdTj4QBEm\n\tP4AjB1rsgx9ObHqmxRuK5rkFFnRO1kmLThn8Xu/MJZUCk5QSqm9eISzDc7UpCv1+GVuE59EV1x8\n\ttsRg1MGEDbXo5T0om0yHLVwaPn18IyobCpZStd7akU4iP2YGJbydA4jHT99PhcCVsFfV2luQXmF\n\t8q2azf5F7zj+GVef7DO6Dxm0I1LKCQI7Rrm7w6Mo71n5Vbr0eolusJeREzR4ehIb/YQ42L65uBK\n\tc8yQsceJUGmUWpBb9aUpR0Bb0N/g34Kc5vsXEcoiWf8+rHm47QzhLC6Y3keB2lWcxq1CWIqfyp3\n\t9+8FSMg18fhvVXERzfevZF2IcX8juCJoxnjMhQNVTG7GDFcKkTviUygEIy8pouApNK4LSQaAP4a\n\tBF7R2Lj+CDCE35/sQSUygr4O0LpF98JjNhutku","X-Received":"by 2002:a17:903:1b45:b0:2ae:6259:5aff with SMTP id\n d9443c01a7336-2b0b09a69b6mr29408665ad.6.1774431283311;\n        Wed, 25 Mar 2026 02:34:43 -0700 (PDT)","From":"Diangang Li <diangangli@gmail.com>","To":"tytso@mit.edu,\n\tadilger.kernel@dilger.ca","Cc":"linux-ext4@vger.kernel.org,\n\tlinux-fsdevel@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tchangfengnan@bytedance.com,\n\tDiangang Li <lidiangang@bytedance.com>","Subject":"[RFC 1/1] ext4: fail fast on repeated metadata reads after IO failure","Date":"Wed, 25 Mar 2026 17:33:49 +0800","Message-Id":"<20260325093349.630193-2-diangangli@gmail.com>","X-Mailer":"git-send-email 2.39.5","In-Reply-To":"<20260325093349.630193-1-diangangli@gmail.com>","References":"<20260325093349.630193-1-diangangli@gmail.com>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tFREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,\n\tMAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"From: Diangang Li <lidiangang@bytedance.com>\n\next4 metadata reads serialize on BH_Lock (lock_buffer). If the read fails,\nthe buffer remains !Uptodate. With concurrent callers, each waiter can\nretry the same failing read after the previous holder drops BH_Lock. This\namplifies device retry latency and may trigger hung tasks.\n\nIn the normal read path the block driver already performs its own retries.\nOnce the retries keep failing, re-submitting the same metadata read from\nthe filesystem just amplifies the latency by serializing waiters on\nBH_Lock.\n\nRemember read failures on buffer_head and fail fast for ext4 metadata reads\nonce a buffer has already failed to read. Clear the flag on successful\nread/write completion so the buffer can recover. ext4 read-ahead uses\next4_read_bh_nowait(), so it does not set the failure flag and remains\nbest-effort.\n\nExample hung stacks:\n\n  INFO: task toutiao.infra.t:3760933 blocked for more than 327 seconds.\n  Call Trace:\n   __schedule\n   io_schedule\n   __wait_on_bit_lock\n   bh_uptodate_or_lock\n   __read_extent_tree_block\n   ext4_find_extent\n   ext4_ext_map_blocks\n   ext4_map_blocks\n   ext4_getblk\n   ext4_bread\n   __ext4_read_dirblock\n   dx_probe\n   ext4_htree_fill_tree\n   ext4_readdir\n   iterate_dir\n   ksys_getdents64\n\n  INFO: task toutiao.infra.t:2724456 blocked for more than 327 seconds.\n  Call Trace:\n   __schedule\n   io_schedule\n   __wait_on_bit_lock\n   ext4_read_bh_lock\n   ext4_bread\n   __ext4_read_dirblock\n   htree_dirblock_to_tree\n   ext4_htree_fill_tree\n   ext4_readdir\n   iterate_dir\n   ksys_getdents64\n\nSigned-off-by: Diangang Li <lidiangang@bytedance.com>\nReviewed-by: Fengnan Chang <changfengnan@bytedance.com>\n---\n fs/buffer.c                 |  2 ++\n fs/ext4/super.c             | 12 +++++++++++-\n include/linux/buffer_head.h |  2 ++\n 3 files changed, 15 insertions(+), 1 deletion(-)","diff":"diff --git a/fs/buffer.c b/fs/buffer.c\nindex 2d2e3ecec6b2b..b41d54b8b1f4d 100644\n--- a/fs/buffer.c\n+++ b/fs/buffer.c\n@@ -145,6 +145,7 @@ static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate)\n {\n \tif (uptodate) {\n \t\tset_buffer_uptodate(bh);\n+\t\tclear_buffer_read_io_error(bh);\n \t} else {\n \t\t/* This happens, due to failed read-ahead attempts. */\n \t\tclear_buffer_uptodate(bh);\n@@ -167,6 +168,7 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate)\n {\n \tif (uptodate) {\n \t\tset_buffer_uptodate(bh);\n+\t\tclear_buffer_read_io_error(bh);\n \t} else {\n \t\tbuffer_io_error(bh, \", lost sync page write\");\n \t\tmark_buffer_write_io_error(bh);\ndiff --git a/fs/ext4/super.c b/fs/ext4/super.c\nindex 781c083000c2e..89a99851864a0 100644\n--- a/fs/ext4/super.c\n+++ b/fs/ext4/super.c\n@@ -198,7 +198,13 @@ int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,\n {\n \tBUG_ON(!buffer_locked(bh));\n \n+\tif (!buffer_write_io_error(bh) && buffer_read_io_error(bh)) {\n+\t\tunlock_buffer(bh);\n+\t\treturn -EIO;\n+\t}\n+\n \tif (ext4_buffer_uptodate(bh)) {\n+\t\tclear_buffer_read_io_error(bh);\n \t\tunlock_buffer(bh);\n \t\treturn 0;\n \t}\n@@ -206,8 +212,12 @@ int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,\n \t__ext4_read_bh(bh, op_flags, end_io, simu_fail);\n \n \twait_on_buffer(bh);\n-\tif (buffer_uptodate(bh))\n+\tif (buffer_uptodate(bh)) {\n+\t\tclear_buffer_read_io_error(bh);\n \t\treturn 0;\n+\t}\n+\tif (!buffer_write_io_error(bh))\n+\t\tset_buffer_read_io_error(bh);\n \treturn -EIO;\n }\n \ndiff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h\nindex b16b88bfbc3e7..be8bedcde379e 100644\n--- a/include/linux/buffer_head.h\n+++ b/include/linux/buffer_head.h\n@@ -29,6 +29,7 @@ enum bh_state_bits {\n \tBH_Delay,\t/* Buffer is not yet allocated on disk */\n \tBH_Boundary,\t/* Block is followed by a discontiguity */\n \tBH_Write_EIO,\t/* I/O error on write */\n+\tBH_Read_EIO,\t/* I/O error on read */\n \tBH_Unwritten,\t/* Buffer is allocated on disk but not written */\n \tBH_Quiet,\t/* Buffer Error Prinks to be quiet */\n \tBH_Meta,\t/* Buffer contains metadata */\n@@ -132,6 +133,7 @@ BUFFER_FNS(Async_Write, async_write)\n BUFFER_FNS(Delay, delay)\n BUFFER_FNS(Boundary, boundary)\n BUFFER_FNS(Write_EIO, write_io_error)\n+BUFFER_FNS(Read_EIO, read_io_error)\n BUFFER_FNS(Unwritten, unwritten)\n BUFFER_FNS(Meta, meta)\n BUFFER_FNS(Prio, prio)\n","prefixes":["RFC","1/1"]}