From patchwork Sun Mar 17 16:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13594769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC9ECC54E67 for ; Sun, 17 Mar 2024 16:53:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 871D26B0088; Sun, 17 Mar 2024 12:53:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8226A6B0089; Sun, 17 Mar 2024 12:53:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 711306B008A; Sun, 17 Mar 2024 12:53:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5F8576B0088 for ; Sun, 17 Mar 2024 12:53:40 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0432914010D for ; Sun, 17 Mar 2024 16:53:39 +0000 (UTC) X-FDA: 81907127400.23.4233023 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id AAD66180013 for ; Sun, 17 Mar 2024 16:53:37 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o4qyS3vM; spf=pass (imf16.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710694418; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JNhL+PqgzCZKhF5U0TbOfFlXRNsclkcERHY1UKRh8qA=; b=60T2u2C7rCCzqdfn5+d0ychXBgY7csFwyWgSFPaqFRXY17rFd+Z+dW7s4OqQDdwM/GbtB6 Q4Cx13HN2Ddl6dRSK4P1vKsK+nBiH4HbEOt96K5T44M8lcjSUiflWJNhnJJdag2SqVcu0+ 8/XslxsxAk0nJjszWhUuwH6o8wDLPKI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710694418; a=rsa-sha256; cv=none; b=hAMqQXpPEUFCg9FkwNsoMXFMQ2aK28hjV/O7tuDP9S0Z0OnHVRP99NhEA7KyT+IHbMlSDJ wdgwOH1Ngj5xlSBgzoQTgK7JbpMFpt3Edn/Hzs2QFXBPPDrcVu5hFqj5ns1e08aXJLSq8I nAnySMqUYxiYdoiP5Dg5FdvO2ovs8Ik= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=o4qyS3vM; spf=pass (imf16.hostedemail.com: domain of djwong@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=djwong@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C41BDCE0104; Sun, 17 Mar 2024 16:53:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 075D5C433F1; Sun, 17 Mar 2024 16:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710694414; bh=NvVEy+UL4F7Ica1lAxSJkcql2WZ1Sh8WJGokKutUW/U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o4qyS3vMpopBBgAys30XOgNamkiF8DmvS+Igfqh+n75uqSWxq6jYjhm0fVYHgOlAm zMWTbzL4VXeZ9YQ7W34I20Bmd2VdPsXGQYpJPaFXwKltDT7c9EwTHpCzIPzeDNVQY0 2mVHADRFWsQUYK9QdwqD+plT6ld6uRkkxkc3ag3W/v8ZDHN9K1U2pE4uoBiyU6EdyW vYnqeFdVnNS21KO/WvJ2KUr7HQGeIS1oOtpSQaO7wUOWo671QLAxJTcISaySy7wKXj 4RiCwdvBXAIAD8bfDMymQQUKUKaB+Z4E3nBhhsbfo9+CNqWXzf5WJvV/S+hb6PlYMj D8O4fYjeWq98Q== Date: Sun, 17 Mar 2024 09:53:33 -0700 From: "Darrick J. Wong" To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, fstests , xfs Subject: [RFC PATCH] fstests: test MADV_POPULATE_READ with IO errors Message-ID: <20240317165333.GF1927156@frogsfrogsfrogs> References: <20240314161300.382526-1-david@redhat.com> <20240317165157.GE1927156@frogsfrogsfrogs> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240317165157.GE1927156@frogsfrogsfrogs> X-Rspamd-Queue-Id: AAD66180013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6a18876h9ztangfkgjkoqz54aj7mwza5 X-HE-Tag: 1710694417-897916 X-HE-Meta: U2FsdGVkX1/xJcC6AoFGlgcs5o/eOsaTEWaQ5W6/xyzEcg4o/lvvaoO5DmPUfs5KUA9nk892SvqD4smUi4nrAdsMXK+JFjrm70Qu83vVLdYZIKO+CP+x6O8vu6CbkX4aJvoofR2P0ltngjuYmGVlZKd8OKKCzR/epJR+hDlmP0LT+tWXvZTnOs9pUCnxMM9tlNC56oyZn9BmC8qIrgisLcIupXK9alP+oIKIH/TRhf/4D5ww6m92Wl7UF3s4yWJAiBLpyFKTT/8KeqO+bvTf0ksvlTdKNFaMzlLA0oCJW9tVGHFP7EVoeJfKqZaO6a1OlInK+hTYJDQzq+VSvP0dGfO7ovHFweu3rdFqzmlqKxrYLQfWUMHTWA37T3s5vONzm3b1YhDew2KGBRA3MWT1TMH3fIC2CmKGfit4fXaYpIL5NIPtOqYHxIN0V4vUDKnf4mNOohIscAjvQ3A/jExxbMbSorUC6c2A9Cmc84IcPXn6zjMztAfodkXs3yZtELjmCpf6qnI4m/SJwYBVgmkhIdFDMZAG569fQzdFNhpSrpXAdKMX48Etqa0X4TFRacQ4Wu8hefVbxODGo/7S2DZSKvnAMqrHv2UrPVwqbyExiumxomCAUDpB/P+IhiLiATVczA6htjimH6nXNCAxi2DDcSQGRFdpWM0k2EnPtoeGfidoEwKTsVJ+1Gc4ioTT7H9956p0qWA90fwmBtk/p8mC229k8Lcpn84vvjt5aClagQ28PymJFHfI6wCEd2iU6QHZpBpammc5xQiu18Yr3hNxHYVpv6SiP9D40KAAZy4SXLMshNEDjjUKyCfWS52N8tg3XL0I0QfKcMji2UJrnOIWW+0vaCcHKzGrSVmb6yNpFg6lvfn1CA3o3VlKGEX6JWpZ6nmSX56SUHWZZdwNkxRc37QtEFZOzUVkfooJeRQ16otvwCPZcvOTanNGYR8fHa4NqSKcIuhyHswlgFvg1Z8 Uh4P9JDG qjXrqjOHETjrg27afyRegfMu7tUdnZNoBGeiF0SCPXCCIhl2EkcWOj3XwnZ68kUOGxutFxBy7Zr+S0DPoA/tGtftvXim7YgKN26TQsrJ5wH9BN2rFE5POTHDu8aGDekYmy6qKlUxAjJbwJLvH26U1h3MHXkyG6E8kidSLmApM6sO0+oZQuKkAhYnZ5F5nA4sgnyNRhVQ13ZEbftKi0Gop6WDg5a1BmDnVsDjgnF4YUUcRRqPOrI/urA9M7mQd5SL2gzFEfm5IUyWj3kk+/I0PDEHQNv0Zs0qf8wmbCITOR1rCPWaO4+VkI3A5m4YsijHM1Gk/CmfAFgQbECGmUEpsSsi8Bw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Darrick J. Wong This is a regression test for "mm/madvise: make MADV_POPULATE_(READ|WRITE) handle VM_FAULT_RETRY properly". Cc: David Hildenbrand Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- tests/generic/1835 | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/1835.out | 4 +++ 2 files changed, 69 insertions(+) create mode 100755 tests/generic/1835 create mode 100644 tests/generic/1835.out diff --git a/tests/generic/1835 b/tests/generic/1835 new file mode 100755 index 0000000000..07479ab712 --- /dev/null +++ b/tests/generic/1835 @@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test 1835 +# +# This is a regression test for a kernel hang that I saw when creating a memory +# mapping, injecting EIO errors on the block device, and invoking +# MADV_POPULATE_READ on the mapping to fault in the pages. +# +. ./common/preamble +_begin_fstest auto rw + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* + _dmerror_unmount + _dmerror_cleanup +} + +# Import common functions. +. ./common/dmerror + +_fixed_by_kernel_commit XXXXXXXXXXXX \ + "mm/madvise: make MADV_POPULATE_(READ|WRITE) handle VM_FAULT_RETRY properly" + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_require_xfs_io_command madvise -R +_require_scratch +_require_dm_target error +_require_command "$TIMEOUT_PROG" "timeout" + +_scratch_mkfs >> $seqres.full 2>&1 +_dmerror_init + +filesz=2m + +# Create a file that we'll read, then cycle mount to zap pagecache +_dmerror_mount +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $filesz" "$SCRATCH_MNT/a" >> $seqres.full +_dmerror_unmount +_dmerror_mount + +# Try to read the file data in a regular fashion just to prove that it works. +echo read with no errors +timeout -s KILL 10s $XFS_IO_PROG -c "mmap -r 0 $filesz" -c "madvise -R 0 $filesz" "$SCRATCH_MNT/a" +_dmerror_unmount +_dmerror_mount + +# Load file metadata and induce EIO errors on read. Try to provoke the kernel; +# kill the process after 10s so we can clean up. +stat "$SCRATCH_MNT/a" >> $seqres.full +echo read with IO errors +_dmerror_load_error_table +timeout -s KILL 10s $XFS_IO_PROG -c "mmap -r 0 $filesz" -c "madvise -R 0 $filesz" "$SCRATCH_MNT/a" +_dmerror_load_working_table + +# success, all done +status=0 +exit diff --git a/tests/generic/1835.out b/tests/generic/1835.out new file mode 100644 index 0000000000..1b03586e8c --- /dev/null +++ b/tests/generic/1835.out @@ -0,0 +1,4 @@ +QA output created by 1835 +read with no errors +read with IO errors +madvise: Bad address