Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111635891
D34071.id102075.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D34071.id102075.diff
View Options
diff --git a/share/man/man9/insmntque.9 b/share/man/man9/insmntque.9
--- a/share/man/man9/insmntque.9
+++ b/share/man/man9/insmntque.9
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 8, 2008
+.Dd January 29, 2022
.Dt INSMNTQUE 9
.Os
.Sh NAME
@@ -39,7 +39,7 @@
.Ft int
.Fn insmntque "struct vnode *vp" "struct mount *mp"
.Ft int
-.Fn insmntque1 "struct vnode *vp" "struct mount *mp" "void (*dtr)(struct vnode *, void *)" "void *dtr_arg"
+.Fn insmntque1 "struct vnode *vp" "struct mount *mp"
.Sh DESCRIPTION
The
.Fn insmntque
@@ -48,32 +48,33 @@
.Va v_mount
for the vnode, and inserting the vnode into the mount's vnode list.
.Pp
-The mount reference count is incremented for each vnode added to the
+The indirect mount reference count, maintained as the count of the
+vnodes owned by it, is incremented for each vnode added to the
mount, and that reference is decremented by
.Xr vgone 9 .
.Pp
The mount's interlock is held while the vnode is inserted.
-For MP-safe file systems, the vnode must be exclusively locked.
+The vnode must be exclusively locked.
.Pp
On failure,
.Fn insmntque
-calls
+resets vnode' operation vector to the vector of
+.Xr deadfs 9 ,
+clears
+.Va v_data ,
+and then calls
.Xr vgone 9
-on the supplied vnode, and then drops the vnode lock and reference.
+and
+.Xr vput 9 .
If more elaborated cleanup after
.Fn insmntque
failure is needed, the
.Fn insmntque1
function may be used instead.
-The
-.Fa dtr
-argument is a pointer to a function that is called on failure.
-This function may perform any custom cleanup.
-The vnode pointer is supplied as the first argument to
-.Fa dtr .
-The
-.Fa dtr_arg
-argument is the second, supplying any additional context needed.
+It does not do any cleanup, leaving all the work to the caller.
+In particular, the operation vector and
+.Va v_data
+of the vnode are kept intact.
.Sh RETURN VALUES
The
.Fn insmntque
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -507,18 +507,6 @@
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 @@
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
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -191,7 +191,7 @@
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
--- a/sys/fs/nullfs/null_subr.c
+++ b/sys/fs/nullfs/null_subr.c
@@ -235,7 +235,7 @@
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
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -822,21 +822,6 @@
}
}
-/*
- * 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 @@
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
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -386,7 +386,7 @@
vp->v_vflag |= VV_ROOT;
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
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1934,22 +1934,8 @@
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 @@
(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 @@
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
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -689,9 +689,8 @@
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);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 8:11 AM (19 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17028091
Default Alt Text
D34071.id102075.diff (6 KB)
Attached To
Mode
D34071: insmntque1(): remove useless arguments
Attached
Detach File
Event Timeline
Log In to Comment