On Fri, Aug 15, 2025 at 11:19:55AM -0700, Bakul Shah wrote:
> Is this a known bug or may be something specific on my machine?
> If the latter, any way to "fsck" it? FYI, the zpool is a mirror
> (two files on the host via nvme). built from c992ac621327 commit hash
> (which has other issues but they seem to be separate from this).
> I saw the same panic when I booted from a day old snapshot.
> 
> Note that "ls /.zfs" panics but "ls /.zfs/snapshot" doesn't!
> 
> This is on a -current VM:
> 
> root@:/ # ls .zfs
> VNASSERT failed: oresid == 0 || nresid != oresid || *(a)->a_eofflag == 1 not 
> true at vnode_if.c:1824 (VOP_READDIR_APV)

Try this, untested.

commit a97fc29bf2c03bbfc57b9c188ab3b24450d453bc
Author: Konstantin Belousov <[email protected]>
Date:   Sat Aug 16 01:50:42 2025 +0300

    zfs control dir: properly set eof

diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c 
b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
index 61d0bb26d1e5..725c02d47edf 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_ctldir.c
@@ -1056,17 +1056,22 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap)
        zfs_uio_t uio;
        int *eofp = ap->a_eofflag;
        off_t dots_offset;
+       offset_t orig_resid;
        int error;
 
        zfs_uio_init(&uio, ap->a_uio);
+       orig_resid = uio.uio->uio_resid;
 
        ASSERT3S(vp->v_type, ==, VDIR);
 
        error = sfs_readdir_common(ZFSCTL_INO_ROOT, ZFSCTL_INO_SNAPDIR, ap,
            &uio, &dots_offset);
        if (error != 0) {
-               if (error == ENAMETOOLONG) /* ran out of destination space */
+               if (error == ENAMETOOLONG) { /* ran out of destination space */
                        error = 0;
+                       if (orig_resid == uio.uio->uio_resid && eofp != NULL)
+                               *eofp = 1;
+               }
                return (error);
        }
 
@@ -1084,7 +1089,8 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap)
                dsl_pool_config_exit(dmu_objset_pool(zfsvfs->z_os), FTAG);
                if (error != 0) {
                        if (error == ENOENT) {
-                               if (eofp != NULL)
+                               if (orig_resid == uio.uio->uio_resid &&
+                                   eofp != NULL)
                                        *eofp = 1;
                                error = 0;
                        }
@@ -1099,8 +1105,12 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap)
                entry.d_reclen = sizeof (entry);
                error = vfs_read_dirent(ap, &entry, zfs_uio_offset(&uio));
                if (error != 0) {
-                       if (error == ENAMETOOLONG)
+                       if (error == ENAMETOOLONG) {
                                error = 0;
+                               if (orig_resid == uio.uio->uio_resid &&
+                                   eofp != NULL)
+                                       *eofp = 1;
+                       }
                        zfs_exit(zfsvfs, FTAG);
                        return (SET_ERROR(error));
                }

Reply via email to