From 67a55598218e71bc64ac390e2aaaf64ecfef937b Mon Sep 17 00:00:00 2001 From: yamt Date: Tue, 23 Sep 2003 05:26:49 +0000 Subject: [PATCH] cleanup IN_ADIROP/VDIROP handling a little. --- sys/ufs/lfs/lfs_alloc.c | 20 ++++----------- sys/ufs/lfs/lfs_extern.h | 3 ++- sys/ufs/lfs/lfs_vnops.c | 53 ++++++++++++++++++++++------------------ 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/sys/ufs/lfs/lfs_alloc.c b/sys/ufs/lfs/lfs_alloc.c index f04eecdd4834..6469013b2350 100644 --- a/sys/ufs/lfs/lfs_alloc.c +++ b/sys/ufs/lfs/lfs_alloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_alloc.c,v 1.71 2003/08/07 16:34:34 agc Exp $ */ +/* $NetBSD: lfs_alloc.c,v 1.72 2003/09/23 05:26:49 yamt Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.71 2003/08/07 16:34:34 agc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.72 2003/09/23 05:26:49 yamt Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -199,12 +199,11 @@ lfs_rf_valloc(struct lfs *fs, ino_t ino, int version, struct proc *p, /* printf("lfs_rf_valloc: ino %d vp %p\n", ino, vp); */ /* The dirop-nature of this vnode is past */ + lfs_unmark_vnode(vp); (void)lfs_vunref(vp); --lfs_dirvcount; vp->v_flag &= ~VDIROP; TAILQ_REMOVE(&fs->lfs_dchainhd, ip, i_lfs_dchain); - --fs->lfs_nadirop; - ip->i_flag &= ~IN_ADIROP; } *vpp = vp; return error; @@ -392,16 +391,7 @@ lfs_ialloc(struct lfs *fs, struct vnode *pvp, ino_t new_ino, int new_gen, uvm_vnp_setsize(vp, 0); *vpp = vp; - if (!(vp->v_flag & VDIROP)) { - (void)lfs_vref(vp); - ++lfs_dirvcount; - TAILQ_INSERT_TAIL(&fs->lfs_dchainhd, ip, i_lfs_dchain); - } - vp->v_flag |= VDIROP; - - if (!(ip->i_flag & IN_ADIROP)) - ++fs->lfs_nadirop; - ip->i_flag |= IN_ADIROP; + lfs_mark_vnode(vp); genfs_node_init(vp, &lfs_genfsops); VREF(ip->i_devvp); /* Set superblock modified bit and increment file count. */ @@ -500,6 +490,7 @@ lfs_vfree(void *v) lfs_seglock(fs, SEGM_PROT); + lfs_unmark_vnode(vp); if (vp->v_flag & VDIROP) { --lfs_dirvcount; vp->v_flag &= ~VDIROP; @@ -507,7 +498,6 @@ lfs_vfree(void *v) wakeup(&lfs_dirvcount); lfs_vunref(vp); } - lfs_unmark_vnode(vp); LFS_CLR_UINO(ip, IN_ACCESSED|IN_CLEANING|IN_MODIFIED); ip->i_flag &= ~IN_ALLMOD; diff --git a/sys/ufs/lfs/lfs_extern.h b/sys/ufs/lfs/lfs_extern.h index 456970e4c1c0..ce850cc685ad 100644 --- a/sys/ufs/lfs/lfs_extern.h +++ b/sys/ufs/lfs/lfs_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_extern.h,v 1.53 2003/08/07 16:34:36 agc Exp $ */ +/* $NetBSD: lfs_extern.h,v 1.54 2003/09/23 05:26:49 yamt Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -220,6 +220,7 @@ int lfs_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); void lfs_vinit(struct mount *mp, struct vnode *); /* lfs_vnops.c */ +void lfs_mark_vnode(struct vnode *); void lfs_unmark_vnode(struct vnode *); void lfs_itimes(struct inode *, struct timespec *, struct timespec *, struct timespec *); diff --git a/sys/ufs/lfs/lfs_vnops.c b/sys/ufs/lfs/lfs_vnops.c index 785e0fa3741e..f9423ff675db 100644 --- a/sys/ufs/lfs/lfs_vnops.c +++ b/sys/ufs/lfs/lfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vnops.c,v 1.116 2003/09/23 05:26:13 yamt Exp $ */ +/* $NetBSD: lfs_vnops.c,v 1.117 2003/09/23 05:26:50 yamt Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.116 2003/09/23 05:26:13 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.117 2003/09/23 05:26:50 yamt Exp $"); #include #include @@ -452,33 +452,38 @@ unreserve: vrele(vp2); \ } -#define MARK_VNODE(dvp) do { \ - struct inode *_ip = VTOI(dvp); \ - struct lfs *_fs = _ip->i_lfs; \ - \ - if (!((dvp)->v_flag & VDIROP)) { \ - (void)lfs_vref(dvp); \ - ++lfs_dirvcount; \ - TAILQ_INSERT_TAIL(&_fs->lfs_dchainhd, _ip, i_lfs_dchain); \ - } \ - (dvp)->v_flag |= VDIROP; \ - if (!(_ip->i_flag & IN_ADIROP)) { \ - ++_fs->lfs_nadirop; \ - } \ - _ip->i_flag |= IN_ADIROP; \ -} while (0) +#define MARK_VNODE(vp) lfs_mark_vnode(vp) +#define UNMARK_VNODE(vp) lfs_unmark_vnode(vp) -#define UNMARK_VNODE(vp) lfs_unmark_vnode(vp) - -void lfs_unmark_vnode(struct vnode *vp) +void +lfs_mark_vnode(struct vnode *vp) { - struct inode *ip; + struct inode *ip = VTOI(vp); + struct lfs *fs = ip->i_lfs; - ip = VTOI(vp); + if (!(ip->i_flag & IN_ADIROP)) { + if (!(vp->v_flag & VDIROP)) { + (void)lfs_vref(vp); + ++lfs_dirvcount; + TAILQ_INSERT_TAIL(&fs->lfs_dchainhd, ip, i_lfs_dchain); + vp->v_flag |= VDIROP; + } + ++fs->lfs_nadirop; + ip->i_flag |= IN_ADIROP; + } else + KASSERT(vp->v_flag & VDIROP); +} - if (ip->i_flag & IN_ADIROP) +void +lfs_unmark_vnode(struct vnode *vp) +{ + struct inode *ip = VTOI(vp); + + if (ip->i_flag & IN_ADIROP) { + KASSERT(vp->v_flag & VDIROP); --ip->i_lfs->lfs_nadirop; - ip->i_flag &= ~IN_ADIROP; + ip->i_flag &= ~IN_ADIROP; + } } int