Simplify the vfs_hash calling convention.
This commit is contained in:
parent
356eadcdd6
commit
e82ef95c11
@ -662,10 +662,8 @@ cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir)
|
||||
int error;
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
imp = VFSTOISOFS(mp);
|
||||
dev = imp->im_dev;
|
||||
@ -682,30 +680,12 @@ cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir)
|
||||
ip->i_dev = dev;
|
||||
ip->i_number = ino;
|
||||
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, curthread);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp != NULL) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (isodir == 0) {
|
||||
int lbn, off;
|
||||
|
||||
|
@ -459,16 +459,13 @@ hpfs_vget(
|
||||
struct vnode *vp;
|
||||
struct hpfsnode *hp;
|
||||
struct buf *bp;
|
||||
struct thread *td = curthread; /* XXX */
|
||||
int error;
|
||||
|
||||
dprintf(("hpfs_vget(0x%x): ",ino));
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
*vpp = NULL;
|
||||
hp = NULL;
|
||||
@ -516,30 +513,12 @@ hpfs_vget(
|
||||
hp->h_mode = hpmp->hpm_mode;
|
||||
hp->h_devvp = hpmp->hpm_devvp;
|
||||
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, td);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
VREF(hp->h_devvp);
|
||||
|
||||
error = bread(hpmp->hpm_devvp, ino, FNODESIZE, NOCRED, &bp);
|
||||
|
@ -98,7 +98,6 @@ deget(pmp, dirclust, diroffset, depp)
|
||||
struct denode *ldep;
|
||||
struct vnode *nvp, *xvp;
|
||||
struct buf *bp;
|
||||
struct thread *td = curthread; /* XXX */
|
||||
|
||||
hash = DEHASH(dirclust, diroffset);
|
||||
|
||||
@ -161,15 +160,6 @@ deget(pmp, dirclust, diroffset, depp)
|
||||
ldep->de_diroffset = diroffset;
|
||||
fc_purge(ldep, 0); /* init the fat cache for this denode */
|
||||
|
||||
/*
|
||||
* Lock the denode so that it can't be accessed until we've read
|
||||
* it in and have done what we need to it. Do this here instead
|
||||
* of at the start of msdosfs_hashins() so that reinsert() can
|
||||
* call msdosfs_hashins() with a locked denode.
|
||||
*/
|
||||
if (VOP_LOCK(nvp, LK_EXCLUSIVE, td) != 0)
|
||||
panic("deget: unexpected lock failure");
|
||||
|
||||
error = vfs_hash_insert(nvp, hash, 0, curthread, &xvp);
|
||||
if (error) {
|
||||
vput(nvp);
|
||||
|
@ -582,10 +582,8 @@ udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
|
||||
int error, sector, size;
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
td = curthread;
|
||||
udfmp = VFSTOUDFFS(mp);
|
||||
@ -605,30 +603,12 @@ udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
|
||||
unode->udfmp = udfmp;
|
||||
vp->v_data = unode;
|
||||
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, td);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp != NULL) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy in the file entry. Per the spec, the size can only be 1 block.
|
||||
*/
|
||||
|
@ -916,10 +916,8 @@ ext2_vget(mp, ino, flags, vpp)
|
||||
int used_blocks;
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
ump = VFSTOEXT2(mp);
|
||||
dev = ump->um_dev;
|
||||
@ -945,30 +943,12 @@ ext2_vget(mp, ino, flags, vpp)
|
||||
ip->i_dev = dev;
|
||||
ip->i_number = ino;
|
||||
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, curthread);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp != NULL) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Read in the disk contents for the inode, copy into the inode. */
|
||||
#if 0
|
||||
printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino)));
|
||||
|
@ -916,10 +916,8 @@ ext2_vget(mp, ino, flags, vpp)
|
||||
int used_blocks;
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
ump = VFSTOEXT2(mp);
|
||||
dev = ump->um_dev;
|
||||
@ -945,30 +943,12 @@ ext2_vget(mp, ino, flags, vpp)
|
||||
ip->i_dev = dev;
|
||||
ip->i_number = ino;
|
||||
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, curthread);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp != NULL) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Read in the disk contents for the inode, copy into the inode. */
|
||||
#if 0
|
||||
printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino)));
|
||||
|
@ -662,10 +662,8 @@ cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir)
|
||||
int error;
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
imp = VFSTOISOFS(mp);
|
||||
dev = imp->im_dev;
|
||||
@ -682,30 +680,12 @@ cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir)
|
||||
ip->i_dev = dev;
|
||||
ip->i_number = ino;
|
||||
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, curthread);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp != NULL) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (isodir == 0) {
|
||||
int lbn, off;
|
||||
|
||||
|
@ -102,6 +102,8 @@ vfs_hash_insert(struct vnode *vp, u_int hash, int flags, struct thread *td, stru
|
||||
struct vnode *vp2;
|
||||
int error;
|
||||
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, NULL, td);
|
||||
*vpp = NULL;
|
||||
while (1) {
|
||||
mtx_lock(&vfs_hash_mtx);
|
||||
LIST_FOREACH(vp2,
|
||||
@ -132,7 +134,6 @@ vfs_hash_insert(struct vnode *vp, u_int hash, int flags, struct thread *td, stru
|
||||
vp->v_iflag |= VI_HASHED;
|
||||
VI_UNLOCK(vp);
|
||||
mtx_unlock(&vfs_hash_mtx);
|
||||
*vpp = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,6 @@ ffs_vget(mp, ino, flags, vpp)
|
||||
int flags;
|
||||
struct vnode **vpp;
|
||||
{
|
||||
struct thread *td = curthread; /* XXX */
|
||||
struct fs *fs;
|
||||
struct inode *ip;
|
||||
struct ufsmount *ump;
|
||||
@ -1174,10 +1173,8 @@ ffs_vget(mp, ino, flags, vpp)
|
||||
int error;
|
||||
|
||||
error = vfs_hash_get(mp, ino, flags, curthread, vpp);
|
||||
if (error)
|
||||
if (error || *vpp != NULL)
|
||||
return (error);
|
||||
if (*vpp != NULL)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* We do not lock vnode creation as it is believed to be too
|
||||
@ -1227,30 +1224,13 @@ ffs_vget(mp, ino, flags, vpp)
|
||||
ip->i_dquot[i] = NODQUOT;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Exclusively lock the vnode before adding to hash. Note, that we
|
||||
* must not release nor downgrade the lock (despite flags argument
|
||||
* says) till it is fully initialized.
|
||||
*/
|
||||
lockmgr(vp->v_vnlock, LK_EXCLUSIVE, (struct mtx *)0, td);
|
||||
|
||||
/*
|
||||
* Atomicaly (in terms of vfs_hash operations) check the hash for
|
||||
* duplicate of vnode being created and add it to the hash. If a
|
||||
* duplicate vnode was found, it will be vget()ed from hash for us.
|
||||
*/
|
||||
if ((error = vfs_hash_insert(vp, ino, flags, curthread, vpp)) != 0) {
|
||||
error = vfs_hash_insert(vp, ino, flags, curthread, vpp);
|
||||
if (error || *vpp != NULL) {
|
||||
vput(vp);
|
||||
*vpp = NULL;
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* We lost the race, then throw away our vnode and return existing */
|
||||
if (*vpp != NULL) {
|
||||
vput(vp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Read in the disk contents for the inode, copy into the inode. */
|
||||
error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)),
|
||||
(int)fs->fs_bsize, NOCRED, &bp);
|
||||
|
Loading…
Reference in New Issue
Block a user