summaryrefslogtreecommitdiff
path: root/sys/ufs/mfs
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2013-01-15 11:20:56 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2013-01-15 11:20:56 +0000
commite025eadc694f657db82487c03f667c17e3e398c1 (patch)
tree08764c5e761f9187d7e0f2b495012c8bbd754d84 /sys/ufs/mfs
parentb2285ef6912c5da6b5afb247bbe6881eacf36761 (diff)
Switch mfs to bufq. This simplifies the code, gives us queue limits for
free and uses FIFO queueing (rather than the current LIFO queueing). Tested by sthen@ ok beck@ krw@
Diffstat (limited to 'sys/ufs/mfs')
-rw-r--r--sys/ufs/mfs/mfs_vfsops.c29
-rw-r--r--sys/ufs/mfs/mfs_vnops.c50
-rw-r--r--sys/ufs/mfs/mfsnode.h8
3 files changed, 33 insertions, 54 deletions
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c
index 8ecee1a38d9..c29b924d14b 100644
--- a/sys/ufs/mfs/mfs_vfsops.c
+++ b/sys/ufs/mfs/mfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfs_vfsops.c,v 1.44 2012/12/29 14:54:11 beck Exp $ */
+/* $OpenBSD: mfs_vfsops.c,v 1.45 2013/01/15 11:20:55 jsing Exp $ */
/* $NetBSD: mfs_vfsops.c,v 1.10 1996/02/09 22:31:28 christos Exp $ */
/*
@@ -132,16 +132,15 @@ mfs_mount(struct mount *mp, const char *path, void *data,
if (checkalias(devvp, makedev(255, mfs_minor), (struct mount *)0))
panic("mfs_mount: dup dev");
mfs_minor++;
- mfsp = malloc(sizeof *mfsp, M_MFSNODE, M_WAITOK);
+ mfsp = malloc(sizeof *mfsp, M_MFSNODE, M_WAITOK | M_ZERO);
devvp->v_data = mfsp;
mfsp->mfs_baseoff = args.base;
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;
+ bufq_init(&mfsp->mfs_bufq, BUFQ_FIFO);
if ((error = ffs_mountfs(devvp, mp, p)) != 0) {
- mfsp->mfs_buflist = (struct buf *)-1;
+ mfsp->mfs_shutdown = 1;
vrele(devvp);
return (error);
}
@@ -175,25 +174,21 @@ mfs_start(struct mount *mp, int flags, struct proc *p)
struct vnode *vp = VFSTOUFS(mp)->um_devvp;
struct mfsnode *mfsp = VTOMFS(vp);
struct buf *bp;
- int sleepreturn = 0, s;
+ int sleepreturn = 0;
while (1) {
while (1) {
- s = splbio();
- bp = mfsp->mfs_buflist;
- if (bp == NULL || bp == (struct buf *)-1) {
- splx(s);
+ if (mfsp->mfs_shutdown == 1)
+ break;
+ bp = bufq_dequeue(&mfsp->mfs_bufq);
+ if (bp == NULL)
break;
- }
- mfsp->mfs_buflist = bp->b_actf;
- mfsp->mfs_numbufs--;
- splx(s);
mfs_doio(mfsp, bp);
- wakeup((caddr_t)bp);
- wakeup(&mfsp->mfs_numbufs);
+ wakeup(bp);
}
- if (bp == (struct buf *)-1)
+ if (mfsp->mfs_shutdown == 1)
break;
+
/*
* If a non-ignored signal is received, try to unmount.
* If that fails, clear the signal (it has been "processed"),
diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c
index 2d19f1658a3..b66a95f29d6 100644
--- a/sys/ufs/mfs/mfs_vnops.c
+++ b/sys/ufs/mfs/mfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfs_vnops.c,v 1.43 2012/12/29 14:54:11 beck Exp $ */
+/* $OpenBSD: mfs_vnops.c,v 1.44 2013/01/15 11:20:55 jsing Exp $ */
/* $NetBSD: mfs_vnops.c,v 1.8 1996/03/17 02:16:32 christos Exp $ */
/*
@@ -133,12 +133,6 @@ mfs_strategy(void *v)
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");
@@ -147,14 +141,8 @@ mfs_strategy(void *v)
if (p != NULL && mfsp->mfs_pid == p->p_pid) {
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);
+ bufq_queue(&mfsp->mfs_bufq, bp);
+ wakeup(vp);
}
return (0);
}
@@ -199,42 +187,39 @@ mfs_close(void *v)
struct vnode *vp = ap->a_vp;
struct mfsnode *mfsp = VTOMFS(vp);
struct buf *bp;
- int error, s;
+ int error;
/*
* Finish any pending I/O requests.
*/
while (1) {
- s = splbio();
- bp = mfsp->mfs_buflist;
- if (bp == NULL) {
- splx(s);
+ bp = bufq_dequeue(&mfsp->mfs_bufq);
+ if (bp == NULL)
break;
- }
- mfsp->mfs_buflist = bp->b_actf;
- splx(s);
mfs_doio(mfsp, bp);
- wakeup((caddr_t)bp);
+ wakeup(bp);
}
+
/*
- * On last close of a memory filesystem
- * we must invalidate any in core blocks, so that
- * we can free up its vnode.
+ * On last close of a memory filesystem we must invalidate any in
+ * core blocks, so that we can free up its vnode.
*/
if ((error = vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 0, 0)) != 0)
return (error);
+
#ifdef DIAGNOSTIC
/*
* There should be no way to have any more buffers on this vnode.
*/
- if (mfsp->mfs_buflist)
+ if (bufq_peek(&mfsp->mfs_bufq))
printf("mfs_close: dirty buffers\n");
#endif
+
/*
* Send a request to the filesystem server to exit.
*/
- mfsp->mfs_buflist = (struct buf *)(-1);
- wakeup((caddr_t)vp);
+ mfsp->mfs_shutdown = 1;
+ wakeup(vp);
return (0);
}
@@ -249,9 +234,8 @@ mfs_inactive(void *v)
#ifdef DIAGNOSTIC
struct mfsnode *mfsp = VTOMFS(ap->a_vp);
- if (mfsp->mfs_buflist && mfsp->mfs_buflist != (struct buf *)(-1))
- panic("mfs_inactive: not inactive (mfs_buflist %p)",
- mfsp->mfs_buflist);
+ if (mfsp->mfs_shutdown && bufq_peek(&mfsp->mfs_bufq))
+ panic("mfs_inactive: not inactive");
#endif
VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
return (0);
diff --git a/sys/ufs/mfs/mfsnode.h b/sys/ufs/mfs/mfsnode.h
index 0c5d89a1a76..644c72a2e8e 100644
--- a/sys/ufs/mfs/mfsnode.h
+++ b/sys/ufs/mfs/mfsnode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfsnode.h,v 1.13 2012/12/29 14:54:11 beck Exp $ */
+/* $OpenBSD: mfsnode.h,v 1.14 2013/01/15 11:20:55 jsing Exp $ */
/* $NetBSD: mfsnode.h,v 1.3 1996/02/09 22:31:31 christos Exp $ */
/*
@@ -37,13 +37,13 @@
*/
struct mfsnode {
- struct vnode *mfs_vnode; /* vnode associated with this mfsnode */
+ struct vnode *mfs_vnode; /* vnode associated with this mfsnode */
+ struct bufq mfs_bufq; /* bufq for MFS I/O */
caddr_t mfs_baseoff; /* base of file system in memory */
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_numbufs; /* # of bufs on I/O request list */
- long mfs_spare[3];
+ int mfs_shutdown; /* shutdown request */
};
/*