Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs cleanup IN_ADIROP/VDIROP handling a little.



details:   https://anonhg.NetBSD.org/src/rev/f63a2bb50b59
branches:  trunk
changeset: 552286:f63a2bb50b59
user:      yamt <yamt%NetBSD.org@localhost>
date:      Tue Sep 23 05:26:49 2003 +0000

description:
cleanup IN_ADIROP/VDIROP handling a little.

diffstat:

 sys/ufs/lfs/lfs_alloc.c  |  20 ++++-------------
 sys/ufs/lfs/lfs_extern.h |   3 +-
 sys/ufs/lfs/lfs_vnops.c  |  55 ++++++++++++++++++++++++++---------------------
 3 files changed, 37 insertions(+), 41 deletions(-)

diffs (163 lines):

diff -r bcaab5f667b3 -r f63a2bb50b59 sys/ufs/lfs/lfs_alloc.c
--- a/sys/ufs/lfs/lfs_alloc.c   Tue Sep 23 05:26:12 2003 +0000
+++ b/sys/ufs/lfs/lfs_alloc.c   Tue Sep 23 05:26:49 2003 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
                /* 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 @@
 
        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_seglock(fs, SEGM_PROT);
        
+       lfs_unmark_vnode(vp);
        if (vp->v_flag & VDIROP) {
                --lfs_dirvcount;
                vp->v_flag &= ~VDIROP;
@@ -507,7 +498,6 @@
                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 -r bcaab5f667b3 -r f63a2bb50b59 sys/ufs/lfs/lfs_extern.h
--- a/sys/ufs/lfs/lfs_extern.h  Tue Sep 23 05:26:12 2003 +0000
+++ b/sys/ufs/lfs/lfs_extern.h  Tue Sep 23 05:26:49 2003 +0000
@@ -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 @@
 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 -r bcaab5f667b3 -r f63a2bb50b59 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Tue Sep 23 05:26:12 2003 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Tue Sep 23 05:26:49 2003 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
 #include <sys/systm.h>
@@ -452,33 +452,38 @@
                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)
+
+void
+lfs_mark_vnode(struct vnode *vp)
+{
+       struct inode *ip = VTOI(vp);
+       struct lfs *fs = ip->i_lfs;
 
-#define UNMARK_VNODE(vp) lfs_unmark_vnode(vp)
-
-void lfs_unmark_vnode(struct vnode *vp)
-{
-       struct inode *ip;
+       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);
+}
 
-       ip = VTOI(vp);
+void
+lfs_unmark_vnode(struct vnode *vp)
+{
+       struct inode *ip = VTOI(vp);
 
-       if (ip->i_flag & IN_ADIROP)
+       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



Home | Main Index | Thread Index | Old Index