From f0b5dad41d4fe0b891a9410a3c479cf6a5d10ad4 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Thu, 7 Jun 2007 22:58:38 +0000 Subject: [PATCH] Get rid of disklabel faking/processing. --- sys/dev/raid/vinum/vinumext.h | 4 +- sys/dev/raid/vinum/vinumio.c | 124 +----------------------------- sys/dev/raid/vinum/vinumioctl.c | 113 ++------------------------- sys/dev/raid/vinum/vinumrequest.c | 14 +--- sys/dev/raid/vinum/vinumvar.h | 4 +- 5 files changed, 13 insertions(+), 246 deletions(-) diff --git a/sys/dev/raid/vinum/vinumext.h b/sys/dev/raid/vinum/vinumext.h index 12341613cc..473681d529 100644 --- a/sys/dev/raid/vinum/vinumext.h +++ b/sys/dev/raid/vinum/vinumext.h @@ -35,7 +35,7 @@ * * $Id: vinumext.h,v 1.26 2000/05/16 07:38:08 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumext.h,v 1.25.2.3 2001/05/11 02:11:06 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumext.h,v 1.11 2006/12/22 23:26:24 swildner Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumext.h,v 1.12 2007/06/07 22:58:38 corecode Exp $ */ /* vinumext.h: external definitions */ @@ -184,14 +184,12 @@ void forceup(int plexno); void update_plex_state(int plexno); void update_volume_state(int volno); void invalidate_subdisks(struct plex *, enum sdstate); -void get_volume_label(char *name, int plexes, u_int64_t size, struct disklabel *lp); int write_volume_label(int); void start_object(struct vinum_ioctl_msg *); void stop_object(struct vinum_ioctl_msg *); void setstate(struct vinum_ioctl_msg *msg); void setstate_by_force(struct vinum_ioctl_msg *msg); void vinum_label(int); -int vinum_writedisklabel(struct volume *, struct disklabel *); int initsd(int, int); struct buf *parityrebuild(struct plex *, u_int64_t, int, enum parityop, struct rangelock **, off_t *); enum requeststatus sddownstate(struct request *rq); diff --git a/sys/dev/raid/vinum/vinumio.c b/sys/dev/raid/vinum/vinumio.c index e804a5e9f4..00ade9f383 100644 --- a/sys/dev/raid/vinum/vinumio.c +++ b/sys/dev/raid/vinum/vinumio.c @@ -35,7 +35,7 @@ * * $Id: vinumio.c,v 1.30 2000/05/10 23:23:30 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.52.2.6 2002/05/02 08:43:44 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumio.c,v 1.23 2007/05/15 17:50:56 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumio.c,v 1.24 2007/06/07 22:58:38 corecode Exp $ */ #include "vinumhdr.h" @@ -706,124 +706,6 @@ daemon_save_config(void) Free(config); } -/* - * Disk labels are a mess. The correct way to - * access them is with the DIOC[GSW]DINFO ioctls, - * but some programs, such as newfs, access the - * disk directly, so we have to write things - * there. We do this only on request. If a user - * request tries to read it directly, we fake up - * one on the fly. - */ - -/* - * get_volume_label returns a label structure to lp, which - * is allocated by the caller - */ -void -get_volume_label(char *name, int plexes, u_int64_t size, struct disklabel *lp) -{ - bzero(lp, sizeof(struct disklabel)); - - strncpy(lp->d_typename, "vinum", sizeof(lp->d_typename)); - lp->d_type = DTYPE_VINUM; - strncpy(lp->d_packname, name, min(sizeof(lp->d_packname), sizeof(name))); - lp->d_rpm = 14400 * plexes; /* to keep them guessing */ - lp->d_interleave = 1; - lp->d_flags = 0; - - /* - * A Vinum volume has a single track with all - * its sectors. - */ - lp->d_secsize = DEV_BSIZE; /* bytes per sector */ - lp->d_nsectors = size; /* data sectors per track */ - lp->d_ntracks = 1; /* tracks per cylinder */ - lp->d_ncylinders = 1; /* data cylinders per unit */ - lp->d_secpercyl = size; /* data sectors per cylinder */ - lp->d_secperunit = size; /* data sectors per unit */ - - lp->d_bbsize = BBSIZE; - lp->d_sbsize = SBSIZE; - - lp->d_magic = DISKMAGIC; - lp->d_magic2 = DISKMAGIC; - - /* - * Set up partitions a, b and c to be identical - * and the size of the volume. a is UFS, b is - * swap, c is nothing. - */ - lp->d_partitions[0].p_size = size; - lp->d_partitions[0].p_fsize = 1024; - lp->d_partitions[0].p_fstype = FS_BSDFFS; /* FreeBSD File System :-) */ - lp->d_partitions[0].p_fsize = 1024; /* FS fragment size */ - lp->d_partitions[0].p_frag = 8; /* and fragments per block */ - lp->d_partitions[SWAP_PART].p_size = size; - lp->d_partitions[SWAP_PART].p_fstype = FS_SWAP; /* swap partition */ - lp->d_partitions[LABEL_PART].p_size = size; - lp->d_npartitions = LABEL_PART + 1; - strncpy(lp->d_packname, name, min(sizeof(lp->d_packname), sizeof(name))); - lp->d_checksum = dkcksum(lp); -} - -/* Write a volume label. This implements the VINUM_LABEL ioctl. */ -int -write_volume_label(int volno) -{ - struct disklabel *lp; - struct buf *bp; - struct disklabel *dlp; - struct volume *vol; - int error; - cdev_t dev; - - lp = (struct disklabel *) Malloc((sizeof(struct disklabel) + (DEV_BSIZE - 1)) & (DEV_BSIZE - 1)); - if (lp == 0) - return ENOMEM; - - if ((unsigned) (volno) >= (unsigned) vinum_conf.volumes_allocated) /* invalid volume */ - return ENOENT; - - vol = &VOL[volno]; /* volume in question */ - if (vol->state <= volume_uninit) /* nothing there */ - return ENXIO; - else if (vol->state < volume_up) /* not accessible */ - return EIO; /* I/O error */ - - get_volume_label(vol->name, vol->plexes, vol->size, lp); /* get the label */ - - /* - * Now write to disk. This code is derived from the - * system writedisklabel (), which does silly things - * like reading the label and refusing to write - * unless it's already there. - */ - bp = geteblk((int) lp->d_secsize); /* get a buffer */ - dev = make_adhoc_dev(&vinum_ops, vol->volno); - bp->b_bio1.bio_offset = (off_t)LABELSECTOR * lp->d_secsize; - bp->b_bcount = lp->d_secsize; - bzero(bp->b_data, lp->d_secsize); - dlp = (struct disklabel *) bp->b_data; - *dlp = *lp; - bp->b_flags &= ~B_INVAL; - bp->b_cmd = BUF_CMD_WRITE; - - /* - * This should read: - * - * vinumstrategy (bp); - * - * Negotiate with phk to get it fixed. - */ - dev_dstrategy(dev, &bp->b_bio1); - error = biowait(bp); - bp->b_flags |= B_INVAL | B_AGE; - bp->b_flags &= ~B_ERROR; - brelse(bp); - return error; -} - /* Look at all disks on the system for vinum slices */ int vinum_scandisk(char *devicename[], int drives) @@ -891,7 +773,7 @@ vinum_scandisk(char *devicename[], int drives) if (has_slice && slice != has_slice) continue; - for (part = 'a'; part <= 'p'; part++) { + for (part = 'a'; part < 'a' + MAXPARTITIONS; part++) { if (has_part && part != has_part) continue; if (part == 'c') @@ -915,7 +797,7 @@ vinum_scandisk(char *devicename[], int drives) } } if (founddrive == 0 && has_slice == 0) { /* didn't find anything, */ - for (part = 'a'; part <= 'p'; part++) { /* try the compatibility partition */ + for (part = 'a'; part < 'a' + MAXPARTITIONS; part++) { /* try the compatibility partition */ if (has_part && has_part != part) continue; if (part == 'c') diff --git a/sys/dev/raid/vinum/vinumioctl.c b/sys/dev/raid/vinum/vinumioctl.c index 901290e519..92b09dc815 100644 --- a/sys/dev/raid/vinum/vinumioctl.c +++ b/sys/dev/raid/vinum/vinumioctl.c @@ -43,7 +43,7 @@ * * $Id: vinumioctl.c,v 1.14 2000/10/27 03:07:53 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumioctl.c,v 1.25.2.4 2002/02/03 00:44:19 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumioctl.c,v 1.8 2007/05/15 17:50:56 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumioctl.c,v 1.9 2007/06/07 22:58:38 corecode Exp $ */ #include "vinumhdr.h" @@ -68,11 +68,7 @@ vinumioctl(struct dev_ioctl_args *ap) cdev_t dev = ap->a_head.a_dev; u_long cmd = ap->a_cmd; caddr_t data = ap->a_data; - unsigned int objno; int error = 0; - struct sd *sd; - struct plex *plex; - struct volume *vol; unsigned int index; /* for transferring config info */ unsigned int sdno; /* for transferring config info */ int fe; /* free list element number */ @@ -313,6 +309,11 @@ vinumioctl(struct dev_ioctl_args *ap) } case VINUM_DRIVE_TYPE: + case VINUM_SD_TYPE: + case VINUM_RAWSD_TYPE: + case VINUM_RAWPLEX_TYPE: + case VINUM_PLEX_TYPE: + case VINUM_VOLUME_TYPE: default: log(LOG_WARNING, "vinumioctl: invalid ioctl from process %d (%s): %lx\n", @@ -320,108 +321,6 @@ vinumioctl(struct dev_ioctl_args *ap) curproc->p_comm, cmd); return EINVAL; - - case VINUM_SD_TYPE: - case VINUM_RAWSD_TYPE: - objno = Sdno(dev); - - sd = &SD[objno]; - - switch (cmd) { - case DIOCGDINFO: /* get disk label */ - get_volume_label(sd->name, 1, sd->sectors, (struct disklabel *) data); - break; - - /* - * We don't have this stuff on hardware, - * so just pretend to do it so that - * utilities don't get upset. - */ - case DIOCWDINFO: /* write partition info */ - case DIOCSDINFO: /* set partition info */ - return 0; /* not a titty */ - - default: - return ENOTTY; /* not my kind of ioctl */ - } - - return 0; /* pretend we did it */ - - case VINUM_RAWPLEX_TYPE: - case VINUM_PLEX_TYPE: - objno = Plexno(dev); - - plex = &PLEX[objno]; - - switch (cmd) { - case DIOCGDINFO: /* get disk label */ - get_volume_label(plex->name, 1, plex->length, (struct disklabel *) data); - break; - - /* - * We don't have this stuff on hardware, - * so just pretend to do it so that - * utilities don't get upset. - */ - case DIOCWDINFO: /* write partition info */ - case DIOCSDINFO: /* set partition info */ - return 0; /* not a titty */ - - default: - return ENOTTY; /* not my kind of ioctl */ - } - - return 0; /* pretend we did it */ - - case VINUM_VOLUME_TYPE: - objno = Volno(dev); - - if ((unsigned) objno >= (unsigned) vinum_conf.volumes_allocated) /* not a valid volume */ - return ENXIO; - vol = &VOL[objno]; - if (vol->state != volume_up) /* not up, */ - return EIO; /* I/O error */ - - switch (cmd) { - case DIOCGDINFO: /* get disk label */ - get_volume_label(vol->name, vol->plexes, vol->size, (struct disklabel *) data); - break; - - case DIOCGPART: /* get partition information */ - { - struct partinfo *dpart = (void *)data; - - bzero(dpart, sizeof(*dpart)); - dpart->media_offset = 0; - dpart->media_size = (u_int64_t)vol->size * DEV_BSIZE; - dpart->media_blocks = vol->size; - dpart->media_blksize = DEV_BSIZE; - dpart->fstype = FS_BSDFFS; - } - break; - - /* - * We don't have this stuff on hardware, - * so just pretend to do it so that - * utilities don't get upset. - */ - case DIOCWDINFO: /* write partition info */ - case DIOCSDINFO: /* set partition info */ - return 0; /* not a titty */ - - case DIOCWLABEL: /* set or reset label writeable */ - if ((ap->a_fflag & FWRITE) == 0) /* not writeable? */ - return EACCES; /* no, die */ - if (*(int *) data != 0) /* set it? */ - vol->flags |= VF_WLABEL; /* yes */ - else - vol->flags &= ~VF_WLABEL; /* no, reset */ - break; - - default: - return ENOTTY; /* not my kind of ioctl */ - } - break; } return 0; /* XXX */ } diff --git a/sys/dev/raid/vinum/vinumrequest.c b/sys/dev/raid/vinum/vinumrequest.c index f38c149fbc..a7a08ccbda 100644 --- a/sys/dev/raid/vinum/vinumrequest.c +++ b/sys/dev/raid/vinum/vinumrequest.c @@ -39,7 +39,7 @@ * * $Id: vinumrequest.c,v 1.30 2001/01/09 04:20:55 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumrequest.c,v 1.44.2.5 2002/08/28 04:30:56 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.18 2007/05/17 21:08:49 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.19 2007/06/07 22:58:38 corecode Exp $ */ #include "vinumhdr.h" @@ -1017,18 +1017,6 @@ vinum_bounds_check(struct bio *bio, struct volume *vol) int size = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT; /* size of this request (sectors) */ daddr_t blkno = (daddr_t)(bio->bio_offset >> DEV_BSHIFT); - /* Would this transfer overwrite the disk label? */ - if (blkno <= LABELSECTOR /* starts before or at the label */ -#if LABELSECTOR != 0 - && blkno + size > LABELSECTOR /* and finishes after */ -#endif - && (!(vol->flags & VF_RAW)) /* and it's not raw */ - && (bp->b_cmd != BUF_CMD_READ) /* and it's a write */ - &&(!vol->flags & (VF_WLABEL | VF_LABELLING))) { /* and we're not allowed to write the label */ - bp->b_error = EROFS; /* read-only */ - bp->b_flags |= B_ERROR; - return (NULL); - } if (size == 0) /* no transfer specified, */ return 0; /* treat as EOF */ /* beyond partition? */ diff --git a/sys/dev/raid/vinum/vinumvar.h b/sys/dev/raid/vinum/vinumvar.h index 1561174d62..a608107c51 100644 --- a/sys/dev/raid/vinum/vinumvar.h +++ b/sys/dev/raid/vinum/vinumvar.h @@ -39,7 +39,7 @@ * * $Id: vinumvar.h,v 1.24 2000/03/01 02:34:57 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumvar.h,v 1.32.2.4 2001/05/28 05:56:27 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumvar.h,v 1.10 2007/05/15 17:50:56 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumvar.h,v 1.11 2007/06/07 22:58:38 corecode Exp $ */ #include @@ -264,7 +264,7 @@ enum objflags { VF_OPEN = 4, /* object has openers */ VF_WRITETHROUGH = 8, /* volume: write through */ VF_INITED = 0x10, /* unit has been initialized */ - VF_WLABEL = 0x20, /* label area is writable */ + /* 0x20 unused, was: VF_WLABEL: label area is writable */ VF_LABELLING = 0x40, /* unit is currently being labelled */ VF_WANTED = 0x80, /* someone is waiting to obtain a lock */ VF_RAW = 0x100, /* raw volume (no file system) */ -- 2.41.0