git: 44e214f8241f - stable/15 - deadfs: Return ENXIO instead of EIO when the device is gone.

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Tue, 28 Oct 2025 02:57:11 UTC
The branch stable/15 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=44e214f8241faa224e2346a5a03db8c029a7d4af

commit 44e214f8241faa224e2346a5a03db8c029a7d4af
Author:     Poul-Henning Kamp <phk@FreeBSD.org>
AuthorDate: 2025-10-24 07:19:31 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-28 02:56:34 +0000

    deadfs: Return ENXIO instead of EIO when the device is gone.
    
    One some systems, under some conditions, pulling a USB stick would
    read(2) returning EIO and not ENXIO, like it should and used to.
    
    Recoverdisk(1), which does not give up on EIO, like most programs
    would, spins furiously.
    
    Arguably, deadfs was always wrong in returning EIO, because once you
    get to deadfs no operation will ever work again, but we used to
    take a different path through devfs_vnops.c which got us the ENXIO.
    
    Something changed recently, and while testing this fix, I noticed
    that drm-kmod-66/i915kms may be the condition which trigger
    the different code-path.
    
    MFC to: stable/15
    Fixes: 289785
    Thanks to: imp, kib
    
    (cherry picked from commit 2612f1b8649bb4f069a6a064ed714daa5f10d037)
---
 sys/fs/deadfs/dead_vnops.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/fs/deadfs/dead_vnops.c b/sys/fs/deadfs/dead_vnops.c
index 296cf058f8c9..137c86b65058 100644
--- a/sys/fs/deadfs/dead_vnops.c
+++ b/sys/fs/deadfs/dead_vnops.c
@@ -122,18 +122,18 @@ dead_read(struct vop_read_args *ap)
 {
 
 	/*
-	 * Return EOF for tty devices, EIO for others
+	 * Return EOF for tty devices, ENXIO for others
 	 */
-	if ((ap->a_vp->v_vflag & VV_ISTTY) == 0)
-		return (EIO);
-	return (0);
+	if (ap->a_vp->v_vflag & VV_ISTTY)
+		return (0);
+	return (ENXIO);
 }
 
 int
 dead_write(struct vop_write_args *ap)
 {
 
-	return (EIO);
+	return (ENXIO);
 }
 
 int