summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2003-06-14 23:27:29 +0000
committerdas <das@FreeBSD.org>2003-06-14 23:27:29 +0000
commitc07dc83d2b107dd072974998fcc61754849dfecc (patch)
treef4a04e29ebf023c3b89978dd65428dc4eeaf47ae /sys/fs
parent83f108b04dd3280195b5f0cf6bc2af10630e5f75 (diff)
downloadFreeBSD-src-c07dc83d2b107dd072974998fcc61754849dfecc.zip
FreeBSD-src-c07dc83d2b107dd072974998fcc61754849dfecc.tar.gz
Factor out the process of freeing ``directory caches'', which unionfs
directory vnodes use to refer to their constituent vnodes, into union_dircache_free(). Also s/union_dircache/union_dircache_get/ and tweak the structure of union_dircache_r(). MFC after: 3 days
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/unionfs/union.h3
-rw-r--r--sys/fs/unionfs/union_subr.c37
-rw-r--r--sys/fs/unionfs/union_vnops.c9
3 files changed, 25 insertions, 24 deletions
diff --git a/sys/fs/unionfs/union.h b/sys/fs/unionfs/union.h
index 58afd21..caca116 100644
--- a/sys/fs/unionfs/union.h
+++ b/sys/fs/unionfs/union.h
@@ -108,7 +108,8 @@ extern int union_allocvp(struct vnode **, struct mount *,
struct componentname *, struct vnode *,
struct vnode *, int);
extern int union_freevp(struct vnode *);
-extern struct vnode *union_dircache(struct vnode *, struct thread *);
+extern struct vnode *union_dircache_get(struct vnode *, struct thread *);
+extern void union_dircache_free(struct union_node *);
extern int union_copyup(struct union_node *, int, struct ucred *,
struct thread *);
extern int union_dowhiteout(struct union_node *, struct ucred *,
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 0777268..ae0323a 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -1173,12 +1173,8 @@ union_removed_upper(un)
* the union node from cache, so that it will not be referrenced.
*/
union_newupper(un, NULLVP);
- if (un->un_dircache != 0) {
- for (vpp = un->un_dircache; *vpp != NULLVP; vpp++)
- vrele(*vpp);
- free(un->un_dircache, M_TEMP);
- un->un_dircache = 0;
- }
+ if (un->un_dircache != NULL)
+ union_dircache_free(un);
if (un->un_flags & UN_CACHED) {
un->un_flags &= ~UN_CACHED;
@@ -1227,19 +1223,17 @@ union_dircache_r(vp, vppp, cntp)
} else {
(*cntp)++;
}
-
- return;
+ } else {
+ un = VTOUNION(vp);
+ if (un->un_uppervp != NULLVP)
+ union_dircache_r(un->un_uppervp, vppp, cntp);
+ if (un->un_lowervp != NULLVP)
+ union_dircache_r(un->un_lowervp, vppp, cntp);
}
-
- un = VTOUNION(vp);
- if (un->un_uppervp != NULLVP)
- union_dircache_r(un->un_uppervp, vppp, cntp);
- if (un->un_lowervp != NULLVP)
- union_dircache_r(un->un_lowervp, vppp, cntp);
}
struct vnode *
-union_dircache(vp, td)
+union_dircache_get(vp, td)
struct vnode *vp;
struct thread *td;
{
@@ -1305,6 +1299,17 @@ out:
return (nvp);
}
+void
+union_dircache_free(struct union_node *un)
+{
+ struct vnode **vpp;
+
+ for (vpp = un->un_dircache; *vpp != NULLVP; vpp++)
+ vrele(*vpp);
+ free(un->un_dircache, M_TEMP);
+ un->un_dircache = NULL;
+}
+
/*
* Module glue to remove #ifdef UNION from vfs_syscalls.c
*/
@@ -1316,7 +1321,7 @@ union_dircheck(struct thread *td, struct vnode **vp, struct file *fp)
if ((*vp)->v_op == union_vnodeop_p) {
struct vnode *lvp;
- lvp = union_dircache(*vp, td);
+ lvp = union_dircache_get(*vp, td);
if (lvp != NULLVP) {
struct vattr va;
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
index d8e07bf..65714cd 100644
--- a/sys/fs/unionfs/union_vnops.c
+++ b/sys/fs/unionfs/union_vnops.c
@@ -1655,7 +1655,6 @@ union_inactive(ap)
struct vnode *vp = ap->a_vp;
struct thread *td = ap->a_td;
struct union_node *un = VTOUNION(vp);
- struct vnode **vpp;
/*
* Do nothing (and _don't_ bypass).
@@ -1665,12 +1664,8 @@ union_inactive(ap)
*
*/
- if (un->un_dircache != 0) {
- for (vpp = un->un_dircache; *vpp != NULLVP; vpp++)
- vrele(*vpp);
- free (un->un_dircache, M_TEMP);
- un->un_dircache = 0;
- }
+ if (un->un_dircache != NULL)
+ union_dircache_free(un);
#if 0
if ((un->un_flags & UN_ULOCK) && un->un_uppervp) {
OpenPOWER on IntegriCloud