Modify to work with new style dev_t.

With_copious_input_from:  peter
			  phk
This commit is contained in:
grog 1999-05-15 05:49:21 +00:00
parent 891aeb93bc
commit f834718a6b
11 changed files with 69 additions and 90 deletions

View File

@ -33,7 +33,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
* $Id: vinum.c,v 1.21 1999/05/07 08:07:08 grog Exp $
* $Id: vinum.c,v 1.24 1999/03/19 05:35:25 grog Exp grog $
*/
#define STATIC static /* nothing while we're testing XXX */
@ -266,13 +266,10 @@ vinumopen(dev_t dev,
struct volume *vol;
struct plex *plex;
struct sd *sd;
struct devcode *device;
device = (struct devcode *) &dev;
error = 0;
/* First, decide what we're looking at */
switch (device->type) {
switch (DEVTYPE(dev)) {
case VINUM_VOLUME_TYPE:
index = Volno(dev);
if (index >= vinum_conf.volumes_allocated)
@ -367,11 +364,10 @@ vinumclose(dev_t dev,
{
unsigned int index;
struct volume *vol;
struct devcode *device = (struct devcode *) &dev;
index = Volno(dev);
/* First, decide what we're looking at */
switch (device->type) {
switch (DEVTYPE(dev)) {
case VINUM_VOLUME_TYPE:
if (index >= vinum_conf.volumes_allocated)
return ENXIO; /* no such device */

View File

@ -1443,7 +1443,7 @@ config_volume(int update)
}
current_volume = volno; /* note last referred volume */
vol->devno = VINUMBDEV(volno, 0, 0, VINUM_VOLUME_TYPE); /* also note device number */
vol->volno = volno; /* also note in volume */
/*
* Before we can actually use the volume, we need

View File

@ -92,10 +92,11 @@ vinum_daemon(void)
struct request *rq = request->info.rq;
log(LOG_WARNING,
"vinumd: recovering I/O request: %x\n%s dev 0x%x, offset 0x%x, length %ld\n",
"vinumd: recovering I/O request: %x\n%s dev %d.%d, offset 0x%x, length %ld\n",
(u_int) rq,
rq->bp->b_flags & B_READ ? "Read" : "Write",
rq->bp->b_dev,
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
rq->bp->b_bcount);
}

View File

@ -33,7 +33,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
* $Id: vinumio.c,v 1.24 1999/05/07 10:10:04 phk Exp $
* $Id: vinumio.c,v 1.24 1999/03/23 02:00:52 grog Exp grog $
*/
#include <dev/vinum/vinumhdr.h>
@ -51,7 +51,6 @@ int
open_drive(struct drive *drive, struct proc *p, int verbose)
{
struct nameidata nd;
struct vattr va;
int error;
if (drive->devicename[0] != '/') /* no device name */
@ -77,21 +76,7 @@ open_drive(struct drive *drive, struct proc *p, int verbose)
drive->devicename,
drive->vp->v_usecount);
}
error = VOP_GETATTR(drive->vp, &va, NOCRED, drive->p);
if (error) {
VOP_UNLOCK(drive->vp, 0, drive->p);
close_drive(drive);
set_drive_state(drive->driveno, drive_down, setstate_force);
drive->lasterror = error;
if (verbose)
log(LOG_WARNING,
"vinum open_drive %s: GETAATTR returns error %d\n",
drive->devicename, error); /* XXX */
return error;
}
drive->dev = va.va_rdev; /* device */
if (va.va_type != VBLK) { /* only consider block devices */
if (drive->vp->v_type != VBLK) { /* only consider block devices */
VOP_UNLOCK(drive->vp, 0, drive->p);
close_drive(drive);
set_drive_state(drive->driveno, drive_down, setstate_force); /* this also closes the drive */
@ -285,12 +270,13 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag)
bp->b_bcount = len;
bp->b_bufsize = len;
(*bdevsw(bp->b_dev)->d_strategy) (bp); /* initiate the transfer */
(*bdevsw(bp->b_dev)->d_strategy) (bp); /* initiate the transfer */
error = biowait(bp);
printf("driveio: %s dev 0x%x, block 0x%x, len 0x%lx, error %d\n", /* XXX */
printf("driveio: %s dev %d.%d, block 0x%x, len 0x%lx, error %d\n", /* XXX */
flag ? "read" : "write",
bp->b_dev,
major(bp->b_dev),
minor(bp->b_dev),
bp->b_blkno,
bp->b_bcount,
error);
@ -905,7 +891,7 @@ write_volume_label(int volno)
* like reading the label and refusing to write
* unless it's already there. */
bp = geteblk((int) lp->d_secsize); /* get a buffer */
bp->b_dev = minor(vol->devno) | (CDEV_MAJOR << MAJORDEV_SHIFT); /* our own raw volume */
bp->b_dev = makedev(CDEV_MAJOR, vol->volno); /* our own raw volume */
bp->b_blkno = LABELSECTOR * ((int) lp->d_secsize / DEV_BSIZE);
bp->b_bcount = lp->d_secsize;
bzero(bp->b_data, lp->d_secsize);

View File

@ -71,10 +71,8 @@ vinumioctl(dev_t dev,
int fe; /* free list element number */
struct _ioctl_reply *ioctl_reply = (struct _ioctl_reply *) data; /* struct to return */
struct devcode *device = (struct devcode *) &dev;
/* First, decide what we're looking at */
switch (device->type) {
switch (DEVTYPE(dev)) {
case VINUM_SUPERDEV_TYPE: /* ordinary super device */
ioctl_reply = (struct _ioctl_reply *) data; /* save the address to reply to */
error = setjmp(command_fail); /* come back here on error */

View File

@ -120,7 +120,7 @@ lockvol(struct volume *vol)
* guarantee that this address won't change due to
* table expansion. The address we choose won't change.
*/
if ((error = tsleep(&vinum_conf.volume + vol->devno,
if ((error = tsleep(&vinum_conf.volume + vol->volno,
PRIBIO | PCATCH,
"volock",
0)) != 0)
@ -137,7 +137,7 @@ unlockvol(struct volume *vol)
vol->flags &= ~VF_LOCKED;
if ((vol->flags & VF_LOCKING) != 0) {
vol->flags &= ~VF_LOCKING;
wakeup(&vinum_conf.volume + vol->devno);
wakeup(&vinum_conf.volume + vol->volno);
}
}

View File

@ -57,7 +57,9 @@
*/
#include <sys/param.h>
#ifndef KERNEL
#ifdef KERNEL
#include <sys/systm.h>
#else
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>

View File

@ -33,7 +33,7 @@
* otherwise) arising in any way out of the use of this software, even if
* advised of the possibility of such damage.
*
* $Id: vinumrequest.c,v 1.22 1999/05/07 10:10:07 phk Exp $
* $Id: vinumrequest.c,v 1.23 1999/03/20 21:58:38 grog Exp grog $
*/
#include <dev/vinum/vinumhdr.h>
@ -104,9 +104,8 @@ vinumstrategy(struct buf *bp)
{
int volno;
struct volume *vol = NULL;
struct devcode *device = (struct devcode *) &bp->b_dev; /* decode device number */
switch (device->type) {
switch (DEVTYPE(bp->b_dev)) {
case VINUM_SD_TYPE:
case VINUM_RAWSD_TYPE:
sdio(bp);
@ -328,11 +327,12 @@ launch_requests(struct request *rq, int reviveok)
#if VINUMDEBUG
if (debug & DEBUG_REVIVECONFLICT)
log(LOG_DEBUG,
"Revive conflict sd %d: %x\n%s dev 0x%x, offset 0x%x, length %ld\n",
"Revive conflict sd %d: %x\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq->sdno,
(u_int) rq,
rq->bp->b_flags & B_READ ? "Read" : "Write",
rq->bp->b_dev,
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
rq->bp->b_bcount); /* XXX */
#endif
@ -348,10 +348,11 @@ launch_requests(struct request *rq, int reviveok)
#if VINUMDEBUG
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
"Request: %x\n%s dev 0x%x, offset 0x%x, length %ld\n",
"Request: %x\n%s dev %d.%d, offset 0x%x, length %ld\n",
(u_int) rq,
rq->bp->b_flags & B_READ ? "Read" : "Write",
rq->bp->b_dev,
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
rq->bp->b_bcount); /* XXX */
vinum_conf.lastrq = (int) rq;
@ -374,9 +375,10 @@ launch_requests(struct request *rq, int reviveok)
#if VINUMDEBUG
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
" %s dev 0x%x, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
rqe->b.b_flags & B_READ ? "Read" : "Write",
rqe->b.b_dev,
major(rqe->b.b_dev),
minor(rqe->b.b_dev),
rqe->sdno,
(u_int) (rqe->b.b_blkno - SD[rqe->sdno].driveoffset),
rqe->b.b_blkno,
@ -729,7 +731,7 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex)
* set B_ORDERED if so?
*/
bp->b_iodone = complete_rqe; /* by calling us here */
bp->b_dev = DRIVE[rqe->driveno].dev; /* drive device */
bp->b_dev = DRIVE[rqe->driveno].vp->v_rdev; /* drive device */
bp->b_blkno = rqe->sdoffset + sd->driveoffset; /* start address */
bp->b_bcount = rqe->buflen << DEV_BSHIFT; /* number of bytes to transfer */
bp->b_resid = bp->b_bcount; /* and it's still all waiting */
@ -824,7 +826,7 @@ sdio(struct buf *bp)
bcopy(bp, &sbp->b, sizeof(struct buf)); /* start with the user's buffer */
sbp->b.b_flags |= B_CALL; /* tell us when it's done */
sbp->b.b_iodone = sdio_done; /* here */
sbp->b.b_dev = DRIVE[sd->driveno].dev; /* device */
sbp->b.b_dev = DRIVE[sd->driveno].vp->v_rdev; /* device */
sbp->b.b_vp = DRIVE[sd->driveno].vp; /* vnode */
sbp->b.b_blkno += sd->driveoffset;
sbp->bp = bp; /* note the address of the original header */
@ -851,9 +853,10 @@ sdio(struct buf *bp)
#if VINUMDEBUG
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
" %s dev 0x%x, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
sbp->b.b_flags & B_READ ? "Read" : "Write",
sbp->b.b_dev,
major(sbp->b.b_dev),
minor(sbp->b.b_dev),
sbp->sdno,
(u_int) (sbp->b.b_blkno - SD[sbp->sdno].driveoffset),
(int) sbp->b.b_blkno,

View File

@ -168,11 +168,12 @@ revive_block(int sdno)
if (debug & DEBUG_REVIVECONFLICT)
log(LOG_DEBUG,
"Relaunch revive conflict sd %d: %x\n%s dev 0x%x, offset 0x%x, length %ld\n",
"Relaunch revive conflict sd %d: %x\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq->sdno,
(u_int) rq,
rq->bp->b_flags & B_READ ? "Read" : "Write",
rq->bp->b_dev,
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
rq->bp->b_bcount);
#endif

View File

@ -238,8 +238,7 @@ sizespec(char *spec)
int
Volno(dev_t dev)
{
int x = (int) dev;
return (x & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT;
return (minor(dev) & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT;
}
/*
@ -250,8 +249,6 @@ Volno(dev_t dev)
int
Plexno(dev_t dev)
{
int x = (int) dev;
switch (DEVTYPE(dev)) {
case VINUM_VOLUME_TYPE:
case VINUM_DRIVE_TYPE:
@ -261,11 +258,11 @@ Plexno(dev_t dev)
case VINUM_PLEX_TYPE:
case VINUM_SD_TYPE:
return VOL[Volno(x)].plex[(x >> VINUM_PLEX_SHIFT) & (MASK(VINUM_PLEX_WIDTH))];
return VOL[Volno(dev)].plex[(minor(dev) >> VINUM_PLEX_SHIFT) & (MASK(VINUM_PLEX_WIDTH))];
case VINUM_RAWPLEX_TYPE:
return ((x & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT) /* low order 8 bits */
|((x >> VINUM_RAWPLEX_SHIFT)
return ((minor(dev) & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT) /* low order 8 bits */
|((minor(dev) >> VINUM_RAWPLEX_SHIFT)
& (MASK(VINUM_RAWPLEX_WIDTH)
<< (VINUM_VOL_SHIFT + VINUM_VOL_WIDTH))); /* upper 12 bits */
}
@ -280,8 +277,6 @@ Plexno(dev_t dev)
int
Sdno(dev_t dev)
{
int x = (int) dev;
switch (DEVTYPE(dev)) {
case VINUM_VOLUME_TYPE:
case VINUM_DRIVE_TYPE:
@ -291,11 +286,11 @@ Sdno(dev_t dev)
return -1;
case VINUM_SD_TYPE:
return PLEX[Plexno(x)].sdnos[(x >> VINUM_SD_SHIFT) & (MASK(VINUM_SD_WIDTH))];
return PLEX[Plexno(dev)].sdnos[(minor(dev) >> VINUM_SD_SHIFT) & (MASK(VINUM_SD_WIDTH))];
case VINUM_RAWSD_TYPE:
return ((x & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT) /* low order 8 bits */
|((x >> VINUM_RAWPLEX_SHIFT) & (MASK(VINUM_RAWPLEX_WIDTH)
return ((minor(dev) & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT) /* low order 8 bits */
|((minor(dev) >> VINUM_RAWPLEX_SHIFT) & (MASK(VINUM_RAWPLEX_WIDTH)
<< (VINUM_VOL_SHIFT + VINUM_VOL_WIDTH))); /* upper 12 bits */
}
return -1; /* compiler paranoia */

View File

@ -92,32 +92,28 @@ enum constants {
MAXNAME = 64, /* maximum length of any name */
/* Create a block device number */
#define VINUMBDEV(v,p,s,t) ((BDEV_MAJOR << MAJORDEV_SHIFT) \
| (v << VINUM_VOL_SHIFT) \
| (p << VINUM_PLEX_SHIFT) \
| (s << VINUM_SD_SHIFT) \
| (t << VINUM_TYPE_SHIFT) )
#define VINUMMINOR(v,p,s,t) ( (v << VINUM_VOL_SHIFT) \
| (p << VINUM_PLEX_SHIFT) \
| (s << VINUM_SD_SHIFT) \
| (t << VINUM_TYPE_SHIFT) )
/* Create block and character device minor numbers */
#define VINUMBDEV(v,p,s,t) makedev (BDEV_MAJOR, VINUMMINOR (v, p, s, t))
#define VINUMCDEV(v,p,s,t) makedev (CDEV_MAJOR, VINUMMINOR (v, p, s, t))
/* Create a bit mask for x bits */
#define MASK(x) ((1 << (x)) - 1)
/* Create a raw block device number */
#define VINUMRBDEV(d,t) ((BDEV_MAJOR << MAJORDEV_SHIFT) \
| ((d & MASK (VINUM_VOL_WIDTH)) << VINUM_VOL_SHIFT) \
| ((d & ~MASK (VINUM_VOL_WIDTH)) \
<< (VINUM_PLEX_SHIFT + VINUM_VOL_WIDTH)) \
| (t << VINUM_TYPE_SHIFT) )
/* Create a raw block device minor number */
#define VINUMRMINOR(d,t) ( ((d & MASK (VINUM_VOL_WIDTH)) << VINUM_VOL_SHIFT) \
| ((d & ~MASK (VINUM_VOL_WIDTH)) \
<< (VINUM_PLEX_SHIFT + VINUM_VOL_WIDTH)) \
| (t << VINUM_TYPE_SHIFT) )
/* And a character device number */
#define VINUMCDEV(v,p,s,t) ((CDEV_MAJOR << MAJORDEV_SHIFT) \
| (v << VINUM_VOL_SHIFT) \
| (p << VINUM_PLEX_SHIFT) \
| (s << VINUM_SD_SHIFT) \
| (t << VINUM_TYPE_SHIFT) )
#define VINUMRBDEV(d,t) makedev (BDEV_MAJOR, VINUMRMINOR (d, t))
/* extract device type */
#define DEVTYPE(x) ((x >> VINUM_TYPE_SHIFT) & 7)
#define DEVTYPE(x) ((minor (x) >> VINUM_TYPE_SHIFT) & 7)
/*
* This mess is used to catch people who compile
@ -126,13 +122,14 @@ enum constants {
*/
#ifdef VINUMDEBUG
VINUM_SUPERDEV = VINUMBDEV(1, 0, 0, VINUM_SUPERDEV_TYPE), /* superdevice number */
VINUM_WRONGSUPERDEV = VINUMBDEV(2, 0, 0, VINUM_SUPERDEV_TYPE), /* non-debug superdevice number */
#define VINUM_SUPERDEV VINUMBDEV (1, 0, 0, VINUM_SUPERDEV_TYPE) /* superdevice number */
#define VINUM_WRONGSUPERDEV VINUMBDEV (2, 0, 0, VINUM_SUPERDEV_TYPE) /* non-debug superdevice number */
#else
VINUM_SUPERDEV = VINUMBDEV(2, 0, 0, VINUM_SUPERDEV_TYPE), /* superdevice number */
VINUM_WRONGSUPERDEV = VINUMBDEV(1, 0, 0, VINUM_SUPERDEV_TYPE), /* debug superdevice number */
#define VINUM_SUPERDEV VINUMBDEV (2, 0, 0, VINUM_SUPERDEV_TYPE) /* superdevice number */
#define VINUM_WRONGSUPERDEV VINUMBDEV (1, 0, 0, VINUM_SUPERDEV_TYPE) /* debug superdevice number */
#endif
VINUM_DAEMON_DEV = VINUMBDEV(0, 0, 0, VINUM_SUPERDEV_TYPE), /* daemon superdevice number */
#define VINUM_DAEMON_DEV VINUMBDEV (0, 0, 0, VINUM_SUPERDEV_TYPE) /* daemon superdevice number */
/*
* the number of object entries to cater for initially, and also the
@ -173,6 +170,7 @@ enum constants {
* raw subdisk: type, subdisk number is made of bits 27-16 and 7-0
*/
/* This doesn't get used. Consider removing it. */
struct devcode {
/*
* CARE. These fields assume a big-endian word. On a
@ -367,7 +365,6 @@ struct drive {
u_int64_t writes; /* number of writes on this drive */
u_int64_t bytes_read; /* number of bytes read */
u_int64_t bytes_written; /* number of bytes written */
dev_t dev; /* and device number */
char devicename[MAXDRIVENAME]; /* name of the slice it's on */
struct vnode *vp; /* vnode pointer */
struct proc *p;
@ -464,7 +461,7 @@ struct volume {
int preferred_plex; /* plex to read from, -1 for round-robin */
int last_plex_read; /* index of plex used for last read,
* for round-robin */
dev_t devno; /* device number */
int volno; /* volume number */
int flags; /* status and configuration flags */
int openflags; /* flags supplied to last open(2) */
u_int64_t size; /* size of volume */