Dear David,

On 2020-11-24, Yorick Hardy wrote:
> Dear David,
> 
> On 2020-11-22, David Brownlee wrote:
> > I'm seeing a (new?) panic on netbsd-9 with zfs. It seems to trigger
> > when a newly created zfs pool attempts to be mounted:
> > 
> > panic: vrelel: bad ref count
> > cpu0: Begin traceback...
> > vpanic() at netbsd:vpanic+0x160
> > vcache_reclaim() at netbsd:vcache_reclaim
> > vrelel() at netbsd:vrelel+0x22e
> > vdev_disk_open.part.4() at zfs:vdev_disk_open.part.4+0x44e
> > vdev_open() at zfs:vdev_open+0x9e
> > vdev_open_children() at zfs:vdev_open_children+0x39
> > vdev_root_open() at zfs:vdev_root_open+0x33
> > vdev_open() at zfs:vdev_open+0x9e
> > vdev_create() at zfs:vdev_create+0x1b
> > spa_create() at zfs:spa_create+0x28c
> > zfs_ioc_pool_create() at zfs:zfs_ioc_pool_create+0x19b
> > zfsdev_ioctl() at zfs:zfsdev_ioctl+0x265
> > nb_zfsdev_ioctl() at zfs:nb_zfsdev_ioctl+0x38
> > VOP_IOCTL() at netbsd:VOP_IOCTL+0x54
> > vn_ioctl() at netbsd:vn_ioctl+0xa5
> > sys_ioctl() at netbsd:sys_ioctl+0x5ab
> > syscall() at netbsd:syscall+0x157
> > --- syscall (number 54) ---
> > 7e047af6822a:
> > cpu0: End traceback...
> > 
> > Anyone seeing anything similar (I continue to have a bunch of other
> > boxes which use zfs without issue)
> > 
> > David
> 
> I don't know if it helps, but it looks like vn_close(vp,..) should be called 
> instead
> of vrele(vp) at
> 
>  
> https://nxr.netbsd.org/xref/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c#218
> 
> and
> 
>  
> https://nxr.netbsd.org/xref/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c#250

Unless I am mistaken, I think you are hitting the error path which
should probably call vn_close as below. My machine is a bit old, so
I have not even compile tested yet and there is still the question
of why/if you are in the error path.

If it does not help, apologies in advance!

-- 
Kind regards,

Yorick Hardy

Index: external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c
===================================================================
RCS file: /cvsroot/src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c,v
retrieving revision 1.18
diff -u -r1.18 vdev_disk.c
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c  25 Jun 2020 
09:39:15 -0000      1.18
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/vdev_disk.c  24 Nov 2020 
18:10:07 -0000
@@ -215,7 +215,8 @@
                return (SET_ERROR(error));
        }
        if (vp->v_type != VBLK) {
-               vrele(vp);
+               /* VN_RELE(vp); ?? */
+               vn_close(vp, FREAD|FWRITE, kcred);
                vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
                return (SET_ERROR(EINVAL));
        }
@@ -247,7 +248,8 @@
        error = workqueue_create(&dvd->vd_wq, "vdevsync",
            vdev_disk_flush, dvd, PRI_NONE, IPL_NONE, WQ_MPSAFE);
        if (error != 0) {
-               vrele(vp);
+               /* VN_RELE(vp); ?? */
+               vn_close(vp, FREAD|FWRITE, kcred);
                return (SET_ERROR(error));
        }
 

Reply via email to