The branch main has been updated by kib:

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

commit 66c5fbca7719dca1ac361a010fa511a4514a662d
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2022-01-28 00:57:09 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2022-01-31 14:49:08 +0000

    insmntque1(): remove useless arguments
    
    Also remove once-used functions to clean up after failed insmntque1(),
    which were destructor callbacks in previous life.
    
    Reviewed by:    markj
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    Differential revision:  https://reviews.freebsd.org/D34071
---
 sys/fs/devfs/devfs_vnops.c   | 21 +++++++--------------
 sys/fs/fdescfs/fdesc_vnops.c |  2 +-
 sys/fs/nullfs/null_subr.c    |  2 +-
 sys/fs/tmpfs/tmpfs_subr.c    | 25 ++++++++-----------------
 sys/fs/unionfs/union_subr.c  |  2 +-
 sys/kern/vfs_subr.c          | 38 +++++++++++++++++++-------------------
 sys/sys/vnode.h              |  3 +--
 7 files changed, 38 insertions(+), 55 deletions(-)

diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 38d581db9154..d003820d4a3a 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -507,18 +507,6 @@ devfs_allocv_drop_refs(int drop_dm_lock, struct 
devfs_mount *dmp,
        return (not_found);
 }
 
-static void
-devfs_insmntque_dtr(struct vnode *vp, struct devfs_dirent *de)
-{
-
-       mtx_lock(&devfs_de_interlock);
-       vp->v_data = NULL;
-       de->de_vnode = NULL;
-       mtx_unlock(&devfs_de_interlock);
-       vgone(vp);
-       vput(vp);
-}
-
 /*
  * devfs_allocv shall be entered with dmp->dm_lock held, and it drops
  * it on return.
@@ -615,9 +603,14 @@ loop:
        vp->v_data = de;
        de->de_vnode = vp;
        mtx_unlock(&devfs_de_interlock);
-       error = insmntque1(vp, mp, NULL, NULL);
+       error = insmntque1(vp, mp);
        if (error != 0) {
-               devfs_insmntque_dtr(vp, de);
+               mtx_lock(&devfs_de_interlock);
+               vp->v_data = NULL;
+               de->de_vnode = NULL;
+               mtx_unlock(&devfs_de_interlock);
+               vgone(vp);
+               vput(vp);
                (void) devfs_allocv_drop_refs(1, dmp, de);
                return (error);
        }
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
index 1dead8f1153c..2fbdcac34583 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -191,7 +191,7 @@ loop:
        fd->fd_ix = ix;
        if (ftype == Fdesc && fmp->flags & FMNT_LINRDLNKF)
                vp->v_vflag |= VV_READLINK;
-       error = insmntque1(vp, mp, NULL, NULL);
+       error = insmntque1(vp, mp);
        if (error != 0) {
                vgone(vp);
                vput(vp);
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c
index acf77d5cfd47..6b422410b9ec 100644
--- a/sys/fs/nullfs/null_subr.c
+++ b/sys/fs/nullfs/null_subr.c
@@ -235,7 +235,7 @@ null_nodeget(struct mount *mp, struct vnode *lowervp, 
struct vnode **vpp)
        vp->v_type = lowervp->v_type;
        vp->v_data = xp;
        vp->v_vnlock = lowervp->v_vnlock;
-       error = insmntque1(vp, mp, NULL, NULL);
+       error = insmntque1(vp, mp);
        if (error != 0) {
                vput(lowervp);
                null_destroy_proto(vp, xp);
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index c6ac1b0bf357..a8f02c4284d2 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -822,21 +822,6 @@ tmpfs_destroy_vobject(struct vnode *vp, vm_object_t obj)
        }
 }
 
-/*
- * Need to clear v_object for insmntque failure.
- */
-static void
-tmpfs_insmntque_dtr(struct vnode *vp)
-{
-
-       tmpfs_destroy_vobject(vp, vp->v_object);
-       vp->v_object = NULL;
-       vp->v_data = NULL;
-       vp->v_op = &dead_vnodeops;
-       vgone(vp);
-       vput(vp);
-}
-
 /*
  * Allocates a new vnode for the node node or returns a new reference to
  * an existing one if the node had already a vnode referencing it.  The
@@ -983,9 +968,15 @@ loop:
        if (vp->v_type != VFIFO)
                VN_LOCK_ASHARE(vp);
 
-       error = insmntque1(vp, mp, NULL, NULL);
+       error = insmntque1(vp, mp);
        if (error != 0) {
-               tmpfs_insmntque_dtr(vp);
+               /* Need to clear v_object for insmntque failure. */
+               tmpfs_destroy_vobject(vp, vp->v_object);
+               vp->v_object = NULL;
+               vp->v_data = NULL;
+               vp->v_op = &dead_vnodeops;
+               vgone(vp);
+               vput(vp);
                vp = NULL;
        }
 
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 2b5754a560c7..557d4589df55 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -389,7 +389,7 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp,
            ("%s: NULL dvp for non-root vp %p", __func__, vp));
 
        vn_lock_pair(lowervp, false, uppervp, false); 
-       error = insmntque1(vp, mp, NULL, NULL);
+       error = insmntque1(vp, mp);
        if (error != 0) {
                unionfs_nodeget_cleanup(vp, unp);
                return (error);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 839282fe318f..94748a4a4858 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1934,22 +1934,8 @@ delmntque(struct vnode *vp)
        MNT_IUNLOCK(mp);
 }
 
-static void
-insmntque_stddtr(struct vnode *vp, void *dtr_arg)
-{
-
-       vp->v_data = NULL;
-       vp->v_op = &dead_vnodeops;
-       vgone(vp);
-       vput(vp);
-}
-
-/*
- * Insert into list of vnodes for the new mount point, if available.
- */
-int
-insmntque1(struct vnode *vp, struct mount *mp,
-       void (*dtr)(struct vnode *, void *), void *dtr_arg)
+static int
+insmntque1_int(struct vnode *vp, struct mount *mp, bool dtr)
 {
 
        KASSERT(vp->v_mount == NULL,
@@ -1974,8 +1960,12 @@ insmntque1(struct vnode *vp, struct mount *mp,
            (vp->v_vflag & VV_FORCEINSMQ) == 0) {
                VI_UNLOCK(vp);
                MNT_IUNLOCK(mp);
-               if (dtr != NULL)
-                       dtr(vp, dtr_arg);
+               if (dtr) {
+                       vp->v_data = NULL;
+                       vp->v_op = &dead_vnodeops;
+                       vgone(vp);
+                       vput(vp);
+               }
                return (EBUSY);
        }
        vp->v_mount = mp;
@@ -1989,11 +1979,21 @@ insmntque1(struct vnode *vp, struct mount *mp,
        return (0);
 }
 
+/*
+ * Insert into list of vnodes for the new mount point, if available.
+ * insmntque() reclaims the vnode on insertion failure, insmntque1()
+ * leaves handling of the vnode to the caller.
+ */
 int
 insmntque(struct vnode *vp, struct mount *mp)
 {
+       return (insmntque1_int(vp, mp, true));
+}
 
-       return (insmntque1(vp, mp, insmntque_stddtr, NULL));
+int
+insmntque1(struct vnode *vp, struct mount *mp)
+{
+       return (insmntque1_int(vp, mp, false));
 }
 
 /*
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index a1dbdcff4cb5..6e8373379587 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -689,9 +689,8 @@ int getnewvnode(const char *tag, struct mount *mp, struct 
vop_vector *vops,
            struct vnode **vpp);
 void   getnewvnode_reserve(void);
 void   getnewvnode_drop_reserve(void);
-int    insmntque1(struct vnode *vp, struct mount *mp,
-           void (*dtr)(struct vnode *, void *), void *dtr_arg);
 int    insmntque(struct vnode *vp, struct mount *mp);
+int    insmntque1(struct vnode *vp, struct mount *mp);
 u_quad_t init_va_filerev(void);
 int    speedup_syncer(void);
 int    vn_vptocnp(struct vnode **vp, char *buf, size_t *buflen);

Reply via email to