Re: [PATCH 1/1] generic: test fsnotify filesystem error reporting

Amir Goldstein
2026-03-03T09:21:17Z

On Tue, Mar 3, 2026 at 1:40 AM Darrick J. Wong <djwong@kernel.org> wrote:
>
> From: Darrick J. Wong <djwong@kernel.org>
>
> Test the fsnotify filesystem error reporting.

For the record, I feel that I need to say to all the people whom we pushed back
on fanotify tests in fstests until there was a good enough reason to do so,
that this seems like a good reason to do so ;)

But also for future test writers, please note that FAN_FS_ERROR is an
exception to the rule and please keep writing new fanotify/inotify tests in LTP
(until there is a good enough reason...)

>
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
> src/Makefile | 2
> src/fs-monitor.c | 155 +++++++++++++++++++++++++++++++++
> tests/generic/1838 | 228 ++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/1838.out | 20 ++++
> 4 files changed, 404 insertions(+), 1 deletion(-)
> create mode 100644 src/fs-monitor.c
> create mode 100755 tests/generic/1838
> create mode 100644 tests/generic/1838.out
>
>
...

> diff --git a/tests/generic/1838 b/tests/generic/1838
> new file mode 100755
> index 00000000000000..087851ddcbdb44
> --- /dev/null
> +++ b/tests/generic/1838
> @@ -0,0 +1,228 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2024-2026 Oracle. All Rights Reserved.
> +#
> +# FS QA Test No. 1838
> +#
> +# Check that fsnotify can report file IO errors.
> +
> +. ./common/preamble
> +_begin_fstest auto quick eio selfhealing
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> + cd /
> + test -n "$fsmonitor_pid" && kill -TERM $fsmonitor_pid
> + rm -f $tmp.*
> + _dmerror_cleanup
> +}
> +
> +# Import common functions.
> +. ./common/fuzzy
> +. ./common/filter
> +. ./common/dmerror
> +. ./common/systemd
> +
> +case "$FSTYP" in
> +xfs)
> + # added as a part of xfs health monitoring
> + _require_xfs_io_command healthmon
> + # no out of place writes
> + _require_no_xfs_always_cow
> + ;;
> +ext4)
> + # added at the same time as uevents
> + modprobe fs-$FSTYP
> + test -e /sys/fs/ext4/features/uevents || \
> + _notrun "$FSTYP does not support fsnotify ioerrors"
> + ;;
> +*)
> + _notrun "$FSTYP does not support fsnotify ioerrors"
> + ;;
> +esac
> +

_require_fsnotify_errors ?

> +_require_scratch
> +_require_dm_target error
> +_require_test_program fs-monitor
> +_require_xfs_io_command "fiemap"
> +_require_odirect
> +
> +# fsnotify only gives us a file handle, the error number, and the number of
> +# times it was seen in between event deliveries. The handle is mostly useless
> +# since we have no generic way to map that to a file path. Therefore we can
> +# only coalesce all the I/O errors into one report.
> +filter_fsnotify_errors() {
> + _filter_scratch | \
> + grep -E '(FAN_FS_ERROR|Generic Error Record|error: 5)' | \
> + sed -e "s/len=[0-9]*/len=XXX/g" | \
> + sort | \
> + uniq
> +}

move to common/filter?

Apart from those nits, no further comments.

Thanks,
Amir.