Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/miscfs/kernfs Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/439106497042
branches:  netbsd-9
changeset: 744786:439106497042
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Feb 12 19:59:22 2020 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #702):

        sys/miscfs/kernfs/kernfs_vfsops.c: revision 1.98
        sys/miscfs/kernfs/kernfs_vnops.c: revision 1.163
        sys/miscfs/kernfs/kernfs.h: revision 1.43

Use specfs vnops for specnodes in kernfs.

While here, don't filter out rootdev and rrootdev merely because
they're not cached.

Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only
appeared sometimes when they felt like it, and fixes operations on
/kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP.

We didn't seem to have a single PR for these issues but the following
PRs are all relevant:

PR bin/13564
PR kern/38265
PR kern/38778
PR kern/45974

XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, p=
ullup-2, pullup-1.4T...

diffstat:

 sys/miscfs/kernfs/kernfs.h        |   3 +-
 sys/miscfs/kernfs/kernfs_vfsops.c |   7 ++-
 sys/miscfs/kernfs/kernfs_vnops.c  |  70 +++++++++++++++++++++++++++-----------
 3 files changed, 57 insertions(+), 23 deletions(-)

diffs (160 lines):

diff -r 0d540c963a7e -r 439106497042 sys/miscfs/kernfs/kernfs.h
--- a/sys/miscfs/kernfs/kernfs.h        Wed Feb 12 19:55:56 2020 +0000
+++ b/sys/miscfs/kernfs/kernfs.h        Wed Feb 12 19:59:22 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernfs.h,v 1.40 2014/07/20 13:58:04 hannken Exp $      */
+/*     $NetBSD: kernfs.h,v 1.40.32.1 2020/02/12 19:59:22 martin Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -121,6 +121,7 @@
 extern int nkern_targets;
 extern const int static_nkern_targets;
 extern int (**kernfs_vnodeop_p)(void *);
+extern int (**kernfs_specop_p)(void *);
 extern struct vfsops kernfs_vfsops;
 extern dev_t rrootdev;
 extern kmutex_t kfs_lock;
diff -r 0d540c963a7e -r 439106497042 sys/miscfs/kernfs/kernfs_vfsops.c
--- a/sys/miscfs/kernfs/kernfs_vfsops.c Wed Feb 12 19:55:56 2020 +0000
+++ b/sys/miscfs/kernfs/kernfs_vfsops.c Wed Feb 12 19:59:22 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $       */
+/*     $NetBSD: kernfs_vfsops.c,v 1.96.18.1 2020/02/12 19:59:22 martin Exp $   */
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.96.18.1 2020/02/12 19:59:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -283,6 +283,7 @@
                vp->v_vflag = VV_ROOT;
 
        if (kt->kt_tag == KFSdevice) {
+               vp->v_op = kernfs_specop_p;
                spec_node_init(vp, *(dev_t *)kt->kt_data);
        }
 
@@ -293,9 +294,11 @@
 }
 
 extern const struct vnodeopv_desc kernfs_vnodeop_opv_desc;
+extern const struct vnodeopv_desc kernfs_specop_opv_desc;
 
 const struct vnodeopv_desc * const kernfs_vnodeopv_descs[] = {
        &kernfs_vnodeop_opv_desc,
+       &kernfs_specop_opv_desc,
        NULL,
 };
 
diff -r 0d540c963a7e -r 439106497042 sys/miscfs/kernfs/kernfs_vnops.c
--- a/sys/miscfs/kernfs/kernfs_vnops.c  Wed Feb 12 19:55:56 2020 +0000
+++ b/sys/miscfs/kernfs/kernfs_vnops.c  Wed Feb 12 19:59:22 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernfs_vnops.c,v 1.160.4.1 2019/09/01 11:02:27 martin Exp $    */
+/*     $NetBSD: kernfs_vnops.c,v 1.160.4.2 2020/02/12 19:59:22 martin Exp $    */
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.160.4.1 2019/09/01 11:02:27 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.160.4.2 2020/02/12 19:59:22 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -227,6 +227,54 @@
 const struct vnodeopv_desc kernfs_vnodeop_opv_desc =
        { &kernfs_vnodeop_p, kernfs_vnodeop_entries };
 
+int (**kernfs_specop_p)(void *);
+const struct vnodeopv_entry_desc kernfs_specop_entries[] = {
+       { &vop_default_desc, vn_default_error },
+       { &vop_lookup_desc, spec_lookup },              /* lookup */
+       { &vop_create_desc, spec_create },              /* create */
+       { &vop_mknod_desc, spec_mknod },                /* mknod */
+       { &vop_open_desc, spec_open },                  /* open */
+       { &vop_close_desc, spec_close },                /* close */
+       { &vop_access_desc, kernfs_access },            /* access */
+       { &vop_getattr_desc, kernfs_getattr },          /* getattr */
+       { &vop_setattr_desc, kernfs_setattr },          /* setattr */
+       { &vop_read_desc, spec_read },                  /* read */
+       { &vop_write_desc, spec_write },                /* write */
+       { &vop_fallocate_desc, spec_fallocate },        /* fallocate */
+       { &vop_fdiscard_desc, spec_fdiscard },          /* fdiscard */
+       { &vop_fcntl_desc, spec_fcntl },                /* fcntl */
+       { &vop_ioctl_desc, spec_ioctl },                /* ioctl */
+       { &vop_poll_desc, spec_poll },                  /* poll */
+       { &vop_revoke_desc, spec_revoke },              /* revoke */
+       { &vop_fsync_desc, spec_fsync },                /* fsync */
+       { &vop_seek_desc, spec_seek },                  /* seek */
+       { &vop_remove_desc, spec_remove },              /* remove */
+       { &vop_link_desc, spec_link },                  /* link */
+       { &vop_rename_desc, spec_rename },              /* rename */
+       { &vop_mkdir_desc, spec_mkdir },                /* mkdir */
+       { &vop_rmdir_desc, spec_rmdir },                /* rmdir */
+       { &vop_symlink_desc, spec_symlink },            /* symlink */
+       { &vop_readdir_desc, spec_readdir },            /* readdir */
+       { &vop_readlink_desc, spec_readlink },          /* readlink */
+       { &vop_abortop_desc, spec_abortop },            /* abortop */
+       { &vop_inactive_desc, kernfs_inactive },        /* inactive */
+       { &vop_reclaim_desc, kernfs_reclaim },          /* reclaim */
+       { &vop_lock_desc, kernfs_lock },                /* lock */
+       { &vop_unlock_desc, kernfs_unlock },            /* unlock */
+       { &vop_bmap_desc, spec_bmap },                  /* bmap */
+       { &vop_strategy_desc, spec_strategy },          /* strategy */
+       { &vop_print_desc, kernfs_print },              /* print */
+       { &vop_islocked_desc, kernfs_islocked },        /* islocked */
+       { &vop_pathconf_desc, spec_pathconf },          /* pathconf */
+       { &vop_advlock_desc, spec_advlock },            /* advlock */
+       { &vop_bwrite_desc, spec_bwrite },              /* bwrite */
+       { &vop_getpages_desc, spec_getpages },          /* getpages */
+       { &vop_putpages_desc, spec_putpages },          /* putpages */
+       { NULL, NULL }
+};
+const struct vnodeopv_desc kernfs_specop_opv_desc =
+       { &kernfs_specop_p, kernfs_specop_entries };
+
 static inline int
 kernfs_fileop_compare(struct kernfs_fileop *a, struct kernfs_fileop *b)
 {
@@ -934,15 +982,6 @@
                                        break;
                                kt = &dkt->dkt_kt;
                        }
-                       if (kt->kt_tag == KFSdevice) {
-                               dev_t *dp = kt->kt_data;
-                               struct vnode *fvp;
-
-                               if (*dp == NODEV ||
-                                   !vfinddev(*dp, kt->kt_vtype, &fvp))
-                                       continue;
-                               vrele(fvp);
-                       }
                        if (kt->kt_tag == KFSmsgbuf) {
                                if (!logenabled(msgbufp)) {
                                        continue;
@@ -1016,15 +1055,6 @@
                                kt = &dkt->dkt_kt;
                                dkt = SIMPLEQ_NEXT(dkt, dkt_queue);
                        }
-                       if (kt->kt_tag == KFSdevice) {
-                               dev_t *dp = kt->kt_data;
-                               struct vnode *fvp;
-
-                               if (*dp == NODEV ||
-                                   !vfinddev(*dp, kt->kt_vtype, &fvp))
-                                       continue;
-                               vrele(fvp);
-                       }
                        d.d_namlen = kt->kt_namlen;
                        if ((error = kernfs_setdirentfileno(&d, i, kfs,
                            ks->ks_parent, kt, ap)) != 0)



Home | Main Index | Thread Index | Old Index