summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2005-03-15 08:07:07 +0000
committerphk <phk@FreeBSD.org>2005-03-15 08:07:07 +0000
commit124bf5e823dfe2ddde94c57660a3beffc2f99b57 (patch)
tree222a537cdd030d8083d8dae9e650ae3be7de0573 /sys/fs
parenta7b3bd456408d157545ff8c8ffd7060ae2070886 (diff)
downloadFreeBSD-src-124bf5e823dfe2ddde94c57660a3beffc2f99b57.zip
FreeBSD-src-124bf5e823dfe2ddde94c57660a3beffc2f99b57.tar.gz
Simplify the vfs_hash calling convention.
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/cd9660/cd9660_vfsops.c26
-rw-r--r--sys/fs/hpfs/hpfs_vfsops.c27
-rw-r--r--sys/fs/msdosfs/msdosfs_denode.c10
-rw-r--r--sys/fs/udf/udf_vfsops.c26
4 files changed, 9 insertions, 80 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.
*/
OpenPOWER on IntegriCloud