describe ap (Kirk); delete lfs_mntinvalbuf, lfs_vinvalbuf, add
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 6 Jul 1992 05:39:39 +0000 (21:39 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 6 Jul 1992 05:39:39 +0000 (21:39 -0800)
lfs_seglock/unlock

SCCS-vsn: sys/ufs/lfs/lfs_subr.c 7.13

usr/src/sys/ufs/lfs/lfs_subr.c

index 71d1498..4e4d98c 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)lfs_subr.c  7.12 (Berkeley) %G%
+ *     @(#)lfs_subr.c  7.13 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
  * remaining space in the directory.
  */
 int
  * remaining space in the directory.
  */
 int
-lfs_blkatoff (ap)
-       struct vop_blkatoff_args *ap;
+lfs_blkatoff(ap)
+       struct vop_blkatoff_args /* {
+               struct vnode *a_vp;
+               off_t a_offset;
+               char **a_res;
+               struct buf **a_bpp;
+       } */ *ap;
 {
        register struct lfs *fs;
        struct inode *ip;
 {
        register struct lfs *fs;
        struct inode *ip;
@@ -49,70 +54,27 @@ lfs_blkatoff (ap)
        return (0);
 }
 
        return (0);
 }
 
-int
-lfs_mntinvalbuf(mp)
-       struct mount *mp;
+/*
+ * lfs_seglock --
+ *     Single thread the segment writer.
+ */
+void
+lfs_seglock(fs)
+       struct lfs *fs;
 {
 {
-       struct vnode *vp;
-       int dirty;
-
-       dirty = 0;
-       if ((mp->mnt_flag & MNT_MPBUSY) == 0)
-               panic("lfs_mntinvalbuf: not busy");
-loop:
-       for (vp = mp->mnt_mounth; vp; vp = vp->v_mountf) {
-               if (VTOI(vp)->i_number == LFS_IFILE_INUM)
-                       continue;
-               if (vget(vp))
-                       goto loop;
-               dirty += lfs_vinvalbuf(vp);
-               vput(vp);
-               if (vp->v_mount != mp)
-                       goto loop;
-       }
-       return (dirty);
+       while (fs->lfs_seglock)
+               (void)tsleep(&fs->lfs_seglock, PRIBIO + 1, "lfs seglock", 0);
+       fs->lfs_seglock = 1;
 }
 
 /*
 }
 
 /*
- * For LFS, we need to do two passes.  First we need to wait on any dirty and
- * busy buffers.  Once we've guaranteed that all the buffers are unbusy, we
- * can do the segment write.  Then we need to go through and invalidate all
- * the buffers on the clean list.
+ * lfs_segunlock --
+ *     Single thread the segment writer.
  */
  */
-int
-lfs_vinvalbuf(vp)
-       register struct vnode *vp;
+void
+lfs_segunlock(fs)
+       struct lfs *fs;
 {
 {
-       register struct buf *bp;
-       struct buf *nbp, *blist;
-       int s, dirty = 0;
-
-loop:  for (bp = vp->v_dirtyblkhd; bp; bp = nbp) {
-               nbp = bp->b_blockf;
-               s = splbio();
-               if (bp->b_flags & B_BUSY) {
-                       bp->b_flags |= B_WANTED;
-                       sleep((caddr_t)bp, PRIBIO + 1);
-                       splx(s);
-                       goto loop;
-               }
-               bremfree(bp);
-               splx(s);
-               dirty++;
-               brelse(bp);
-       }
-       if (dirty)
-               lfs_segwrite(vp->v_mount, 0);
-
-       /* Remove blocks from the clean list. */
-       for (bp = vp->v_cleanblkhd; bp; bp = nbp) {
-               nbp = bp->b_blockf;
-               bremfree(bp);
-               bp->b_flags |= B_INVAL;
-               brelse(bp);
-       }
-
-       if (vp->v_dirtyblkhd || vp->v_cleanblkhd)
-               panic("lfs_vinvalbuf: flush failed");
-       return (dirty);
+       fs->lfs_seglock = 0;
+       wakeup(&fs->lfs_seglock);       /* XXX: May not be necessary. */
 }
 }