mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-21 15:45:02 +00:00
Remove "to do" comments.
get_emppty_drive: Fix a day one bug with strcpy parameters. Change name of find_drive_by_dev to the more descriptive find_drive_by_name. Rewrite minor number decoding. Now we have only three types of object: subdisks, plexes and volumes. The encoding for plexes and subdisks no longer reflects the object to which they belong. The super devices are high-order volume numbers. This gives vastly more potential volumes (4 million instead of 256).
This commit is contained in:
parent
47f9c49661
commit
d55f8bc42e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114351
@ -1,15 +1,3 @@
|
||||
/*
|
||||
* To do:
|
||||
*
|
||||
* Don't store drive configuration on the config DB: read each drive's header
|
||||
* to decide where it is.
|
||||
*
|
||||
* Accept any old crap in the config_<foo> functions, and complain when
|
||||
* we try to bring it up.
|
||||
*
|
||||
* When trying to bring volumes up, check that the complete address range
|
||||
* is covered.
|
||||
*/
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998
|
||||
* Nan Yang Computer Services Limited. All rights reserved.
|
||||
@ -45,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: vinumconfig.c,v 1.30 2000/05/01 09:45:50 grog Exp grog $
|
||||
* $Id: vinumconfig.c,v 1.38 2003/04/28 02:54:07 grog Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
@ -85,10 +73,11 @@ struct putchar_arg {
|
||||
|
||||
#define MSG_MAX 1024 /* maximum length of a formatted message */
|
||||
/*
|
||||
* Format an error message and return to the user in the reply.
|
||||
* CARE: This routine is designed to be called only from the
|
||||
* configuration routines, so it assumes it's the owner of
|
||||
* the configuration lock, and unlocks it on exit
|
||||
* Format an error message and return to the user
|
||||
* in the reply. CARE: This routine is designed
|
||||
* to be called only from the configuration
|
||||
* routines, so it assumes it's the owner of the
|
||||
* configuration lock, and unlocks it on exit.
|
||||
*/
|
||||
void
|
||||
throw_rude_remark(int error, char *msg,...)
|
||||
@ -99,8 +88,8 @@ throw_rude_remark(int error, char *msg,...)
|
||||
static int finishing; /* don't recurse */
|
||||
int was_finishing;
|
||||
|
||||
if ((vinum_conf.flags & VF_LOCKED) == 0) /* bug catcher */
|
||||
panic ("throw_rude_remark: called without config lock");
|
||||
if ((vinum_conf.flags & VF_LOCKED) == 0) /* bug catcher */
|
||||
panic("throw_rude_remark: called without config lock");
|
||||
va_start(ap, msg);
|
||||
if ((ioctl_reply != NULL) /* we're called from the user */
|
||||
&&(!(vinum_conf.flags & VF_READING_CONFIG))) { /* and not reading from disk: return msg */
|
||||
@ -139,9 +128,9 @@ throw_rude_remark(int error, char *msg,...)
|
||||
/*
|
||||
* We have a problem here: we want to unlock the
|
||||
* configuration, which implies tidying up, but
|
||||
* if we find an error while tidying up, we could
|
||||
* recurse for ever. Use this kludge to only try
|
||||
* once
|
||||
* if we find an error while tidying up, we
|
||||
* could recurse for ever. Use this kludge to
|
||||
* only try once.
|
||||
*/
|
||||
was_finishing = finishing;
|
||||
finishing = 1;
|
||||
@ -472,7 +461,7 @@ get_empty_drive(void)
|
||||
bzero(drive, sizeof(struct drive));
|
||||
drive->driveno = driveno; /* put number in structure */
|
||||
drive->flags |= VF_NEWBORN; /* newly born drive */
|
||||
strcpy("unknown", drive->devicename); /* and make the name ``unknown'' */
|
||||
strcpy(drive->devicename, "unknown"); /* and make the name ``unknown'' */
|
||||
return driveno; /* return the index */
|
||||
}
|
||||
|
||||
@ -519,7 +508,7 @@ find_drive(const char *name, int create)
|
||||
* Otherwise the same as find_drive above
|
||||
*/
|
||||
int
|
||||
find_drive_by_dev(const char *devname, int create)
|
||||
find_drive_by_name(const char *devname, int create)
|
||||
{
|
||||
int driveno;
|
||||
struct drive *drive;
|
||||
@ -562,6 +551,11 @@ get_empty_sd(void)
|
||||
* We've run out of space. sdno is pointing
|
||||
* where we want it, but at the moment we
|
||||
* don't have the space. Get it.
|
||||
*
|
||||
* XXX We should check for overflow here. We
|
||||
* shouldn't allocate more than VINUM_MAXSD
|
||||
* subdisks (currently at least a quarter of a
|
||||
* million).
|
||||
*/
|
||||
EXPAND(SD, struct sd, vinum_conf.subdisks_allocated, INITIAL_SUBDISKS);
|
||||
|
||||
@ -814,7 +808,7 @@ free_plex(int plexno)
|
||||
Free(plex->sdnos);
|
||||
if (plex->lock)
|
||||
Free(plex->lock);
|
||||
if (isstriped (plex))
|
||||
if (isstriped(plex))
|
||||
mtx_destroy(&plex->lockmtx);
|
||||
destroy_dev(plex->dev);
|
||||
bzero(plex, sizeof(struct plex)); /* and clear it out */
|
||||
@ -927,7 +921,7 @@ config_drive(int update)
|
||||
switch (get_keyword(token[parameter], &keyword_set)) {
|
||||
case kw_device:
|
||||
parameter++;
|
||||
otherdriveno = find_drive_by_dev(token[parameter], 0); /* see if it exists already */
|
||||
otherdriveno = find_drive_by_name(token[parameter], 0); /* see if it exists already */
|
||||
if (otherdriveno >= 0) { /* yup, */
|
||||
drive->state = drive_unallocated; /* deallocate the drive */
|
||||
throw_rude_remark(EEXIST, /* and complain */
|
||||
@ -1231,10 +1225,18 @@ config_subdisk(int update)
|
||||
throw_rude_remark(EINVAL, "sd %s has no length spec", sd->name);
|
||||
|
||||
if (sd->dev == NULL)
|
||||
sd->dev = make_dev(&vinum_cdevsw, VINUMRMINOR(sdno, VINUM_RAWSD_TYPE),
|
||||
/*
|
||||
* sdno can (at least theoretically) overflow
|
||||
* into the low order bit of the type field.
|
||||
* This gives rise to a subdisk with type
|
||||
* VINUM_SD2_TYPE. This is a feature, not a
|
||||
* bug.
|
||||
*/
|
||||
sd->dev = make_dev(&vinum_cdevsw,
|
||||
VINUMMINOR(sdno, VINUM_SD_TYPE),
|
||||
UID_ROOT,
|
||||
GID_OPERATOR,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP,
|
||||
"vinum/sd/%s",
|
||||
sd->name);
|
||||
if (state != sd_unallocated) /* we had a specific state to set */
|
||||
@ -1425,14 +1427,14 @@ config_plex(int update)
|
||||
plex->state = state; /* set whatever state we chose */
|
||||
vinum_conf.plexes_used++; /* one more in use */
|
||||
if (plex->dev == NULL)
|
||||
plex->dev = make_dev(&vinum_cdevsw,
|
||||
VINUMRMINOR(plexno, VINUM_RAWPLEX_TYPE),
|
||||
plex->dev = make_dev(&vinum_cdevsw,
|
||||
VINUMMINOR(plexno, VINUM_PLEX_TYPE),
|
||||
UID_ROOT,
|
||||
GID_OPERATOR,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP,
|
||||
"vinum/plex/%s",
|
||||
plex->name);
|
||||
}
|
||||
S_IRUSR | S_IWUSR | S_IRGRP,
|
||||
"vinum/plex/%s",
|
||||
plex->name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle a volume definition.
|
||||
@ -1561,13 +1563,13 @@ config_volume(int update)
|
||||
vol->size = max(vol->size, PLEX[vol->plex[i]].length);
|
||||
vinum_conf.volumes_used++; /* one more in use */
|
||||
if (vol->dev == NULL)
|
||||
vol->dev = make_dev(&vinum_cdevsw,
|
||||
VINUMRMINOR(volno, VINUM_VOLUME_TYPE),
|
||||
UID_ROOT,
|
||||
GID_OPERATOR,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP,
|
||||
"vinum/%s",
|
||||
vol->name);
|
||||
vol->dev = make_dev(&vinum_cdevsw,
|
||||
VINUMMINOR(volno, VINUM_VOLUME_TYPE),
|
||||
UID_ROOT,
|
||||
GID_OPERATOR,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP,
|
||||
"vinum/%s",
|
||||
vol->name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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: vinumext.h,v 1.27 2001/05/22 04:07:22 grog Exp grog $
|
||||
* $Id: vinumext.h,v 1.31 2003/04/25 08:01:37 grog Exp $
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
@ -84,7 +84,7 @@ int my_plex(int volno, int plexno);
|
||||
int my_sd(int plexno, int sdno);
|
||||
int get_empty_drive(void);
|
||||
int find_drive(const char *name, int create);
|
||||
int find_drive_by_dev(const char *devname, int create);
|
||||
int find_drive_by_name(const char *devname, int create);
|
||||
int get_empty_sd(void);
|
||||
int find_subdisk(const char *name, int create);
|
||||
void return_drive_space(int driveno, int64_t offset, int length);
|
||||
@ -126,7 +126,6 @@ int init_drive(struct drive *, int);
|
||||
/* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */
|
||||
void throw_rude_remark(int, char *,...);
|
||||
|
||||
/* XXX die die */
|
||||
void format_config(char *config, int len);
|
||||
void checkkernel(char *op);
|
||||
void free_drive(struct drive *drive);
|
||||
@ -141,6 +140,7 @@ d_close_t vinumclose;
|
||||
d_strategy_t vinumstrategy;
|
||||
d_ioctl_t vinumioctl;
|
||||
|
||||
int vinum_super_ioctl(dev_t, u_long, caddr_t);
|
||||
int vinumstart(struct buf *bp, int reviveok);
|
||||
int launch_requests(struct request *rq, int reviveok);
|
||||
void sdio(struct buf *bp);
|
||||
|
Loading…
Reference in New Issue
Block a user