Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Oct 2025 11:21:00 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Poul-Henning Kamp <phk@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 2612f1b8649b - main - deadfs: Return ENXIO instead of EIO when the device is gone.
Message-ID:  <aPs27Dc_w10t3ENH@kib.kiev.ua>
In-Reply-To: <202510240741.59O7fBAe041995@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail

On Fri, Oct 24, 2025 at 07:41:11AM +0000, Poul-Henning Kamp wrote:
> 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
Nothing changed WRT code, it is just a race that causes the behavior.

>     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)
Old style with explicit '== 0' was more style-correct.

> +		return (0);
> +	return (ENXIO);
>  }
>  
>  int
>  dead_write(struct vop_write_args *ap)
>  {
>  
> -	return (EIO);
> +	return (ENXIO);
>  }
>  
>  int


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?aPs27Dc_w10t3ENH>