Source-Changes-HG archive

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

[src/fvdl-softdep]: src/sys Merge changes in the trickle-sync and softdep cod...



details:   https://anonhg.NetBSD.org/src/rev/b35cf712b865
branches:  fvdl-softdep
changeset: 477511:b35cf712b865
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Tue Oct 26 19:15:15 1999 +0000

description:
Merge changes in the trickle-sync and softdep code as done by Kirk McKusick
in FreeBSD since the version that we based the branch on. Merging mostly
done by Ethan Solomita <ethan%geocast.com@localhost>.

Also, make sure the syncer thread/process isn't active when we're
unmounting a filesystem. This could wreak havoc. XXX should be done
on a per-mountpoint basis, but especially the softdep code would
end up to be a big pile of vfs_busy() calls.

diffstat:

 sys/adosfs/advfsops.c            |    4 +-
 sys/filecorefs/filecore_vfsops.c |    5 +-
 sys/kern/vfs_subr.c              |   23 +-
 sys/kern/vfs_syscalls.c          |   17 +-
 sys/miscfs/specfs/specdev.h      |    8 +-
 sys/miscfs/syncfs/sync_subr.c    |   76 +++-
 sys/miscfs/syncfs/sync_vnops.c   |    8 +-
 sys/miscfs/syncfs/syncfs.h       |    9 +-
 sys/sys/buf.h                    |    4 +-
 sys/sys/vnode.h                  |   10 +-
 sys/ufs/ffs/ffs_extern.h         |    3 +-
 sys/ufs/ffs/ffs_inode.c          |   17 +-
 sys/ufs/ffs/ffs_softdep.c        |  642 ++++++++++++++++++++++++++++----------
 sys/ufs/ffs/ffs_softdep.stub.c   |    7 +
 sys/ufs/ffs/ffs_vnops.c          |   60 ++-
 sys/ufs/ffs/softdep.h            |    6 +-
 sys/ufs/ufs/ufs_lookup.c         |    4 +-
 17 files changed, 654 insertions(+), 249 deletions(-)

diffs (truncated from 1726 to 300 lines):

diff -r f387a758c6e1 -r b35cf712b865 sys/adosfs/advfsops.c
--- a/sys/adosfs/advfsops.c     Sat Oct 23 14:54:04 1999 +0000
+++ b/sys/adosfs/advfsops.c     Tue Oct 26 19:15:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advfsops.c,v 1.38 1999/10/18 19:52:24 wrstuden Exp $   */
+/*     $NetBSD: advfsops.c,v 1.38.4.1 1999/10/26 19:15:15 fvdl Exp $   */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -235,7 +235,6 @@
         mp->mnt_stat.f_fsid.val[0] = (long)devvp->v_rdev;
         mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_ADOSFS);
        mp->mnt_flag |= MNT_LOCAL;
-       devvp->v_specflags |= SI_MOUNTEDON;
 
        /*
         * init anode table.
@@ -300,7 +299,6 @@
        if ((error = vflush(mp, NULLVP, flags)) != 0)
                return (error);
        amp = VFSTOADOSFS(mp);
-       amp->devvp->v_specflags &= ~SI_MOUNTEDON;
        vn_lock(amp->devvp, LK_EXCLUSIVE | LK_RETRY);
        error = VOP_CLOSE(amp->devvp, FREAD, NOCRED, p);
        vput(amp->devvp);
diff -r f387a758c6e1 -r b35cf712b865 sys/filecorefs/filecore_vfsops.c
--- a/sys/filecorefs/filecore_vfsops.c  Sat Oct 23 14:54:04 1999 +0000
+++ b/sys/filecorefs/filecore_vfsops.c  Tue Oct 26 19:15:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_vfsops.c,v 1.8 1999/10/16 23:53:27 wrstuden Exp $     */
+/*     $NetBSD: filecore_vfsops.c,v 1.8.4.1 1999/10/26 19:15:16 fvdl Exp $     */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -335,8 +335,6 @@
                fcmp->fc_gid = argp->gid;
        }
        
-       devvp->v_specflags |= SI_MOUNTEDON;
-
        return 0;
 out:
        if (bp) {
@@ -393,7 +391,6 @@
 
        fcmp = VFSTOFILECORE(mp);
 
-       fcmp->fc_devvp->v_specflags &= ~SI_MOUNTEDON;
        vn_lock(fcmp->fc_devvp, LK_EXCLUSIVE | LK_RETRY);
        error = VOP_CLOSE(fcmp->fc_devvp, FREAD, NOCRED, p);
        vput(fcmp->fc_devvp);
diff -r f387a758c6e1 -r b35cf712b865 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Sat Oct 23 14:54:04 1999 +0000
+++ b/sys/kern/vfs_subr.c       Tue Oct 26 19:15:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.112.4.3 1999/10/23 14:54:04 fvdl Exp $  */
+/*     $NetBSD: vfs_subr.c,v 1.112.4.4 1999/10/26 19:15:16 fvdl Exp $  */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -753,7 +753,6 @@
        register struct buf *bp;
 {
        struct vnode *vp;
-       struct buf *wasdirty;
 
        if (bp->b_vp == (struct vnode *) 0)
                panic("brelvp: NULL");
@@ -761,11 +760,12 @@
        /*
         * Delete from old vnode list, if on one.
         */
-       wasdirty = vp->v_dirtyblkhd.lh_first;
        if (bp->b_vnbufs.le_next != NOLIST)
                bufremvn(bp);
-       if (wasdirty && LIST_FIRST(&vp->v_dirtyblkhd) == NULL)
+       if ((vp->v_flag & VONWORKLST) && LIST_FIRST(&vp->v_dirtyblkhd) == NULL) {
+               vp->v_flag &= ~VONWORKLST;
                LIST_REMOVE(vp, v_synclist);
+       }
        bp->b_vp = (struct vnode *) 0;
        HOLDRELE(vp);
 }
@@ -781,7 +781,6 @@
        struct vnode *newvp;
 {
        struct buflists *listheadp;
-       struct buf *wasdirty;
        int delay;
 
        if (newvp == NULL) {
@@ -791,7 +790,6 @@
        /*
         * Delete from old vnode list, if on one.
         */
-       wasdirty = newvp->v_dirtyblkhd.lh_first;
        if (bp->b_vnbufs.le_next != NOLIST)
                bufremvn(bp);
        /*
@@ -800,23 +798,26 @@
         */
        if ((bp->b_flags & B_DELWRI) == 0) {
                listheadp = &newvp->v_cleanblkhd;
-               if (wasdirty && LIST_FIRST(&newvp->v_dirtyblkhd) == NULL)
+               if ((newvp->v_flag & VONWORKLST) &&
+                   LIST_FIRST(&newvp->v_dirtyblkhd) == NULL) {
+                       newvp->v_flag &= ~VONWORKLST;
                        LIST_REMOVE(newvp, v_synclist);
+               }
        } else {
                listheadp = &newvp->v_dirtyblkhd;
-               if (LIST_FIRST(listheadp) == NULL) {
+               if ((newvp->v_flag & VONWORKLST) == 0) {
                        switch (newvp->v_type) {
                        case VDIR:
-                               delay = syncdelay / 3;
+                               delay = dirdelay;
                                break;
                        case VBLK:
                                if (newvp->v_specmountpoint != NULL) {
-                                       delay = syncdelay / 2;
+                                       delay = metadelay;
                                        break;
                                }
                                /* fall through */
                        default:
-                               delay = syncdelay;
+                               delay = filedelay;;
                        }
                        vn_syncer_add_to_worklist(newvp, delay);
                }
diff -r f387a758c6e1 -r b35cf712b865 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Sat Oct 23 14:54:04 1999 +0000
+++ b/sys/kern/vfs_syscalls.c   Tue Oct 26 19:15:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.147.4.4 1999/10/23 14:54:05 fvdl Exp $      */
+/*     $NetBSD: vfs_syscalls.c,v 1.147.4.5 1999/10/26 19:15:17 fvdl Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -476,9 +476,17 @@
        int async;
 
        simple_lock(&mountlist_slock);
+       vfs_unbusy(mp);
+       /*
+        * XXX Freeze syncer. This should really be done on a mountpoint
+        * basis, but especially the softdep code possibly called from
+        * the syncer doesn't exactly work on a per-mountpoint basis,
+        * so the softdep code would become a maze of vfs_busy calls.
+        */
+       lockmgr(&syncer_lock, LK_EXCLUSIVE, NULL);
+
        mp->mnt_flag |= MNT_UNMOUNT;
        mp->mnt_unmounter = p;
-       vfs_unbusy(mp);
        lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_slock);
        if (mp->mnt_flag & MNT_EXPUBLIC)
                vfs_setpublicfs(NULL, NULL, NULL);
@@ -500,6 +508,7 @@
                mp->mnt_flag |= async;
                lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK | LK_REENABLE,
                    &mountlist_slock);
+               lockmgr(&syncer_lock, LK_RELEASE, NULL);
                while(mp->mnt_wcnt > 0) {
                        wakeup((caddr_t)mp);
                        tsleep(&mp->mnt_wcnt, PVFS, "mntwcnt1", 0);
@@ -516,6 +525,7 @@
                panic("unmount: dangling vnode");
        mp->mnt_flag |= MNT_GONE;
        lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock);
+       lockmgr(&syncer_lock, LK_RELEASE, NULL);
        while(mp->mnt_wcnt > 0) {
                wakeup((caddr_t)mp);
                tsleep(&mp->mnt_wcnt, PVFS, "mntwcnt2", 0);
@@ -2662,7 +2672,8 @@
        vp = (struct vnode *)fp->f_data;
        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        error = VOP_FSYNC(vp, fp->f_cred, FSYNC_WAIT, p);
-       if (error == 0 && bioops.io_fsync != NULL)
+       if (error == 0 && bioops.io_fsync != NULL &&
+           vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP))
                (*bioops.io_fsync)(vp);
        VOP_UNLOCK(vp, 0);
        FILE_UNUSE(fp, p);
diff -r f387a758c6e1 -r b35cf712b865 sys/miscfs/specfs/specdev.h
--- a/sys/miscfs/specfs/specdev.h       Sat Oct 23 14:54:04 1999 +0000
+++ b/sys/miscfs/specfs/specdev.h       Tue Oct 26 19:15:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: specdev.h,v 1.17.16.1 1999/10/19 12:50:13 fvdl Exp $   */
+/*     $NetBSD: specdev.h,v 1.17.16.2 1999/10/26 19:15:18 fvdl Exp $   */
 
 /*
  * Copyright (c) 1990, 1993
@@ -53,16 +53,10 @@
 #define v_rdev         v_specinfo->si_rdev
 #define v_hashchain    v_specinfo->si_hashchain
 #define v_specnext     v_specinfo->si_specnext
-#define v_specflags    v_specinfo->si_flags
 #define v_speclockf    v_specinfo->si_lockf
 #define v_specmountpoint v_specinfo->si_mountpoint
 
 /*
- * Flags for specinfo
- */
-#define        SI_MOUNTEDON    0x0001  /* block special device is mounted on */
-
-/*
  * Special device management
  */
 #define        SPECHSZ 64
diff -r f387a758c6e1 -r b35cf712b865 sys/miscfs/syncfs/sync_subr.c
--- a/sys/miscfs/syncfs/sync_subr.c     Sat Oct 23 14:54:04 1999 +0000
+++ b/sys/miscfs/syncfs/sync_subr.c     Tue Oct 26 19:15:15 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sync_subr.c,v 1.1.2.1 1999/10/19 12:50:15 fvdl Exp $   */
+/*     $NetBSD: sync_subr.c,v 1.1.2.2 1999/10/26 19:15:18 fvdl Exp $   */
 
 /*
  * Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
@@ -49,12 +49,20 @@
  * Defines and variables for the syncer process. 
  */
 int syncer_maxdelay = SYNCER_MAXDELAY; /* maximum delay time */
-time_t syncdelay = 30;                 /* time to delay syncing vnodes */ 
-int rushjob;                           /* number of slots to run ASAP */ 
+time_t syncdelay = 30;                 /* max time to delay syncing data */ 
+time_t filedelay = 30;                 /* time to delay syncing files */
+time_t dirdelay  = 15;                 /* time to dely syncing directories */
+time_t metadelay = 10;                 /* time to delay syncing metadata */
+
+struct lock syncer_lock;               /* used to freeze syncer */
+
+static int rushjob;                    /* number of slots to run ASAP */ 
+static int stat_rush_requests;         /* number of times I/O speeded up */
  
 static int syncer_delayno = 0;
 static long syncer_last;
 static struct synclist *syncer_workitem_pending;
+static struct proc *updateproc = NULL;
 
 void
 vn_initialize_syncerd()
@@ -68,6 +76,8 @@
 
        for (i = 0; i < syncer_last; i++)
                LIST_INIT(&syncer_workitem_pending[i]);
+
+       lockinit(&syncer_lock, PVFS, "synclk", 0, 0);
 }
 
 /*
@@ -107,10 +117,17 @@
        int s, slot;
 
        s = splbio();
+
+       if (vp->v_flag & VONWORKLST) {
+               LIST_REMOVE(vp, v_synclist);
+       }
+
        if (delay > syncer_maxdelay - 2)
                delay = syncer_maxdelay - 2;
        slot = (syncer_delayno + delay) % syncer_last;
+
        LIST_INSERT_HEAD(&syncer_workitem_pending[slot], vp, v_synclist);
+       vp->v_flag |= VONWORKLST;
        splx(s);
 }
 
@@ -126,11 +143,14 @@
        long starttime;
        int s;
 
+       updateproc = curproc;
+       
        for (;;) {
                starttime = time.tv_sec;
 
                /*
-                * Push files whose dirty time has expired.
+                * Push files whose dirty time has expired. Be careful
+                * of interrupt race on slp queue.
                 */
                s = splbio();
                slp = &syncer_workitem_pending[syncer_delayno];
@@ -138,21 +158,31 @@
                if (syncer_delayno >= syncer_last)
                        syncer_delayno = 0;
                splx(s);
+
+               lockmgr(&syncer_lock, LK_EXCLUSIVE, NULL);
+
                while ((vp = LIST_FIRST(slp)) != NULL) {
-                       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-                       (void) VOP_FSYNC(vp, curproc->p_ucred, FSYNC_LAZY,
-                           curproc);
-                       VOP_UNLOCK(vp, 0);
+                       if (VOP_ISLOCKED(vp) == 0) {
+                               vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);



Home | Main Index | Thread Index | Old Index