summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_swap.c
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1995-05-18 05:09:54 +0000
committerdg <dg@FreeBSD.org>1995-05-18 05:09:54 +0000
commit0856c15479a94dc9f8b3964a85ef6ebf7348894f (patch)
treefd998d10d846922c7be156770d15b51eec467d70 /sys/vm/vm_swap.c
parent8e24cb7a8783fa40f2c987ec244b1bcd1d89883d (diff)
downloadFreeBSD-src-0856c15479a94dc9f8b3964a85ef6ebf7348894f.zip
FreeBSD-src-0856c15479a94dc9f8b3964a85ef6ebf7348894f.tar.gz
Fixed a bug that managed to slip in during Poul's dynamic swap partition
changes. The check for nswap was bogus, but the code was so convoluted that it was difficult to tell. It's better now. :-) Reviewed by: David Greenman (extensively), and John Dyson Submitted by: Poul-Henning Kamp, w/tweaks by me.
Diffstat (limited to 'sys/vm/vm_swap.c')
-rw-r--r--sys/vm/vm_swap.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c
index 682d11a..d66fb01 100644
--- a/sys/vm/vm_swap.c
+++ b/sys/vm/vm_swap.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vm_swap.c 8.5 (Berkeley) 2/17/94
- * $Id: vm_swap.c,v 1.16 1995/05/12 03:54:59 phk Exp $
+ * $Id: vm_swap.c,v 1.17 1995/05/14 03:00:10 davidg Exp $
*/
#include <sys/param.h>
@@ -58,7 +58,7 @@
#endif
static struct swdevt should_be_malloced[NSWAPDEV];
struct swdevt *swdevt = should_be_malloced;
-int nswap;
+int nswap; /* first block after the interleaved devs */
int nswdev = NSWAPDEV;
int vm_swap_size;
int bswneeded;
@@ -73,12 +73,6 @@ swstrategy(bp)
struct vnode *vp;
sz = howmany(bp->b_bcount, DEV_BSIZE);
- if (bp->b_blkno + sz > nswap) {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- }
if (nswdev > 1) {
off = bp->b_blkno % dmmax;
if (off + sz > dmmax) {
@@ -94,6 +88,12 @@ swstrategy(bp)
} else
index = 0;
sp = &swdevt[index];
+ if (bp->b_blkno + sz > sp->sw_nblks) {
+ bp->b_error = EINVAL;
+ bp->b_flags |= B_ERROR;
+ biodone(bp);
+ return;
+ }
if ((bp->b_dev = sp->sw_dev) == NODEV)
panic("swstrategy");
if (sp->sw_vp == NULL) {
@@ -241,17 +241,11 @@ swaponvp(p, vp, dev, nblks)
sp->sw_nblks = nblks;
if (nblks * nswdev > nswap)
- nswap = nblks * nswdev;
+ nswap = (nblks+1) * nswdev;
for (dvbase = dmmax; dvbase < nblks; dvbase += dmmax) {
- blk = nblks - dvbase;
-
- if ((vsbase = index * dmmax + dvbase * nswdev) >= nswap)
- panic("swfree");
- if (blk > dmmax)
- blk = dmmax;
- /* XXX -- we need to exclude the first cluster as above */
- /* but for now, this will work fine... */
+ blk = min(nblks - dvbase,dmmax);
+ vsbase = index * dmmax + dvbase * nswdev;
rlist_free(&swaplist, vsbase, vsbase + blk - 1);
vm_swap_size += blk;
}
OpenPOWER on IntegriCloud