From 3a3b9e8a275dbec133255c3cfc7a9e684618f84c Mon Sep 17 00:00:00 2001 From: grog Date: Fri, 29 Jan 1999 01:17:54 +0000 Subject: Change multiline comments to start with a lone /* and end with a */, apparently in accordance with style(9). Complained-about-by: bde --- sys/dev/vinum/request.h | 36 ++++-- sys/dev/vinum/statetexts.h | 2 +- sys/dev/vinum/vinumconfig.c | 284 +++++++++++++++++++++++++++-------------- sys/dev/vinum/vinumdaemon.c | 25 ++-- sys/dev/vinum/vinumext.h | 2 - sys/dev/vinum/vinumhdr.h | 1 - sys/dev/vinum/vinuminterrupt.c | 3 +- sys/dev/vinum/vinumio.c | 144 +++++++++++++-------- sys/dev/vinum/vinumio.h | 12 +- sys/dev/vinum/vinumioctl.c | 45 ++++--- sys/dev/vinum/vinumkw.h | 12 +- sys/dev/vinum/vinumlock.c | 24 ++-- sys/dev/vinum/vinummemory.c | 6 +- sys/dev/vinum/vinumparser.c | 12 +- sys/dev/vinum/vinumrequest.c | 156 ++++++++++++++-------- sys/dev/vinum/vinumrevive.c | 18 ++- sys/dev/vinum/vinumstate.c | 103 ++++++++++----- sys/dev/vinum/vinumstate.h | 105 ++++++++++----- sys/dev/vinum/vinumutil.c | 30 +++-- sys/dev/vinum/vinumvar.h | 82 +++++++----- 20 files changed, 723 insertions(+), 379 deletions(-) diff --git a/sys/dev/vinum/request.h b/sys/dev/vinum/request.h index dfeb196..cf01513 100644 --- a/sys/dev/vinum/request.h +++ b/sys/dev/vinum/request.h @@ -65,7 +65,8 @@ enum xferinfo { XFR_NEEDS_MALLOC = (XFR_NORMAL_WRITE | XFR_RECOVERY_READ | XFR_DEGRADED_WRITE) }; -/* Describe one low-level request, part +/* + * Describe one low-level request, part * of a high-level request. This is an * extended struct buf buffer, and the first * element *must* be a struct buf. We pass this structure @@ -73,21 +74,24 @@ enum xferinfo { * to be able to locate the high-level request when it * completes. * - * All offsets and lengths are in "blocks", i.e. sectors */ + * All offsets and lengths are in "blocks", i.e. sectors + */ struct rqelement { struct buf b; /* buf structure */ struct rqgroup *rqg; /* pointer to our group */ /* Information about the transfer */ daddr_t sdoffset; /* offset in subdisk */ int useroffset; /* offset in user buffer of normal data */ - /* dataoffset and datalen refer to "individual" + /* + * dataoffset and datalen refer to "individual" * data transfers (normal read, parityless write) * and also degraded write. * * groupoffset and grouplen refer to the other * "group" operations (normal write, recovery read) * Both the offsets are relative to the start of the - * local buffer */ + * local buffer + */ int dataoffset; /* offset in buffer of the normal data */ int groupoffset; /* offset in buffer of group data */ short datalen; /* length of normal data (sectors) */ @@ -99,8 +103,10 @@ struct rqelement { short driveno; /* drive number */ }; -/* A group of requests built to satisfy a certain - * component of a user request */ +/* + * A group of requests built to satisfy a certain + * component of a user request + */ struct rqgroup { struct rqgroup *next; /* pointer to next group */ struct request *rq; /* pointer to the request */ @@ -112,8 +118,10 @@ struct rqgroup { struct rqelement rqe[0]; /* and the elements of this request */ }; -/* Describe one high-level request and the - * work we have to do to satisfy it */ +/* + * Describe one high-level request and the + * work we have to do to satisfy it + */ struct request { struct buf *bp; /* pointer to the high-level request */ enum xferinfo flags; @@ -130,8 +138,10 @@ struct request { struct request *next; /* link of waiting requests */ }; -/* Extended buffer header for subdisk I/O. Includes - * a pointer to the user I/O request. */ +/* + * Extended buffer header for subdisk I/O. Includes + * a pointer to the user I/O request. + */ struct sdbuf { struct buf b; /* our buffer */ struct buf *bp; /* and pointer to parent */ @@ -139,10 +149,12 @@ struct sdbuf { short sdno; /* and subdisk index */ }; -/* Values returned by rqe and friends. +/* + * Values returned by rqe and friends. * Be careful with these: they are in order of increasing * seriousness. Some routines check for > REQUEST_RECOVERED - * to indicate a completely failed request. */ + * to indicate a completely failed request. + */ enum requeststatus { REQUEST_OK, /* request built OK */ REQUEST_RECOVERED, /* request OK, but involves RAID5 recovery */ diff --git a/sys/dev/vinum/statetexts.h b/sys/dev/vinum/statetexts.h index 1388400..936a636 100644 --- a/sys/dev/vinum/statetexts.h +++ b/sys/dev/vinum/statetexts.h @@ -35,7 +35,7 @@ * */ -/* Created by ./makestatetext on Wed Jan 20 16:30:10 CST 1999. Do not edit */ +/* Created by ./makestatetext on Fri Jan 29 10:38:01 CST 1999. Do not edit */ /* Drive state texts */ char *drivestatetext[] = diff --git a/sys/dev/vinum/vinumconfig.c b/sys/dev/vinum/vinumconfig.c index 5ceaf5f..0c7445e 100644 --- a/sys/dev/vinum/vinumconfig.c +++ b/sys/dev/vinum/vinumconfig.c @@ -1,5 +1,6 @@ -/* To do: - +/* + * To do: + * * Don't store drive configuration on the config DB: read each drive's header * to decide where it is. * @@ -44,7 +45,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumconfig.c,v 1.8 1999/01/21 00:32:54 grog Exp $ + * $Id: vinumconfig.c,v 1.22 1998/12/30 05:07:24 grog Exp grog $ */ #define STATIC /* nothing while we're testing XXX */ @@ -60,9 +61,11 @@ void longjmp(jmp_buf, int); #define MAXTOKEN 64 /* maximum number of tokens in a line */ -/* We can afford the luxury of global variables here, +/* + * We can afford the luxury of global variables here, * since start_config ensures that these functions - * are single-threaded. */ + * are single-threaded. + */ /* These are indices in vinum_conf of the last-mentioned of each kind of object */ static int current_drive = -1; /* note the last drive we mention, for @@ -86,10 +89,12 @@ struct putchar_arg { }; #define MSG_MAX 1024 /* maximum length of a formatted message */ -/* Format an error message and return to the user in the reply. +/* + * 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 */ + * the configuration lock, and unlocks it on exit + */ void throw_rude_remark(int error, char *msg,...) { @@ -101,9 +106,11 @@ throw_rude_remark(int error, char *msg,...) va_start(ap, msg); if ((ioctl_reply != NULL) /* we're called from the user */ - &&(!(vinum_conf.flags & VF_KERNELOP))) { /* and we're not doing kernel things: return msg */ - /* XXX We can't just format to ioctl_reply, since it - * may contain our input parameters */ + &&(!(vinum_conf.flags & VF_KERNELOP))) { /* and not in kernel: return msg */ + /* + * XXX We can't just format to ioctl_reply, since it + * may contain our input parameters + */ text = Malloc(MSG_MAX); if (text == NULL) { printf("vinum: can't allocate error message buffer"); @@ -126,11 +133,13 @@ throw_rude_remark(int error, char *msg,...) if (vinum_conf.flags & VF_READING_CONFIG) /* go through to the bitter end, */ return; - /* We have a problem here: we want to unlock the + /* + * We have a problem here: we want to unlock the * configuration, which implies tidying up, but * if we find an error while tidying up, we could * recurse for ever. Use this kludge to only try - * once */ + * once + */ was_finishing = finishing; finishing = 1; finish_config(was_finishing); /* unlock anything we may be holding */ @@ -157,8 +166,10 @@ atoi(char *s) return r; } -/* Find index of volume in vinum_conf. Return the index - * if found, or -1 if not */ +/* + * Find index of volume in vinum_conf. Return the index + * if found, or -1 if not + */ int volume_index(struct volume *vol) { @@ -170,8 +181,10 @@ volume_index(struct volume *vol) return -1; } -/* Find index of plex in vinum_conf. Return the index - * if found, or -1 if not */ +/* + * Find index of plex in vinum_conf. Return the index + * if found, or -1 if not + */ int plex_index(struct plex *plex) { @@ -183,8 +196,10 @@ plex_index(struct plex *plex) return -1; } -/* Find index of subdisk in vinum_conf. Return the index - * if found, or -1 if not */ +/* + * Find index of subdisk in vinum_conf. Return the index + * if found, or -1 if not + */ int sd_index(struct sd *sd) { @@ -196,8 +211,10 @@ sd_index(struct sd *sd) return -1; } -/* Find index of drive in vinum_conf. Return the index - * if found, or -1 if not */ +/* + * Find index of drive in vinum_conf. Return the index + * if found, or -1 if not + */ int drive_index(struct drive *drive) { @@ -209,8 +226,10 @@ drive_index(struct drive *drive) return -1; } -/* Check a volume to see if the plex is already assigned to it. - * Return index in volume->plex, or -1 if not assigned */ +/* + * Check a volume to see if the plex is already assigned to it. + * Return index in volume->plex, or -1 if not assigned + */ int my_plex(int volno, int plexno) { @@ -224,8 +243,10 @@ my_plex(int volno, int plexno) return -1; /* not found */ } -/* Check a plex to see if the subdisk is already assigned to it. - * Return index in plex->sd, or -1 if not assigned */ +/* + * Check a plex to see if the subdisk is already assigned to it. + * Return index in plex->sd, or -1 if not assigned + */ int my_sd(int plexno, int sdno) { @@ -239,13 +260,15 @@ my_sd(int plexno, int sdno) return -1; /* not found */ } -/* Check that this operation is being done in the kernel. - * longjmp out if not. op the name of the operation. */ +/* + * Check that this operation is being done in the kernel. + * longjmp out if not. op is the name of the operation. + */ void checkkernel(char *op) { if ((vinum_conf.flags & VF_KERNELOP) == 0) - throw_rude_remark(EPERM, "Can't perform '%s' from user space", op); + throw_rude_remark(EPERM, "Can't perform '%s' from user space", op); } /* Add plex to the volume if possible */ @@ -254,10 +277,12 @@ give_plex_to_volume(int volno, int plexno) { struct volume *vol; - /* XXX It's not an error for the plex to already + /* + * XXX It's not an error for the plex to already * belong to the volume, but we need to check a * number of things to make sure it's done right. - * Some day. */ + * Some day. + */ if (my_plex(volno, plexno) >= 0) return plexno; /* that's it */ @@ -267,7 +292,7 @@ give_plex_to_volume(int volno, int plexno) "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 */ + &&((vol->flags & VF_CONFIG_SETUPSTATE) == 0)) /* and we're not setting up state */ invalidate_subdisks(&PLEX[plexno], sd_stale); /* make the subdisks invalid */ vol->plex[vol->plexes] = plexno; /* this one */ vol->plexes++; /* add another plex */ @@ -276,7 +301,9 @@ give_plex_to_volume(int volno, int plexno) return vol->plexes - 1; /* and return its index */ } -/* Add subdisk to a plex if possible */ +/* + * Add subdisk to a plex if possible + */ int give_sd_to_plex(int plexno, int sdno) { @@ -284,10 +311,12 @@ give_sd_to_plex(int plexno, int sdno) struct plex *plex; struct sd *sd; - /* XXX It's not an error for the sd to already + /* + * XXX It's not an error for the sd to already * belong to the plex, but we need to check a * number of things to make sure it's done right. - * Some day. */ + * Some day. + */ i = my_sd(plexno, sdno); if (i >= 0) /* does it already belong to us? */ return i; /* that's it */ @@ -322,10 +351,12 @@ give_sd_to_plex(int plexno, int sdno) if (plex->volno >= 0) /* we have a volume */ VOL[plex->volno].size = max(VOL[plex->volno].size, plex->length); /* adjust its size */ - /* We need to check that the subdisks don't overlap, + /* + * We need to check that the subdisks don't overlap, * but we can't do that until a point where we *must* * know the size of all the subdisks. That's not - * here. But we need to sort them by offset */ + * here. But we need to sort them by offset + */ 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 */ @@ -339,16 +370,20 @@ give_sd_to_plex(int plexno, int sdno) } } - /* The plex doesn't have any subdisk with a larger - * offset. Insert it */ + /* + * The plex doesn't have any subdisk with a larger + * offset. Insert it + */ plex->sdnos[i] = sdno; sd->plexsdno = i; /* note where we are in the subdisk */ return i; } -/* Add a subdisk to drive if possible. The pointer to the drive +/* + * 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. */ + * doesn't know about the subdisk yet. + */ static void give_sd_to_drive(int sdno) { @@ -387,15 +422,19 @@ give_sd_to_drive(int sdno) } } if (fe == drive->freelist_entries) - /* Didn't find anything. Although the drive has - * enough space, it's too fragmented */ + /* + * Didn't find anything. Although the drive has + * enough space, it's too fragmented + */ { sd->driveoffset = -1; /* don't be confusing */ throw_rude_remark(ENOSPC, "No space for %s on %s", sd->name, drive->label.name); } } else { /* specific offset */ - /* For a specific offset to work, the space must be - * entirely in a single freelist entry. Look for it. */ + /* + * For a specific offset to work, the space must be + * entirely in a single freelist entry. Look for it. + */ 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 */ @@ -406,7 +445,8 @@ give_sd_to_drive(int sdno) sd->name, drive->label.name); - /* We've found the space, and we can allocate it. + /* + * We've found the space, and we can allocate it. * 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: @@ -479,7 +519,8 @@ get_empty_drive(void) return driveno; /* return the index */ } -/* Find the named drive in vinum_conf.drive, return a pointer +/* + * Find the named drive in vinum_conf.drive, return a pointer * 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 @@ -515,9 +556,11 @@ find_drive(const char *name, int create) return driveno; /* return the index */ } -/* Find a drive given its device name. +/* + * Find a drive given its device name. * devname must be valid. - * Otherwise the same as find_drive above */ + * Otherwise the same as find_drive above + */ int find_drive_by_dev(const char *devname, int create) { @@ -586,8 +629,9 @@ free_drive(struct drive *drive) unlockdrive(drive); } -/* Find the named subdisk in vinum_conf.sd. - +/* + * Find the named subdisk in vinum_conf.sd. + * * If create != 0, create an entry if it doesn't exist * * Return index in vinum_conf.sd @@ -615,7 +659,8 @@ find_subdisk(const char *name, int create) return sdno; /* return the pointer */ } -/* Free an allocated sd entry +/* + * Free an allocated sd entry * This performs memory management only. remove() * is responsible for checking relationships. */ @@ -638,15 +683,18 @@ free_sd(int sdno) for (fe = 0; (fe < drive->freelist_entries) && (drive->freelist[fe].offset < sd->driveoffset); fe++); - /* Now we are pointing to the last entry, the first - * with a higher offset than the subdisk, or both. */ + /* + * Now we are pointing to the last entry, the first + * with a higher offset than the subdisk, or both. + */ if ((fe > 1) /* not the first entry */ &&((fe == drive->freelist_entries) /* gone past the end */ ||(drive->freelist[fe].offset > sd->driveoffset))) /* or past the block were looking for */ fe--; /* point to the block before */ dend = drive->freelist[fe].offset + drive->freelist[fe].sectors; /* end of the entry */ - /* At this point, we are pointing to the correct + /* + * At this point, we are pointing to the correct * place in the free list. A number of possibilities * exist: * @@ -735,8 +783,9 @@ get_empty_plex(void) return plexno; /* return the index */ } -/* Find the named plex in vinum_conf.plex - +/* + * Find the named plex in vinum_conf.plex + * * If create != 0, create an entry if it doesn't exist * return index in vinum_conf.plex */ @@ -763,8 +812,10 @@ find_plex(const char *name, int create) return plexno; /* return the pointer */ } -/* Free an allocated plex entry - * and its associated memory areas */ +/* + * Free an allocated plex entry + * and its associated memory areas + */ void free_plex(int plexno) { @@ -809,8 +860,9 @@ get_empty_volume(void) return volno; /* return the index */ } -/* Find the named volume in vinum_conf.volume. - +/* + * Find the named volume in vinum_conf.volume. + * * If create != 0, create an entry if it doesn't exist * return the index in vinum_conf */ @@ -838,8 +890,10 @@ find_volume(const char *name, int create) return volno; /* return the pointer */ } -/* Free an allocated volume entry - * and its associated memory areas */ +/* + * Free an allocated volume entry + * and its associated memory areas + */ void free_volume(int volno) { @@ -851,7 +905,8 @@ free_volume(int volno) vinum_conf.volumes_used--; /* one less volume */ } -/* Handle a drive definition. We store the information in the global variable +/* + * Handle a drive definition. We store the information in the global variable * drive, so we don't need to allocate. * * If we find an error, print a message and return @@ -873,8 +928,10 @@ config_drive(int update) drive->flags &= ~VF_NEWBORN; /* no longer newly born */ if (drive->state != drive_uninit) { /* we already know this drive */ - /* XXX Check which definition is more up-to-date. Give - * preference for the definition on its own drive */ + /* + * XXX Check which definition is more up-to-date. Give + * preference for the definition on its own drive + */ return; /* XXX */ } for (parameter = 2; parameter < tokens; parameter++) { /* look at the other tokens */ @@ -921,9 +978,11 @@ config_drive(int update) case DL_OURS: break; } - /* read_drive_label overwrites the device name. + /* + * read_drive_label overwrites the device name. * If we get here, we can have the drive, - * so put it back again */ + * so put it back again + */ bcopy(token[parameter], drive->devicename, min(sizeof(drive->devicename), @@ -950,7 +1009,8 @@ config_drive(int update) } } -/* Handle a subdisk definition. We store the information in the global variable +/* + * Handle a subdisk definition. We store the information in the global variable * sd, so we don't need to allocate. * * If we find an error, print a message and return @@ -1021,8 +1081,10 @@ config_subdisk(int update) sd->plexno = find_plex(token[++parameter], 1); /* insert plex information */ break; - /* Set the state. We can't do this directly, - * because give_sd_to_plex may change it */ + /* + * Set the state. We can't do this directly, + * because give_sd_to_plex may change it + */ case kw_state: checkkernel(token[++parameter]); /* must be a kernel user */ state = SdState(token[parameter]); /* set the state */ @@ -1070,14 +1132,17 @@ config_subdisk(int update) else if (sd->state == sd_unallocated) /* no, nothing set yet, */ sd->state = sd_up; /* must be up */ - /* register the subdisk with the drive. This action + /* + * register the subdisk with the drive. This action * will have the side effect of setting the offset if * we haven't specified one, and causing an error - * message if it overlaps with another subdisk. */ + * message if it overlaps with another subdisk. + */ give_sd_to_drive(sdno); } -/* Handle a plex definition. +/* + * Handle a plex definition. */ void config_plex(int update) @@ -1194,7 +1259,8 @@ config_plex(int update) plex->state = plex_init; /* we're initialized now */ } -/* Handle a volume definition. +/* + * Handle a volume definition. * If we find an error, print a message, deallocate the nascent volume, and return */ void @@ -1275,9 +1341,11 @@ config_volume(int update) vol->state = VolState(token[parameter]); /* set the state */ break; - /* XXX experimental ideas. These are not + /* + * XXX experimental ideas. These are not * documented, and will not be until I - * decide they're worth keeping */ + * decide they're worth keeping + */ case kw_writethrough: /* set writethrough mode */ vol->flags |= VF_WRITETHROUGH; break; @@ -1300,11 +1368,13 @@ config_volume(int update) current_volume = volno; /* note last referred volume */ vol->devno = VINUMBDEV(volno, 0, 0, VINUM_VOLUME_TYPE); /* also note device number */ - /* Before we can actually use the volume, we need + /* + * Before we can actually use the volume, we need * 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 - * set up the configuration. XXX */ + * set up the configuration. XXX + */ if (vol->state == volume_unallocated) vol->state = volume_down; /* now ready to bring up at the end */ @@ -1313,11 +1383,13 @@ config_volume(int update) vol->size = max(vol->size, PLEX[vol->plex[i]].length); } -/* Parse a config entry. CARE! This destroys the original contents of the +/* + * Parse a config entry. CARE! This destroys the original contents of the * config entry, which we don't really need after this. More specifically, it * places \0 characters at the end of each token. * - * Return 0 if all is well, otherwise EINVAL */ + * Return 0 if all is well, otherwise EINVAL + */ int parse_config(char *cptr, struct keywordset *keyset, int update) { @@ -1362,13 +1434,15 @@ parse_config(char *cptr, struct keywordset *keyset, int update) return status; } -/* parse a line handed in from userland via ioctl. +/* + * parse a line handed in from userland via ioctl. * 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- - * threaded manner */ + * threaded manner + */ int parse_user_config(char *cptr, struct keywordset *keyset) { @@ -1474,12 +1548,16 @@ remove_sd_entry(int sdno, int force, int recurse) &plex->sdnos[mysdno], (plex->subdisks - 1 - mysdno) * sizeof(int)); plex->subdisks--; - /* removing a subdisk from a striped or + /* + * removing a subdisk from a striped or * RAID-5 plex really tears the hell out * of the structure, and it needs to be - * reinitialized */ - /* XXX Think about this. Maybe we should just - * leave a hole */ + * reinitialized + */ + /* + * XXX Think about this. Maybe we should just + * leave a hole + */ if (plex->organization != plex_concat) /* not concatenated, */ set_plex_state(plex->plexno, plex_faulty, setstate_force); /* need to reinitialize */ printf("vinum: removing %s\n", sd->name); @@ -1522,12 +1600,14 @@ remove_plex_entry(int plexno, int force, int recurse) } } if (plex->volno >= 0) { /* we are part of a volume */ - /* XXX This should be more intelligent. We should + /* + * XXX This should be more intelligent. We should * be able to remove a plex as long as the volume * does not lose any data, which is normally the * case when it has more than one plex. To do it * right we must compare the completeness of the - * mapping of all the plexes in the volume */ + * mapping of all the plexes in the volume + */ if (force) { /* do it at any cost */ struct volume *vol = &VOL[plex->volno]; int myplexno; @@ -1601,10 +1681,12 @@ update_plex_config(int plexno, int kernelstate) /* XXX Insert checks here for sparse plexes and volumes */ - /* Check that our subdisks make sense. For + /* + * Check that our subdisks make sense. For * striped and RAID5 plexes, we need at least * two subdisks, and they must all be the same - * size */ + * size + */ if (((plex->organization == plex_striped) ) && (plex->subdisks < 2)) { @@ -1627,8 +1709,10 @@ update_plex_config(int plexno, int kernelstate) } if (plex->subdisks) { /* plex has subdisks, calculate size */ - /* XXX We shouldn't need to calculate the size any - * more. Check this some time */ + /* + * XXX We shouldn't need to calculate the size any + * more. Check this some time + */ if (plex->length != size) printf("Correcting length of %s: was %qd, is %qd\n", plex->name, plex->length, size); plex->length = size; @@ -1661,7 +1745,8 @@ update_volume_config(int volno, int kernelstate) set_volume_state(volno, volume_up, setstate_configuring); } -/* Update the global configuration. +/* + * Update the global configuration. * kernelstate is != 0 if we're reading in a config * from disk. In this case, we don't try to * bring the devices up, though we will bring @@ -1685,9 +1770,11 @@ updateconfig(int kernelstate) save_config(); } -/* Start manual changes to the configuration and lock out +/* + * Start manual changes to the configuration and lock out * others who may wish to do so. - * XXX why do we need this and lock_config too? */ + * XXX why do we need this and lock_config too? + */ int start_config(void) { @@ -1698,11 +1785,13 @@ start_config(void) if ((error = tsleep(&vinum_conf, PRIBIO | PCATCH, "vincfg", 0)) != 0) return error; } - /* We need two flags here: VF_CONFIGURING + /* + * We need two flags here: VF_CONFIGURING * tells other processes to hold off (this * function), and VF_CONFIG_INCOMPLETE * tells the state change routines not to - * propagate incrememntal state changes */ + * propagate incrememntal state changes + */ vinum_conf.flags |= VF_CONFIGURING | VF_CONFIG_INCOMPLETE; current_drive = -1; /* reset the defaults */ current_plex = -1; /* and the same for the last plex */ @@ -1710,7 +1799,8 @@ start_config(void) return 0; } -/* Update the config if update is 1, and unlock +/* + * Update the config if update is 1, and unlock * it. We won't update the configuration if we * are called in a recursive loop via throw_rude_remark. */ diff --git a/sys/dev/vinum/vinumdaemon.c b/sys/dev/vinum/vinumdaemon.c index 54afc3e..39da3c3 100644 --- a/sys/dev/vinum/vinumdaemon.c +++ b/sys/dev/vinum/vinumdaemon.c @@ -34,7 +34,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumdaemon.c,v 1.1 1999/01/21 00:31:31 grog Exp $ + * $Id: vinumdaemon.c,v 1.3 1999/01/18 04:32:50 grog Exp grog $ */ #define REALLYKERNEL @@ -71,8 +71,10 @@ vinum_daemon(void) splx(s); switch (request->type) { - /* We had an I/O error on a request. Go through the - * request and try to salvage it */ + /* + * We had an I/O error on a request. Go through the + * request and try to salvage it + */ case daemonrq_ioerror: if (daemon_options & daemon_verbose) { struct request *rq = request->info.rq; @@ -87,9 +89,11 @@ vinum_daemon(void) recover_io(request->info.rq); /* the failed request */ break; - /* Write the config to disk. We could end up with + /* + * Write the config to disk. We could end up with * quite a few of these in a row. Only honour the - * last one */ + * last one + */ case daemonrq_saveconfig: if ((daemonq == NULL) /* no more requests */ ||(daemonq->type != daemonrq_saveconfig)) { /* or the next isn't the same */ @@ -128,8 +132,9 @@ vinum_daemon(void) } } -/* Recover a failed I/O operation. - +/* + * Recover a failed I/O operation. + * * The correct way to do this is to examine the request and determine * how to recover each individual failure. In the case of a write, * this could be as simple as doing nothing: the defective drives may @@ -172,8 +177,10 @@ queue_daemon_request(enum daemonrq type, union daemoninfo info) wakeup(&vinum_daemon); /* and give the dæmon a kick */ } -/* see if the daemon is running. Return 0 (no error) - * if it is, ESRCH otherwise */ +/* + * see if the daemon is running. Return 0 (no error) + * if it is, ESRCH otherwise + */ int vinum_finddaemon() diff --git a/sys/dev/vinum/vinumext.h b/sys/dev/vinum/vinumext.h index 40ffbbb..9f02e67 100644 --- a/sys/dev/vinum/vinumext.h +++ b/sys/dev/vinum/vinumext.h @@ -106,8 +106,6 @@ void checkernel(char *); int open_drive(struct drive *, struct proc *, int); void close_drive(struct drive *drive); int driveio(struct drive *, char *, size_t, off_t, int); -/* #define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ) - #define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) */ int set_drive_parms(struct drive *drive); int init_drive(struct drive *, int); /* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */ diff --git a/sys/dev/vinum/vinumhdr.h b/sys/dev/vinum/vinumhdr.h index c913665..14cc7af 100644 --- a/sys/dev/vinum/vinumhdr.h +++ b/sys/dev/vinum/vinumhdr.h @@ -32,7 +32,6 @@ * 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. - * */ /* Header files used by all modules */ diff --git a/sys/dev/vinum/vinuminterrupt.c b/sys/dev/vinum/vinuminterrupt.c index 073ee76..f157770 100644 --- a/sys/dev/vinum/vinuminterrupt.c +++ b/sys/dev/vinum/vinuminterrupt.c @@ -51,7 +51,8 @@ void free_rqg(struct rqgroup *rqg); void complete_rqe(struct buf *bp); void sdio_done(struct buf *bp); -/* Take a completed buffer, transfer the data back if +/* + * Take a completed buffer, transfer the data back if * it's a read, and complete the high-level request * if this is the last subrequest. * diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 25099d5..26be524 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -33,7 +33,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumio.c,v 1.21 1998/12/30 06:04:31 grog Exp grog $ + * $Id: vinumio.c,v 1.7.2.3 1999/01/29 01:13:41 grog Exp $ */ #define STATIC /* nothing while we're testing XXX */ @@ -55,8 +55,10 @@ void longjmp(jmp_buf, int); static char *sappend(char *txt, char *s); static int drivecmp(const void *va, const void *vb); -/* Open the device associated with the drive, and set drive's vp. - * Return an error number */ +/* + * Open the device associated with the drive, and set drive's vp. + * Return an error number + */ int open_drive(struct drive *drive, struct proc *p, int verbose) { @@ -111,8 +113,10 @@ open_drive(struct drive *drive, struct proc *p, int verbose) return 0; } -/* Set some variables in the drive struct - * in more convenient form. Return error indication */ +/* + * Set some variables in the drive struct + * in more convenient form. Return error indication + */ int set_drive_parms(struct drive *drive) { @@ -129,8 +133,10 @@ set_drive_parms(struct drive *drive) /* number of sectors available for subdisks */ drive->sectors_available = drive->label.drive_size / DEV_BSIZE - DATASTART; - /* XXX Bug in 3.0 as of January 1998: you can open - * non-existent slices. They have a length of 0 */ + /* + * XXX Bug in 3.0 as of January 1998: you can open + * non-existent slices. They have a length of 0 + */ if (drive->label.drive_size < MINVINUMSLICE) { /* too small to worry about */ set_drive_state(drive->driveno, drive_down, setstate_force); drive->lasterror = ENOSPC; @@ -151,8 +157,10 @@ set_drive_parms(struct drive *drive) return 0; } -/* Initialize a drive: open the device and add device - * information */ +/* + * Initialize a drive: open the device and add device + * information + */ int init_drive(struct drive *drive, int verbose) { @@ -160,8 +168,10 @@ init_drive(struct drive *drive, int verbose) if (drive->devicename[0] == '\0') { /* no device name yet, default to drive name */ drive->lasterror = EINVAL; - /* This is a bug if it happens internally, - * so print a message regardless */ + /* + * This is a bug if it happens internally, + * so print a message regardless + */ printf("vinum: Can't open drive without drive name\n"); /* XXX */ return EINVAL; } @@ -212,7 +222,8 @@ close_drive(struct drive *drive) } } -/* Remove drive from the configuration. +/* + * Remove drive from the configuration. * Caller must ensure that it isn't active */ void @@ -229,7 +240,8 @@ remove_drive(int driveno) save_config(); /* and save the updated configuration */ } -/* Transfer drive data. Usually called from one of these defines; +/* + * Transfer drive data. Usually called from one of these defines; * #define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ) * #define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) * @@ -281,8 +293,9 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag) return error; } -/* Read data from a drive - +/* + * Read data from a drive + * * Return error number */ int @@ -343,8 +356,9 @@ read_drive(struct drive *drive, void *buf, size_t length, off_t offset) return error; } -/* Write data to a drive - +/* + * Write data to a drive + * * Return error number */ int @@ -411,8 +425,10 @@ write_drive(struct drive *drive, void *buf, size_t length, off_t offset) return error; } if (count + blockoff == drive->blocksize) - /* The transfer goes to the end of the block. There's - * no need to wait for any more data to arrive. */ + /* + * The transfer goes to the end of the block. There's + * no need to wait for any more data to arrive. + */ bawrite(bp); /* start the write now */ else bdwrite(bp); /* do a delayed write */ @@ -431,7 +447,8 @@ drive_io_done(struct buf *bp) bp->b_flags &= ~B_CALL; /* don't do this again */ } -/* Check a drive for a vinum header. If found, +/* + * Check a drive for a vinum header. If found, * update the drive information. We come here * with a partially populated drive structure * which includes the device name. @@ -469,9 +486,11 @@ read_drive_label(struct drive *drive, int verbose) drive->state = drive_up; /* it's OK by us */ result = DL_OURS; } - /* We copy the drive anyway so that we have + /* + * We copy the drive anyway so that we have * the correct name in the drive info. This - * may not be the name specified */ + * may not be the name specified + */ drive->label = vhdr->label; /* put in the label information */ } else if (vhdr->magic == VINUM_NOMAGIC) /* was ours, but we gave it away */ result = DL_DELETED_LABEL; @@ -481,7 +500,8 @@ read_drive_label(struct drive *drive, int verbose) return result; } -/* Check a drive for a vinum header. If found, +/* + * Check a drive for a vinum header. If found, * read configuration information from the drive and * incorporate the data into the configuration. * @@ -511,6 +531,7 @@ sappend(char *txt, char *s) return s - 1; } +/* Kludge: kernel printf doesn't handle quads correctly XXX */ static char *lltoa(long long l, char *s); static char * @@ -527,9 +548,11 @@ lltoa(long long l, char *s) *s++ = l + '0'; return s; } -/* Format the configuration in text form into the buffer +/* + * Format the configuration in text form into the buffer * at config. Don't go beyond len bytes - * XXX this stinks. Fix soon. */ + * XXX this stinks. Fix soon. + */ void format_config(char *config, int len) { @@ -626,16 +649,20 @@ format_config(char *config, int len) } } -/* issue a save config request to the dæmon. The actual work - * is done in process context by daemon_save_config */ +/* + * issue a save config request to the dæmon. The actual work + * is done in process context by daemon_save_config + */ void save_config(void) { queue_daemon_request(daemonrq_saveconfig, NULL); } -/* Write the configuration to all vinum slices. This - * is performed by the dæmon only */ +/* + * Write the configuration to all vinum slices. This + * is performed by the dæmon only + */ void daemon_save_config(void) { @@ -666,9 +693,11 @@ daemon_save_config(void) drive = &vinum_conf.drive[driveno]; /* point to drive */ lockdrive(drive); /* don't let it change */ - /* First, do some drive consistency checks. Some + /* + * First, do some drive consistency checks. Some * of these are kludges, others require a process - * context and couldn't be done before */ + * context and couldn't be done before + */ if ((drive->devicename[0] == '\0') /* XXX we keep getting these nameless drives */ ||(drive->label.name[0] == '\0')) { /* XXX we keep getting these nameless drives */ unlockdrive(drive); @@ -728,15 +757,18 @@ daemon_save_config(void) Free(config); } -/* Disk labels are a mess. The correct way to access them +/* + * Disk labels are a mess. The correct way to access them * is with the DIOC[GSW]DINFO ioctls, but some programs, such * as newfs, access the disk directly, so we have to write * things there. We do this only on request. If a user * request tries to read it directly, we fake up one on the fly. */ -/* get_volume_label returns a label structure to lp, which - * is allocated by the caller */ +/* + * get_volume_label returns a label structure to lp, which + * is allocated by the caller + */ void get_volume_label(struct volume *vol, struct disklabel *lp) { @@ -749,8 +781,10 @@ get_volume_label(struct volume *vol, struct disklabel *lp) lp->d_interleave = 1; lp->d_flags = 0; - /* Fitting unto the vine, a vinum has a single - * track with all its sectors */ + /* + * Fitting unto the vine, a vinum has a single + * track with all its sectors + */ lp->d_secsize = DEV_BSIZE; /* bytes per sector */ lp->d_nsectors = vol->size; /* data sectors per track */ lp->d_ntracks = 1; /* tracks per cylinder */ @@ -764,9 +798,11 @@ get_volume_label(struct volume *vol, struct disklabel *lp) lp->d_magic = DISKMAGIC; lp->d_magic2 = DISKMAGIC; - /* Set up partitions a, b and c to be identical + /* + * Set up partitions a, b and c to be identical * and the size of the volume. a is UFS, b is - * swap, c is nothing */ + * swap, c is nothing + */ lp->d_partitions[0].p_size = vol->size; lp->d_partitions[0].p_fsize = 1024; lp->d_partitions[0].p_fstype = FS_BSDFFS; /* FreeBSD File System :-) */ @@ -803,7 +839,8 @@ write_volume_label(int volno) get_volume_label(vol, lp); /* get the label */ - /* Now write to disk. This code is derived from the + /* + * Now write to disk. This code is derived from the * system writedisklabel (), which does silly things * like reading the label and refusing to write * unless it's already there. */ @@ -893,10 +930,12 @@ vinum_scandisk(char *drivename[], int drives) printf("vinum: no drives found\n"); return; } - /* We now have at least one drive + /* + * We now have at least one drive * open. Sort them in order of config time * and merge the config info with what we - * have already */ + * have already + */ qsort(drivelist, gooddrives, sizeof(struct drive *), drivecmp); config_text = (char *) Malloc(MAXCONFIG * 2); /* allocate buffers */ CHECKALLOC(config_text, "Can't allocate memory"); @@ -920,10 +959,11 @@ vinum_scandisk(char *drivename[], int drives) free_drive(drive); /* give it back */ status = error; } - /* XXX At this point, check that the two copies are the same, and do something useful if not. + /* + * XXX At this point, check that the two copies are the same, and do something useful if not. * In particular, consider which is newer, and what this means for the integrity of the - * data on the drive */ - + * data on the drive + */ else { /* Parse the configuration, and add it to the global configuration */ for (cptr = config_text; *cptr != '\0';) { /* love this style(9) */ @@ -935,10 +975,12 @@ vinum_scandisk(char *drivename[], int drives) if (setjmp(command_fail) == 0) { /* come back here on error and continue */ parse_status = parse_config(config_line, &keyword_set, 1); /* parse the config line */ if (parse_status < 0) { /* error in config */ - /* This config should have been parsed in user - * space. If we run into problems here, something - * serious is afoot. Complain and let the user - * snarf the config to see what's wrong */ + /* + * This config should have been parsed in user + * space. If we run into problems here, something + * serious is afoot. Complain and let the user + * snarf the config to see what's wrong + */ printf("vinum: Config error on drive %s, aborting integration\n", nd.ni_dirp); Free(config_text); Free(config_line); @@ -961,9 +1003,11 @@ vinum_scandisk(char *drivename[], int drives) updateconfig(VF_KERNELOP); /* update from kernel space */ } -/* Compare the modification dates of the drives, for qsort. +/* + * Compare the modification dates of the drives, for qsort. * Return 1 if a < b, 0 if a == b, 01 if a > b: in other - * words, sort backwards */ + * words, sort backwards + */ int drivecmp(const void *va, const void *vb) { diff --git a/sys/dev/vinum/vinumio.h b/sys/dev/vinum/vinumio.h index fe1c09b..105c170 100644 --- a/sys/dev/vinum/vinumio.h +++ b/sys/dev/vinum/vinumio.h @@ -80,7 +80,8 @@ enum objecttype { invalid_object }; -/* Start an object. Pass two integers: +/* + * Start an object. Pass two integers: * msg [0] index in vinum_conf. * msg [1] type of object (see below) * @@ -88,16 +89,19 @@ enum objecttype { */ #define VINUM_SETSTATE _IOC(IOC_IN | IOC_OUT, L, 76, MAX_IOCTL_REPLY) /* start an object */ -/* The state to set with VINUM_SETSTATE. Since +/* + * The state to set with VINUM_SETSTATE. Since * each object has a different set of states, we - * need to translate later */ + * need to translate later + */ enum objectstate { object_down, object_initializing, object_up }; -/* This structure is used for modifying objects +/* + * This structure is used for modifying objects * (VINUM_SETSTATE, VINUM_REMOVE, VINUM_RESETSTATS, VINUM_ATTACH, * VINUM_DETACH, VINUM_REPLACE */ diff --git a/sys/dev/vinum/vinumioctl.c b/sys/dev/vinum/vinumioctl.c index a2e3f2b..373cb40 100644 --- a/sys/dev/vinum/vinumioctl.c +++ b/sys/dev/vinum/vinumioctl.c @@ -1,5 +1,7 @@ -/* XXX replace all the checks on object validity with - * calls to valid */ +/* + * XXX replace all the checks on object validity with + * calls to valid + */ /*- * Copyright (c) 1997, 1998 * Nan Yang Computer Services Limited. All rights reserved. @@ -35,7 +37,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumioctl.c,v 1.6 1999/01/21 00:35:35 grog Exp $ + * $Id: vinumioctl.c,v 1.7 1999/01/18 03:36:17 grog Exp grog $ */ #define STATIC /* nothing while we're testing XXX */ @@ -127,8 +129,9 @@ vinumioctl(dev_t dev, case VINUM_STARTCONFIG: return start_config(); /* just lock it */ - /* Move the individual parts of the config to user space. - + /* + * Move the individual parts of the config to user space. + * * Specify the index of the object in the first word of data, * and return the object there */ @@ -194,8 +197,10 @@ vinumioctl(dev_t dev, case VINUM_RESETCONFIG: if (vinum_inactive() && (vinum_conf.opencount < 2)) { /* if we're not active */ - /* Note the open count. We may be called from v, so we'll be open. - * Keep the count so we don't underflow */ + /* + * Note the open count. We may be called from v, so we'll be open. + * Keep the count so we don't underflow + */ int oc = vinum_conf.opencount; free_vinum(1); /* clean up everything */ printf("vinum: CONFIGURATION OBLITERATED\n"); @@ -291,7 +296,7 @@ vinumioctl(dev_t dev, printf("vinumioctl: invalid ioctl from process %d (%s): %lx\n", curproc->p_pid, curproc->p_comm, - cmd); /* XXX */ + cmd); return EINVAL; case VINUM_DRIVE_TYPE: @@ -324,18 +329,22 @@ vinumioctl(dev_t dev, get_volume_label(vol, (struct disklabel *) data); break; - /* Care! DIOCGPART returns *pointers* to + /* + * Care! DIOCGPART returns *pointers* to * the caller, so we need to store this crap as well. - * And yes, we need it. */ + * And yes, we need it. + */ case DIOCGPART: /* get partition information */ get_volume_label(vol, &vol->label); ((struct partinfo *) data)->disklab = &vol->label; ((struct partinfo *) data)->part = &vol->label.d_partitions[0]; break; - /* We don't have this stuff on hardware, + /* + * We don't have this stuff on hardware, * so just pretend to do it so that - * utilities don't get upset. */ + * utilities don't get upset. + */ case DIOCWDINFO: /* write partition info */ case DIOCSDINFO: /* set partition info */ return 0; /* not a titty */ @@ -357,10 +366,12 @@ vinumioctl(dev_t dev, return 0; /* XXX */ } -/* The following four functions check the supplied +/* + * The following four functions check the supplied * object index and return a pointer to the object * if it exists. Otherwise they longjump out via - * throw_rude_remark */ + * throw_rude_remark. + */ struct drive * validdrive(int driveno, struct _ioctl_reply *reply) { @@ -636,8 +647,10 @@ detachobject(struct vinum_ioctl_msg *msg) if ((!msg->force) /* don't force things */ &&((vol->state == volume_up) /* and the volume is up */ &&(vol->plexes == 1))) { /* and this is the last plex */ - /* XXX As elsewhere, check whether we will lose - * mapping by removing this plex */ + /* + * XXX As elsewhere, check whether we will lose + * mapping by removing this plex + */ reply->error = EBUSY; /* we need this plex */ reply->msg[0] = '\0'; return; diff --git a/sys/dev/vinum/vinumkw.h b/sys/dev/vinum/vinumkw.h index 25dbced..37da667 100644 --- a/sys/dev/vinum/vinumkw.h +++ b/sys/dev/vinum/vinumkw.h @@ -40,13 +40,17 @@ #include "opt_vinum.h" #endif -/* Command keywords that vinum knows. These include both user-level - * and kernel-level stuff */ +/* + * Command keywords that vinum knows. These include both user-level + * and kernel-level stuff + */ -/* Our complete vocabulary. The names of the commands are +/* + * Our complete vocabulary. The names of the commands are * the same as the identifier without the kw_ at the beginning * (i.e. kw_create defines the "create" keyword). Preprocessor - * magic in parser.c does the rest. */ + * magic in parser.c does the rest. + */ enum keyword { kw_create, kw_modify, diff --git a/sys/dev/vinum/vinumlock.c b/sys/dev/vinum/vinumlock.c index b367dc5..0809424 100644 --- a/sys/dev/vinum/vinumlock.c +++ b/sys/dev/vinum/vinumlock.c @@ -40,9 +40,11 @@ #include "opt_vinum.h" #include -/* Lock routines. Currently, we lock either an individual volume +/* + * Lock routines. Currently, we lock either an individual volume * or the global configuration. I don't think tsleep and - * wakeup are SMP safe. FIXME XXX */ + * wakeup are SMP safe. FIXME XXX + */ /* Lock a drive, wait if it's in use */ int @@ -52,11 +54,13 @@ lockdrive(struct drive *drive) /* XXX get rid of drive->flags |= VF_LOCKING; */ while ((drive->flags & VF_LOCKED) != 0) { - /* There are problems sleeping on a unique identifier, + /* + * There are problems sleeping on a unique identifier, * since the drive structure can move, and the unlock * function can be called after killing the drive. * Solve this by waiting on this function; the number - * of conflicts is negligible */ + * of conflicts is negligible + */ if ((error = tsleep(&lockdrive, PRIBIO | PCATCH, "vindrv", @@ -85,10 +89,12 @@ lockvol(struct volume *vol) while ((vol->flags & VF_LOCKED) != 0) { vol->flags |= VF_LOCKING; - /* It would seem to make more sense to sleep on + /* + * It would seem to make more sense to sleep on * the address 'vol'. Unfortuntaly we can't * guarantee that this address won't change due to - * table expansion. The address we choose won't change. */ + * table expansion. The address we choose won't change. + */ if ((error = tsleep(&vinum_conf.volume + vol->devno, PRIBIO | PCATCH, "volock", @@ -118,10 +124,12 @@ lockplex(struct plex *plex) while ((plex->flags & VF_LOCKED) != 0) { plex->flags |= VF_LOCKING; - /* It would seem to make more sense to sleep on + /* + * It would seem to make more sense to sleep on * the address 'plex'. Unfortunately we can't * guarantee that this address won't change due to - * table expansion. The address we choose won't change. */ + * table expansion. The address we choose won't change. + */ if ((error = tsleep(&vinum_conf.plex + plex->sdnos[0], PRIBIO | PCATCH, "plexlk", diff --git a/sys/dev/vinum/vinummemory.c b/sys/dev/vinum/vinummemory.c index c06bd9a..bbd24f2 100644 --- a/sys/dev/vinum/vinummemory.c +++ b/sys/dev/vinum/vinummemory.c @@ -178,9 +178,11 @@ vinum_mallocinfo(caddr_t data) return 0; } -/* return the nth request trace buffer entry. This +/* + * return the nth request trace buffer entry. This * is indexed back from the current entry (which - * has index 0) */ + * has index 0) + */ int vinum_rqinfo(caddr_t data) { diff --git a/sys/dev/vinum/vinumparser.c b/sys/dev/vinum/vinumparser.c index 7812f64..75c403d 100644 --- a/sys/dev/vinum/vinumparser.c +++ b/sys/dev/vinum/vinumparser.c @@ -36,10 +36,13 @@ * $Id: vinumparser.c,v 1.14 1999/01/18 03:30:07 grog Exp grog $ */ -/* This file contains the parser for the configuration routines. It's used - * both in the kernel and in the user interface program, thus the separate file. */ +/* + * This file contains the parser for the configuration routines. It's used + * both in the kernel and in the user interface program, thus the separate file. + */ -/* Go through a text and split up into text tokens. These are either non-blank +/* + * Go through a text and split up into text tokens. These are either non-blank * sequences, or any sequence (except \0) enclosed in ' or ". Embedded ' or * " characters may be escaped by \, which otherwise has no special meaning. * @@ -50,7 +53,8 @@ * grey space. * * Error conditions are end of line before end of quote, or no space after - * a closing quote. In this case, tokenize() returns -1. */ + * a closing quote. In this case, tokenize() returns -1. + */ #ifdef KERNEL #include "opt_vinum.h" diff --git a/sys/dev/vinum/vinumrequest.c b/sys/dev/vinum/vinumrequest.c index bba7e1d..ba22fa9 100644 --- a/sys/dev/vinum/vinumrequest.c +++ b/sys/dev/vinum/vinumrequest.c @@ -119,8 +119,10 @@ vinumstrategy(struct buf *bp) sdio(bp); return; - /* In fact, vinum doesn't handle drives: they're - * handled directly by the disk drivers */ + /* + * In fact, vinum doesn't handle drives: they're + * handled directly by the disk drivers + */ case VINUM_DRIVE_TYPE: default: bp->b_error = EIO; /* I/O error */ @@ -142,9 +144,11 @@ vinumstrategy(struct buf *bp) return; } /* FALLTHROUGH */ - /* Plex I/O is pretty much the same as volume I/O + /* + * Plex I/O is pretty much the same as volume I/O * for a single plex. Indicate this by passing a NULL - * pointer (set above) for the volume */ + * pointer (set above) for the volume + */ case VINUM_PLEX_TYPE: case VINUM_RAWPLEX_TYPE: bp->b_resid = bp->b_bcount; /* transfer everything */ @@ -153,14 +157,16 @@ vinumstrategy(struct buf *bp) } } -/* Start a transfer. Return -1 on error, +/* + * Start a transfer. Return -1 on error, * 0 if OK, 1 if we need to retry. * Parameter reviveok is set when doing * transfers for revives: it allows transfers to * be started immediately when a revive is in * progress. During revive, normal transfers * are queued if they share address space with - * a currently active revive operation. */ + * a currently active revive operation. + */ int vinumstart(struct buf *bp, int reviveok) { @@ -175,12 +181,14 @@ vinumstart(struct buf *bp, int reviveok) logrq(loginfo_user_bp, bp, bp); #endif - /* XXX In these routines, we're assuming that + /* + * XXX In these routines, we're assuming that * we will always be called with bp->b_bcount * which is a multiple of the sector size. This * is a reasonable assumption, since we are only * called from system routines. Should we check - * anyway? */ + * anyway? + */ if ((bp->b_bcount % DEV_BSIZE) != 0) { /* bad length */ bp->b_error = EINVAL; /* invalid size */ @@ -197,9 +205,11 @@ vinumstart(struct buf *bp, int reviveok) } bzero(rq, sizeof(struct request)); - /* Note the volume ID. This can be NULL, which + /* + * Note the volume ID. This can be NULL, which * the request building functions use as an - * indication for single plex I/O */ + * indication for single plex I/O + */ rq->bp = bp; /* and the user buffer struct */ if (DEVTYPE(bp->b_dev) == VINUM_VOLUME_TYPE) { /* it's a volume, */ @@ -215,14 +225,16 @@ vinumstart(struct buf *bp, int reviveok) } if (bp->b_flags & B_READ) { - /* This is a read request. Decide + /* + * This is a read request. Decide * which plex to read from. * * There's a potential race condition here, * since we're not locked, and we could end * up multiply incrementing the round-robin * counter. This doesn't have any serious - * effects, however. */ + * effects, however. + */ if (vol != NULL) { vol->reads++; vol->bytes_read += bp->b_bcount; @@ -259,9 +271,11 @@ vinumstart(struct buf *bp, int reviveok) return result; } } else - /* This is a write operation. We write to all + /* + * This is a write operation. We write to all * plexes. If this is a RAID 5 plex, we must also - * update the parity stripe. */ + * update the parity stripe. + */ { if (vol != NULL) { vol->writes++; @@ -291,8 +305,10 @@ vinumstart(struct buf *bp, int reviveok) } } -/* Call the low-level strategy routines to - * perform the requests in a struct request */ +/* + * Call the low-level strategy routines to + * perform the requests in a struct request + */ int launch_requests(struct request *rq, int reviveok) { @@ -301,10 +317,12 @@ launch_requests(struct request *rq, int reviveok) struct rqelement *rqe; /* current element */ int s; - /* First find out whether we're reviving, and the + /* + * First find out whether we're reviving, and the * request contains a conflict. If so, we hang * the request off plex->waitlist of the first - * plex we find which is reviving */ + * plex we find which is reviving + */ if ((rq->flags & XFR_REVIVECONFLICT) /* possible revive conflict */ &&(!reviveok)) { /* and we don't want to do it now, */ struct sd *sd; @@ -389,7 +407,8 @@ launch_requests(struct request *rq, int reviveok) return 0; } -/* define the low-level requests needed to perform a +/* + * define the low-level requests needed to perform a * high-level I/O operation for a specific plex 'plexno'. * * Return 0 if all subdisks involved in the request are up, 1 if some @@ -483,20 +502,28 @@ bre(struct request *rq, case plex_striped: { while (*diskaddr < diskend) { /* until we get it all sorted out */ - /* The offset of the start address from - * the start of the stripe */ + /* + * The offset of the start address from + * the start of the stripe + */ stripeoffset = *diskaddr % (plex->stripesize * plex->subdisks); - /* The plex-relative address of the - * start of the stripe */ + /* + * The plex-relative address of the + * start of the stripe + */ stripebase = *diskaddr - stripeoffset; - /* The number of the subdisk in which - * the start is located */ + /* + * The number of the subdisk in which + * the start is located + */ sdno = stripeoffset / plex->stripesize; - /* The offset from the beginning of the stripe - * on this subdisk */ + /* + * The offset from the beginning of the stripe + * on this subdisk + */ blockoffset = stripeoffset % plex->stripesize; sd = &SD[plex->sdnos[sdno]]; /* the subdisk in question */ @@ -561,9 +588,11 @@ bre(struct request *rq, return status; } -/* Build up a request structure for reading volumes. +/* + * Build up a request structure for reading volumes. * This function is not needed for plex reads, since there's - * no recovery if a plex read can't be satisified. */ + * no recovery if a plex read can't be satisified. + */ enum requeststatus build_read_request(struct request *rq, /* request */ int plexindex) @@ -600,14 +629,18 @@ build_read_request(struct request *rq, /* request */ case REQUEST_ENOMEM: return status; - /* if we get here, we have either had a failure or + /* + * if we get here, we have either had a failure or * a RAID 5 recovery. We don't want to use the * recovery, because it's expensive, so first we - * check if we have alternatives */ + * check if we have alternatives + */ case REQUEST_DOWN: /* can't access the plex */ if (vol != NULL) { /* and this is volume I/O */ - /* Try to satisfy the request - * from another plex */ + /* + * Try to satisfy the request + * from another plex + */ for (plexno = 0; plexno < vol->plexes; plexno++) { diskaddr = startaddr; /* start at the beginning again */ oldstart = startaddr; /* and note where that was */ @@ -631,10 +664,12 @@ build_read_request(struct request *rq, /* request */ return status; } -/* Build up a request structure for writes. +/* + * Build up a request structure for writes. * Return 0 if all subdisks involved in the request are up, 1 if some * subdisks are not up, and -1 if the request is at least partially - * outside the bounds of the subdisks. */ + * outside the bounds of the subdisks. + */ enum requeststatus build_write_request(struct request *rq) { /* request */ @@ -651,9 +686,11 @@ build_write_request(struct request *rq) status = REQUEST_OK; for (plexno = 0; plexno < vol->plexes; plexno++) { diskstart = bp->b_blkno; /* start offset of transfer */ - /* Build requests for the plex. + /* + * Build requests for the plex. * We take the best possible result here (min, - * not max): we're happy if we can write at all */ + * not max): we're happy if we can write at all + */ status = min(status, bre(rq, vol->plex[plexno], &diskstart, @@ -681,8 +718,10 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex) bp->b_proc = ubp->b_proc; /* process pointer */ bp->b_flags = ubp->b_flags & (B_NOCACHE | B_READ | B_ASYNC); /* copy these flags from user bp */ bp->b_flags |= B_CALL | B_BUSY; /* inform us when it's done */ - /* XXX Should we check for reviving plexes here, and - * set B_ORDERED if so? */ + /* + * XXX Should we check for reviving plexes here, and + * set B_ORDERED if so? + */ bp->b_iodone = complete_rqe; /* by calling us here */ bp->b_dev = DRIVE[rqe->driveno].dev; /* drive device */ bp->b_blkno = rqe->sdoffset + sd->driveoffset; /* start address */ @@ -701,14 +740,18 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex) return REQUEST_ENOMEM; /* no memory */ } } else - /* Point directly to user buffer data. This means + /* + * Point directly to user buffer data. This means * that we don't need to do anything when we have - * finished the transfer */ + * finished the transfer + */ bp->b_data = ubp->b_data + rqe->useroffset * DEV_BSIZE; return 0; } -/* Abort a request: free resources and complete the - * user request with the specified error */ +/* + * Abort a request: free resources and complete the + * user request with the specified error + */ int abortrequest(struct request *rq, int error) { @@ -721,10 +764,12 @@ abortrequest(struct request *rq, int error) return error; /* and give up */ } -/* Check that our transfer will cover the +/* + * Check that our transfer will cover the * complete address space of the user request. * - * Return 1 if it can, otherwise 0 */ + * Return 1 if it can, otherwise 0 + */ int check_range_covered(struct request *rq) { @@ -784,8 +829,10 @@ sdio(struct buf *bp) sbp->b.b_bcount -= (endoffset - sd->sectors) * DEV_BSIZE; /* trim */ if (sbp->b.b_bcount <= 0) { /* nothing to transfer */ bp->b_resid = bp->b_bcount; /* nothing transferred */ - /* XXX Grrr. This doesn't seem to work. Return - * an error after all */ + /* + * XXX Grrr. This doesn't seem to work. Return + * an error after all + */ bp->b_flags |= B_ERROR; bp->b_error = ENOSPC; biodone(bp); @@ -814,7 +861,8 @@ sdio(struct buf *bp) splx(s); } -/* Simplified version of bounds_check_with_label +/* + * Simplified version of bounds_check_with_label * Determine the size of the transfer, and make sure it is * within the boundaries of the partition. Adjust transfer * if needed, and signal errors or early completion. @@ -871,8 +919,10 @@ vinum_bounds_check(struct buf *bp, struct volume *vol) return 1; } -/* Allocate a request group and hook - * it in in the list for rq */ +/* + * Allocate a request group and hook + * it in in the list for rq + */ struct rqgroup * allocrqg(struct request *rq, int elements) { @@ -895,10 +945,12 @@ allocrqg(struct request *rq, int elements) return rqg; } -/* Deallocate a request group out of a chain. We do +/* + * Deallocate a request group out of a chain. We do * this by linear search: the chain is short, this * almost never happens, and currently it can only - * happen to the first member of the chain. */ + * happen to the first member of the chain. + */ void deallocrqg(struct rqgroup *rqg) { diff --git a/sys/dev/vinum/vinumrevive.c b/sys/dev/vinum/vinumrevive.c index e7cc3dd..09f874f 100644 --- a/sys/dev/vinum/vinumrevive.c +++ b/sys/dev/vinum/vinumrevive.c @@ -41,14 +41,16 @@ #include #include -/* revive a block of a subdisk. Return an error +/* + * revive a block of a subdisk. Return an error * indication. EAGAIN means successful copy, but * that more blocks remain to be copied. EINVAL means * that the subdisk isn't associated with a plex (which * means a programming error if we get here at all; * FIXME) * XXX We should specify a block size here. At the moment, - * just take a default value. FIXME */ + * just take a default value. FIXME + */ int revive_block(int sdno) { @@ -91,8 +93,10 @@ revive_block(int sdno) bremfree(bp); /* remove it XXX how can this happen? */ splx(s); - /* Amount to transfer: block size, unless it - * would overlap the end */ + /* + * Amount to transfer: block size, unless it + * would overlap the end + */ bp->b_bufsize = size; bp->b_bcount = bp->b_bufsize; bp->b_resid = 0; @@ -120,8 +124,10 @@ revive_block(int sdno) { bp->b_blkno = plexblkno; /* start here */ if (vol != NULL) /* it's part of a volume, */ - /* First, read the data from the volume. We don't - * care which plex, that's bre's job */ + /* + * First, read the data from the volume. We don't + * care which plex, that's bre's job + */ bp->b_dev = VINUMBDEV(plex->volno, 0, 0, VINUM_VOLUME_TYPE); /* create the device number */ else /* it's an unattached plex */ bp->b_dev = VINUMRBDEV(sd->plexno, VINUM_RAWPLEX_TYPE); /* create the device number */ diff --git a/sys/dev/vinum/vinumstate.c b/sys/dev/vinum/vinumstate.c index d71a561..31c3999 100644 --- a/sys/dev/vinum/vinumstate.c +++ b/sys/dev/vinum/vinumstate.c @@ -33,7 +33,7 @@ * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * - * $Id: vinumstate.c,v 1.7 1999/01/21 00:40:32 grog Exp $ + * $Id: vinumstate.c,v 2.10 1999/01/17 06:19:23 grog Exp grog $ */ #define REALLYKERNEL @@ -77,7 +77,8 @@ set_drive_state(int driveno, enum drivestate newstate, enum setstateflags flags) return 0; } -/* Try to set the subdisk state. Return 1 if state changed to +/* + * Try to set the subdisk state. Return 1 if state changed to * what we wanted, -1 if it changed to something else, and 0 * if no change. * @@ -122,7 +123,8 @@ set_sd_state(int sdno, enum sdstate newstate, enum setstateflags flags) &&(((PLEX[sd->plexno].state < plex_firstup) /* and it's not up */ ||(PLEX[sd->plexno].subdisks > 1)))) /* or it's the only one */ break; /* do it */ - /* XXX Get this right: make sure that other plexes in + /* + * XXX Get this right: make sure that other plexes in * the volume cover this address space, otherwise * we make this one sd_up. * @@ -149,8 +151,9 @@ set_sd_state(int sdno, enum sdstate newstate, enum setstateflags flags) case sd_stale: /* out of date info, need reviving */ case sd_obsolete: - /* 1. If the subdisk is not part of a plex, bring it up, don't revive. - + /* + * 1. If the subdisk is not part of a plex, bring it up, don't revive. + * * 2. If the subdisk is part of a one-plex volume or an unattached plex, * and it's not RAID-5, we *can't revive*. The subdisk doesn't * change its state. @@ -162,7 +165,8 @@ set_sd_state(int sdno, enum sdstate newstate, enum setstateflags flags) * 4. If the subdisk is part of a multi-plex volume, we'll change to * reviving and let the revive routines find out whether it will work * or not. If they don't, the revive stops with an error message, - * but the state doesn't change (FWIW).*/ + * but the state doesn't change (FWIW). + */ if (sd->plexno < 0) /* no plex associated, */ break; /* bring it up */ plex = &PLEX[sd->plexno]; @@ -179,12 +183,14 @@ set_sd_state(int sdno, enum sdstate newstate, enum setstateflags flags) status = EAGAIN; /* need to repeat */ break; - /* XXX This is silly. We need to be able to + /* + * XXX This is silly. We need to be able to * bring the subdisk up when it's finished * initializing, but not from the user. We * use the same ioctl in each case, but Vinum(8) * doesn't supply the -f flag, so we use that - * to decide whether to do it or not */ + * to decide whether to do it or not + */ case sd_initializing: if (flags & setstate_force) break; /* do it if we have to */ @@ -196,9 +202,11 @@ set_sd_state(int sdno, enum sdstate newstate, enum setstateflags flags) return EAGAIN; /* no, try again */ default: /* can't do it */ - /* There's no way to bring subdisks up directly from + /* + * There's no way to bring subdisks up directly from * other states. First they need to be initialized - * or revived */ + * or revived + */ return 0; } break; @@ -220,7 +228,8 @@ set_sd_state(int sdno, enum sdstate newstate, enum setstateflags flags) return status; } -/* Set the state of a plex dependent on its subdisks. +/* + * Set the state of a plex dependent on its subdisks. * This time round, we'll let plex state just reflect * aggregate subdisk state, so this becomes an order of * magnitude less complicated. In particular, ignore @@ -244,9 +253,11 @@ set_plex_state(int plexno, enum plexstate state, enum setstateflags flags) vps = vpstate(plex); /* how do we compare with the other plexes? */ switch (state) { - /* We can't bring the plex up, even by force, + /* + * We can't bring the plex up, even by force, * unless it's ready. update_plex_state - * checks that */ + * checks that + */ case plex_up: /* bring the plex up */ update_plex_state(plex->plexno); /* it'll come up if it can */ break; @@ -260,8 +271,10 @@ set_plex_state(int plexno, enum plexstate state, enum setstateflags flags) invalidate_subdisks(plex, sd_down); /* and down all up subdisks */ break; - /* This is only requested internally. - * Trust ourselves */ + /* + * This is only requested internally. + * Trust ourselves + */ case plex_faulty: plex->state = state; /* do it */ invalidate_subdisks(plex, sd_crashed); /* and crash all up subdisks */ @@ -280,8 +293,10 @@ set_plex_state(int plexno, enum plexstate state, enum setstateflags flags) } if (plex->state != oldstate) /* we've changed, */ printf("vinum: %s is %s\n", plex->name, plex_state(plex->state)); /* tell them about it */ - /* Now see what we have left, and whether - * we're taking the volume down */ + /* + * Now see what we have left, and whether + * we're taking the volume down + */ if (plex->volno >= 0) /* we have a volume */ update_volume_state(plex->volno); /* update its state */ if ((flags & setstate_configuring) == 0) /* save config now */ @@ -370,15 +385,18 @@ update_plex_state(int plexno) statemap = sdstatemap(plex); /* get a map of the subdisk states */ if (statemap == sd_upstate) /* all subdisks ready for action */ - /* All the subdisks are up. This also means that + /* + * All the subdisks are up. This also means that * they are consistent, so we can just bring - * the plex up */ + * the plex up + */ plex->state = plex_up; /* go for it */ else if (statemap == sd_emptystate) { /* nothing done yet */ if (((vps & (volplex_otherup | volplex_onlyus)) == 0) /* nothing is up */ &&(plex->state == plex_init) /* we're brand spanking new */ &&(plex->volno >= 0) /* and we have a volume */ &&(VOL[plex->volno].flags & VF_CONFIG_SETUPSTATE)) { /* and we consider that up */ - /* Conceptually, an empty plex does not contain valid data, + /* + * Conceptually, an empty plex does not contain valid data, * but normally we'll see this state when we have just * created a plex, and it's either consistent from earlier, * or we don't care about the previous contents (we're going @@ -390,7 +408,8 @@ update_plex_state(int plexno) * This code assumes that all the other plexes are also * capable of coming up (i.e. all the sds are up), but * that's OK: we'll come back to this function for the remaining - * plexes in the volume. */ + * plexes in the volume. + */ struct volume *vol = &VOL[plex->volno]; int plexno; @@ -448,16 +467,20 @@ update_volume_state(int volno) } } -/* Called from request routines when they find +/* + * Called from request routines when they find * a subdisk which is not kosher. Decide whether * it warrants changing the state. Return * REQUEST_DOWN if we can't use the subdisk, - * REQUEST_OK if we can. */ -/* A prior version of this function checked the plex + * REQUEST_OK if we can. + */ +/* + * A prior version of this function checked the plex * state as well. At the moment, consider plex states * information for the user only. We'll ignore them * and use the subdisk state only. The last version of - * this file with the old logic was 2.7. XXX */ + * this file with the old logic was 2.7. XXX + */ enum requeststatus checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend) { @@ -470,7 +493,8 @@ checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t disken return REQUEST_OK; case sd_reviving: - /* Access to a reviving subdisk depends on the + /* + * Access to a reviving subdisk depends on the * organization of the plex: * - If it's concatenated, access the subdisk up to its current @@ -481,7 +505,8 @@ checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t disken * - if it's striped, we can't do it (we could do some hairy * calculations, but it's unlikely to work). * - if it's RAID-5, we can do it as long as only one - * subdisk is down */ + * subdisk is down + */ if (plex->state == plex_striped) /* plex is striped, */ return REQUEST_DOWN; /* can't access it now */ if (diskaddr > (sd->revived @@ -501,9 +526,11 @@ checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t disken if (writeop) return REQUEST_OK; /* always write to a reborn disk */ else /* don't allow a read */ - /* Handle the mapping. We don't want to reject + /* + * Handle the mapping. We don't want to reject * a read request to a reborn subdisk if that's - * all we have. XXX */ + * all we have. XXX + */ return REQUEST_DOWN; case sd_down: @@ -662,7 +689,8 @@ invalidate_subdisks(struct plex *plex, enum sdstate state) } } -/* Start an object, in other words do what we can to get it up. +/* + * Start an object, in other words do what we can to get it up. * This is called from vinumioctl (VINUMSTART). * Return error indications via ioctl_reply */ @@ -727,12 +755,15 @@ start_object(struct vinum_ioctl_msg *data) strcpy(ioctl_reply->msg, "Invalid object type"); return; } - /* There's no point in saying anything here: - * the userland program does it better */ + /* + * There's no point in saying anything here: + * the userland program does it better + */ ioctl_reply->msg[0] = '\0'; } -/* Stop an object, in other words do what we can to get it down +/* + * Stop an object, in other words do what we can to get it down * This is called from vinumioctl (VINUMSTOP). * Return error indications via ioctl_reply. */ @@ -772,8 +803,10 @@ stop_object(struct vinum_ioctl_msg *data) ioctl_reply->error = 0; } -/* VINUM_SETSTATE ioctl: set an object state - * msg is the message passed by the user */ +/* + * VINUM_SETSTATE ioctl: set an object state + * msg is the message passed by the user + */ void setstate(struct vinum_ioctl_msg *msg) { diff --git a/sys/dev/vinum/vinumstate.h b/sys/dev/vinum/vinumstate.h index 2676269..c9a53b7 100644 --- a/sys/dev/vinum/vinumstate.h +++ b/sys/dev/vinum/vinumstate.h @@ -36,9 +36,11 @@ * $Id: vinumstate.h,v 1.12 1998/12/30 01:31:52 grog Exp grog $ */ -/* This file gets read by makestatetext to create text files +/* + * This file gets read by makestatetext to create text files * with the names of the states, so don't change the file - * format */ + * format + */ enum volumestate { volume_unallocated, @@ -58,45 +60,61 @@ enum plexstate { /* An empty entry, not a plex at all. */ plex_unallocated, - /* The plex has been allocated, but there configuration - * is not complete */ + /* + * The plex has been allocated, but there configuration + * is not complete + */ plex_init, - /* A plex which has gone completely down because of - * I/O errors. */ + /* + * A plex which has gone completely down because of + * I/O errors. + */ plex_faulty, - /* A plex which has been taken down by the - * administrator. */ + /* + * A plex which has been taken down by the + * administrator. + */ plex_down, /* A plex which is being initialized */ plex_initializing, - /* *** The remaining states represent plexes which are + /* + * *** The remaining states represent plexes which are * at least partially up. Keep these separate so that - * they can be checked more easily. */ + * they can be checked more easily. + */ - /* A plex entry which is at least partially up. Not + /* + * A plex entry which is at least partially up. Not * all subdisks are available, and an inconsistency * has occurred. If no other plex is uncorrupted, - * the volume is no longer consistent. */ + * the volume is no longer consistent. + */ plex_corrupt, plex_firstup = plex_corrupt, /* first "up" state */ - /* A RAID-5 plex entry which is accessible, but one + /* + * A RAID-5 plex entry which is accessible, but one * subdisk is down, requiring recovery for many - * I/O requests. */ + * I/O requests. + */ plex_degraded, - /* A plex which is really up, but which has a reborn + /* + * A plex which is really up, but which has a reborn * subdisk which we don't completely trust, and - * which we don't want to read if we can avoid it */ + * which we don't want to read if we can avoid it + */ plex_flaky, - /* A plex entry which is completely up. All subdisks - * are up. */ + /* + * A plex entry which is completely up. All subdisks + * are up. + */ plex_up, plex_laststate = plex_up /* last value, for table dimensions */ @@ -107,29 +125,35 @@ enum sdstate { /* An empty entry, not a subdisk at all. */ sd_unallocated, - /* A subdisk entry which has not been created + /* + * A subdisk entry which has not been created * completely. Some fields may be empty. */ sd_uninit, - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, but the disk hasn't * been updated. */ sd_init, - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, and the disk has been * updated, but there is no data on the disk. */ sd_empty, - /* A subdisk entry which has been created completely and - * which is currently being initialized */ + /* + * A subdisk entry which has been created completely and + * which is currently being initialized + */ sd_initializing, /* *** The following states represent invalid data */ - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, the config on disk has been * updated, and the data was valid, but since then the * drive has been taken down, and as a result updates @@ -137,7 +161,8 @@ enum sdstate { */ sd_obsolete, - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, the disk has been updated, * and the data was valid, but since then the drive * has been crashed and updates have been lost. @@ -146,7 +171,8 @@ enum sdstate { /* *** The following states represent valid, inaccessible data */ - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, the disk has been updated, * and the data was valid, but since then the drive * has gone down. No attempt has been made to write @@ -154,20 +180,27 @@ enum sdstate { */ sd_crashed, - /* A subdisk entry which was up, which contained + /* + * A subdisk entry which was up, which contained * valid data, and which was taken down by the - * administrator. The data is valid. */ + * administrator. The data is valid. + */ sd_down, - /* *** This is invalid data (the subdisk previously had + /* + * *** This is invalid data (the subdisk previously had * a numerically lower state), but it is currently in the - * process of being revived. We can write but not read. */ + * process of being revived. We can write but not read. + */ sd_reviving, - /* *** The following states represent accessible subdisks - * with valid data */ + /* + * *** The following states represent accessible subdisks + * with valid data + */ - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, the disk has been updated, * and the data was valid, but since then the drive * has gone down and up again. No updates were lost, @@ -177,10 +210,12 @@ enum sdstate { * covers this address space in the plex, we set its * state to sd_up under these circumstances, so this * status implies that there is another subdisk to - * fulfil the request. */ + * fulfil the request. + */ sd_reborn, - /* A subdisk entry which has been created completely. + /* + * A subdisk entry which has been created completely. * All fields are correct, the disk has been updated, * and the data is valid. */ diff --git a/sys/dev/vinum/vinumutil.c b/sys/dev/vinum/vinumutil.c index 22d8be8..2bc3553 100644 --- a/sys/dev/vinum/vinumutil.c +++ b/sys/dev/vinum/vinumutil.c @@ -122,8 +122,10 @@ sd_state(enum sdstate state) } /* Now convert in the other direction */ -/* These are currently used only internally, - * so we don't do too much error checking */ +/* + * These are currently used only internally, + * so we don't do too much error checking + */ enum drivestate DriveState(char *text) { @@ -164,7 +166,8 @@ VolState(char *text) return -1; } -/* Take a number with an optional scale factor and convert +/* + * Take a number with an optional scale factor and convert * it to a number of bytes. * * The scale factors are: @@ -216,8 +219,10 @@ sizespec(char *spec) return -1; } -/* Extract the volume number from a device number. - * Perform no checking. */ +/* + * Extract the volume number from a device number. + * Perform no checking. + */ int Volno(dev_t dev) { @@ -225,9 +230,11 @@ Volno(dev_t dev) return (x & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT; } -/* Extract a plex number from a device number. +/* + * Extract a plex number from a device number. * Don't check the major number, but check the - * type. Return -1 for invalid types. */ + * type. Return -1 for invalid types. + */ int Plexno(dev_t dev) { @@ -253,9 +260,11 @@ Plexno(dev_t dev) return 0; /* compiler paranoia */ } -/* Extract a subdisk number from a device number. +/* + * Extract a subdisk number from a device number. * Don't check the major number, but check the - * type. Return -1 for invalid types. */ + * type. Return -1 for invalid types. + */ int Sdno(dev_t dev) { @@ -274,7 +283,8 @@ Sdno(dev_t dev) case VINUM_RAWSD_TYPE: return ((x & MASK(VINUM_VOL_WIDTH)) >> VINUM_VOL_SHIFT) /* low order 8 bits */ - |((x >> VINUM_RAWPLEX_SHIFT) & (MASK(VINUM_RAWPLEX_WIDTH) << (VINUM_VOL_SHIFT + VINUM_VOL_WIDTH))); /* upper 12 bits */ + |((x >> VINUM_RAWPLEX_SHIFT) & (MASK(VINUM_RAWPLEX_WIDTH) + << (VINUM_VOL_SHIFT + VINUM_VOL_WIDTH))); /* upper 12 bits */ } return -1; /* compiler paranoia */ } diff --git a/sys/dev/vinum/vinumvar.h b/sys/dev/vinum/vinumvar.h index df579fa..4709fa5 100644 --- a/sys/dev/vinum/vinumvar.h +++ b/sys/dev/vinum/vinumvar.h @@ -38,7 +38,8 @@ #include #include -/* Some configuration maxima. They're an enum because +/* + * Some configuration maxima. They're an enum because * we can't define global constants. Sorry about that. * * These aren't as bad as they look: most of them are soft limits. @@ -73,8 +74,10 @@ enum constants { VINUM_PLEX_WIDTH = 3, VINUM_SD_WIDTH = 8, - /* Shifts for the second half of raw plex and - * subdisk numbers */ +/* + * Shifts for the second half of raw plex and + * subdisk numbers + */ VINUM_RAWPLEX_SHIFT = 8, /* shift the second half this much */ VINUM_RAWPLEX_WIDTH = 12, /* width of second half */ @@ -118,7 +121,8 @@ enum constants { VINUM_SUPERDEV = VINUMBDEV(0, 0, 0, VINUM_SUPERDEV_TYPE), /* superdevice number */ -/* the number of object entries to cater for initially, and also the +/* + * the number of object entries to cater for initially, and also the * value by which they are incremented. It doesn't take long * to extend them, so theoretically we could start with 1 of each, but * it's untidy to allocate such small areas. These values are @@ -157,22 +161,25 @@ enum constants { */ struct devcode { -/* CARE. These fields assume a big-endian word. On a - * little-endian system, they're the wrong way around */ +/* + * CARE. These fields assume a big-endian word. On a + * little-endian system, they're the wrong way around + */ unsigned volume:8; /* up to 256 volumes */ unsigned major:8; /* this is where the major number fits */ unsigned plex:3; /* up to 8 plexes per volume */ unsigned unused:1; /* up for grabs */ unsigned sd:8; /* up to 256 subdisks per plex */ unsigned type:3; /* type of object */ - /* type field - VINUM_VOLUME = 0, - VINUM_PLEX = 1, - VINUM_SUBDISK = 2, - VINUM_DRIVE = 3, - VINUM_SUPERDEV = 4, - VINUM_RAWPLEX = 5, - VINUM_RAWSD = 6 */ + /* + * type field + VINUM_VOLUME = 0, + VINUM_PLEX = 1, + VINUM_SUBDISK = 2, + VINUM_DRIVE = 3, + VINUM_SUPERDEV = 4, + VINUM_RAWPLEX = 5, + VINUM_RAWSD = 6 */ unsigned signbit:1; /* to make 32 bits */ }; @@ -180,9 +187,11 @@ struct devcode { #define VINUM_RDIR "/dev/rvinum" #define VINUM_SUPERDEV_NAME VINUM_DIR"/control" -/* Flags for all objects. Most of them only apply to +/* + * Flags for all objects. Most of them only apply to * specific objects, but we have space for all in any - * 32 bit flags word. */ + * 32 bit flags word. + */ enum objflags { VF_LOCKED = 1, /* somebody has locked access to this object */ VF_LOCKING = 2, /* we want access to this object */ @@ -240,8 +249,9 @@ struct _vinum_conf { #define VOL vinum_conf.volume #define VFLAGS vinum_conf.flags -/* Slice header - +/* + * Slice header + * * Vinum drives start with this structure: * *\ Sector @@ -271,10 +281,12 @@ enum { DATASTART = (MAXCONFIG * 2 + VINUM_CONFIG_OFFSET) / DEV_BSIZE /* this is where the data starts */ }; -/* hostname is 256 bytes long, but we don't need to shlep +/* + * hostname is 256 bytes long, but we don't need to shlep * multiple copies in vinum. We use the host name just * to identify this system, and 32 bytes should be ample - * for that purpose */ + * for that purpose + */ struct vinum_label { char sysname[VINUMHOSTNAMELEN]; /* system name at time of creation */ @@ -307,9 +319,11 @@ enum drive_label_info { }; /*** Drive definitions ***/ -/* A drive corresponds to a disk slice. We use a different term to show +/* + * A drive corresponds to a disk slice. We use a different term to show * the difference in usage: it doesn't have to be a slice, and could - * theroretically be a complete, unpartitioned disk */ + * theroretically be a complete, unpartitioned disk + */ struct drive { enum drivestate state; /* current state */ @@ -349,10 +363,12 @@ struct sd { int lasterror; /* last error occurred */ /* offsets in blocks */ int64_t driveoffset; /* offset on drive */ - /* plexoffset is the offset from the beginning of the + /* + * plexoffset is the offset from the beginning of the * plex to the very first part of the subdisk, in * sectors. For striped and RAID-5 plexes, only - * the first stripe is located at this offset */ + * the first stripe is located at this offset + */ int64_t plexoffset; /* offset in plex */ u_int64_t sectors; /* and length in sectors */ int plexno; /* index of plex, if it belongs */ @@ -442,9 +458,11 @@ struct volume { struct disklabel label; /* for DIOCGPART */ }; -/* Table expansion. Expand table, which contains oldcount +/* + * Table expansion. Expand table, which contains oldcount * entries of type element, by increment entries, and change - * oldcount accordingly */ + * oldcount accordingly + */ #define EXPAND(table, element, oldcount, increment) \ { \ expand_table ((void **) &table, \ @@ -472,14 +490,16 @@ struct mc { char file[16]; }; -/* These enums are used by the state transition +/* + * These enums are used by the state transition * routines. They're in bit map format: * * Bit 0: Other plexes in the volume are down * Bit 1: Other plexes in the volume are up * Bit 2: The current plex is up * Maybe they should be local to - * state.c */ + * state.c + */ enum volplexstate { volplex_onlyusdown = 0, /* we're the only plex, and we're down */ volplex_alldown, /* 1: another plex is down, and so are we */ @@ -504,10 +524,12 @@ enum sdstates { sd_otherstate = 256 /* found an SD in some other state */ }; -/* This is really just a parameter to pass to +/* + * This is really just a parameter to pass to * set__state, but since it needs to be known * in the external definitions, we need to define - * it here */ + * it here + */ enum setstateflags { setstate_none = 0, /* no flags */ setstate_force = 1, /* force the state change */ -- cgit v1.1