aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/unionfs
diff options
context:
space:
mode:
authorCraig Rodrigues <rodrigc@FreeBSD.org>2007-01-05 14:06:42 +0000
committerCraig Rodrigues <rodrigc@FreeBSD.org>2007-01-05 14:06:42 +0000
commitdda4f444debb70e747a22e8241f61624c238fa5e (patch)
treed3fe580901606fef897fe2747f133bc59f848682 /sys/fs/unionfs
parent3d2fff0d3d4555da66d98e8e097918ef00eb0413 (diff)
downloadsrc-dda4f444debb70e747a22e8241f61624c238fa5e.tar.gz
src-dda4f444debb70e747a22e8241f61624c238fa5e.zip
Simplify code in union_hashins() and union_hashget() functions. These
functions now more closely resemble similar functions in nullfs. This also eliminates some errors. Submitted by: daichi, Masanori OZAWA <ozawa ongs co jp>
Notes
Notes: svn path=/head/; revision=165804
Diffstat (limited to 'sys/fs/unionfs')
-rw-r--r--sys/fs/unionfs/union_subr.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 8968b6caf3d1..09e2f6d8c8ac 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -108,12 +108,12 @@ unionfs_hashget(struct mount *mp, struct vnode *uppervp,
struct unionfs_node_hashhead *hd;
struct unionfs_node *unp;
struct vnode *vp;
+ int error;
if (lkflags & LK_TYPE_MASK)
lkflags |= LK_RETRY;
hd = UNIONFS_NHASH(uppervp, lowervp);
-loop:
mtx_lock(&unionfs_hashmtx);
LIST_FOREACH(unp, hd, un_hash) {
if (unp->un_uppervp == uppervp &&
@@ -123,26 +123,18 @@ loop:
(!path || !(unp->un_path) || !strcmp(unp->un_path, path))) {
vp = UNIONFSTOV(unp);
VI_LOCK(vp);
-
- /*
- * If the unionfs node is being recycled we have to
- * wait until it finishes prior to scanning again.
- */
mtx_unlock(&unionfs_hashmtx);
- if (vp->v_iflag & VI_DOOMED) {
- /* Wait for recycling to finish. */
- vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, td);
- VOP_UNLOCK(vp, 0, td);
- goto loop;
- }
/*
* We need to clear the OWEINACT flag here as this
* may lead vget() to try to lock our vnode which is
* already locked via vp.
*/
vp->v_iflag &= ~VI_OWEINACT;
- vget(vp, lkflags | LK_INTERLOCK, td);
-
+ error = vget(vp, LK_INTERLOCK, td);
+ if (error != 0)
+ panic("unionfs_hashget: vget error %d", error);
+ if (lkflags & LK_TYPE_MASK)
+ vn_lock(vp, lkflags, td);
return (vp);
}
}
@@ -163,12 +155,12 @@ unionfs_hashins(struct mount *mp, struct unionfs_node *uncp,
struct unionfs_node_hashhead *hd;
struct unionfs_node *unp;
struct vnode *vp;
+ int error;
if (lkflags & LK_TYPE_MASK)
lkflags |= LK_RETRY;
hd = UNIONFS_NHASH(uncp->un_uppervp, uncp->un_lowervp);
-loop:
mtx_lock(&unionfs_hashmtx);
LIST_FOREACH(unp, hd, un_hash) {
if (unp->un_uppervp == uncp->un_uppervp &&
@@ -178,17 +170,13 @@ loop:
(!path || !(unp->un_path) || !strcmp(unp->un_path, path))) {
vp = UNIONFSTOV(unp);
VI_LOCK(vp);
-
mtx_unlock(&unionfs_hashmtx);
- if (vp->v_iflag & VI_DOOMED) {
- /* Wait for recycling to finish. */
- vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, td);
- VOP_UNLOCK(vp, 0, td);
- goto loop;
- }
vp->v_iflag &= ~VI_OWEINACT;
- vget(vp, lkflags | LK_INTERLOCK, td);
-
+ error = vget(vp, LK_INTERLOCK, td);
+ if (error)
+ panic("unionfs_hashins: vget error %d", error);
+ if (lkflags & LK_TYPE_MASK)
+ vn_lock(vp, lkflags, td);
return (vp);
}
}