Commits

beck  committed 45a80d9

Keep mfs from potentially consuming the entire buffer cache if it gets
behind.
ok jsing@

  • Participants
  • Parent commits 8579b35

Comments (0)

Files changed (3)

File sys/ufs/mfs/mfs_vfsops.c

-/*	$OpenBSD: mfs_vfsops.c,v 1.43 2012/09/10 11:11:00 jsing Exp $	*/
+/*	$OpenBSD: mfs_vfsops.c,v 1.44 2012/12/29 14:54:11 beck Exp $	*/
 /*	$NetBSD: mfs_vfsops.c,v 1.10 1996/02/09 22:31:28 christos Exp $	*/
 
 /*
 	mfsp->mfs_size = args.size;
 	mfsp->mfs_vnode = devvp;
 	mfsp->mfs_pid = p->p_pid;
+	mfsp->mfs_numbufs = 0;
 	mfsp->mfs_buflist = (struct buf *)0;
 	if ((error = ffs_mountfs(devvp, mp, p)) != 0) {
 		mfsp->mfs_buflist = (struct buf *)-1;
 				break;
 			}
 			mfsp->mfs_buflist = bp->b_actf;
+			mfsp->mfs_numbufs--;
 			splx(s);
 			mfs_doio(mfsp, bp);
 			wakeup((caddr_t)bp);
+			wakeup(&mfsp->mfs_numbufs);
 		}
 		if (bp == (struct buf *)-1)
 			break;

File sys/ufs/mfs/mfs_vnops.c

-/*	$OpenBSD: mfs_vnops.c,v 1.42 2011/07/04 20:35:35 deraadt Exp $	*/
+/*	$OpenBSD: mfs_vnops.c,v 1.43 2012/12/29 14:54:11 beck Exp $	*/
 /*	$NetBSD: mfs_vnops.c,v 1.8 1996/03/17 02:16:32 christos Exp $	*/
 
 /*
 #include <sys/buf.h>
 #include <sys/vnode.h>
 #include <sys/malloc.h>
+#include <sys/mount.h>
 #include <sys/specdev.h>
 
 #include <machine/vmparam.h>
 	struct mfsnode *mfsp;
 	struct vnode *vp;
 	struct proc *p = curproc;
+	int bufmax;
 	int s;
 
+	/* Constrain queue to a sensible value. */
+	bufmax = MIN(256, bcstats.kvaslots / 16);
+	bufmax = MIN(bufmax, bcstats.numbufs / 16);
+
 	if (!vfinddev(bp->b_dev, VBLK, &vp) || vp->v_usecount == 0)
 		panic("mfs_strategy: bad dev");
 
 		mfs_doio(mfsp, bp);
 	} else {
 		s = splbio();
+		while (mfsp->mfs_numbufs > bufmax)
+			tsleep(&mfsp->mfs_numbufs, PRIBIO + 1, "mfsbufs", 0);
 		bp->b_actf = mfsp->mfs_buflist;
 		mfsp->mfs_buflist = bp;
+		mfsp->mfs_numbufs++;
 		splx(s);
 		wakeup((caddr_t)vp);
 	}

File sys/ufs/mfs/mfsnode.h

-/*	$OpenBSD: mfsnode.h,v 1.12 2008/04/24 17:39:45 thib Exp $	*/
+/*	$OpenBSD: mfsnode.h,v 1.13 2012/12/29 14:54:11 beck Exp $	*/
 /*	$NetBSD: mfsnode.h,v 1.3 1996/02/09 22:31:31 christos Exp $	*/
 
 /*
 	long	mfs_size;		/* size of memory file system */
 	pid_t	mfs_pid;		/* supporting process pid */
 	struct	buf *mfs_buflist;	/* list of I/O requests */
-	long	mfs_spare[4];
+	long	mfs_numbufs;		/* # of bufs on I/O request list */
+	long	mfs_spare[3];
 };
 
 /*