diff options
author | phk <phk@FreeBSD.org> | 2005-03-15 08:07:07 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2005-03-15 08:07:07 +0000 |
commit | 124bf5e823dfe2ddde94c57660a3beffc2f99b57 (patch) | |
tree | 222a537cdd030d8083d8dae9e650ae3be7de0573 /sys | |
parent | a7b3bd456408d157545ff8c8ffd7060ae2070886 (diff) | |
download | FreeBSD-src-124bf5e823dfe2ddde94c57660a3beffc2f99b57.zip FreeBSD-src-124bf5e823dfe2ddde94c57660a3beffc2f99b57.tar.gz |
Simplify the vfs_hash calling convention.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/cd9660/cd9660_vfsops.c | 26 | ||||
-rw-r--r-- | sys/fs/hpfs/hpfs_vfsops.c | 27 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_denode.c | 10 | ||||
-rw-r--r-- | sys/fs/udf/udf_vfsops.c | 26 | ||||
-rw-r--r-- | sys/gnu/ext2fs/ext2_vfsops.c | 26 | ||||
-rw-r--r-- | sys/gnu/fs/ext2fs/ext2_vfsops.c | 26 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vfsops.c | 26 | ||||
-rw-r--r-- | sys/kern/vfs_hash.c | 3 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 26 |
9 files changed, 23 insertions, 173 deletions
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index bcbcae8..169df65 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -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; diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index ae96087..e3f24e9 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -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); diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index cddcd6c..d582a36 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -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); diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c index 6a9f9e7..60eaa7b 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -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. */ diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 81787f8..5c2fed4 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -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))); diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 81787f8..5c2fed4 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -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))); diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index bcbcae8..169df65 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -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; diff --git a/sys/kern/vfs_hash.c b/sys/kern/vfs_hash.c index 43d945e..5b77b1f 100644 --- a/sys/kern/vfs_hash.c +++ b/sys/kern/vfs_hash.c @@ -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); } diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index c551efb..950f14e 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -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); |