From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145351; b=UvR44qDDFVqWDyQwG+l1C03Jw4rp2bde+Zs5ZOwzrw+LYmfZVf1YZUtaJn+4D7zjbOhS iG7C9hNVAQgS6mPYZZTvT1HaohjSIGzL5o8j9PrTZqmtKZLxbvGw7KFdgTIsZ5EM59WAR xVI8p629tMoxwX1Q7jYZ55WhWoMi8T/KFkn4Z4Ty12pV2Sb/Nj81ksCtMAbXc2iC+Mrg/ wg/D9Vbf48EfCUBC0Fvapfy0DZWnHMMD/ylqb36z0m2OsmLdi4WaR+CkAJ6/55TFt2vFC NKrEz7RuLwNqkOm6N4MEJA2nAAkqFrRUD5eNQPDxUV9OLGeFL6A4BNVUBvuycKS8Z4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145351; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=T89bBx3RWMSmju2HwArOfr9E9B+AJ7P4dBheuEaDiH8=; b=0njy/AR0OaA+orcQX7dSuYNXEMWJ3OqprJFlvq3L4H7l6gwWZPMJcD6ifxnZ320gRJvu WIL5qASZsCVin/aadYMq4aJT6LH+QUrI17rlT8b4sCmoJpyyGZIaKdTQKnK6MKdpclBBZ vs6ocnJD6BCGVfnbeoDJIB5/Bn7lo11PAKxET3EuOR6owNyJjSuPrlQfd4IrOOndLqQbg J+lRwNBXPkvuiGIeWoGBXXPuVvxXzyL4d5+fgpaothSo8lv9xL8X9Ag6eowMSNiZT2SPn kJGCKV3vkzjwh5oIwwJva13WgMH1VlfcqvZqmFndrViVON8vQh6UJ1zXPN5poxxcH/w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=uBsyBBHT; arc=none smtp.remote-ip=209.85.214.181 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67770606A31A for ; Tue, 1 Dec 2026 17:15:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 67770606A31A 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.a=rsa-sha256 header.s=20260707 header.b=uBsyBBHT Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2f046b0adc0so70530075ad.1 for ; Tue, 01 Dec 2026 09:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796145350; x=1796750150; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=T89bBx3RWMSmju2HwArOfr9E9B+AJ7P4dBheuEaDiH8=; b=uBsyBBHT3c9OKsbShHalvxZMhcX9rOgXf3GUuf9Qb8hOQRRvtCjSNUJggDyiCCGznf eBPjN2Njz8Wb6zXhZgmtqolzVgJXmx/XocBwN2Xcgm0KjtrkaLjbCxJzi96ekmQqcP5c gxDCocoGbikmSnCKvsT1xHldDgEgpznp3dviHVbD6pcpPV+/KsHMgCzGt5ZmQn/B/dZZ ro3eo8WfU6w2EdVI+wTpmr/p4qzY/YgfgPV452MVHkWuWAB6KxX5PJbuGvpsGNS9iGb+ Fzkoy6PJ2m14UW0QK/9SVem4iHvNB+gz+Ayv5NFmoASYaZR5NxzIY5OC/PQf6ltRGBIC fJqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796145350; x=1796750150; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=T89bBx3RWMSmju2HwArOfr9E9B+AJ7P4dBheuEaDiH8=; b=2kSfsMuMabujp3EuEjvXFoVK7PVzhmEH4bVD30xw45tIJA80NCDO6uQdzVqLJwV6JH AsEMI+UZ6KRl+IthIFhs+q6Q9VPf8GjdJIjVOwA5gFiwzgXJTnxWe5AHm+wml4oZluTi Q+zEnLoDpNyji/hZCk92P0qjs4HUfYnxGICXx2Y3R+1qaiarliImm8Xbmm6agWCspnV8 fbRrHKRZO1Y53tP54GkRFxLF2pGG+0XP4reaFwT5tID4gORb0y3952T9t072z+dfCeLs EMZKnqkmaqjXC254Vi2V+24xFk/4FtZgZ5BR6Hl2ao8Q8IqQ0HnTqocMJEdx1mPyjWBr xH5A== X-Forwarded-Encrypted: i=1; AL+hErFCD9OgqTAUkKJao72FH9OIbdTyAF8745FSiiyuTUARlYj+MlcbUSxOI/ovwlXoLmTMeE5IibdhIfq8Tcw=@vger.kernel.org X-Gm-Message-State: APuU4Z87x2v+XYyUfms1tl4g1oZwo9gooDsYAosdWoaseO+/9tCNPIig dnyHl8BXd+KVjcUy9Diod22bZVTOi/deq/bZRWj683GU4tSHmzPpo/BifvCM4g== X-Gm-Gg: AZFdTZcCz2tLc/6goA82pQm1A4N+QA8CDjRMVB1BgPz2LBCleBJT34NTJ3DhrP2XsfZ LYeqbDhgZgxuMKp419HXeNvkCmBCt7SWdiFFamRDY1sL7khJxoP+cIVVf4XLEQdet1I2DOdTqrs 311gaW2Sy/IhQvmjKBPC9oMQqB80vw52a9I3iPfc1BzZcXYoAxaKVgbMlImCz4Nzd/DlqxN94Zq nRgRGTPjAbVIx2p/X7aH+3KSMHzzQHVSrvaXc+ebmInrQiEw/ysfM2sCRNGlGdNQrdJXZ/2fgfD lCPP4LIRi8M3gm7BL9lxnViSzcyuHWQlgM4dWXF7scDybfFTWiNFI7f5bluRiXiEGghXL4Bv80H yss2Muz5qVvbfgwTOsJb2wYhSy3DwNtaFB8vAiw16/bKXvE658AXBX7ORp0QHb02X8/UvW5qh5Y wN1u5ZmfMBQ+exycLDxgKHDeMyccKTP8ZSm1U0z3jFVp4bFIVe6kYN/NEnBF6AW0Y0TwX2LUn1y ckfMoN6IzTmz9YcnrQx1EwSvmgXi1pG3uAqPh8cESUJT5oHRWfvY/Tw6a0TZ+isZeaVWIbmICNn rVjQmLjd4zKBtG1SyAE5zK6hhAZjlAAD3er8nKlNthfT8d3YndSTocdSaH7PytFSL4TKXVNahLN N97s= X-Received: by 2002:a17:902:da48:b0:2f0:382c:5597 with SMTP id d9443c01a7336-2f03f1a52aamr368010465ad.62.1796145350454; Tue, 01 Dec 2026 09:15:50 -0800 (PST) Received: from [192.168.18.15] (218-35-178-218.cm.dynamic.apol.com.tw. [218.35.178.218]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f1207f1sm187738735ad.64.2026.12.01.09.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 09:15:50 -0800 (PST) From: Kurt Lin Date: Wed, 02 Dec 2026 01:15:45 +0800 Subject: [PATCH] f2fs: let memory-failure remove poisoned page-cache folios X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-f2fs-error-remove-folio-v1-1-645aef601439@gmail.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAA/x3MQQrCQAwF0KuEv26gGbHVuYp0oTXRgDaSgSKU3 l3wHeBtaJquDZU2pK7ePBZUko4wP6/LQ9nvqITSl0FKL2zFGmtmJKe+Y1W2eHnwYZyPMoznk9w MHeGTav79z5dp339/IO0gaQAAAA== X-Change-ID: 20261201-f2fs-error-remove-folio-37c5167981bf To: Jaegeuk Kim , Chao Yu Cc: Andrew Morton , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Kurt Lin X-Mailer: b4 0.14.3 f2fs_dblock_aops has no ->error_remove_folio(). memory_failure() then falls back to mapping_evict_folio(), which cannot remove a dirty folio. So when a dirty f2fs page-cache page is hard-poisoned, recovery fails: Memory failure: 0x6289: Failed to invalidate Memory failure: 0x6289: recovery action for dirty LRU page: Failed madvise(MADV_HWPOISON) returns -EBUSY and the poisoned folio stays in the page cache. read() keeps returning its contents without an error, and the next fsync() writes it back to disk before reporting -EIO. With a real memory error, the kernel keeps reading the poisoned memory. Set ->error_remove_folio() to generic_error_remove_folio(), as ext4, xfs, btrfs and others do. The folio is then truncated at the time of the error, and f2fs_invalidate_folio() drops its dirty accounting: Memory failure: 0x742b: recovery action for dirty LRU page: Recovered madvise() returns 0 and nothing is written back. fsync() still reports -EIO, and an atomic write with a poisoned page still fails to commit with -EIO and is rolled back. Found and tested with the help of an AI coding assistant. Signed-off-by: Kurt Lin --- Tested on f2fs dev b61a029304bb in a QEMU x86_64 guest (4K blocks) with MADV_HWPOISON on a dirty mmap'd page. The two kernels differ only by this patch: before after recovery action (20 runs) Failed 20/20 Recovered 20/20 madvise() -EBUSY 0 that page on disk after poisoned page not written fsync() (O_DIRECT read) fsync() -EIO -EIO atomic write commit -EIO, rolled back -EIO, rolled back With the patch it is also Recovered in a compress_algorithm=lz4 directory (chattr +c), and in a 4-page file the other three pages read back intact. fsck.f2fs shows nothing new. The mm memory-failure selftest passes with and without the patch, as it does not check the recovery result. Not tested: block size smaller than PAGE_SIZE, large folios, a real memory error. This is the f2fs counterpart of Andrew's FUSE patch: https://lore.kernel.org/all/82801b542ac4481a85ec2c869294ca28.1@linux-foundation.org/ --- fs/f2fs/data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index cdc9e6e8633c..6df85fb7d5af 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -6403,6 +6403,7 @@ const struct address_space_operations f2fs_dblock_aops = { .migrate_folio = filemap_migrate_folio, .invalidate_folio = f2fs_invalidate_folio, .release_folio = f2fs_release_folio, + .error_remove_folio = generic_error_remove_folio, .is_partially_uptodate = f2fs_is_partially_uptodate, .bmap = f2fs_bmap, .swap_activate = f2fs_swap_activate, --- base-commit: b61a029304bb5531312ebc133b2a895d14dc3fee change-id: 20261201-f2fs-error-remove-folio-37c5167981bf Best regards, -- Kurt Lin