Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162421935
D4953.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D4953.diff
View Options
Index: sys/kern/vfs_subr.c
===================================================================
--- sys/kern/vfs_subr.c
+++ sys/kern/vfs_subr.c
@@ -104,6 +104,7 @@
static int vtryrecycle(struct vnode *vp);
static void v_init_counters(struct vnode *);
static void v_incr_usecount(struct vnode *);
+static void v_incr_usecount_locked(struct vnode *);
static void v_incr_devcount(struct vnode *);
static void v_decr_devcount(struct vnode *);
static void vnlru_free(int);
@@ -2371,6 +2372,20 @@
refcount_init(&vp->v_usecount, 1);
}
+static void
+v_incr_usecount_locked(struct vnode *vp)
+{
+
+ ASSERT_VI_LOCKED(vp, __func__);
+ if (vp->v_iflag & VI_OWEINACT) {
+ VNASSERT(vp->v_usecount == 0, vp,
+ ("vnode with usecount and VI_OWEINACT set"));
+ vp->v_iflag &= ~VI_OWEINACT;
+ }
+ refcount_acquire(&vp->v_usecount);
+ v_incr_devcount(vp);
+}
+
/*
* Increment the use and hold counts on the vnode, taking care to reference
* the driver's usecount if this is a chardev. The _vhold() will remove
@@ -2383,29 +2398,13 @@
ASSERT_VI_UNLOCKED(vp, __func__);
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
- if (vp->v_type == VCHR) {
- VI_LOCK(vp);
- _vhold(vp, true);
- if (vp->v_iflag & VI_OWEINACT) {
- VNASSERT(vp->v_usecount == 0, vp,
- ("vnode with usecount and VI_OWEINACT set"));
- vp->v_iflag &= ~VI_OWEINACT;
- }
- refcount_acquire(&vp->v_usecount);
- v_incr_devcount(vp);
- VI_UNLOCK(vp);
- return;
- }
-
- _vhold(vp, false);
- if (vfs_refcount_acquire_if_not_zero(&vp->v_usecount)) {
+ if (vp->v_type != VCHR &&
+ vfs_refcount_acquire_if_not_zero(&vp->v_usecount)) {
VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
("vnode with usecount and VI_OWEINACT set"));
} else {
VI_LOCK(vp);
- if (vp->v_iflag & VI_OWEINACT)
- vp->v_iflag &= ~VI_OWEINACT;
- refcount_acquire(&vp->v_usecount);
+ v_incr_usecount_locked(vp);
VI_UNLOCK(vp);
}
}
@@ -2520,9 +2519,19 @@
{
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
+ _vhold(vp, false);
v_incr_usecount(vp);
}
+void
+vrefl(struct vnode *vp)
+{
+
+ CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
+ _vhold(vp, true);
+ v_incr_usecount_locked(vp);
+}
+
/*
* Return reference count of a vnode.
*
Index: sys/sys/vnode.h
===================================================================
--- sys/sys/vnode.h
+++ sys/sys/vnode.h
@@ -823,6 +823,7 @@
void vput(struct vnode *vp);
void vrele(struct vnode *vp);
void vref(struct vnode *vp);
+void vrefl(struct vnode *vp);
int vrefcnt(struct vnode *vp);
void v_addpollinfo(struct vnode *vp);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jul 14, 2:54 AM (3 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35053618
Default Alt Text
D4953.diff (2 KB)
Attached To
Mode
D4953: Code de-dup for v_incr_usecount and vrefl().
Attached
Detach File
Event Timeline
Log In to Comment