diff options
-rw-r--r-- | sys/vm/swap_pager.c | 14 | ||||
-rw-r--r-- | sys/vm/swap_pager.h | 4 | ||||
-rw-r--r-- | sys/vm/vm_swap.c | 78 |
3 files changed, 14 insertions, 82 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 4807ddf..ba737e8 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1129,11 +1129,11 @@ swap_pager_getpages(object, m, count, reqpage) * The other pages in our m[] array are also released on completion, * so we cannot assume they are valid anymore either. * - * NOTE: b_blkno is destroyed by the call to VOP_STRATEGY + * NOTE: b_blkno is destroyed by the call to swstrategy() */ BUF_KERNPROC(bp); - VOP_STRATEGY(bp->b_vp, bp); + swstrategy(bp); /* * wait for the page we want to complete. PG_SWAPINPROG is always @@ -1186,7 +1186,7 @@ swap_pager_getpages(object, m, count, reqpage) * We support both OBJT_DEFAULT and OBJT_SWAP objects. DEFAULT objects * are automatically converted to SWAP objects. * - * In a low memory situation we may block in VOP_STRATEGY(), but the new + * In a low memory situation we may block in swstrategy(), but the new * vm_page reservation system coupled with properly written VFS devices * should ensure that no low-memory deadlock occurs. This is an area * which needs work. @@ -1380,13 +1380,13 @@ swap_pager_putpages(object, m, count, sync, rtvals) /* * asynchronous * - * NOTE: b_blkno is destroyed by the call to VOP_STRATEGY + * NOTE: b_blkno is destroyed by the call to swstrategy() */ if (sync == FALSE) { bp->b_iodone = swp_pager_async_iodone; BUF_KERNPROC(bp); - VOP_STRATEGY(bp->b_vp, bp); + swstrategy(bp); for (j = 0; j < n; ++j) rtvals[i+j] = VM_PAGER_PEND; @@ -1396,11 +1396,11 @@ swap_pager_putpages(object, m, count, sync, rtvals) /* * synchronous * - * NOTE: b_blkno is destroyed by the call to VOP_STRATEGY + * NOTE: b_blkno is destroyed by the call to swstrategy() */ bp->b_iodone = swp_pager_sync_iodone; - VOP_STRATEGY(bp->b_vp, bp); + swstrategy(bp); /* * Wait for the sync I/O to complete, then update rtvals. diff --git a/sys/vm/swap_pager.h b/sys/vm/swap_pager.h index 69bdbd1..308a6b1 100644 --- a/sys/vm/swap_pager.h +++ b/sys/vm/swap_pager.h @@ -104,6 +104,10 @@ int swap_pager_reserve __P((vm_object_t, vm_pindex_t, vm_size_t)); void swap_pager_page_removed __P((vm_page_t, vm_object_t)); +/* choose underlying swap device and queue up I/O */ +struct buf; +void swstrategy __P((struct buf *bp)); /* probably needs to move elsewhere */ + #endif #endif /* _SWAP_PAGER_ */ diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index f6d5084..4231fc2 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -55,40 +55,6 @@ #include <vm/swap_pager.h> /* - * "sw" is a fake device implemented - * in vm_swap.c and used only internally to get to swstrategy. - * It cannot be provided to the users, because the - * swstrategy routine munches the b_dev and b_blkno entries - * before calling the appropriate driver. This would horribly - * confuse, e.g. the hashing routines. Instead, /dev/drum is - * provided as a character (raw) device. - */ - -static d_open_t swopen; -static d_strategy_t swstrategy; - -#define CDEV_MAJOR 4 -#define BDEV_MAJOR 26 - -static struct cdevsw sw_cdevsw = { - /* open */ swopen, - /* close */ nullclose, - /* read */ noread, - /* write */ nowrite, - /* ioctl */ noioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ swstrategy, - /* name */ "sw", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ D_DISK, - /* bmaj */ BDEV_MAJOR -}; - - -/* * Indirect driver for multi-controller paging. */ @@ -110,21 +76,7 @@ int vm_swap_size; * The bp is expected to be locked and *not* B_DONE on call. */ -static int -swopen(dev, flag, mode, p) - dev_t dev; - int flag; - int mode; - struct proc *p; -{ - - if (mode == S_IFBLK || minor(dev) != 0) - return (ENXIO); - return (0); -} - - -static void +void swstrategy(bp) register struct buf *bp; { @@ -132,17 +84,6 @@ swstrategy(bp) register struct swdevt *sp; struct vnode *vp; - /* - * XXX: if we allow userland to come through, it will panic - * XXX: so use minor zero for userland and fail it right here - * XXX: and in noread/nowrite. - */ - if (minor(bp->b_dev) == 0) { - bp->b_error = EINVAL; - bp->b_flags |= B_ERROR; - biodone(bp); - return; - } sz = howmany(bp->b_bcount, PAGE_SIZE); /* * Convert interleaved swap into per-device swap. Note that @@ -224,12 +165,7 @@ swapon(p, uap) dev_t dev; struct nameidata nd; int error; - static int once; - if (!once) { - make_dev(&sw_cdevsw, 0, UID_ROOT, GID_KMEM, 0640, "drum"); - once++; - } error = suser(p); if (error) return (error); @@ -361,19 +297,11 @@ swaponvp(p, vp, dev, nblks) } if (!swapdev_vp) { - struct vnode *vp1; - struct vnode *nvp; - dev_t dev; - error = getnewvnode(VT_NON, (struct mount *) 0, - spec_vnodeop_p, &nvp); + spec_vnodeop_p, &swapdev_vp); if (error) panic("Cannot get vnode for swapdev"); - vp1 = nvp; - vp1->v_type = VBLK; - dev = make_dev(&sw_cdevsw, 1, UID_ROOT, GID_KMEM, 0640, "swapdev"); - addalias(vp1, dev); - swapdev_vp = vp1; + swapdev_vp->v_type = VBLK; } return (0); } |