1998-12-28 04:56:24 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1997, 1998
|
|
|
|
* Nan Yang Computer Services Limited. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is distributed under the so-called ``Berkeley
|
|
|
|
* License'':
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Nan Yang Computer
|
|
|
|
* Services Limited.
|
|
|
|
* 4. Neither the name of the Company nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* This software is provided ``as is'', and any express or implied
|
|
|
|
* warranties, including, but not limited to, the implied warranties of
|
|
|
|
* merchantability and fitness for a particular purpose are disclaimed.
|
|
|
|
* In no event shall the company or contributors be liable for any
|
|
|
|
* direct, indirect, incidental, special, exemplary, or consequential
|
|
|
|
* damages (including, but not limited to, procurement of substitute
|
|
|
|
* goods or services; loss of use, data, or profits; or business
|
|
|
|
* interruption) however caused and on any theory of liability, whether
|
|
|
|
* in contract, strict liability, or tort (including negligence or
|
|
|
|
* otherwise) arising in any way out of the use of this software, even if
|
|
|
|
* advised of the possibility of such damage.
|
|
|
|
*
|
2003-06-12 05:28:18 +00:00
|
|
|
* $Id: vinumconfig.c,v 1.41 2003/05/23 00:57:34 grog Exp grog $
|
1998-12-28 04:56:24 +00:00
|
|
|
*/
|
2001-05-22 02:29:54 +00:00
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
#define STATIC static
|
1998-12-28 04:56:24 +00:00
|
|
|
|
1998-12-28 16:28:24 +00:00
|
|
|
#include <dev/vinum/vinumhdr.h>
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
#include <dev/vinum/request.h>
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
#define MAXTOKEN 64 /* maximum number of tokens in a line */
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* We can afford the luxury of global variables here,
|
1998-12-28 04:56:24 +00:00
|
|
|
* since start_config ensures that these functions
|
1999-01-29 01:17:54 +00:00
|
|
|
* are single-threaded.
|
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
/* These are indices in vinum_conf of the last-mentioned of each kind of object */
|
1999-08-14 06:24:34 +00:00
|
|
|
static int current_drive; /* note the last drive we mention, for
|
1998-12-28 04:56:24 +00:00
|
|
|
* some defaults */
|
1999-08-14 06:24:34 +00:00
|
|
|
static int current_plex; /* and the same for the last plex */
|
|
|
|
static int current_volume; /* and the last volme */
|
1998-12-28 04:56:24 +00:00
|
|
|
static struct _ioctl_reply *ioctl_reply; /* struct to return via ioctl */
|
|
|
|
|
|
|
|
|
|
|
|
/* These values are used by most of these routines, so set them as globals */
|
|
|
|
static char *token[MAXTOKEN]; /* pointers to individual tokens */
|
|
|
|
static int tokens; /* number of tokens */
|
|
|
|
|
|
|
|
#define TOCONS 0x01
|
|
|
|
#define TOTTY 0x02
|
|
|
|
#define TOLOG 0x04
|
|
|
|
|
|
|
|
struct putchar_arg {
|
|
|
|
int flags;
|
|
|
|
struct tty *tty;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MSG_MAX 1024 /* maximum length of a formatted message */
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
2003-05-01 01:29:52 +00:00
|
|
|
* 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.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(int error, char *msg,...)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
va_list ap;
|
|
|
|
char *text;
|
|
|
|
static int finishing; /* don't recurse */
|
|
|
|
int was_finishing;
|
|
|
|
|
2003-05-01 01:29:52 +00:00
|
|
|
if ((vinum_conf.flags & VF_LOCKED) == 0) /* bug catcher */
|
|
|
|
panic("throw_rude_remark: called without config lock");
|
1998-12-28 04:56:24 +00:00
|
|
|
va_start(ap, msg);
|
|
|
|
if ((ioctl_reply != NULL) /* we're called from the user */
|
1999-03-19 07:10:19 +00:00
|
|
|
&&(!(vinum_conf.flags & VF_READING_CONFIG))) { /* and not reading from disk: return msg */
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* We can't just format to ioctl_reply, since it
|
1999-03-28 08:53:02 +00:00
|
|
|
* may contain our input parameters
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
text = Malloc(MSG_MAX);
|
|
|
|
if (text == NULL) {
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
log(LOG_ERR, "vinum: can't allocate error message buffer\n");
|
1998-12-28 04:56:24 +00:00
|
|
|
printf("vinum: ");
|
|
|
|
vprintf(msg, ap); /* print to the console */
|
|
|
|
printf("\n");
|
|
|
|
} else {
|
|
|
|
retval = kvprintf(msg, NULL, (void *) text, 10, ap);
|
|
|
|
text[retval] = '\0'; /* delimit */
|
2003-05-23 01:13:10 +00:00
|
|
|
strlcpy(ioctl_reply->msg, text, sizeof(ioctl_reply->msg));
|
1998-12-28 04:56:24 +00:00
|
|
|
ioctl_reply->error = error; /* first byte is the error number */
|
|
|
|
Free(text);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("vinum: ");
|
|
|
|
vprintf(msg, ap); /* print to the console */
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (vinum_conf.flags & VF_READING_CONFIG) { /* go through to the bitter end, */
|
1999-03-19 07:10:19 +00:00
|
|
|
if ((vinum_conf.flags & VF_READING_CONFIG) /* we're reading from disk, */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
&&((daemon_options & daemon_noupdate) == 0)) {
|
|
|
|
log(LOG_NOTICE, "Disabling configuration updates\n");
|
|
|
|
daemon_options |= daemon_noupdate;
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
return;
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
}
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* We have a problem here: we want to unlock the
|
1998-12-28 04:56:24 +00:00
|
|
|
* configuration, which implies tidying up, but
|
2003-05-01 01:29:52 +00:00
|
|
|
* if we find an error while tidying up, we
|
|
|
|
* could recurse for ever. Use this kludge to
|
|
|
|
* only try once.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
was_finishing = finishing;
|
|
|
|
finishing = 1;
|
|
|
|
finish_config(was_finishing); /* unlock anything we may be holding */
|
|
|
|
finishing = was_finishing;
|
|
|
|
longjmp(command_fail, error);
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Check a volume to see if the plex is already assigned to it.
|
1999-03-28 08:53:02 +00:00
|
|
|
* Return index in volume->plex, or -1 if not assigned
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
my_plex(int volno, int plexno)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct volume *vol;
|
|
|
|
|
|
|
|
vol = &VOL[volno]; /* point to volno */
|
|
|
|
for (i = 0; i < vol->plexes; i++)
|
|
|
|
if (vol->plex[i] == plexno)
|
|
|
|
return i;
|
|
|
|
return -1; /* not found */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Check a plex to see if the subdisk is already assigned to it.
|
1999-03-28 08:53:02 +00:00
|
|
|
* Return index in plex->sd, or -1 if not assigned
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
my_sd(int plexno, int sdno)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct plex *plex;
|
|
|
|
|
|
|
|
plex = &PLEX[plexno];
|
|
|
|
for (i = 0; i < plex->subdisks; i++)
|
|
|
|
if (plex->sdnos[i] == sdno)
|
|
|
|
return i;
|
|
|
|
return -1; /* not found */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add plex to the volume if possible */
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
2003-05-05 05:32:15 +00:00
|
|
|
give_plex_to_volume(int volno, int plexno, int preferme)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
struct volume *vol;
|
2000-12-20 05:13:26 +00:00
|
|
|
int i;
|
2003-05-05 05:32:15 +00:00
|
|
|
int volplexno;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* It's not an error for the plex to already
|
1998-12-28 04:56:24 +00:00
|
|
|
* belong to the volume, but we need to check a
|
|
|
|
* number of things to make sure it's done right.
|
1999-03-28 08:53:02 +00:00
|
|
|
* Some day.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
2003-05-05 05:32:15 +00:00
|
|
|
volplexno = my_plex(volno, plexno);
|
1998-12-28 04:56:24 +00:00
|
|
|
vol = &VOL[volno]; /* point to volume */
|
2003-05-05 05:32:15 +00:00
|
|
|
if (volplexno < 0) {
|
|
|
|
if (vol->plexes == MAXPLEX) /* all plexes allocated */
|
|
|
|
throw_rude_remark(ENOSPC,
|
|
|
|
"Too many plexes for volume %s",
|
|
|
|
vol->name);
|
|
|
|
else if ((vol->plexes > 0) /* we have other plexes */
|
|
|
|
&&((vol->flags & VF_CONFIG_SETUPSTATE) == 0)) /* and we're not setting up state */
|
|
|
|
invalidate_subdisks(&PLEX[plexno], sd_stale); /* make our subdisks invalid */
|
|
|
|
vol->plex[vol->plexes] = plexno; /* this one */
|
|
|
|
vol->plexes++; /* add another plex */
|
|
|
|
PLEX[plexno].volno = volno; /* note the number of our volume */
|
|
|
|
|
|
|
|
/* Find out how big our volume is */
|
|
|
|
for (i = 0; i < vol->plexes; i++)
|
|
|
|
vol->size = max(vol->size, PLEX[vol->plex[i]].length);
|
|
|
|
volplexno = vol->plexes - 1; /* number of plex in volume */
|
|
|
|
}
|
|
|
|
if (preferme) {
|
2003-05-05 08:42:42 +00:00
|
|
|
if (vol->preferred_plex >= 0) /* already had a facourite, */
|
2003-05-05 05:32:15 +00:00
|
|
|
printf("vinum: changing preferred plex for %s from %s to %s\n",
|
|
|
|
vol->name,
|
|
|
|
PLEX[vol->plex[vol->preferred_plex]].name,
|
|
|
|
PLEX[plexno].name);
|
|
|
|
vol->preferred_plex = volplexno;
|
|
|
|
}
|
|
|
|
return volplexno;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
1999-03-28 08:53:02 +00:00
|
|
|
* Add subdisk to a plex if possible
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
give_sd_to_plex(int plexno, int sdno)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct plex *plex;
|
|
|
|
struct sd *sd;
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* It's not an error for the sd to already
|
1998-12-28 04:56:24 +00:00
|
|
|
* belong to the plex, but we need to check a
|
|
|
|
* number of things to make sure it's done right.
|
1999-03-28 08:53:02 +00:00
|
|
|
* Some day.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
i = my_sd(plexno, sdno);
|
|
|
|
if (i >= 0) /* does it already belong to us? */
|
|
|
|
return i; /* that's it */
|
|
|
|
|
|
|
|
plex = &PLEX[plexno]; /* point to the plex */
|
|
|
|
sd = &SD[sdno]; /* and the subdisk */
|
|
|
|
|
|
|
|
/* Do we have an offset? Otherwise put it after the last one */
|
|
|
|
if (sd->plexoffset < 0) { /* no offset specified */
|
|
|
|
if (plex->subdisks > 0) {
|
|
|
|
struct sd *lastsd = &SD[plex->sdnos[plex->subdisks - 1]]; /* last subdisk */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
|
|
|
|
if (plex->organization == plex_concat) /* concat, */
|
|
|
|
sd->plexoffset = lastsd->sectors + lastsd->plexoffset; /* starts here */
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
else /* striped, RAID-4 or RAID-5 */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
sd->plexoffset = plex->stripesize * plex->subdisks; /* starts here */
|
1998-12-28 04:56:24 +00:00
|
|
|
} else /* first subdisk */
|
|
|
|
sd->plexoffset = 0; /* start at the beginning */
|
|
|
|
}
|
2003-09-29 08:50:03 +00:00
|
|
|
if (plex->subdisks == MAXSD) { /* we already have our maximum */
|
|
|
|
if (sd->state == sd_unallocated) /* haven't finished allocating the sd, */
|
|
|
|
free_sd(sdno); /* free it to return drive space */
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(ENOSPC, /* crap out */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
"Can't add %s to %s: plex full",
|
1998-12-28 04:56:24 +00:00
|
|
|
sd->name,
|
|
|
|
plex->name);
|
2003-09-29 08:50:03 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
plex->subdisks++; /* another entry */
|
|
|
|
if (plex->subdisks >= plex->subdisks_allocated) /* need more space */
|
|
|
|
EXPAND(plex->sdnos, int, plex->subdisks_allocated, INITIAL_SUBDISKS_IN_PLEX);
|
|
|
|
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
/* Adjust size of plex and volume. */
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
if (isparity(plex)) /* RAID-4 or RAID-5 */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
plex->length = (plex->subdisks - 1) * sd->sectors; /* size is one disk short */
|
1999-03-28 08:53:02 +00:00
|
|
|
else
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
plex->length += sd->sectors; /* plex gets this much bigger */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
if (plex->volno >= 0) /* we have a volume */
|
|
|
|
VOL[plex->volno].size = max(VOL[plex->volno].size, plex->length); /* adjust its size */
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* We need to check that the subdisks don't overlap,
|
1998-12-28 04:56:24 +00:00
|
|
|
* but we can't do that until a point where we *must*
|
|
|
|
* know the size of all the subdisks. That's not
|
1999-03-28 08:53:02 +00:00
|
|
|
* here. But we need to sort them by offset
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
for (i = 0; i < plex->subdisks - 1; i++) {
|
|
|
|
if (sd->plexoffset < SD[plex->sdnos[i]].plexoffset) { /* it fits before this one */
|
|
|
|
/* First move any remaining subdisks by one */
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = plex->subdisks - 1; j > i; j--) /* move up one at a time */
|
|
|
|
plex->sdnos[j] = plex->sdnos[j - 1];
|
|
|
|
plex->sdnos[i] = sdno;
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
sd->plexsdno = i; /* note where we are in the subdisk */
|
1998-12-28 04:56:24 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
2000-06-02 04:02:15 +00:00
|
|
|
* The plex doesn't have any subdisk with a
|
|
|
|
* larger offset. Insert it here.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
plex->sdnos[i] = sdno;
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
sd->plexsdno = i; /* note where we are in the subdisk */
|
2000-06-02 04:02:15 +00:00
|
|
|
sd->plexno = plex->plexno; /* and who we belong to */
|
1998-12-28 04:56:24 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
* Add a subdisk to drive if possible. The
|
|
|
|
* pointer to the drive must already be stored in
|
|
|
|
* the sd structure, but the drive doesn't know
|
|
|
|
* about the subdisk yet.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
2000-01-05 06:02:57 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
give_sd_to_drive(int sdno)
|
|
|
|
{
|
|
|
|
struct sd *sd; /* pointer to subdisk */
|
|
|
|
struct drive *drive; /* and drive */
|
|
|
|
int fe; /* index in free list */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
int sfe; /* and index of subdisk when assigning max */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
sd = &SD[sdno]; /* point to sd */
|
|
|
|
drive = &DRIVE[sd->driveno]; /* and drive */
|
|
|
|
|
1999-03-23 04:47:09 +00:00
|
|
|
if (drive->state != drive_up) {
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
update_sd_state(sdno); /* that crashes the subdisk */
|
1999-03-23 04:47:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-05-05 08:42:42 +00:00
|
|
|
sd->sectorsize = drive->sectorsize; /* get sector size from drive */
|
1999-08-14 06:24:34 +00:00
|
|
|
if (drive->flags & VF_HOTSPARE) /* the drive is a hot spare, */
|
|
|
|
throw_rude_remark(ENOSPC,
|
|
|
|
"Can't place %s on hot spare drive %s",
|
|
|
|
sd->name,
|
|
|
|
drive->label.name);
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if ((drive->sectors_available == 0) /* no space left */
|
|
|
|
||(sd->sectors > drive->sectors_available)) { /* or too big, */
|
1998-12-28 04:56:24 +00:00
|
|
|
sd->driveoffset = -1; /* don't be confusing */
|
1999-08-24 02:20:30 +00:00
|
|
|
free_sd(sd->sdno);
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(ENOSPC, "No space for %s on %s", sd->name, drive->label.name);
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
return; /* in case we come back here */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
drive->subdisks_used++; /* one more subdisk */
|
|
|
|
|
1999-03-13 07:32:40 +00:00
|
|
|
if (sd->sectors == 0) { /* take the largest chunk */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
sfe = 0; /* to keep the compiler happy */
|
|
|
|
for (fe = 0; fe < drive->freelist_entries; fe++) {
|
|
|
|
if (drive->freelist[fe].sectors >= sd->sectors) { /* more space here */
|
|
|
|
sd->sectors = drive->freelist[fe].sectors; /* take it */
|
|
|
|
sd->driveoffset = drive->freelist[fe].offset;
|
|
|
|
sfe = fe; /* and note the index for later */
|
|
|
|
}
|
|
|
|
}
|
1999-08-24 02:20:30 +00:00
|
|
|
if (sd->sectors == 0) { /* no luck, */
|
|
|
|
sd->driveoffset = -1; /* don't be confusing */
|
|
|
|
free_sd(sd->sdno);
|
1999-03-13 07:32:40 +00:00
|
|
|
throw_rude_remark(ENOSPC, /* give up */
|
|
|
|
"No space for %s on %s",
|
|
|
|
sd->name,
|
|
|
|
drive->label.name);
|
1999-08-24 02:20:30 +00:00
|
|
|
}
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (sfe < (drive->freelist_entries - 1)) /* not the last one, */
|
|
|
|
bcopy(&drive->freelist[sfe + 1],
|
|
|
|
&drive->freelist[sfe],
|
|
|
|
(drive->freelist_entries - sfe) * sizeof(struct drive_freelist));
|
|
|
|
drive->freelist_entries--; /* one less entry */
|
|
|
|
drive->sectors_available -= sd->sectors; /* and note how much less space we have */
|
1999-03-23 04:47:09 +00:00
|
|
|
} else if (sd->driveoffset < 0) { /* no offset specified, find one */
|
1998-12-28 04:56:24 +00:00
|
|
|
for (fe = 0; fe < drive->freelist_entries; fe++) {
|
|
|
|
if (drive->freelist[fe].sectors >= sd->sectors) { /* it'll fit here */
|
|
|
|
sd->driveoffset = drive->freelist[fe].offset;
|
|
|
|
if (sd->sectors == drive->freelist[fe].sectors) { /* used up the entire entry */
|
|
|
|
if (fe < (drive->freelist_entries - 1)) /* not the last one, */
|
|
|
|
bcopy(&drive->freelist[fe + 1],
|
|
|
|
&drive->freelist[fe],
|
|
|
|
(drive->freelist_entries - fe) * sizeof(struct drive_freelist));
|
|
|
|
drive->freelist_entries--; /* one less entry */
|
|
|
|
} else {
|
|
|
|
drive->freelist[fe].sectors -= sd->sectors; /* this much less space */
|
|
|
|
drive->freelist[fe].offset += sd->sectors; /* this much further on */
|
|
|
|
}
|
|
|
|
drive->sectors_available -= sd->sectors; /* and note how much less space we have */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-03-13 07:32:40 +00:00
|
|
|
if (sd->driveoffset < 0)
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Didn't find anything. Although the drive has
|
1999-03-28 08:53:02 +00:00
|
|
|
* enough space, it's too fragmented
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-24 02:20:30 +00:00
|
|
|
{
|
|
|
|
free_sd(sd->sdno);
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(ENOSPC, "No space for %s on %s", sd->name, drive->label.name);
|
1999-08-24 02:20:30 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
} else { /* specific offset */
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* For a specific offset to work, the space must be
|
1999-03-28 08:53:02 +00:00
|
|
|
* entirely in a single freelist entry. Look for it.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
u_int64_t sdend = sd->driveoffset + sd->sectors; /* end of our subdisk */
|
|
|
|
for (fe = 0; fe < drive->freelist_entries; fe++) {
|
|
|
|
u_int64_t dend = drive->freelist[fe].offset + drive->freelist[fe].sectors; /* end of entry */
|
|
|
|
if (dend >= sdend) { /* fits before here */
|
1999-08-24 02:20:30 +00:00
|
|
|
if (drive->freelist[fe].offset > sd->driveoffset) { /* starts after the beginning of sd area */
|
|
|
|
sd->driveoffset = -1; /* don't be confusing */
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
set_sd_state(sd->sdno, sd_down, setstate_force);
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(ENOSPC,
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
"No space for %s on drive %s at offset %lld",
|
1998-12-28 04:56:24 +00:00
|
|
|
sd->name,
|
2000-01-05 06:02:57 +00:00
|
|
|
drive->label.name,
|
|
|
|
sd->driveoffset);
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
return;
|
1999-08-24 02:20:30 +00:00
|
|
|
}
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* We've found the space, and we can allocate it.
|
1998-12-28 04:56:24 +00:00
|
|
|
* We don't need to say that to the subdisk, which
|
|
|
|
* already knows about it. We need to tell it to
|
|
|
|
* the free list, though. We have four possibilities:
|
|
|
|
*
|
|
|
|
* 1. The subdisk exactly eats up the entry. That's the
|
|
|
|
* same as above.
|
|
|
|
* 2. The subdisk starts at the beginning and leaves space
|
|
|
|
* at the end.
|
|
|
|
* 3. The subdisk starts after the beginning and leaves
|
|
|
|
* space at the end as well: we end up with another
|
|
|
|
* fragment.
|
|
|
|
* 4. The subdisk leaves space at the beginning and finishes
|
|
|
|
* at the end.
|
|
|
|
*/
|
|
|
|
drive->sectors_available -= sd->sectors; /* note how much less space we have */
|
|
|
|
if (sd->driveoffset == drive->freelist[fe].offset) { /* 1 or 2 */
|
|
|
|
if (sd->sectors == drive->freelist[fe].sectors) { /* 1: used up the entire entry */
|
|
|
|
if (fe < (drive->freelist_entries - 1)) /* not the last one, */
|
|
|
|
bcopy(&drive->freelist[fe + 1],
|
|
|
|
&drive->freelist[fe],
|
|
|
|
(drive->freelist_entries - fe) * sizeof(struct drive_freelist));
|
|
|
|
drive->freelist_entries--; /* one less entry */
|
|
|
|
} else { /* 2: space at the end */
|
|
|
|
drive->freelist[fe].sectors -= sd->sectors; /* this much less space */
|
|
|
|
drive->freelist[fe].offset += sd->sectors; /* this much further on */
|
|
|
|
}
|
|
|
|
} else { /* 3 or 4 */
|
|
|
|
drive->freelist[fe].sectors = sd->driveoffset - drive->freelist[fe].offset;
|
|
|
|
if (dend > sdend) { /* 3: space at the end as well */
|
|
|
|
if (fe < (drive->freelist_entries - 1)) /* not the last one */
|
|
|
|
bcopy(&drive->freelist[fe], /* move the rest down */
|
|
|
|
&drive->freelist[fe + 1],
|
|
|
|
(drive->freelist_entries - fe) * sizeof(struct drive_freelist));
|
|
|
|
drive->freelist_entries++; /* one less entry */
|
|
|
|
drive->freelist[fe + 1].offset = sdend; /* second entry starts after sd */
|
|
|
|
drive->freelist[fe + 1].sectors = dend - sdend; /* and is this long */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drive->opencount++; /* one more subdisk attached */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get an empty drive entry from the drive table */
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
get_empty_drive(void)
|
|
|
|
{
|
|
|
|
int driveno;
|
|
|
|
struct drive *drive;
|
|
|
|
|
|
|
|
/* first see if we have one which has been deallocated */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (driveno = 0; driveno < vinum_conf.drives_allocated; driveno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
if (DRIVE[driveno].state == drive_unallocated) /* bingo */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if (driveno >= vinum_conf.drives_allocated) /* we've used all our allocation */
|
|
|
|
EXPAND(DRIVE, struct drive, vinum_conf.drives_allocated, INITIAL_DRIVES);
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
/* got a drive entry. Make it pretty */
|
|
|
|
drive = &DRIVE[driveno];
|
|
|
|
bzero(drive, sizeof(struct drive));
|
|
|
|
drive->driveno = driveno; /* put number in structure */
|
1999-03-13 07:32:40 +00:00
|
|
|
drive->flags |= VF_NEWBORN; /* newly born drive */
|
2004-03-11 14:11:08 +00:00
|
|
|
drive->dev = NODEV;
|
2003-05-01 01:29:52 +00:00
|
|
|
strcpy(drive->devicename, "unknown"); /* and make the name ``unknown'' */
|
1998-12-28 04:56:24 +00:00
|
|
|
return driveno; /* return the index */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
2003-05-23 01:13:10 +00:00
|
|
|
* Find the named drive in vinum_conf.drive,
|
1998-12-28 04:56:24 +00:00
|
|
|
* return the index in vinum_conf.drive.
|
|
|
|
* Don't mark the drive as allocated (XXX SMP)
|
|
|
|
* If create != 0, create an entry if it doesn't exist
|
|
|
|
*/
|
|
|
|
/* XXX check if we have it open from attach */
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
find_drive(const char *name, int create)
|
|
|
|
{
|
|
|
|
int driveno;
|
|
|
|
struct drive *drive;
|
|
|
|
|
|
|
|
if (name != NULL) {
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (driveno = 0; driveno < vinum_conf.drives_allocated; driveno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
drive = &DRIVE[driveno]; /* point to drive */
|
|
|
|
if ((drive->label.name[0] != '\0') /* it has a name */
|
2001-01-14 06:29:56 +00:00
|
|
|
&&(strcmp(drive->label.name, name) == 0) /* and it's this one */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
&&(drive->state > drive_unallocated)) /* and it's a real one: found */
|
1998-12-28 04:56:24 +00:00
|
|
|
return driveno;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* the drive isn't in the list. Add it if he wants */
|
|
|
|
if (create == 0) /* don't want to create */
|
|
|
|
return -1; /* give up */
|
|
|
|
|
|
|
|
driveno = get_empty_drive();
|
|
|
|
drive = &DRIVE[driveno];
|
|
|
|
if (name != NULL)
|
2003-05-23 01:13:10 +00:00
|
|
|
strlcpy(drive->label.name, /* put in its name */
|
|
|
|
name,
|
|
|
|
sizeof(drive->label.name));
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
drive->state = drive_referenced; /* in use, nothing worthwhile there */
|
1998-12-28 04:56:24 +00:00
|
|
|
return driveno; /* return the index */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Find a drive given its device name.
|
1998-12-28 04:56:24 +00:00
|
|
|
* devname must be valid.
|
2003-05-04 05:15:07 +00:00
|
|
|
* Otherwise the same as find_drive above.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
2003-05-01 01:29:52 +00:00
|
|
|
find_drive_by_name(const char *devname, int create)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int driveno;
|
|
|
|
struct drive *drive;
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (driveno = 0; driveno < vinum_conf.drives_allocated; driveno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
drive = &DRIVE[driveno]; /* point to drive */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if ((strcmp(drive->devicename, devname) == 0) /* it's this device */
|
|
|
|
&&(drive->state > drive_unallocated)) /* and it's a real one: found */
|
1998-12-28 04:56:24 +00:00
|
|
|
return driveno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the drive isn't in the list. Add it if he wants */
|
|
|
|
if (create == 0) /* don't want to create */
|
|
|
|
return -1; /* give up */
|
|
|
|
|
|
|
|
driveno = get_empty_drive();
|
|
|
|
drive = &DRIVE[driveno];
|
|
|
|
bcopy(devname, /* put in its name */
|
|
|
|
drive->devicename,
|
|
|
|
min(sizeof(drive->devicename),
|
|
|
|
strlen(devname)));
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
drive->state = drive_referenced; /* in use, nothing worthwhile there */
|
1998-12-28 04:56:24 +00:00
|
|
|
return driveno; /* return the index */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find an empty subdisk in the subdisk table */
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
get_empty_sd(void)
|
|
|
|
{
|
|
|
|
int sdno;
|
|
|
|
struct sd *sd;
|
|
|
|
|
|
|
|
/* first see if we have one which has been deallocated */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (sdno = 0; sdno < vinum_conf.subdisks_allocated; sdno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
if (SD[sdno].state == sd_unallocated) /* bingo */
|
|
|
|
break;
|
|
|
|
}
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if (sdno >= vinum_conf.subdisks_allocated)
|
|
|
|
/*
|
|
|
|
* 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.
|
2003-05-01 01:29:52 +00:00
|
|
|
*
|
|
|
|
* XXX We should check for overflow here. We
|
|
|
|
* shouldn't allocate more than VINUM_MAXSD
|
|
|
|
* subdisks (currently at least a quarter of a
|
|
|
|
* million).
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
*/
|
|
|
|
EXPAND(SD, struct sd, vinum_conf.subdisks_allocated, INITIAL_SUBDISKS);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
/* initialize some things */
|
|
|
|
sd = &SD[sdno]; /* point to it */
|
|
|
|
bzero(sd, sizeof(struct sd)); /* initialize */
|
1999-03-13 07:32:40 +00:00
|
|
|
sd->flags |= VF_NEWBORN; /* newly born subdisk */
|
1998-12-28 04:56:24 +00:00
|
|
|
sd->plexno = -1; /* no plex */
|
1999-08-14 06:24:34 +00:00
|
|
|
sd->sectors = -1; /* no space */
|
|
|
|
sd->driveno = -1; /* no drive */
|
1998-12-28 04:56:24 +00:00
|
|
|
sd->plexoffset = -1; /* and no offsets */
|
|
|
|
sd->driveoffset = -1;
|
|
|
|
return sdno; /* return the index */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return a drive to the free pool */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
free_drive(struct drive *drive)
|
|
|
|
{
|
2003-07-01 07:53:54 +00:00
|
|
|
LOCKDRIVE(drive);
|
|
|
|
if (drive->flags & VF_OPEN) /* it's open, */
|
|
|
|
close_locked_drive(drive); /* close it */
|
|
|
|
if (drive->freelist)
|
|
|
|
Free(drive->freelist);
|
2004-03-11 14:11:08 +00:00
|
|
|
if (drive->dev != NODEV)
|
|
|
|
dev_rel(drive->dev);
|
2003-07-01 07:53:54 +00:00
|
|
|
bzero(drive, sizeof(struct drive)); /* this also sets drive_unallocated */
|
|
|
|
unlockdrive(drive);
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Find the named subdisk in vinum_conf.sd.
|
|
|
|
*
|
1998-12-28 04:56:24 +00:00
|
|
|
* If create != 0, create an entry if it doesn't exist
|
|
|
|
*
|
|
|
|
* Return index in vinum_conf.sd
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
find_subdisk(const char *name, int create)
|
|
|
|
{
|
|
|
|
int sdno;
|
|
|
|
struct sd *sd;
|
|
|
|
|
|
|
|
for (sdno = 0; sdno < vinum_conf.subdisks_allocated; sdno++) {
|
|
|
|
if (strcmp(SD[sdno].name, name) == 0) /* found it */
|
|
|
|
return sdno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the subdisk isn't in the list. Add it if he wants */
|
|
|
|
if (create == 0) /* don't want to create */
|
|
|
|
return -1; /* give up */
|
|
|
|
|
|
|
|
/* Allocate one and insert the name */
|
|
|
|
sdno = get_empty_sd();
|
|
|
|
sd = &SD[sdno];
|
|
|
|
bcopy(name, sd->name, min(sizeof(sd->name), strlen(name))); /* put in its name */
|
|
|
|
return sdno; /* return the pointer */
|
|
|
|
}
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
/* Return space to a drive */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
return_drive_space(int driveno, int64_t offset, int length)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
struct drive *drive;
|
|
|
|
int fe; /* free list entry */
|
|
|
|
u_int64_t sdend; /* end of our subdisk */
|
|
|
|
u_int64_t dend; /* end of our freelist entry */
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
drive = &DRIVE[driveno];
|
|
|
|
if (drive->state == drive_up) {
|
|
|
|
sdend = offset + length; /* end of our subdisk */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
/* Look for where to return the sd address space */
|
|
|
|
for (fe = 0;
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
(fe < drive->freelist_entries) && (drive->freelist[fe].offset < offset);
|
1998-12-28 04:56:24 +00:00
|
|
|
fe++);
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Now we are pointing to the last entry, the first
|
1999-03-28 08:53:02 +00:00
|
|
|
* with a higher offset than the subdisk, or both.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((fe > 1) /* not the first entry */
|
2001-01-14 06:29:56 +00:00
|
|
|
&&((fe == drive->freelist_entries) /* gone past the end */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
||(drive->freelist[fe].offset > offset))) /* or past the block were looking for */
|
1998-12-28 04:56:24 +00:00
|
|
|
fe--; /* point to the block before */
|
|
|
|
dend = drive->freelist[fe].offset + drive->freelist[fe].sectors; /* end of the entry */
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* At this point, we are pointing to the correct
|
1998-12-28 04:56:24 +00:00
|
|
|
* place in the free list. A number of possibilities
|
|
|
|
* exist:
|
|
|
|
*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* 1. The block to be freed starts at the end of the
|
|
|
|
* block to which we are pointing. This has two
|
|
|
|
* subcases:
|
|
|
|
*
|
|
|
|
* a. The block to be freed ends at the beginning
|
1998-12-28 04:56:24 +00:00
|
|
|
* of the following block. Merge the three
|
|
|
|
* areas into a single block.
|
|
|
|
*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* b. The block is shorter than the space between
|
|
|
|
* the current block and the next one. Enlarge
|
|
|
|
* the current block.
|
|
|
|
*
|
|
|
|
* 2. The block to be freed starts after the end
|
|
|
|
* of the block. Again, we have two cases:
|
|
|
|
*
|
|
|
|
* a. It ends before the start of the following block.
|
|
|
|
* Create a new free block.
|
|
|
|
*
|
|
|
|
* b. It ends at the start of the following block.
|
|
|
|
* Enlarge the following block downwards.
|
|
|
|
*
|
|
|
|
* When there is only one free space block, and the
|
|
|
|
* space to be returned is before it, the pointer is
|
|
|
|
* to a non-existent zeroth block. XXX check this
|
1998-12-28 04:56:24 +00:00
|
|
|
*/
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (offset == dend) { /* Case 1: it starts at the end of this block */
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((fe < drive->freelist_entries - 1) /* we're not the last block in the free list */
|
1999-08-24 02:20:30 +00:00
|
|
|
/* and the subdisk ends at the start of the next block */
|
|
|
|
&&(sdend == drive->freelist[fe + 1].offset)) {
|
|
|
|
drive->freelist[fe].sectors /* 1a: merge all three blocks */
|
|
|
|
= drive->freelist[fe + 1].sectors;
|
1998-12-28 04:56:24 +00:00
|
|
|
if (fe < drive->freelist_entries - 2) /* still more blocks after next */
|
|
|
|
bcopy(&drive->freelist[fe + 2], /* move down one */
|
|
|
|
&drive->freelist[fe + 1],
|
1999-08-24 02:20:30 +00:00
|
|
|
(drive->freelist_entries - 2 - fe)
|
|
|
|
* sizeof(struct drive_freelist));
|
1998-12-28 04:56:24 +00:00
|
|
|
drive->freelist_entries--; /* one less entry in the free list */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
} else /* 1b: just enlarge this block */
|
|
|
|
drive->freelist[fe].sectors += length;
|
|
|
|
} else { /* Case 2 */
|
|
|
|
if (offset > dend) /* it starts after this block */
|
1998-12-28 04:56:24 +00:00
|
|
|
fe++; /* so look at the next block */
|
|
|
|
if ((fe < drive->freelist_entries) /* we're not the last block in the free list */
|
1999-08-24 02:20:30 +00:00
|
|
|
/* and the subdisk ends at the start of this block: case 4 */
|
|
|
|
&&(sdend == drive->freelist[fe].offset)) {
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
drive->freelist[fe].offset = offset; /* it starts where the sd was */
|
|
|
|
drive->freelist[fe].sectors += length; /* and it's this much bigger */
|
1998-12-28 04:56:24 +00:00
|
|
|
} else { /* case 3: non-contiguous */
|
|
|
|
if (fe < drive->freelist_entries) /* not after the last block, */
|
|
|
|
bcopy(&drive->freelist[fe], /* move the rest up one entry */
|
|
|
|
&drive->freelist[fe + 1],
|
1999-08-24 02:20:30 +00:00
|
|
|
(drive->freelist_entries - fe)
|
|
|
|
* sizeof(struct drive_freelist));
|
1998-12-28 04:56:24 +00:00
|
|
|
drive->freelist_entries++; /* one less entry */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
drive->freelist[fe].offset = offset; /* this entry represents the sd */
|
|
|
|
drive->freelist[fe].sectors = length;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
drive->sectors_available += length; /* the sectors are now available */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
* Free an allocated sd entry.
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* This performs memory management only. remove()
|
|
|
|
* is responsible for checking relationships.
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
free_sd(int sdno)
|
|
|
|
{
|
|
|
|
struct sd *sd;
|
|
|
|
|
|
|
|
sd = &SD[sdno];
|
|
|
|
if ((sd->driveno >= 0) /* we have a drive, */
|
|
|
|
&&(sd->sectors > 0)) /* and some space on it */
|
|
|
|
return_drive_space(sd->driveno, /* return the space */
|
|
|
|
sd->driveoffset,
|
|
|
|
sd->sectors);
|
1999-08-24 02:20:30 +00:00
|
|
|
if (sd->plexno >= 0)
|
2002-10-05 03:33:38 +00:00
|
|
|
PLEX[sd->plexno].subdisks--; /* one less subdisk */
|
2003-09-29 08:50:03 +00:00
|
|
|
/*
|
|
|
|
* If we come here as the result of a
|
|
|
|
* configuration error, we may not yet have
|
|
|
|
* created a device entry for the subdisk.
|
|
|
|
*/
|
|
|
|
if (sd->dev)
|
|
|
|
destroy_dev(sd->dev);
|
1998-12-28 04:56:24 +00:00
|
|
|
bzero(sd, sizeof(struct sd)); /* and clear it out */
|
|
|
|
sd->state = sd_unallocated;
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
vinum_conf.subdisks_used--; /* one less sd */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Find an empty plex in the plex table */
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
get_empty_plex(void)
|
|
|
|
{
|
|
|
|
int plexno;
|
|
|
|
struct plex *plex; /* if we allocate one */
|
|
|
|
|
|
|
|
/* first see if we have one which has been deallocated */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (plexno = 0; plexno < vinum_conf.plexes_allocated; plexno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
if (PLEX[plexno].state == plex_unallocated) /* bingo */
|
|
|
|
break; /* and get out of here */
|
|
|
|
}
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if (plexno >= vinum_conf.plexes_allocated)
|
|
|
|
EXPAND(PLEX, struct plex, vinum_conf.plexes_allocated, INITIAL_PLEXES);
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
/* Found a plex. Give it an sd structure */
|
|
|
|
plex = &PLEX[plexno]; /* this one is ours */
|
|
|
|
bzero(plex, sizeof(struct plex)); /* polish it up */
|
|
|
|
plex->sdnos = (int *) Malloc(sizeof(int) * INITIAL_SUBDISKS_IN_PLEX); /* allocate sd table */
|
|
|
|
CHECKALLOC(plex->sdnos, "vinum: Can't allocate plex subdisk table");
|
|
|
|
bzero(plex->sdnos, (sizeof(int) * INITIAL_SUBDISKS_IN_PLEX)); /* do we need this? */
|
1999-03-13 07:32:40 +00:00
|
|
|
plex->flags |= VF_NEWBORN; /* newly born plex */
|
1998-12-28 04:56:24 +00:00
|
|
|
plex->subdisks = 0; /* no subdisks in use */
|
|
|
|
plex->subdisks_allocated = INITIAL_SUBDISKS_IN_PLEX; /* and we have space for this many */
|
|
|
|
plex->organization = plex_disorg; /* and it's not organized */
|
|
|
|
plex->volno = -1; /* no volume yet */
|
|
|
|
return plexno; /* return the index */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Find the named plex in vinum_conf.plex
|
|
|
|
*
|
1998-12-28 04:56:24 +00:00
|
|
|
* If create != 0, create an entry if it doesn't exist
|
|
|
|
* return index in vinum_conf.plex
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
find_plex(const char *name, int create)
|
|
|
|
{
|
|
|
|
int plexno;
|
|
|
|
struct plex *plex;
|
|
|
|
|
|
|
|
for (plexno = 0; plexno < vinum_conf.plexes_allocated; plexno++) {
|
|
|
|
if (strcmp(PLEX[plexno].name, name) == 0) /* found it */
|
|
|
|
return plexno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the plex isn't in the list. Add it if he wants */
|
|
|
|
if (create == 0) /* don't want to create */
|
|
|
|
return -1; /* give up */
|
|
|
|
|
|
|
|
/* Allocate one and insert the name */
|
|
|
|
plexno = get_empty_plex();
|
|
|
|
plex = &PLEX[plexno]; /* point to it */
|
|
|
|
bcopy(name, plex->name, min(sizeof(plex->name), strlen(name))); /* put in its name */
|
|
|
|
return plexno; /* return the pointer */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Free an allocated plex entry
|
1999-03-28 08:53:02 +00:00
|
|
|
* and its associated memory areas
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
free_plex(int plexno)
|
|
|
|
{
|
|
|
|
struct plex *plex;
|
|
|
|
|
|
|
|
plex = &PLEX[plexno];
|
|
|
|
if (plex->sdnos)
|
|
|
|
Free(plex->sdnos);
|
|
|
|
if (plex->lock)
|
|
|
|
Free(plex->lock);
|
2003-12-15 00:44:05 +00:00
|
|
|
if (plex->dev)
|
|
|
|
destroy_dev(plex->dev);
|
1998-12-28 04:56:24 +00:00
|
|
|
bzero(plex, sizeof(struct plex)); /* and clear it out */
|
|
|
|
plex->state = plex_unallocated;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find an empty volume in the volume table */
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
get_empty_volume(void)
|
|
|
|
{
|
|
|
|
int volno;
|
|
|
|
struct volume *vol;
|
1999-09-28 22:43:07 +00:00
|
|
|
int i;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
/* first see if we have one which has been deallocated */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (volno = 0; volno < vinum_conf.volumes_allocated; volno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
if (VOL[volno].state == volume_unallocated) /* bingo */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if (volno >= vinum_conf.volumes_allocated)
|
|
|
|
EXPAND(VOL, struct volume, vinum_conf.volumes_allocated, INITIAL_VOLUMES);
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
/* Now initialize fields */
|
|
|
|
vol = &VOL[volno];
|
|
|
|
bzero(vol, sizeof(struct volume));
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vol->flags |= VF_NEWBORN | VF_CREATED; /* newly born volume */
|
1998-12-28 04:56:24 +00:00
|
|
|
vol->preferred_plex = ROUND_ROBIN_READPOL; /* round robin */
|
1999-09-28 22:43:07 +00:00
|
|
|
for (i = 0; i < MAXPLEX; i++) /* mark the plexes missing */
|
|
|
|
vol->plex[i] = -1;
|
1998-12-28 04:56:24 +00:00
|
|
|
return volno; /* return the index */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Find the named volume in vinum_conf.volume.
|
|
|
|
*
|
1998-12-28 04:56:24 +00:00
|
|
|
* If create != 0, create an entry if it doesn't exist
|
|
|
|
* return the index in vinum_conf
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
find_volume(const char *name, int create)
|
|
|
|
{
|
|
|
|
int volno;
|
|
|
|
struct volume *vol;
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (volno = 0; volno < vinum_conf.volumes_allocated; volno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
if (strcmp(VOL[volno].name, name) == 0) /* found it */
|
|
|
|
return volno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the volume isn't in the list. Add it if he wants */
|
|
|
|
if (create == 0) /* don't want to create */
|
|
|
|
return -1; /* give up */
|
|
|
|
|
|
|
|
/* Allocate one and insert the name */
|
|
|
|
volno = get_empty_volume();
|
|
|
|
vol = &VOL[volno];
|
|
|
|
bcopy(name, vol->name, min(sizeof(vol->name), strlen(name))); /* put in its name */
|
|
|
|
vol->blocksize = DEV_BSIZE; /* block size of this volume */
|
|
|
|
return volno; /* return the pointer */
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Free an allocated volume entry
|
1999-03-28 08:53:02 +00:00
|
|
|
* and its associated memory areas
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
free_volume(int volno)
|
|
|
|
{
|
|
|
|
struct volume *vol;
|
|
|
|
|
|
|
|
vol = &VOL[volno];
|
2003-12-15 00:44:05 +00:00
|
|
|
if (vol->dev)
|
|
|
|
destroy_dev(vol->dev);
|
1998-12-28 04:56:24 +00:00
|
|
|
bzero(vol, sizeof(struct volume)); /* and clear it out */
|
|
|
|
vol->state = volume_unallocated;
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Handle a drive definition. We store the information in the global variable
|
1998-12-28 04:56:24 +00:00
|
|
|
* drive, so we don't need to allocate.
|
|
|
|
*
|
|
|
|
* If we find an error, print a message and return
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_drive(int update)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
enum drive_label_info partition_status; /* info about the partition */
|
|
|
|
int parameter;
|
|
|
|
int driveno; /* index of drive in vinum_conf */
|
|
|
|
struct drive *drive; /* and pointer to it */
|
1999-08-15 02:30:34 +00:00
|
|
|
int otherdriveno; /* index of possible second drive */
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
int sdno;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
if (tokens < 2) /* not enough tokens */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
throw_rude_remark(EINVAL, "Drive has no name\n");
|
1998-12-28 04:56:24 +00:00
|
|
|
driveno = find_drive(token[1], 1); /* allocate a drive to initialize */
|
|
|
|
drive = &DRIVE[driveno]; /* and get a pointer */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
if (update && ((drive->flags & VF_NEWBORN) == 0)) /* this drive exists already */
|
|
|
|
return; /* don't do anything */
|
|
|
|
drive->flags &= ~VF_NEWBORN; /* no longer newly born */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (drive->state != drive_referenced) { /* we already know this drive */
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* XXX Check which definition is more up-to-date. Give
|
2000-12-20 05:13:26 +00:00
|
|
|
* preference for the definition on its own drive.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
return; /* XXX */
|
|
|
|
}
|
|
|
|
for (parameter = 2; parameter < tokens; parameter++) { /* look at the other tokens */
|
|
|
|
switch (get_keyword(token[parameter], &keyword_set)) {
|
|
|
|
case kw_device:
|
|
|
|
parameter++;
|
2003-05-01 01:29:52 +00:00
|
|
|
otherdriveno = find_drive_by_name(token[parameter], 0); /* see if it exists already */
|
1999-08-15 02:30:34 +00:00
|
|
|
if (otherdriveno >= 0) { /* yup, */
|
|
|
|
drive->state = drive_unallocated; /* deallocate the drive */
|
|
|
|
throw_rude_remark(EEXIST, /* and complain */
|
|
|
|
"Drive %s would have same device as drive %s",
|
|
|
|
token[1],
|
|
|
|
DRIVE[otherdriveno].label.name);
|
|
|
|
}
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (drive->devicename[0] == '/') { /* we know this drive... */
|
1998-12-28 04:56:24 +00:00
|
|
|
if (strcmp(drive->devicename, token[parameter])) /* different name */
|
|
|
|
close_drive(drive); /* close it if it's open */
|
|
|
|
else /* no change */
|
|
|
|
break;
|
|
|
|
}
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
/* open the device and get the configuration */
|
1998-12-28 04:56:24 +00:00
|
|
|
bcopy(token[parameter], /* insert device information */
|
|
|
|
drive->devicename,
|
|
|
|
min(sizeof(drive->devicename),
|
|
|
|
strlen(token[parameter])));
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
partition_status = read_drive_label(drive, 1);
|
|
|
|
switch (partition_status) {
|
|
|
|
case DL_CANT_OPEN: /* not our kind */
|
1998-12-28 04:56:24 +00:00
|
|
|
close_drive(drive);
|
|
|
|
if (drive->lasterror == EFTYPE) /* wrong kind of partition */
|
|
|
|
throw_rude_remark(drive->lasterror,
|
|
|
|
"Drive %s has invalid partition type",
|
|
|
|
drive->label.name);
|
|
|
|
else /* I/O error of some kind */
|
|
|
|
throw_rude_remark(drive->lasterror,
|
|
|
|
"Can't initialize drive %s",
|
|
|
|
drive->label.name);
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DL_WRONG_DRIVE: /* valid drive, not the name we expected */
|
1999-03-23 04:47:09 +00:00
|
|
|
if (vinum_conf.flags & VF_FORCECONFIG) { /* but we'll accept that */
|
|
|
|
bcopy(token[1], drive->label.name, sizeof(drive->label.name));
|
|
|
|
break;
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
close_drive(drive);
|
1999-03-13 07:32:40 +00:00
|
|
|
/*
|
|
|
|
* There's a potential race condition here:
|
|
|
|
* the rude remark refers to a field in an
|
|
|
|
* unallocated drive, which potentially could
|
|
|
|
* be reused. This works because we're the only
|
|
|
|
* thread accessing the config at the moment.
|
|
|
|
*/
|
|
|
|
drive->state = drive_unallocated; /* throw it away completely */
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(drive->lasterror,
|
|
|
|
"Incorrect drive name %s specified for drive %s",
|
|
|
|
token[1],
|
|
|
|
drive->label.name);
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DL_DELETED_LABEL: /* it was a drive, but we deleted it */
|
|
|
|
case DL_NOT_OURS: /* nothing to do with the rest */
|
|
|
|
case DL_OURS:
|
|
|
|
break;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* read_drive_label overwrites the device name.
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
* If we get here, we can have the drive,
|
1999-03-28 08:53:02 +00:00
|
|
|
* so put it back again
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
bcopy(token[parameter],
|
|
|
|
drive->devicename,
|
|
|
|
min(sizeof(drive->devicename),
|
|
|
|
strlen(token[parameter])));
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_state:
|
1999-08-14 06:24:34 +00:00
|
|
|
parameter++; /* skip the keyword */
|
|
|
|
if (vinum_conf.flags & VF_READING_CONFIG)
|
|
|
|
drive->state = DriveState(token[parameter]); /* set the state */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_hotspare: /* this drive is a hot spare */
|
|
|
|
drive->flags |= VF_HOTSPARE;
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
close_drive(drive);
|
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"Drive %s, invalid keyword: %s",
|
|
|
|
token[1],
|
|
|
|
token[parameter]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (drive->devicename[0] != '/') {
|
1998-12-28 04:56:24 +00:00
|
|
|
drive->state = drive_unallocated; /* deallocate the drive */
|
|
|
|
throw_rude_remark(EINVAL, "No device name for %s", drive->label.name);
|
|
|
|
}
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.drives_used++; /* passed all hurdles: one more in use */
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
/*
|
|
|
|
* If we're replacing a drive, it could be that
|
|
|
|
* we already have subdisks referencing this
|
|
|
|
* drive. Note where they should be and change
|
|
|
|
* their state to obsolete.
|
|
|
|
*/
|
|
|
|
for (sdno = 0; sdno < vinum_conf.subdisks_allocated; sdno++) {
|
|
|
|
if ((SD[sdno].state > sd_referenced)
|
|
|
|
&& (SD[sdno].driveno == driveno)) {
|
|
|
|
give_sd_to_drive(sdno);
|
|
|
|
if (SD[sdno].state > sd_stale)
|
|
|
|
SD[sdno].state = sd_stale;
|
|
|
|
}
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
2003-05-23 01:13:10 +00:00
|
|
|
* Handle a subdisk definition. We store the
|
|
|
|
* information in the global variable sd, so we
|
|
|
|
* don't need to allocate.
|
1998-12-28 04:56:24 +00:00
|
|
|
*
|
2003-05-23 01:13:10 +00:00
|
|
|
* On error throw a message back to the caller.
|
1998-12-28 04:56:24 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_subdisk(int update)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int parameter;
|
|
|
|
int sdno; /* index of sd in vinum_conf */
|
|
|
|
struct sd *sd; /* and pointer to it */
|
|
|
|
u_int64_t size;
|
|
|
|
int detached = 0; /* set to 1 if this is a detached subdisk */
|
|
|
|
int sdindex = -1; /* index in plexes subdisk table */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
enum sdstate state = sd_unallocated; /* state to set, if specified */
|
1999-03-28 08:53:02 +00:00
|
|
|
int autosize = 0; /* set if we autosize in give_sd_to_drive */
|
|
|
|
int namedsdno; /* index of another with this name */
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
char partition = 0; /* partition of external subdisk */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
sdno = get_empty_sd(); /* allocate an SD to initialize */
|
|
|
|
sd = &SD[sdno]; /* and get a pointer */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
for (parameter = 1; parameter < tokens; parameter++) { /* look at the other tokens */
|
|
|
|
switch (get_keyword(token[parameter], &keyword_set)) {
|
1999-03-28 08:53:02 +00:00
|
|
|
/*
|
|
|
|
* If we have a 'name' parameter, it must
|
|
|
|
* come first, because we're too lazy to tidy
|
|
|
|
* up dangling refs if it comes later.
|
|
|
|
*/
|
|
|
|
case kw_name:
|
|
|
|
namedsdno = find_subdisk(token[++parameter], 0); /* find an existing sd with this name */
|
|
|
|
if (namedsdno >= 0) { /* got one */
|
|
|
|
if (SD[namedsdno].state == sd_referenced) { /* we've been told about this one */
|
|
|
|
if (parameter > 2)
|
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"sd %s: name parameter must come first\n", /* no go */
|
|
|
|
token[parameter]);
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
struct plex *plex; /* for tidying up dangling references */
|
|
|
|
|
|
|
|
*sd = SD[namedsdno]; /* copy from the referenced one */
|
|
|
|
SD[namedsdno].state = sd_unallocated; /* and deallocate the referenced one */
|
|
|
|
plex = &PLEX[sd->plexno]; /* now take a look at our plex */
|
|
|
|
for (i = 0; i < plex->subdisks; i++) { /* look for the pointer */
|
|
|
|
if (plex->sdnos[i] == namedsdno) /* pointing to the old subdisk */
|
|
|
|
plex->sdnos[i] = sdno; /* bend it to point here */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (update) /* are we updating? */
|
|
|
|
return; /* that's OK, nothing more to do */
|
|
|
|
else
|
|
|
|
throw_rude_remark(EINVAL, "Duplicate subdisk %s", token[parameter]);
|
|
|
|
} else
|
|
|
|
bcopy(token[parameter],
|
|
|
|
sd->name,
|
|
|
|
min(sizeof(sd->name), strlen(token[parameter])));
|
|
|
|
break;
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
case kw_detached:
|
|
|
|
detached = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_plexoffset:
|
|
|
|
size = sizespec(token[++parameter]);
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if ((size == -1) /* unallocated */
|
1999-03-19 07:10:19 +00:00
|
|
|
&&(vinum_conf.flags & VF_READING_CONFIG)) /* reading from disk */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
break; /* invalid sd; just ignore it */
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((size % DEV_BSIZE) != 0)
|
2000-01-05 06:02:57 +00:00
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"sd %s, bad plex offset alignment: %lld",
|
|
|
|
sd->name,
|
|
|
|
(long long) size);
|
1998-12-28 04:56:24 +00:00
|
|
|
else
|
|
|
|
sd->plexoffset = size / DEV_BSIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_driveoffset:
|
|
|
|
size = sizespec(token[++parameter]);
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if ((size == -1) /* unallocated */
|
1999-03-19 07:10:19 +00:00
|
|
|
&&(vinum_conf.flags & VF_READING_CONFIG)) /* reading from disk */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
break; /* invalid sd; just ignore it */
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((size % DEV_BSIZE) != 0)
|
2000-01-05 06:02:57 +00:00
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"sd %s, bad drive offset alignment: %lld",
|
|
|
|
sd->name,
|
|
|
|
(long long) size);
|
1998-12-28 04:56:24 +00:00
|
|
|
else
|
|
|
|
sd->driveoffset = size / DEV_BSIZE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_len:
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (get_keyword(token[++parameter], &keyword_set) == kw_max) /* select maximum size from drive */
|
|
|
|
size = 0; /* this is how we say it :-) */
|
|
|
|
else
|
|
|
|
size = sizespec(token[parameter]);
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((size % DEV_BSIZE) != 0)
|
|
|
|
throw_rude_remark(EINVAL, "sd %s, length %d not multiple of sector size", sd->name, size);
|
|
|
|
else
|
|
|
|
sd->sectors = size / DEV_BSIZE;
|
1999-03-28 08:53:02 +00:00
|
|
|
/*
|
|
|
|
* We have a problem with autosizing: we need to
|
|
|
|
* give the drive to the plex before we give it
|
|
|
|
* to the drive, in order to be clean if we give
|
|
|
|
* up in the middle, but at this time the size hasn't
|
|
|
|
* been set. Note that we have to fix up after
|
|
|
|
* giving the subdisk to the drive.
|
|
|
|
*/
|
|
|
|
if (size == 0)
|
|
|
|
autosize = 1; /* note that we're autosizing */
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_drive:
|
|
|
|
sd->driveno = find_drive(token[++parameter], 1); /* insert drive information */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_plex:
|
|
|
|
sd->plexno = find_plex(token[++parameter], 1); /* insert plex information */
|
|
|
|
break;
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Set the state. We can't do this directly,
|
1999-03-28 08:53:02 +00:00
|
|
|
* because give_sd_to_plex may change it
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
case kw_state:
|
1999-08-14 06:24:34 +00:00
|
|
|
parameter++; /* skip the keyword */
|
|
|
|
if (vinum_conf.flags & VF_READING_CONFIG)
|
|
|
|
state = SdState(token[parameter]); /* set the state */
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
case kw_partition:
|
|
|
|
parameter++; /* skip the keyword */
|
|
|
|
if ((strlen(token[parameter]) != 1)
|
|
|
|
|| (token[parameter][0] < 'a')
|
|
|
|
|| (token[parameter][0] > 'h'))
|
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"%s: invalid partition %c",
|
|
|
|
sd->name,
|
|
|
|
token[parameter][0]);
|
|
|
|
else
|
|
|
|
partition = token[parameter][0];
|
|
|
|
break;
|
|
|
|
|
2001-05-22 02:29:54 +00:00
|
|
|
case kw_retryerrors:
|
|
|
|
sd->flags |= VF_RETRYERRORS;
|
|
|
|
break;
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
default:
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
throw_rude_remark(EINVAL, "%s: invalid keyword: %s", sd->name, token[parameter]);
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check we have a drive name */
|
|
|
|
if (sd->driveno < 0) { /* didn't specify a drive */
|
|
|
|
sd->driveno = current_drive; /* set to the current drive */
|
|
|
|
if (sd->driveno < 0) /* no current drive? */
|
|
|
|
throw_rude_remark(EINVAL, "Subdisk %s is not associated with a drive", sd->name);
|
|
|
|
}
|
2003-05-23 01:13:10 +00:00
|
|
|
if (DRIVE[sd->driveno].state != drive_up)
|
|
|
|
sd->state = sd_crashed;
|
|
|
|
|
1999-03-28 08:53:02 +00:00
|
|
|
if (autosize != 0) /* need to find a size, */
|
|
|
|
give_sd_to_drive(sdno); /* do it before the plex */
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
/* Check for a plex name */
|
|
|
|
if ((sd->plexno < 0) /* didn't specify a plex */
|
|
|
|
&&(!detached)) /* and didn't say not to, */
|
|
|
|
sd->plexno = current_plex; /* set to the current plex */
|
|
|
|
|
|
|
|
if (sd->plexno >= 0)
|
|
|
|
sdindex = give_sd_to_plex(sd->plexno, sdno); /* now tell the plex that it has this sd */
|
|
|
|
|
|
|
|
sd->sdno = sdno; /* point to our entry in the table */
|
|
|
|
|
|
|
|
/* Does the subdisk have a name? If not, give it one */
|
|
|
|
if (sd->name[0] == '\0') { /* no name */
|
|
|
|
char sdsuffix[8]; /* form sd name suffix here */
|
|
|
|
|
|
|
|
/* Do we have a plex name? */
|
|
|
|
if (sdindex >= 0) /* we have a plex */
|
2003-05-23 01:13:10 +00:00
|
|
|
strlcpy(sd->name, /* take it from there */
|
|
|
|
PLEX[sd->plexno].name,
|
|
|
|
sizeof(sd->name));
|
2003-09-29 08:50:03 +00:00
|
|
|
else { /* no way */
|
2004-02-08 15:27:58 +00:00
|
|
|
if (sd->state == sd_unallocated) { /* haven't finished allocating the sd, */
|
|
|
|
if (autosize != 0) { /* but we might have allocated drive space */
|
|
|
|
vinum_conf.subdisks_used++; /* ugly hack needed for free_sd() */
|
|
|
|
free_sd(sdno); /* free it to return drive space */
|
|
|
|
} else { /* just clear it */
|
|
|
|
bzero(sd, sizeof(struct sd));
|
|
|
|
sd->state = sd_unallocated;
|
|
|
|
}
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(EINVAL, "Unnamed sd is not associated with a plex");
|
2003-09-29 08:50:03 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
sprintf(sdsuffix, ".s%d", sdindex); /* form the suffix */
|
2003-05-23 01:13:10 +00:00
|
|
|
strlcat(sd->name, sdsuffix, sizeof(sd->name)); /* and add it to the name */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
/* do we have complete info for this subdisk? */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (sd->sectors < 0)
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(EINVAL, "sd %s has no length spec", sd->name);
|
|
|
|
|
2002-12-02 23:53:32 +00:00
|
|
|
if (sd->dev == NULL)
|
2003-05-01 01:29:52 +00:00
|
|
|
/*
|
|
|
|
* 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),
|
2002-12-02 23:53:32 +00:00
|
|
|
UID_ROOT,
|
2003-01-16 23:47:04 +00:00
|
|
|
GID_OPERATOR,
|
2003-05-01 01:29:52 +00:00
|
|
|
S_IRUSR | S_IWUSR | S_IRGRP,
|
2002-12-02 23:53:32 +00:00
|
|
|
"vinum/sd/%s",
|
|
|
|
sd->name);
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
if (state != sd_unallocated) /* we had a specific state to set */
|
|
|
|
sd->state = state; /* do it now */
|
|
|
|
else if (sd->state == sd_unallocated) /* no, nothing set yet, */
|
1999-03-28 08:53:02 +00:00
|
|
|
sd->state = sd_empty; /* must be empty */
|
|
|
|
if (autosize == 0) /* no autoconfig, do the drive now */
|
|
|
|
give_sd_to_drive(sdno);
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.subdisks_used++; /* one more in use */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Handle a plex definition.
|
1998-12-28 04:56:24 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_plex(int update)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int parameter;
|
|
|
|
int plexno; /* index of plex in vinum_conf */
|
|
|
|
struct plex *plex; /* and pointer to it */
|
|
|
|
int pindex = MAXPLEX; /* index in volume's plex list */
|
|
|
|
int detached = 0; /* don't give it to a volume */
|
|
|
|
int namedplexno;
|
1999-03-28 08:53:02 +00:00
|
|
|
enum plexstate state = plex_init; /* state to set at end */
|
2003-05-05 05:32:15 +00:00
|
|
|
int preferme; /* set if we want to be preferred access */
|
2004-02-04 22:29:52 +00:00
|
|
|
int stripesize;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
2004-02-04 22:29:52 +00:00
|
|
|
stripesize = 0;
|
1998-12-28 04:56:24 +00:00
|
|
|
current_plex = -1; /* forget the previous plex */
|
2003-05-05 05:32:15 +00:00
|
|
|
preferme = 0; /* nothing special yet */
|
1998-12-28 04:56:24 +00:00
|
|
|
plexno = get_empty_plex(); /* allocate a plex */
|
|
|
|
plex = &PLEX[plexno]; /* and point to it */
|
|
|
|
plex->plexno = plexno; /* and back to the config */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
for (parameter = 1; parameter < tokens; parameter++) { /* look at the other tokens */
|
|
|
|
switch (get_keyword(token[parameter], &keyword_set)) {
|
1999-03-28 08:53:02 +00:00
|
|
|
/*
|
|
|
|
* If we have a 'name' parameter, it must
|
|
|
|
* come first, because we're too lazy to tidy
|
|
|
|
* up dangling refs if it comes later.
|
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
case kw_name:
|
|
|
|
namedplexno = find_plex(token[++parameter], 0); /* find an existing plex with this name */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
if (namedplexno >= 0) { /* plex exists already, */
|
1999-03-28 08:53:02 +00:00
|
|
|
if (PLEX[namedplexno].state == plex_referenced) { /* we've been told about this one */
|
|
|
|
if (parameter > 2) /* we've done other things first, */
|
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"plex %s: name parameter must come first\n", /* no go */
|
|
|
|
token[parameter]);
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
struct volume *vol; /* for tidying up dangling references */
|
|
|
|
|
|
|
|
*plex = PLEX[namedplexno]; /* get the info */
|
|
|
|
PLEX[namedplexno].state = plex_unallocated; /* and deallocate the other one */
|
|
|
|
vol = &VOL[plex->volno]; /* point to the volume */
|
|
|
|
for (i = 0; i < MAXPLEX; i++) { /* for each plex */
|
|
|
|
if (vol->plex[i] == namedplexno)
|
|
|
|
vol->plex[i] = plexno; /* bend the pointer */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; /* use this one */
|
|
|
|
}
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
if (update) /* are we updating? */
|
|
|
|
return; /* yes: that's OK, just return */
|
|
|
|
else
|
|
|
|
throw_rude_remark(EINVAL, "Duplicate plex %s", token[parameter]);
|
1999-03-28 08:53:02 +00:00
|
|
|
} else
|
|
|
|
bcopy(token[parameter], /* put in the name */
|
|
|
|
plex->name,
|
|
|
|
min(MAXPLEXNAME, strlen(token[parameter])));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_detached:
|
|
|
|
detached = 1;
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_org: /* plex organization */
|
|
|
|
switch (get_keyword(token[++parameter], &keyword_set)) {
|
|
|
|
case kw_concat:
|
|
|
|
plex->organization = plex_concat;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_striped:
|
|
|
|
{
|
|
|
|
plex->organization = plex_striped;
|
2004-02-04 22:29:52 +00:00
|
|
|
|
|
|
|
if (++parameter >= tokens) /* No stripe size specified. */
|
|
|
|
stripesize = 0;
|
1998-12-28 04:56:24 +00:00
|
|
|
else
|
2004-02-04 22:29:52 +00:00
|
|
|
stripesize = sizespec(token[parameter]);
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
case kw_raid4:
|
|
|
|
{
|
|
|
|
plex->organization = plex_raid4;
|
2004-02-04 22:29:52 +00:00
|
|
|
|
|
|
|
if (++parameter >= tokens) /* No stripe size specified. */
|
|
|
|
stripesize = 0;
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
else
|
2004-02-04 22:29:52 +00:00
|
|
|
stripesize = sizespec(token[parameter]);
|
|
|
|
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
case kw_raid5:
|
|
|
|
{
|
|
|
|
plex->organization = plex_raid5;
|
2004-02-04 22:29:52 +00:00
|
|
|
|
|
|
|
if (++parameter >= tokens) /* No stripe size specified. */
|
|
|
|
stripesize = 0;
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
else
|
2004-02-04 22:29:52 +00:00
|
|
|
stripesize = sizespec(token[parameter]);
|
|
|
|
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
throw_rude_remark(EINVAL, "Invalid plex organization");
|
|
|
|
}
|
2004-02-04 22:29:52 +00:00
|
|
|
if (isstriped(plex)) {
|
|
|
|
if (stripesize == 0) /* didn't specify a valid stripe size */
|
|
|
|
throw_rude_remark(EINVAL, "Need a stripe size parameter");
|
|
|
|
else if (stripesize % DEV_BSIZE != 0)
|
|
|
|
throw_rude_remark(EINVAL, "plex %s: stripe size %d not a multiple of sector size",
|
|
|
|
plex->name,
|
|
|
|
stripesize);
|
|
|
|
else
|
|
|
|
plex->stripesize = stripesize / DEV_BSIZE;
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
2003-05-05 05:32:15 +00:00
|
|
|
/*
|
|
|
|
* We're the preferred plex of our volume.
|
|
|
|
* Unfortunately, we don't know who our
|
|
|
|
* volume is yet. Note that we want to be
|
|
|
|
* preferred, and actually do it after we
|
|
|
|
* get a volume.
|
|
|
|
*/
|
|
|
|
case kw_preferred:
|
|
|
|
preferme = 1;
|
|
|
|
break;
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
case kw_volume:
|
|
|
|
plex->volno = find_volume(token[++parameter], 1); /* insert a pointer to the volume */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_sd: /* add a subdisk */
|
|
|
|
{
|
|
|
|
int sdno;
|
|
|
|
|
|
|
|
sdno = find_subdisk(token[++parameter], 1); /* find a subdisk */
|
|
|
|
SD[sdno].plexoffset = sizespec(token[++parameter]); /* get the offset */
|
|
|
|
give_sd_to_plex(plexno, sdno); /* and insert it there */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case kw_state:
|
1999-08-14 06:24:34 +00:00
|
|
|
parameter++; /* skip the keyword */
|
|
|
|
if (vinum_conf.flags & VF_READING_CONFIG)
|
|
|
|
state = PlexState(token[parameter]); /* set the state */
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw_rude_remark(EINVAL, "plex %s, invalid keyword: %s",
|
|
|
|
plex->name,
|
|
|
|
token[parameter]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-14 06:29:56 +00:00
|
|
|
if (plex->organization == plex_disorg)
|
|
|
|
throw_rude_remark(EINVAL, "No plex organization specified");
|
|
|
|
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((plex->volno < 0) /* we don't have a volume */
|
|
|
|
&&(!detached)) /* and we wouldn't object */
|
|
|
|
plex->volno = current_volume;
|
|
|
|
|
|
|
|
if (plex->volno >= 0)
|
2003-05-05 05:32:15 +00:00
|
|
|
pindex = give_plex_to_volume(plex->volno, /* Now tell the volume that it has this plex */
|
|
|
|
plexno,
|
|
|
|
preferme);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
/* Does the plex have a name? If not, give it one */
|
|
|
|
if (plex->name[0] == '\0') { /* no name */
|
|
|
|
char plexsuffix[8]; /* form plex name suffix here */
|
|
|
|
/* Do we have a volume name? */
|
|
|
|
if (plex->volno >= 0) /* we have a volume */
|
2003-05-23 01:13:10 +00:00
|
|
|
strlcpy(plex->name, /* take it from there */
|
|
|
|
VOL[plex->volno].name,
|
|
|
|
sizeof(plex->name));
|
1998-12-28 04:56:24 +00:00
|
|
|
else /* no way */
|
|
|
|
throw_rude_remark(EINVAL, "Unnamed plex is not associated with a volume");
|
|
|
|
sprintf(plexsuffix, ".p%d", pindex); /* form the suffix */
|
2003-05-23 01:13:10 +00:00
|
|
|
strlcat(plex->name, plexsuffix, sizeof(plex->name)); /* and add it to the name */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
2001-05-22 02:29:54 +00:00
|
|
|
if (isstriped(plex)) {
|
2001-01-10 05:01:12 +00:00
|
|
|
plex->lock = (struct rangelock *)
|
|
|
|
Malloc(PLEX_LOCKS * sizeof(struct rangelock));
|
|
|
|
CHECKALLOC(plex->lock, "vinum: Can't allocate lock table\n");
|
|
|
|
bzero((char *) plex->lock, PLEX_LOCKS * sizeof(struct rangelock));
|
2003-05-23 01:13:10 +00:00
|
|
|
plex->lockmtx = &plexmutex[plexno % PLEXMUTEXES]; /* use this mutex for locking */
|
2001-01-10 05:01:12 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
/* Note the last plex we configured */
|
|
|
|
current_plex = plexno;
|
1999-03-28 08:53:02 +00:00
|
|
|
plex->state = state; /* set whatever state we chose */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.plexes_used++; /* one more in use */
|
2002-12-02 23:53:32 +00:00
|
|
|
if (plex->dev == NULL)
|
2003-05-01 01:29:52 +00:00
|
|
|
plex->dev = make_dev(&vinum_cdevsw,
|
|
|
|
VINUMMINOR(plexno, VINUM_PLEX_TYPE),
|
2002-12-02 23:53:32 +00:00
|
|
|
UID_ROOT,
|
2003-01-16 23:47:04 +00:00
|
|
|
GID_OPERATOR,
|
2003-05-01 01:29:52 +00:00
|
|
|
S_IRUSR | S_IWUSR | S_IRGRP,
|
|
|
|
"vinum/plex/%s",
|
|
|
|
plex->name);
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Handle a volume definition.
|
1998-12-28 04:56:24 +00:00
|
|
|
* If we find an error, print a message, deallocate the nascent volume, and return
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_volume(int update)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int parameter;
|
|
|
|
int volno;
|
|
|
|
struct volume *vol; /* collect volume info here */
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (tokens < 2) /* not enough tokens */
|
|
|
|
throw_rude_remark(EINVAL, "Volume has no name");
|
|
|
|
current_volume = -1; /* forget the previous volume */
|
|
|
|
volno = find_volume(token[1], 1); /* allocate a volume to initialize */
|
|
|
|
vol = &VOL[volno]; /* and get a pointer */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if (update && ((vol->flags & VF_CREATED) == 0)) /* this volume exists already */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
return; /* don't do anything */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vol->flags &= ~VF_CREATED; /* it exists now */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
for (parameter = 2; parameter < tokens; parameter++) { /* look at all tokens */
|
|
|
|
switch (get_keyword(token[parameter], &keyword_set)) {
|
|
|
|
case kw_plex:
|
|
|
|
{
|
|
|
|
int plexno; /* index of this plex */
|
1999-03-28 08:53:02 +00:00
|
|
|
int myplexno; /* and index if it's already ours */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
plexno = find_plex(token[++parameter], 1); /* find a plex */
|
|
|
|
if (plexno < 0) /* couldn't */
|
|
|
|
break; /* we've already had an error message */
|
1999-03-28 08:53:02 +00:00
|
|
|
myplexno = my_plex(volno, plexno); /* does it already belong to us? */
|
|
|
|
if (myplexno > 0) /* yes, shouldn't get it again */
|
1998-12-28 04:56:24 +00:00
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"Plex %s already belongs to volume %s",
|
|
|
|
token[parameter],
|
|
|
|
vol->name);
|
|
|
|
else if (++vol->plexes > 8) /* another entry */
|
|
|
|
throw_rude_remark(EINVAL,
|
|
|
|
"Too many plexes for volume %s",
|
|
|
|
vol->name);
|
|
|
|
vol->plex[vol->plexes - 1] = plexno;
|
1999-03-28 08:53:02 +00:00
|
|
|
PLEX[plexno].state = plex_referenced; /* we know something about it */
|
|
|
|
PLEX[plexno].volno = volno; /* and this volume references it */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_readpol:
|
|
|
|
switch (get_keyword(token[++parameter], &keyword_set)) { /* decide what to do */
|
|
|
|
case kw_round:
|
|
|
|
vol->preferred_plex = ROUND_ROBIN_READPOL; /* default */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_prefer:
|
|
|
|
{
|
|
|
|
int myplexno; /* index of this plex */
|
|
|
|
|
|
|
|
myplexno = find_plex(token[++parameter], 1); /* find a plex */
|
2003-05-05 05:32:15 +00:00
|
|
|
if (myplexno < 0) { /* couldn't */
|
|
|
|
printf("vinum: couldn't find preferred plex %s for %s\n",
|
|
|
|
token[parameter],
|
|
|
|
vol->name);
|
1998-12-28 04:56:24 +00:00
|
|
|
break; /* we've already had an error message */
|
2003-05-05 05:32:15 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
myplexno = my_plex(volno, myplexno); /* does it already belong to us? */
|
|
|
|
if (myplexno > 0) /* yes */
|
|
|
|
vol->preferred_plex = myplexno; /* just note the index */
|
|
|
|
else if (++vol->plexes > 8) /* another entry */
|
|
|
|
throw_rude_remark(EINVAL, "Too many plexes");
|
|
|
|
else { /* space for the new plex */
|
|
|
|
vol->plex[vol->plexes - 1] = myplexno; /* add it to our list */
|
|
|
|
vol->preferred_plex = vol->plexes - 1; /* and note the index */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw_rude_remark(EINVAL, "Invalid read policy");
|
|
|
|
}
|
|
|
|
|
|
|
|
case kw_setupstate:
|
|
|
|
vol->flags |= VF_CONFIG_SETUPSTATE; /* set the volume up later on */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_state:
|
1999-08-14 06:24:34 +00:00
|
|
|
parameter++; /* skip the keyword */
|
|
|
|
if (vinum_conf.flags & VF_READING_CONFIG)
|
|
|
|
vol->state = VolState(token[parameter]); /* set the state */
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* XXX experimental ideas. These are not
|
1998-12-28 04:56:24 +00:00
|
|
|
* documented, and will not be until I
|
2003-05-05 08:42:42 +00:00
|
|
|
* decide they're worth keeping.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
case kw_writethrough: /* set writethrough mode */
|
|
|
|
vol->flags |= VF_WRITETHROUGH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_writeback: /* set writeback mode */
|
|
|
|
vol->flags &= ~VF_WRITETHROUGH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw_rude_remark(EINVAL, "volume %s, invalid keyword: %s",
|
|
|
|
vol->name,
|
|
|
|
token[parameter]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current_volume = volno; /* note last referred volume */
|
1999-05-15 05:49:21 +00:00
|
|
|
vol->volno = volno; /* also note in volume */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Before we can actually use the volume, we need
|
1998-12-28 04:56:24 +00:00
|
|
|
* a volume label. We could start to fake one here,
|
|
|
|
* but it will be a lot easier when we have some
|
|
|
|
* to copy from the drives, so defer it until we
|
1999-03-28 08:53:02 +00:00
|
|
|
* set up the configuration. XXX
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
if (vol->state == volume_unallocated)
|
|
|
|
vol->state = volume_down; /* now ready to bring up at the end */
|
|
|
|
|
|
|
|
/* Find out how big our volume is */
|
|
|
|
for (i = 0; i < vol->plexes; i++)
|
|
|
|
vol->size = max(vol->size, PLEX[vol->plex[i]].length);
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.volumes_used++; /* one more in use */
|
2002-12-02 23:53:32 +00:00
|
|
|
if (vol->dev == NULL)
|
2003-05-01 01:29:52 +00:00
|
|
|
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);
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Parse a config entry. CARE! This destroys the original contents of the
|
1998-12-28 04:56:24 +00:00
|
|
|
* config entry, which we don't really need after this. More specifically, it
|
|
|
|
* places \0 characters at the end of each token.
|
|
|
|
*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* Return 0 if all is well, otherwise EINVAL for invalid keyword,
|
|
|
|
* or ENOENT if 'read' command doesn't find any drives.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
parse_config(char *cptr, struct keywordset *keyset, int update)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = 0; /* until proven otherwise */
|
2001-05-22 02:29:54 +00:00
|
|
|
tokens = tokenize(cptr, token, MAXTOKEN); /* chop up into tokens */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
if (tokens <= 0) /* screwed up or empty line */
|
|
|
|
return tokens; /* give up */
|
2001-05-22 02:29:54 +00:00
|
|
|
else if (tokens == MAXTOKEN) /* too many */
|
|
|
|
throw_rude_remark(E2BIG,
|
|
|
|
"Configuration error for %s: too many parameters",
|
|
|
|
token[1]);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
|
|
|
if (token[0][0] == '#') /* comment line */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (get_keyword(token[0], keyset)) { /* decide what to do */
|
|
|
|
case kw_drive:
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_drive(update);
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_subdisk:
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_subdisk(update);
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_plex:
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_plex(update);
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kw_volume:
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
config_volume(update);
|
1998-12-28 04:56:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Anything else is invalid in this context */
|
|
|
|
default:
|
|
|
|
throw_rude_remark(EINVAL, /* should we die? */
|
|
|
|
"Invalid configuration information: %s",
|
|
|
|
token[0]);
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* parse a line handed in from userland via ioctl.
|
1998-12-28 04:56:24 +00:00
|
|
|
* This differs only by the error reporting mechanism:
|
|
|
|
* we return the error indication in the reply to the
|
|
|
|
* ioctl, so we need to set a global static pointer in
|
|
|
|
* this file. This technique works because we have
|
|
|
|
* ensured that configuration is performed in a single-
|
1999-03-28 08:53:02 +00:00
|
|
|
* threaded manner
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1998-12-28 04:56:24 +00:00
|
|
|
parse_user_config(char *cptr, struct keywordset *keyset)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
ioctl_reply = (struct _ioctl_reply *) cptr;
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
status = parse_config(cptr, keyset, 0);
|
1998-12-28 04:56:24 +00:00
|
|
|
ioctl_reply = NULL; /* don't do this again */
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove an object */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
remove(struct vinum_ioctl_msg *msg)
|
|
|
|
{
|
|
|
|
struct vinum_ioctl_msg message = *msg; /* make a copy to hand on */
|
|
|
|
|
|
|
|
ioctl_reply = (struct _ioctl_reply *) msg; /* reinstate the address to reply to */
|
|
|
|
ioctl_reply->error = 0; /* no error, */
|
|
|
|
ioctl_reply->msg[0] = '\0'; /* no message */
|
|
|
|
|
|
|
|
switch (message.type) {
|
|
|
|
case drive_object:
|
1999-09-28 22:43:07 +00:00
|
|
|
remove_drive_entry(message.index, message.force);
|
1998-12-28 04:56:24 +00:00
|
|
|
updateconfig(0);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case sd_object:
|
|
|
|
remove_sd_entry(message.index, message.force, message.recurse);
|
|
|
|
updateconfig(0);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case plex_object:
|
|
|
|
remove_plex_entry(message.index, message.force, message.recurse);
|
|
|
|
updateconfig(0);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case volume_object:
|
|
|
|
remove_volume_entry(message.index, message.force, message.recurse);
|
|
|
|
updateconfig(0);
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ioctl_reply->error = EINVAL;
|
|
|
|
strcpy(ioctl_reply->msg, "Invalid object type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove a drive. */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1999-09-28 22:43:07 +00:00
|
|
|
remove_drive_entry(int driveno, int force)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
struct drive *drive = &DRIVE[driveno];
|
1999-09-28 22:43:07 +00:00
|
|
|
int sdno;
|
1998-12-28 04:56:24 +00:00
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if ((driveno > vinum_conf.drives_allocated) /* not a valid drive */
|
1998-12-28 04:56:24 +00:00
|
|
|
||(drive->state == drive_unallocated)) { /* or nothing there */
|
|
|
|
ioctl_reply->error = EINVAL;
|
|
|
|
strcpy(ioctl_reply->msg, "No such drive");
|
|
|
|
} else if (drive->opencount > 0) { /* we have subdisks */
|
|
|
|
if (force) { /* do it at any cost */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (sdno = 0; sdno < vinum_conf.subdisks_allocated; sdno++) {
|
1998-12-28 04:56:24 +00:00
|
|
|
if ((SD[sdno].state != sd_unallocated) /* subdisk is allocated */
|
1999-09-28 22:43:07 +00:00
|
|
|
&&(SD[sdno].driveno == driveno)) /* and it belongs to this drive */
|
|
|
|
remove_sd_entry(sdno, force, 0);
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
remove_drive(driveno); /* now remove it */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.drives_used--; /* one less drive */
|
1998-12-28 04:56:24 +00:00
|
|
|
} else
|
|
|
|
ioctl_reply->error = EBUSY; /* can't do that */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
} else {
|
1998-12-28 04:56:24 +00:00
|
|
|
remove_drive(driveno); /* just remove it */
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.drives_used--; /* one less drive */
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove a subdisk */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
remove_sd_entry(int sdno, int force, int recurse)
|
|
|
|
{
|
|
|
|
struct sd *sd = &SD[sdno];
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if ((sdno > vinum_conf.subdisks_allocated) /* not a valid sd */
|
1998-12-28 04:56:24 +00:00
|
|
|
||(sd->state == sd_unallocated)) { /* or nothing there */
|
|
|
|
ioctl_reply->error = EINVAL;
|
|
|
|
strcpy(ioctl_reply->msg, "No such subdisk");
|
2001-05-22 02:29:54 +00:00
|
|
|
} else if (sd->flags & VF_OPEN) /* we're open */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
ioctl_reply->error = EBUSY; /* no getting around that */
|
2001-05-22 02:29:54 +00:00
|
|
|
else if (sd->plexno >= 0) { /* we have a plex */
|
|
|
|
if (force) { /* do it at any cost */
|
1998-12-28 04:56:24 +00:00
|
|
|
struct plex *plex = &PLEX[sd->plexno]; /* point to our plex */
|
|
|
|
int mysdno;
|
|
|
|
|
|
|
|
for (mysdno = 0; /* look for ourselves */
|
|
|
|
mysdno < plex->subdisks && &SD[plex->sdnos[mysdno]] != sd;
|
|
|
|
mysdno++);
|
2001-05-22 02:29:54 +00:00
|
|
|
if (mysdno == plex->subdisks) /* didn't find it */
|
1999-09-28 22:43:07 +00:00
|
|
|
log(LOG_ERR,
|
|
|
|
"Error removing subdisk %s: not found in plex %s\n",
|
|
|
|
SD[mysdno].name,
|
|
|
|
plex->name);
|
2001-05-22 02:29:54 +00:00
|
|
|
else { /* remove the subdisk from plex */
|
1999-09-28 22:43:07 +00:00
|
|
|
if (mysdno < (plex->subdisks - 1)) /* not the last subdisk */
|
|
|
|
bcopy(&plex->sdnos[mysdno + 1],
|
|
|
|
&plex->sdnos[mysdno],
|
|
|
|
(plex->subdisks - 1 - mysdno) * sizeof(int));
|
|
|
|
plex->subdisks--;
|
|
|
|
sd->plexno = -1; /* disown the subdisk */
|
|
|
|
}
|
1999-08-24 02:20:30 +00:00
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
* Removing a subdisk from a striped or
|
|
|
|
* RAID-4 or RAID-5 plex really tears the
|
|
|
|
* hell out of the structure, and it needs
|
|
|
|
* to be reinitialized.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
if (plex->organization != plex_concat) /* not concatenated, */
|
|
|
|
set_plex_state(plex->plexno, plex_faulty, setstate_force); /* need to reinitialize */
|
2001-05-22 02:29:54 +00:00
|
|
|
log(LOG_INFO, "vinum: removing %s\n", sd->name);
|
|
|
|
free_sd(sdno);
|
|
|
|
} else
|
|
|
|
ioctl_reply->error = EBUSY; /* can't do that */
|
|
|
|
} else {
|
|
|
|
log(LOG_INFO, "vinum: removing %s\n", sd->name);
|
|
|
|
free_sd(sdno);
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove a plex */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
remove_plex_entry(int plexno, int force, int recurse)
|
|
|
|
{
|
|
|
|
struct plex *plex = &PLEX[plexno];
|
|
|
|
int sdno;
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if ((plexno > vinum_conf.plexes_allocated) /* not a valid plex */
|
1998-12-28 04:56:24 +00:00
|
|
|
||(plex->state == plex_unallocated)) { /* or nothing there */
|
|
|
|
ioctl_reply->error = EINVAL;
|
|
|
|
strcpy(ioctl_reply->msg, "No such plex");
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
} else if (plex->flags & VF_OPEN) { /* we're open */
|
1998-12-28 04:56:24 +00:00
|
|
|
ioctl_reply->error = EBUSY; /* no getting around that */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (plex->subdisks) {
|
|
|
|
if (force) { /* do it anyway */
|
|
|
|
if (recurse) { /* remove all below */
|
1999-09-28 22:43:07 +00:00
|
|
|
int sds = plex->subdisks;
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
for (sdno = 0; sdno < sds; sdno++)
|
1998-12-28 04:56:24 +00:00
|
|
|
free_sd(plex->sdnos[sdno]); /* free all subdisks */
|
|
|
|
} else { /* just tear them out */
|
1999-09-28 22:43:07 +00:00
|
|
|
int sds = plex->subdisks;
|
|
|
|
for (sdno = 0; sdno < sds; sdno++)
|
1998-12-28 04:56:24 +00:00
|
|
|
SD[plex->sdnos[sdno]].plexno = -1; /* no plex any more */
|
|
|
|
}
|
|
|
|
} else { /* can't do it without force */
|
|
|
|
ioctl_reply->error = EBUSY; /* can't do that */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (plex->volno >= 0) { /* we are part of a volume */
|
|
|
|
if (force) { /* do it at any cost */
|
|
|
|
struct volume *vol = &VOL[plex->volno];
|
|
|
|
int myplexno;
|
|
|
|
|
|
|
|
for (myplexno = 0; myplexno < vol->plexes; myplexno++)
|
|
|
|
if (vol->plex[myplexno] == plexno) /* found it */
|
|
|
|
break;
|
1999-09-28 22:43:07 +00:00
|
|
|
if (myplexno == vol->plexes) /* didn't find it. Huh? */
|
|
|
|
log(LOG_ERR,
|
|
|
|
"Error removing plex %s: not found in volume %s\n",
|
|
|
|
plex->name,
|
|
|
|
vol->name);
|
1998-12-28 04:56:24 +00:00
|
|
|
if (myplexno < (vol->plexes - 1)) /* not the last plex in the list */
|
1999-09-28 22:43:07 +00:00
|
|
|
bcopy(&vol->plex[myplexno + 1],
|
|
|
|
&vol->plex[myplexno],
|
|
|
|
vol->plexes - 1 - myplexno);
|
1998-12-28 04:56:24 +00:00
|
|
|
vol->plexes--;
|
|
|
|
} else {
|
|
|
|
ioctl_reply->error = EBUSY; /* can't do that */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
log(LOG_INFO, "vinum: removing %s\n", plex->name);
|
1998-12-28 04:56:24 +00:00
|
|
|
free_plex(plexno);
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.plexes_used--; /* one less plex */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove a volume */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
remove_volume_entry(int volno, int force, int recurse)
|
|
|
|
{
|
|
|
|
struct volume *vol = &VOL[volno];
|
|
|
|
int plexno;
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
if ((volno > vinum_conf.volumes_allocated) /* not a valid volume */
|
1998-12-28 04:56:24 +00:00
|
|
|
||(vol->state == volume_unallocated)) { /* or nothing there */
|
|
|
|
ioctl_reply->error = EINVAL;
|
|
|
|
strcpy(ioctl_reply->msg, "No such volume");
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
} else if (vol->flags & VF_OPEN) /* we're open */
|
1998-12-28 04:56:24 +00:00
|
|
|
ioctl_reply->error = EBUSY; /* no getting around that */
|
|
|
|
else if (vol->plexes) {
|
|
|
|
if (recurse && force) { /* remove all below */
|
1999-09-28 22:43:07 +00:00
|
|
|
int plexes = vol->plexes;
|
|
|
|
|
|
|
|
/* for (plexno = plexes - 1; plexno >= 0; plexno--) */
|
|
|
|
for (plexno = 0; plexno < plexes; plexno++)
|
|
|
|
remove_plex_entry(vol->plex[plexno], force, recurse);
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
log(LOG_INFO, "vinum: removing %s\n", vol->name);
|
1998-12-28 04:56:24 +00:00
|
|
|
free_volume(volno);
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.volumes_used--; /* one less volume */
|
1998-12-28 04:56:24 +00:00
|
|
|
} else
|
|
|
|
ioctl_reply->error = EBUSY; /* can't do that */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
} else {
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
log(LOG_INFO, "vinum: removing %s\n", vol->name);
|
1998-12-28 04:56:24 +00:00
|
|
|
free_volume(volno);
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
vinum_conf.volumes_used--; /* one less volume */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-03-13 07:32:40 +00:00
|
|
|
/* Currently called only from ioctl */
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
update_sd_config(int sdno, int diskconfig)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
if (!diskconfig)
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
set_sd_state(sdno, sd_up, setstate_configuring);
|
1999-03-13 07:32:40 +00:00
|
|
|
SD[sdno].flags &= ~VF_NEWBORN;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
update_plex_config(int plexno, int diskconfig)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
u_int64_t size;
|
1998-12-28 04:56:24 +00:00
|
|
|
int sdno;
|
|
|
|
struct plex *plex = &PLEX[plexno];
|
|
|
|
enum plexstate state = plex_up; /* state we want the plex in */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
int remainder; /* size of fractional stripe at end */
|
1999-03-13 07:32:40 +00:00
|
|
|
int added_plex; /* set if we add a plex to a volume */
|
|
|
|
int required_sds; /* number of subdisks we need */
|
|
|
|
struct sd *sd;
|
|
|
|
struct volume *vol;
|
2002-05-24 06:01:07 +00:00
|
|
|
int data_sds = 0; /* number of sds carrying data */
|
1998-12-28 04:56:24 +00:00
|
|
|
|
1999-03-28 08:53:02 +00:00
|
|
|
if (plex->state < plex_init) /* not a real plex, */
|
1999-03-23 04:47:09 +00:00
|
|
|
return;
|
1999-03-13 07:32:40 +00:00
|
|
|
added_plex = 0;
|
|
|
|
if (plex->volno >= 0) { /* we have a volume */
|
|
|
|
vol = &VOL[plex->volno];
|
1999-08-24 02:20:30 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we're newly born,
|
|
|
|
* and the volume isn't,
|
|
|
|
* and it has other plexes,
|
|
|
|
* and we didn't read this mess from disk,
|
|
|
|
* we were added later.
|
|
|
|
*/
|
|
|
|
if ((plex->flags & VF_NEWBORN)
|
|
|
|
&& ((vol->flags & VF_NEWBORN) == 0)
|
|
|
|
&& (vol->plexes > 0)
|
|
|
|
&& (diskconfig == 0)) {
|
|
|
|
added_plex = 1;
|
1999-03-13 07:32:40 +00:00
|
|
|
state = plex_down; /* so take ourselves down */
|
|
|
|
}
|
|
|
|
}
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Check that our subdisks make sense. For
|
2001-05-22 02:29:54 +00:00
|
|
|
* striped plexes, we need at least two
|
|
|
|
* subdisks, and for RAID-4 and RAID-5 plexes we
|
|
|
|
* need at least three subdisks. In each case
|
|
|
|
* they must all be the same size.
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-03-28 08:53:02 +00:00
|
|
|
if (plex->organization == plex_striped) {
|
|
|
|
data_sds = plex->subdisks;
|
1999-03-13 07:32:40 +00:00
|
|
|
required_sds = 2;
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
} else if (isparity(plex)) { /* RAID 4 or 5 */
|
1999-03-28 08:53:02 +00:00
|
|
|
data_sds = plex->subdisks - 1;
|
1999-03-13 07:32:40 +00:00
|
|
|
required_sds = 3;
|
1999-03-28 08:53:02 +00:00
|
|
|
} else
|
1999-03-13 07:32:40 +00:00
|
|
|
required_sds = 0;
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
if (required_sds > 0) { /* striped, RAID-4 or RAID-5 */
|
1999-03-13 07:32:40 +00:00
|
|
|
if (plex->subdisks < required_sds) {
|
|
|
|
log(LOG_ERR,
|
|
|
|
"vinum: plex %s does not have at least %d subdisks\n",
|
|
|
|
plex->name,
|
|
|
|
required_sds);
|
|
|
|
state = plex_faulty;
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Now see if the plex size is a multiple of
|
|
|
|
* the stripe size. If not, trim off the end
|
|
|
|
* of each subdisk and return it to the drive.
|
|
|
|
*/
|
1999-04-09 01:20:22 +00:00
|
|
|
if (plex->length > 0) {
|
1999-04-10 08:08:45 +00:00
|
|
|
if (data_sds > 0) {
|
|
|
|
if (plex->stripesize > 0) {
|
1999-08-24 02:20:30 +00:00
|
|
|
remainder = (int) (plex->length /* are we exact? */
|
|
|
|
% ((u_int64_t) plex->stripesize * data_sds));
|
1999-04-10 08:08:45 +00:00
|
|
|
if (remainder) { /* no */
|
|
|
|
log(LOG_INFO, "vinum: removing %d blocks of partial stripe at the end of %s\n",
|
|
|
|
remainder,
|
|
|
|
plex->name);
|
|
|
|
plex->length -= remainder; /* shorten the plex */
|
|
|
|
remainder /= data_sds; /* spread the remainder amongst the sds */
|
|
|
|
for (sdno = 0; sdno < plex->subdisks; sdno++) {
|
|
|
|
sd = &SD[plex->sdnos[sdno]]; /* point to the subdisk */
|
|
|
|
return_drive_space(sd->driveno, /* return the space */
|
|
|
|
sd->driveoffset + sd->sectors - remainder,
|
|
|
|
remainder);
|
|
|
|
sd->sectors -= remainder; /* and shorten it */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else /* no data sds, */
|
|
|
|
plex->length = 0; /* reset length */
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
size = 0;
|
|
|
|
for (sdno = 0; sdno < plex->subdisks; sdno++) {
|
1999-03-13 07:32:40 +00:00
|
|
|
sd = &SD[plex->sdnos[sdno]];
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
if (isstriped(plex)
|
1998-12-28 04:56:24 +00:00
|
|
|
&& (sdno > 0)
|
1999-03-13 07:32:40 +00:00
|
|
|
&& (sd->sectors != SD[plex->sdnos[sdno - 1]].sectors)) {
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
log(LOG_ERR, "vinum: %s must have equal sized subdisks\n", plex->name);
|
1999-03-13 07:32:40 +00:00
|
|
|
state = plex_down;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
1999-03-13 07:32:40 +00:00
|
|
|
size += sd->sectors;
|
|
|
|
if (added_plex) /* we were added later */
|
|
|
|
sd->state = sd_stale; /* stale until proven otherwise */
|
2003-05-05 08:42:42 +00:00
|
|
|
if (plex->sectorsize != 0) {
|
|
|
|
if (sd->sectorsize != plex->sectorsize) /* incompatible sector sizes? */
|
|
|
|
printf("vinum: incompatible sector sizes. "
|
|
|
|
"%s has %d bytes, %s has %d bytes. Ignored.\n",
|
|
|
|
sd->name,
|
|
|
|
sd->sectorsize,
|
|
|
|
plex->name,
|
|
|
|
plex->sectorsize);
|
|
|
|
} else /* not set yet, */
|
|
|
|
plex->sectorsize = sd->sectorsize;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (plex->subdisks) { /* plex has subdisks, calculate size */
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* XXX We shouldn't need to calculate the size any
|
1999-03-28 08:53:02 +00:00
|
|
|
* more. Check this some time
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
Add support for RAID-4, even though it is inferior in almost every way
to RAID-5. peter claims that it might be faster for sequential
reading, since the drive caches don't trip over the parity blocks. I
have seen no evidence to support this, but it's a trivial change.
Requested-by: peter
Change checks for striped or RAID-5 plexes to a macro 'isstriped',
which now also includes RAID-4.
Change checks for RAID-5 plexes to a macro 'isparity', which now also
includes RAID-4.
atoi(): Remove, nobody was talking to it.
give_sd_to_drive: If no space is available, make the subdisk down,
don't delete it.
Change the manner in which the subdisk count was maintained to avoid
cases where the count was not adjusted correctly.
config_drive: Check if we have subdisks referencing us, and add them
if so. This fixes problems which arose when a drive is replaced in a
running system.
config_sd: Add support for a keyword 'partition', whose meaning will
be revealed in the fullness of time.
Cosmetic: Shorten some console messages.
Approved-by: jkh
2000-02-29 06:08:33 +00:00
|
|
|
if (isparity(plex))
|
|
|
|
size = size / plex->subdisks * (plex->subdisks - 1); /* less space for RAID-4 and RAID-5 */
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
if (plex->length != size)
|
1999-08-14 06:24:34 +00:00
|
|
|
log(LOG_INFO,
|
|
|
|
"Correcting length of %s: was %lld, is %lld\n",
|
|
|
|
plex->name,
|
2000-01-05 06:02:57 +00:00
|
|
|
(long long) plex->length,
|
|
|
|
(long long) size);
|
1998-12-28 04:56:24 +00:00
|
|
|
plex->length = size;
|
|
|
|
} else { /* no subdisks, */
|
|
|
|
plex->length = 0; /* no size */
|
|
|
|
state = plex_down; /* take it down */
|
|
|
|
}
|
1999-09-28 22:43:07 +00:00
|
|
|
update_plex_state(plexno); /* set the state */
|
1999-03-13 07:32:40 +00:00
|
|
|
plex->flags &= ~VF_NEWBORN;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
2003-05-23 01:13:10 +00:00
|
|
|
update_volume_config(int volno)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
struct volume *vol = &VOL[volno];
|
|
|
|
struct plex *plex;
|
|
|
|
int plexno;
|
|
|
|
|
|
|
|
if (vol->state != volume_unallocated)
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
/*
|
|
|
|
* Recalculate the size of the volume,
|
|
|
|
* which might change if the original
|
|
|
|
* plexes were not a multiple of the
|
|
|
|
* stripe size.
|
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
vol->size = 0;
|
|
|
|
for (plexno = 0; plexno < vol->plexes; plexno++) {
|
|
|
|
plex = &PLEX[vol->plex[plexno]];
|
|
|
|
vol->size = max(plex->length, vol->size); /* maximum size */
|
|
|
|
plex->volplexno = plexno; /* note it in the plex */
|
2003-05-05 08:42:42 +00:00
|
|
|
if (vol->sectorsize != 0) {
|
|
|
|
if (plex->sectorsize != vol->sectorsize) /* incompatible sector sizes? */
|
|
|
|
printf("vinum: incompatible sector sizes. "
|
|
|
|
"%s has %d, %s has %d. Ignored.\n",
|
|
|
|
plex->name,
|
|
|
|
plex->sectorsize,
|
|
|
|
vol->name,
|
|
|
|
vol->sectorsize);
|
|
|
|
} else /* not set yet, */
|
|
|
|
vol->sectorsize = plex->sectorsize;
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
1999-03-13 07:32:40 +00:00
|
|
|
vol->flags &= ~VF_NEWBORN; /* no longer newly born */
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
2003-05-05 08:42:42 +00:00
|
|
|
* Update the global configuration. This is
|
|
|
|
* called after configuration changes.
|
|
|
|
*
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
* diskconfig is != 0 if we're reading in a config
|
2003-05-05 08:42:42 +00:00
|
|
|
* from disk. In this case, we don't try to bring
|
|
|
|
* the devices up, though we will bring them down
|
|
|
|
* if there's some error which got missed when
|
|
|
|
* writing to disk.
|
1998-12-28 04:56:24 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
updateconfig(int diskconfig)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int plexno;
|
|
|
|
int volno;
|
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (plexno = 0; plexno < vinum_conf.plexes_allocated; plexno++)
|
Change printf() calls to log() calls.
Rename the VF_KERNELOP to VF_DISKCONFIG and checkkernel () to
checkdiskconfig (), which better describes their function.
Disable configuration updates if we have an error reading in the
configuration. This stops a "shoot-in-foot" problem where a mistake
can cause the configuration to be obliterated.
Tidy up some messages, which included superfluous \ns.
Recognize RAID-5 configuration information even in the non-RAID-5
version. This fixes shoot-in-foot problems where starting the wrong
version of vinum would kill RAID-5 plexes.
Recognize drives that have been referenced, but for which no physical
location is known. This is part of a modification which will
ultimately allow incrementally reading configurations. Such drives
will have a device name "unknown".
New function return_drive_space () returns space to a drive.
Previously this was part of free_sd ().
give_sd_to_drive: don't do it if the subdisk needs more space than the
drive has available.
config_sd: if reading config from disk, accept plex offset, drive
offset and length specs of -1 to indicate error conditions.
parse_config: return ENOENT if the "read" command doesn't find any
drives.
remove_sd_entry: don't do it, even by force, if it's open.
If the size of a striped or RAID-5 plex is not an integral multiple of
the stripe size, trim the size until it is.
reinstate update_volume_config, which had atrophied, to recalculate
the size of a volume if a plex has shrunk due to stripe size
considerations.
1999-03-02 06:52:47 +00:00
|
|
|
update_plex_config(plexno, diskconfig);
|
1998-12-28 04:56:24 +00:00
|
|
|
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
for (volno = 0; volno < vinum_conf.volumes_allocated; volno++) {
|
|
|
|
if (VOL[volno].state > volume_uninit) {
|
|
|
|
VOL[volno].flags &= ~VF_CONFIG_SETUPSTATE; /* no more setupstate */
|
|
|
|
update_volume_state(volno);
|
2003-05-23 01:13:10 +00:00
|
|
|
update_volume_config(volno);
|
Revise use of the vinum_conf variables drives_used, subdisks_used,
plexes_used and volumes_used. Now these fields are only informative,
and the <object>_allocated count is used for searches, etc. This also
required checking the object state before doing things with the
presumed object.
Problems-reported-by: Kiril Mitev <kiril@ideaglobal.com>
Remove unused (and braindead) functions volume_index, plex_index,
sd_index and drive_index.
Add a flag VF_CREATED for volumes. VF_NEWBORN was being used in two
capacities, and they clashed, my Lord, they clashed.
find_object: restructure the search loop as a result of the change in
variable use.
Decrement object use count in the remove_<object> functions, not in
the free_<object> functions, which are often called with partially
initialized (and uncounted) objects.
1999-03-30 04:59:59 +00:00
|
|
|
}
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
}
|
1998-12-28 04:56:24 +00:00
|
|
|
save_config();
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Start manual changes to the configuration and lock out
|
1998-12-28 04:56:24 +00:00
|
|
|
* others who may wish to do so.
|
1999-03-28 08:53:02 +00:00
|
|
|
* XXX why do we need this and lock_config too?
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
int
|
1999-03-23 04:47:09 +00:00
|
|
|
start_config(int force)
|
1998-12-28 04:56:24 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
1999-08-14 06:24:34 +00:00
|
|
|
current_drive = -1; /* note the last drive we mention, for
|
|
|
|
* some defaults */
|
|
|
|
current_plex = -1; /* and the same for the last plex */
|
2000-01-05 06:02:57 +00:00
|
|
|
current_volume = -1; /* and the last volume */
|
1998-12-28 04:56:24 +00:00
|
|
|
while ((vinum_conf.flags & VF_CONFIGURING) != 0) {
|
|
|
|
vinum_conf.flags |= VF_WILL_CONFIGURE;
|
|
|
|
if ((error = tsleep(&vinum_conf, PRIBIO | PCATCH, "vincfg", 0)) != 0)
|
|
|
|
return error;
|
|
|
|
}
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* We need two flags here: VF_CONFIGURING
|
Include Peter Wemm's renaming and restructuring
Change from lkm to kld
Remove BROKEN_GDB kludge (it's not needed with klds)
Add code for interfacing with daemon
Modify device minor number encoding, use selector functions which also
permit anonymous plexes and subdisks.
Remove code for 2.x support.
Change messages to omit obvious words like 'plex' and 'subdisk.
give_plex_to_volume: invalidate subdisks being given to a plex which
is part of a volume with other plexes.
give_sd_to_plex: keep track of plex size in all cases
lock drives before closing them, to keep the daemon from getting
confused.
config_drive: handle partition type errors more gracefully
config_subdisk: set subdisk state correctly
find_drive, find_drive_by_dev, find_subdisk, find_plex, find_volume:
set VF_NEWBORN flag when a new object is created
config_drive:
Handle partition_status returns more cleverly.
Replace the device name in some cases where it got overwritten.
config_subdisk:
add parameter `update'. If the object already exists, exit without
any changes.
Set state correctly.
config_plex, config_volume:
add parameter `update'. If the object already exists, exit without
any changes.
parse_config:
move read function to vinum_scandisk.
add parameter `update' to pass to config_<object>.
remove_<object>_entry:
print a message when the object is removed.
update_plex_config:
Start defusing this function, which will go away some time.
Remove calls to update_volume_config.
Make size 64 bits
1999-01-21 00:32:54 +00:00
|
|
|
* tells other processes to hold off (this
|
1998-12-28 04:56:24 +00:00
|
|
|
* function), and VF_CONFIG_INCOMPLETE
|
|
|
|
* tells the state change routines not to
|
1999-03-28 08:53:02 +00:00
|
|
|
* propagate incrememntal state changes
|
1999-01-29 01:17:54 +00:00
|
|
|
*/
|
1998-12-28 04:56:24 +00:00
|
|
|
vinum_conf.flags |= VF_CONFIGURING | VF_CONFIG_INCOMPLETE;
|
1999-03-23 04:47:09 +00:00
|
|
|
if (force)
|
|
|
|
vinum_conf.flags |= VF_FORCECONFIG; /* overwrite differently named drives */
|
1998-12-28 04:56:24 +00:00
|
|
|
current_drive = -1; /* reset the defaults */
|
|
|
|
current_plex = -1; /* and the same for the last plex */
|
|
|
|
current_volume = -1; /* and the last volme */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-01-29 01:17:54 +00:00
|
|
|
/*
|
|
|
|
* Update the config if update is 1, and unlock
|
1998-12-28 04:56:24 +00:00
|
|
|
* it. We won't update the configuration if we
|
|
|
|
* are called in a recursive loop via throw_rude_remark.
|
|
|
|
*/
|
1999-08-15 02:30:34 +00:00
|
|
|
void
|
1998-12-28 04:56:24 +00:00
|
|
|
finish_config(int update)
|
|
|
|
{
|
1999-03-23 04:47:09 +00:00
|
|
|
/* we've finished our config */
|
|
|
|
vinum_conf.flags &= ~(VF_CONFIG_INCOMPLETE | VF_READING_CONFIG | VF_FORCECONFIG);
|
1998-12-28 04:56:24 +00:00
|
|
|
if (update)
|
|
|
|
updateconfig(0); /* so update things */
|
|
|
|
else
|
|
|
|
updateconfig(1); /* do some updates only */
|
|
|
|
vinum_conf.flags &= ~VF_CONFIGURING; /* and now other people can take a turn */
|
|
|
|
if ((vinum_conf.flags & VF_WILL_CONFIGURE) != 0) {
|
|
|
|
vinum_conf.flags &= ~VF_WILL_CONFIGURE;
|
2000-05-04 07:29:55 +00:00
|
|
|
wakeup_one(&vinum_conf);
|
1998-12-28 04:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-15 02:30:34 +00:00
|
|
|
/* Local Variables: */
|
|
|
|
/* fill-column: 50 */
|
|
|
|
/* End: */
|