git: 2612f1b8649b - main - deadfs: Return ENXIO instead of EIO when the device is gone.

From: Poul-Henning Kamp <phk_at_FreeBSD.org>
Date: Fri, 24 Oct 2025 07:41:11 UTC
The branch main has been updated by phk:

URL: https://cgit.FreeBSD.org/src/commit/?id=2612f1b8649bb4f069a6a064ed714daa5f10d037

commit 2612f1b8649bb4f069a6a064ed714daa5f10d037
Author:     Poul-Henning Kamp <phk@FreeBSD.org>
AuthorDate: 2025-10-24 07:19:31 +0000
Commit:     Poul-Henning Kamp <phk@FreeBSD.org>
CommitDate: 2025-10-24 07:19:31 +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
---
 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