git: f0f9b4007015 - stable/14 - deadfs: Return ENXIO instead of EIO when the device is gone.

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

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

commit f0f9b4007015ffd5b3af072dfb70bdbf1250d875
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 15:52:50 +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 0f850cede292..75a1398ad6aa 100644
--- a/sys/fs/deadfs/dead_vnops.c
+++ b/sys/fs/deadfs/dead_vnops.c
@@ -124,18 +124,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