devfs: use vget_prep/vget_finish

Tested by:	pho
This commit is contained in:
Mateusz Guzik 2020-08-10 10:35:47 +00:00
parent 3ba0e51703
commit f9c13ab856
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364067

View file

@ -420,6 +420,7 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode,
struct cdev *dev;
struct devfs_mount *dmp;
struct cdevsw *dsw;
enum vgetstate vs;
dmp = VFSTODEVFS(mp);
if (de->de_flags & DE_DOOMED) {
@ -432,10 +433,10 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode,
mtx_lock(&devfs_de_interlock);
vp = de->de_vnode;
if (vp != NULL) {
VI_LOCK(vp);
vs = vget_prep(vp);
mtx_unlock(&devfs_de_interlock);
sx_xunlock(&dmp->dm_lock);
vget(vp, lockmode | LK_INTERLOCK | LK_RETRY, curthread);
vget_finish(vp, lockmode | LK_RETRY, vs);
sx_xlock(&dmp->dm_lock);
if (devfs_allocv_drop_refs(0, dmp, de)) {
vput(vp);
@ -1492,13 +1493,14 @@ devfs_revoke(struct vop_revoke_args *ap)
struct cdev *dev;
struct cdev_priv *cdp;
struct devfs_dirent *de;
enum vgetstate vs;
u_int i;
KASSERT((ap->a_flags & REVOKEALL) != 0, ("devfs_revoke !REVOKEALL"));
dev = vp->v_rdev;
cdp = cdev2priv(dev);
dev_lock();
cdp->cdp_inuse++;
dev_unlock();
@ -1521,17 +1523,16 @@ devfs_revoke(struct vop_revoke_args *ap)
vp2 = de->de_vnode;
if (vp2 != NULL) {
dev_unlock();
VI_LOCK(vp2);
vs = vget_prep(vp2);
mtx_unlock(&devfs_de_interlock);
if (vget(vp2, LK_EXCLUSIVE | LK_INTERLOCK,
curthread))
if (vget_finish(vp2, LK_EXCLUSIVE, vs) != 0)
goto loop;
vhold(vp2);
vgone(vp2);
vdrop(vp2);
vput(vp2);
break;
}
}
}
if (vp2 != NULL) {
continue;