Remove the non-functional "swap device" userland front-end to the

multiplexed underlying swap devices (/dev/drum).  The only thing it did
was to allow root to open /dev/drum, but not do anything with it.
Various utilities used to grovel around in here, but Matt has written
a much nicer (and clean) front-end to this for libkvm, and nothing uses
the old system any more.

The VM system was calling VOP_STRATEGY() on the vp of the first underlying
swap device (not the /dev/drum one, the first real device), and using
the VOP system to indirectly (and only) call swstrategy() to choose
an underlying device and enqueue it on that device.  I have changed it
to avoid diverting through the VOP system and to call the only possible
target directly, saving a little bit of time and some complexity.

In all, nothing much changes, except some scaffolding to support the
roundabout way of calling swstrategy() is gone.

Matt gave me the ok to do this some time ago, and I apologize for taking
so long to get around to it.
This commit is contained in:
Peter Wemm 1999-11-18 06:55:40 +00:00
parent 9e2ba5d186
commit cdacc6ab42
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53338
3 changed files with 14 additions and 82 deletions

View file

@ -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.

View file

@ -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_ */

View file

@ -54,40 +54,6 @@
#include <vm/vm_extern.h>
#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);
}