diff options
author | 2002-12-16 07:01:02 +0000 | |
---|---|---|
committer | 2002-12-16 07:01:02 +0000 | |
commit | 02be053e1228ba4c0a567701ded8cec05be5df63 (patch) | |
tree | 4810bcbe357aeb65b2f475f98fd7ce2f26089128 /sys/dev/raidframe/rf_openbsdkintf.c | |
parent | typo; from Tor Houghton <torh@bogus.net> (diff) | |
download | wireguard-openbsd-02be053e1228ba4c0a567701ded8cec05be5df63.tar.xz wireguard-openbsd-02be053e1228ba4c0a567701ded8cec05be5df63.zip |
Major KNF. Incentive from Tedu
Diffstat (limited to 'sys/dev/raidframe/rf_openbsdkintf.c')
-rw-r--r-- | sys/dev/raidframe/rf_openbsdkintf.c | 1725 |
1 files changed, 854 insertions, 871 deletions
diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c index 18964abf085..c8b446653d1 100644 --- a/sys/dev/raidframe/rf_openbsdkintf.c +++ b/sys/dev/raidframe/rf_openbsdkintf.c @@ -1,5 +1,6 @@ -/* $OpenBSD: rf_openbsdkintf.c,v 1.20 2002/10/12 02:03:46 krw Exp $ */ +/* $OpenBSD: rf_openbsdkintf.c,v 1.21 2002/12/16 07:01:04 tdeval Exp $ */ /* $NetBSD: rf_netbsdkintf.c,v 1.109 2001/07/27 03:30:07 oster Exp $ */ + /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. * All rights reserved. @@ -78,9 +79,6 @@ * @(#)cd.c 8.2 (Berkeley) 11/16/93 */ - - - /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -108,11 +106,11 @@ * rights to redistribute these changes. */ -/*********************************************************** +/***************************************************************************** * - * rf_kintf.c -- the kernel interface routines for RAIDframe + * rf_kintf.c -- The kernel interface routines for RAIDframe. * - ***********************************************************/ + *****************************************************************************/ #include <sys/errno.h> @@ -156,51 +154,51 @@ int rf_kdebug_level = 0; -#ifdef RAIDDEBUG -#define db1_printf(a) do if (rf_kdebug_level > 0) printf a; while(0) +#ifdef RAIDDEBUG +#define db1_printf(a) do { if (rf_kdebug_level > 0) printf a; } while(0) #else /* RAIDDEBUG */ -#define db1_printf(a) (void)0 -#endif /* RAIDDEBUG */ +#define db1_printf(a) (void)0 +#endif /* ! RAIDDEBUG */ -static RF_Raid_t **raidPtrs; /* global raid device descriptors */ +static RF_Raid_t **raidPtrs; /* Global raid device descriptors. */ -RF_DECLARE_STATIC_MUTEX(rf_sparet_wait_mutex) +RF_DECLARE_STATIC_MUTEX(rf_sparet_wait_mutex); -/* requests to install a spare table */ +/* Requests to install a spare table. */ static RF_SparetWait_t *rf_sparet_wait_queue; -/* responses from installation process */ +/* Responses from installation process. */ static RF_SparetWait_t *rf_sparet_resp_queue; -/* prototypes */ -void rf_KernelWakeupFunc(struct buf *); -void rf_InitBP(struct buf *, struct vnode *, unsigned, dev_t, - RF_SectorNum_t, RF_SectorCount_t, caddr_t, void (*)(struct buf *), - void *, int, struct proc *); +/* Prototypes. */ +void rf_KernelWakeupFunc(struct buf *); +void rf_InitBP(struct buf *, struct vnode *, unsigned, dev_t, RF_SectorNum_t, + RF_SectorCount_t, caddr_t, void (*)(struct buf *), void *, int, + struct proc *); void raidinit(RF_Raid_t *); -void raidattach(int); -int raidsize(dev_t); -int raidopen(dev_t, int, int, struct proc *); -int raidclose(dev_t, int, int, struct proc *); -int raidioctl(dev_t, u_long, caddr_t, int, struct proc *); -int raidwrite(dev_t, struct uio *, int); -int raidread(dev_t, struct uio *, int); -void raidstrategy(struct buf *); -int raiddump(dev_t, daddr_t, caddr_t, size_t); +void raidattach(int); +int raidsize(dev_t); +int raidopen(dev_t, int, int, struct proc *); +int raidclose(dev_t, int, int, struct proc *); +int raidioctl(dev_t, u_long, caddr_t, int, struct proc *); +int raidwrite(dev_t, struct uio *, int); +int raidread(dev_t, struct uio *, int); +void raidstrategy(struct buf *); +int raiddump(dev_t, daddr_t, caddr_t, size_t); /* * Pilfered from ccd.c */ struct raidbuf { - struct buf rf_buf; /* new I/O buf. MUST BE FIRST!!! */ - struct buf *rf_obp; /* ptr. to original I/O buf */ - int rf_flags; /* misc. flags */ - RF_DiskQueueData_t *req;/* the request that this was part of.. */ + struct buf rf_buf; /* New I/O buf. MUST BE FIRST!!! */ + struct buf *rf_obp; /* Ptr. to original I/O buf. */ + int rf_flags; /* Miscellaneous flags. */ + RF_DiskQueueData_t *req; /* The request that this was part of. */ }; -#define RAIDGETBUF(rs) pool_get(&(rs)->sc_cbufpool, PR_NOWAIT) -#define RAIDPUTBUF(rs, cbp) pool_put(&(rs)->sc_cbufpool, cbp) +#define RAIDGETBUF(rs) pool_get(&(rs)->sc_cbufpool, PR_NOWAIT) +#define RAIDPUTBUF(rs, cbp) pool_put(&(rs)->sc_cbufpool, cbp) /* * Some port (like i386) use a swapgeneric that wants to snoop around @@ -213,24 +211,24 @@ struct cfdriver raid_cd = { /* * XXX Not sure if the following should be replacing the raidPtrs above, - * or if it should be used in conjunction with that... + * or if it should be used in conjunction with that... */ struct raid_softc { - int sc_flags; /* flags */ - int sc_cflags; /* configuration flags */ - size_t sc_size; /* size of the raid device */ - char sc_xname[20]; /* XXX external name */ - struct disk sc_dkdev; /* generic disk device info */ - struct pool sc_cbufpool; /* component buffer pool */ - struct buf sc_q; /* used for the device queue */ + int sc_flags; /* Flags. */ + int sc_cflags; /* Configuration flags. */ + size_t sc_size; /* Size of the raid device. */ + char sc_xname[20]; /* XXX external name. */ + struct disk sc_dkdev; /* Generic disk device info. */ + struct pool sc_cbufpool; /* Component buffer pool. */ + struct buf sc_q; /* Used for the device queue. */ }; /* sc_flags */ -#define RAIDF_INITED 0x01 /* unit has been initialized */ -#define RAIDF_WLABEL 0x02 /* label area is writable */ -#define RAIDF_LABELLING 0x04 /* unit is currently being labelled */ -#define RAIDF_WANTED 0x40 /* someone is waiting to obtain a lock */ -#define RAIDF_LOCKED 0x80 /* unit is locked */ +#define RAIDF_INITED 0x01 /* Unit has been initialized. */ +#define RAIDF_WLABEL 0x02 /* Label area is writable. */ +#define RAIDF_LABELLING 0x04 /* Unit is currently being labelled. */ +#define RAIDF_WANTED 0x40 /* Someone is waiting to obtain a lock. */ +#define RAIDF_LOCKED 0x80 /* Unit is locked. */ #define raidunit(x) DISKUNIT(x) int numraid = 0; @@ -240,11 +238,11 @@ int numraid = 0; * into the device tree. This is needed by some archs that look for * bootable devices in there. */ -int rf_probe(struct device *, void *, void *); -void rf_attach(struct device *, struct device *, void *); -int rf_detach(struct device *, int); -int rf_activate(struct device *, enum devact); -void rf_zeroref(struct device *); +int rf_probe(struct device *, void *, void *); +void rf_attach(struct device *, struct device *, void *); +int rf_detach(struct device *, int); +int rf_activate(struct device *, enum devact); +void rf_zeroref(struct device *); struct cfattach raid_ca = { sizeof(struct raid_softc), rf_probe, rf_attach, @@ -255,132 +253,123 @@ struct cfattach raid_ca = { * Allow RAIDOUTSTANDING number of simultaneous IO's to this RAID device. * Be aware that large numbers can allow the driver to consume a lot of * kernel memory, especially on writes, and in degraded mode reads. - * - * For example: with a stripe width of 64 blocks (32k) and 5 disks, - * a single 64K write will typically require 64K for the old data, - * 64K for the old parity, and 64K for the new parity, for a total + * + * For example: with a stripe width of 64 blocks (32k) and 5 disks, + * a single 64K write will typically require 64K for the old data, + * 64K for the old parity, and 64K for the new parity, for a total * of 192K (if the parity buffer is not re-used immediately). * Even it if is used immedately, that's still 128K, which when multiplied * by say 10 requests, is 1280K, *on top* of the 640K of incoming data. - * + * * Now in degraded mode, for example, a 64K read on the above setup may - * require data reconstruction, which will require *all* of the 4 remaining + * require data reconstruction, which will require *all* of the 4 remaining * disks to participate -- 4 * 32K/disk == 128K again. */ -#ifndef RAIDOUTSTANDING -#define RAIDOUTSTANDING 6 +#ifndef RAIDOUTSTANDING +#define RAIDOUTSTANDING 6 #endif -#define RAIDLABELDEV(dev) \ +#define RAIDLABELDEV(dev) \ (MAKEDISKDEV(major((dev)), raidunit((dev)), RAW_PART)) -/* declared here, and made public, for the benefit of KVM stuff.. */ -struct raid_softc *raid_softc; +/* Declared here, and made public, for the benefit of KVM stuff... */ +struct raid_softc *raid_softc; struct raid_softc **raid_scPtrs; -void rf_shutdown_hook(RF_ThreadArg_t); -void raidgetdefaultlabel(RF_Raid_t *, struct raid_softc *, struct disklabel *); -void raidgetdisklabel(dev_t); -void raidmakedisklabel(struct raid_softc *); +void rf_shutdown_hook(RF_ThreadArg_t); +void raidgetdefaultlabel(RF_Raid_t *, struct raid_softc *, struct disklabel *); +void raidgetdisklabel(dev_t); +void raidmakedisklabel(struct raid_softc *); -int raidlock(struct raid_softc *); -void raidunlock(struct raid_softc *); +int raidlock(struct raid_softc *); +void raidunlock(struct raid_softc *); -void rf_markalldirty(RF_Raid_t *); +void rf_markalldirty(RF_Raid_t *); struct device *raidrootdev; -int findblkmajor(struct device *dv); +int findblkmajor(struct device *dv); char *findblkname(int); void rf_ReconThread(struct rf_recon_req *); /* XXX what I want is: */ -/*void rf_ReconThread(RF_Raid_t *raidPtr); */ +/*void rf_ReconThread(RF_Raid_t *raidPtr);*/ void rf_RewriteParityThread(RF_Raid_t *raidPtr); void rf_CopybackThread(RF_Raid_t *raidPtr); void rf_ReconstructInPlaceThread(struct rf_recon_req *); -#ifdef RAID_AUTOCONFIG +#ifdef RAID_AUTOCONFIG void rf_buildroothack(void *); -int rf_reasonable_label(RF_ComponentLabel_t *); -#endif +int rf_reasonable_label(RF_ComponentLabel_t *); +#endif /* RAID_AUTOCONFIG */ RF_AutoConfig_t *rf_find_raid_components(void); RF_ConfigSet_t *rf_create_auto_sets(RF_AutoConfig_t *); -int rf_does_it_fit(RF_ConfigSet_t *,RF_AutoConfig_t *); +int rf_does_it_fit(RF_ConfigSet_t *,RF_AutoConfig_t *); void rf_create_configuration(RF_AutoConfig_t *,RF_Config_t *, RF_Raid_t *); -int rf_set_autoconfig(RF_Raid_t *, int); -int rf_set_rootpartition(RF_Raid_t *, int); +int rf_set_autoconfig(RF_Raid_t *, int); +int rf_set_rootpartition(RF_Raid_t *, int); void rf_release_all_vps(RF_ConfigSet_t *); void rf_cleanup_config_set(RF_ConfigSet_t *); -int rf_have_enough_components(RF_ConfigSet_t *); -int rf_auto_config_set(RF_ConfigSet_t *, int *); - -#ifdef RAID_AUTOCONFIG -static int raidautoconfig = 0; /* Debugging, mostly. Set to 0 to not - allow autoconfig to take place. - Note that this is overridden by having - RAID_AUTOCONFIG as an option in the - kernel config file. */ -#endif +int rf_have_enough_components(RF_ConfigSet_t *); +int rf_auto_config_set(RF_ConfigSet_t *, int *); + +#ifdef RAID_AUTOCONFIG +static int raidautoconfig = 0; /* + * Debugging, mostly. Set to 0 to not + * allow autoconfig to take place. + * Note that this is overridden by having + * RAID_AUTOCONFIG as an option in the + * kernel config file. + */ +#endif /* RAID_AUTOCONFIG */ int -rf_probe(parent, match_, aux) - struct device *parent; - void *match_; - void *aux; +rf_probe(struct device *parent, void *match_, void *aux) { return 0; } void -rf_attach(parent, self, aux) - struct device *parent, *self; - void *aux; +rf_attach(struct device *parent, struct device *self, void *aux) { - /* struct raid_softc *raid = (void *)self; */ + /*struct raid_softc *raid = (void *)self;*/ } int -rf_detach(self, flags) - struct device *self; - int flags; +rf_detach(struct device *self, int flags) { return 0; } int -rf_activate(self, act) - struct device *self; - enum devact act; +rf_activate(struct device *self, enum devact act) { return 0; } void -rf_zeroref(self) - struct device *self; +rf_zeroref(struct device *self) { } void -raidattach(num) - int num; +raidattach(int num) { int raidID; int i, rc; -#ifdef RAID_AUTOCONFIG - RF_AutoConfig_t *ac_list; /* autoconfig list */ +#ifdef RAID_AUTOCONFIG + RF_AutoConfig_t *ac_list; /* Autoconfig list. */ RF_ConfigSet_t *config_sets; -#endif +#endif /* RAID_AUTOCONFIG */ db1_printf(("raidattach: Asked for %d units\n", num)); if (num <= 0) { -#ifdef DIAGNOSTIC +#ifdef DIAGNOSTIC panic("raidattach: count <= 0"); -#endif +#endif /* DIAGNOSTIC */ return; } @@ -396,27 +385,26 @@ raidattach(num) rc = rf_mutex_init(&rf_sparet_wait_mutex); if (rc) { - RF_PANIC(); - } + RF_PANIC(); + } rf_sparet_wait_queue = rf_sparet_resp_queue = NULL; for (i = 0; i < num; i++) - raidPtrs[i] = NULL; + raidPtrs[i] = NULL; rc = rf_BootRaidframe(); if (rc == 0) - printf("Kernelized RAIDframe activated\n"); + printf("Kernelized RAIDframe activated\n"); else - panic("Serious error booting RAID!!"); + panic("Serious error booting RAID !!!"); /* - * Put together some datastructures like the CCD device does.. + * Put together some datastructures like the CCD device does... * This lets us lock the device and what-not when it gets opened. */ - + raid_softc = (struct raid_softc *) - malloc(num * sizeof(struct raid_softc), - M_RAIDFRAME, M_NOWAIT); + malloc(num * sizeof(struct raid_softc), M_RAIDFRAME, M_NOWAIT); if (raid_softc == NULL) { printf("WARNING: no memory for RAIDframe driver\n"); return; @@ -425,8 +413,8 @@ raidattach(num) bzero(raid_softc, num * sizeof (struct raid_softc)); raid_scPtrs = (struct raid_softc **) - malloc(num * sizeof(struct raid_softc *), - M_RAIDFRAME, M_NOWAIT); + malloc(num * sizeof(struct raid_softc *), M_RAIDFRAME, + M_NOWAIT); if (raid_scPtrs == NULL) { printf("WARNING: no memory for RAIDframe driver\n"); return; @@ -435,7 +423,7 @@ raidattach(num) bzero(raid_scPtrs, num * sizeof (struct raid_softc *)); raidrootdev = (struct device *)malloc(num * sizeof(struct device), - M_RAIDFRAME, M_NOWAIT); + M_RAIDFRAME, M_NOWAIT); if (raidrootdev == NULL) { panic("No memory for RAIDframe driver!!?!?!"); } @@ -464,38 +452,41 @@ raidattach(num) raid_cd.cd_devs = (void **) raid_scPtrs; raid_cd.cd_ndevs = num; -#ifdef RAID_AUTOCONFIG +#ifdef RAID_AUTOCONFIG raidautoconfig = 1; if (raidautoconfig) { - /* 1. locate all RAID components on the system */ + /* 1. Locate all RAID components on the system. */ #ifdef RAIDDEBUG printf("Searching for raid components...\n"); -#endif +#endif /* RAIDDEBUG */ ac_list = rf_find_raid_components(); - /* 2. sort them into their respective sets */ + /* 2. Sort them into their respective sets. */ config_sets = rf_create_auto_sets(ac_list); - /* 3. evaluate each set and configure the valid ones - This gets done in rf_buildroothack() */ + /* + * 3. Evaluate each set and configure the valid ones + * This gets done in rf_buildroothack(). + */ - /* schedule the creation of the thread to do the - "/ on RAID" stuff */ + /* + * Schedule the creation of the thread to do the + * "/ on RAID" stuff. + */ rf_buildroothack(config_sets); } -#endif +#endif /* RAID_AUTOCONFIG */ } -#ifdef RAID_AUTOCONFIG +#ifdef RAID_AUTOCONFIG void -rf_buildroothack(arg) - void *arg; +rf_buildroothack(void *arg) { RF_ConfigSet_t *config_sets = arg; RF_ConfigSet_t *cset; @@ -511,30 +502,34 @@ rf_buildroothack(arg) cset = config_sets; while(cset != NULL ) { next_cset = cset->next; - if (rf_have_enough_components(cset) && + if (rf_have_enough_components(cset) && cset->ac->clabel->autoconfigure==1) { retcode = rf_auto_config_set(cset,&raidID); if (!retcode) { if (cset->rootable) { rootID = raidID; #ifdef RAIDDEBUG - printf("eligible root device %d: raid%d\n", num_root, rootID); + printf("eligible root device %d:" + " raid%d\n", num_root, rootID); #endif /* RAIDDEBUG */ num_root++; } } else { /* The autoconfig didn't work :( */ #ifdef RAIDDEBUG - printf("Autoconfig failed with code %d for raid%d\n", retcode, raidID); -#endif + printf("Autoconfig failed with code %d for" + " raid%d\n", retcode, raidID); +#endif /* RAIDDEBUG */ rf_release_all_vps(cset); } } else { - /* we're not autoconfiguring this set... - release the associated resources */ + /* + * We're not autoconfiguring this set... + * Release the associated resources. + */ rf_release_all_vps(cset); } - /* cleanup */ + /* Cleanup. */ rf_cleanup_config_set(cset); cset = next_cset; } @@ -548,26 +543,25 @@ rf_buildroothack(arg) if (majdev < 0) boothowto |= RB_ASKNAME; else { - rootdev = MAKEDISKDEV(majdev,rootID,0); + rootdev = MAKEDISKDEV(majdev,rootID,0); boothowto |= RB_DFLTROOT; } } else if (num_root > 1) { - /* we can't guess.. require the user to answer... */ + /* We can't guess... Require the user to answer... */ boothowto |= RB_ASKNAME; } } } -#endif +#endif /* RAID_AUTOCONFIG */ void -rf_shutdown_hook(arg) - RF_ThreadArg_t arg; +rf_shutdown_hook(RF_ThreadArg_t arg) { int unit; struct raid_softc *rs; RF_Raid_t *raidPtr; - /* Don't do it if we are not "safe" */ + /* Don't do it if we are not "safe". */ if (boothowto & RB_NOSYNC) return; @@ -575,7 +569,7 @@ rf_shutdown_hook(arg) unit = raidPtr->raidid; rs = &raid_softc[unit]; - /* Shutdown the system */ + /* Shutdown the system. */ if (rf_hook_cookies != NULL && rf_hook_cookies[unit] != NULL) rf_hook_cookies[unit] = NULL; @@ -595,8 +589,7 @@ rf_shutdown_hook(arg) } int -raidsize(dev) - dev_t dev; +raidsize(dev_t dev) { struct raid_softc *rs; struct disklabel *lp; @@ -631,11 +624,7 @@ raidsize(dev) } int -raiddump(dev, blkno, va, size) - dev_t dev; - daddr_t blkno; - caddr_t va; - size_t size; +raiddump(dev_t dev, daddr_t blkno, caddr_t va, size_t size) { /* Not implemented. */ return (ENXIO); @@ -643,17 +632,14 @@ raiddump(dev, blkno, va, size) /* ARGSUSED */ int -raidopen(dev, flags, fmt, p) - dev_t dev; - int flags, fmt; - struct proc *p; +raidopen(dev_t dev, int flags, int fmt, struct proc *p) { int unit = raidunit(dev); struct raid_softc *rs; struct disklabel *lp; int part,pmask; int error = 0; - + if (unit >= numraid) return (ENXIO); rs = &raid_softc[unit]; @@ -672,7 +658,7 @@ raidopen(dev, flags, fmt, p) if ((rs->sc_flags & RAIDF_INITED) && (rs->sc_dkdev.dk_openmask == 0)) raidgetdisklabel(dev); - /* make sure that this partition exists */ + /* Make sure that this partition exists. */ if (part != RAW_PART) { db1_printf(("Not a raw partition..\n")); @@ -686,7 +672,7 @@ raidopen(dev, flags, fmt, p) } } - /* Prevent this unit from being unconfigured while open. */ + /* Prevent this unit from being unconfigured while opened. */ switch (fmt) { case S_IFCHR: rs->sc_dkdev.dk_copenmask |= pmask; @@ -699,15 +685,19 @@ raidopen(dev, flags, fmt, p) if ((rs->sc_dkdev.dk_openmask == 0) && ((rs->sc_flags & RAIDF_INITED) != 0)) { - /* First one... mark things as dirty... Note that we *MUST* - have done a configure before this. I DO NOT WANT TO BE - SCRIBBLING TO RANDOM COMPONENTS UNTIL IT'S BEEN DETERMINED - THAT THEY BELONG TOGETHER!!!!! */ - /* XXX should check to see if we're only open for reading - here... If so, we needn't do this, but then need some - other way of keeping track of what's happened.. */ + /* + * First one... Mark things as dirty... Note that we *MUST* + * have done a configure before this. I DO NOT WANT TO BE + * SCRIBBLING TO RANDOM COMPONENTS UNTIL IT'S BEEN DETERMINED + * THAT THEY BELONG TOGETHER!!!!! + */ + /* + * XXX should check to see if we're only open for reading + * here... If so, we needn't do this, but then need some + * other way of keeping track of what's happened... + */ - rf_markalldirty( raidPtrs[unit] ); + rf_markalldirty( raidPtrs[unit] ); } rs->sc_dkdev.dk_openmask = @@ -720,10 +710,7 @@ raidopen(dev, flags, fmt, p) /* ARGSUSED */ int -raidclose(dev, flags, fmt, p) - dev_t dev; - int flags, fmt; - struct proc *p; +raidclose(dev_t dev, int flags, int fmt, struct proc *p) { int unit = raidunit(dev); struct raid_softc *rs; @@ -754,10 +741,12 @@ raidclose(dev, flags, fmt, p) if ((rs->sc_dkdev.dk_openmask == 0) && ((rs->sc_flags & RAIDF_INITED) != 0)) { - /* Last one... device is not unconfigured yet. - Device shutdown has taken care of setting the - clean bits if RAIDF_INITED is not set - mark things as clean... */ + /* + * Last one... Device is not unconfigured yet. + * Device shutdown has taken care of setting the + * clean bits if RAIDF_INITED is not set. + * Mark things as clean... + */ db1_printf(("Last one on raid%d. Updating status.\n",unit)); rf_update_component_labels(raidPtrs[unit], RF_FINAL_COMPONENT_UPDATE); @@ -768,8 +757,7 @@ raidclose(dev, flags, fmt, p) } void -raidstrategy(bp) - struct buf *bp; +raidstrategy(struct buf *bp) { int s; @@ -838,10 +826,7 @@ raidstrategy_end: /* ARGSUSED */ int -raidread(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; +raidread(dev_t dev, struct uio *uio, int flags) { int unit = raidunit(dev); struct raid_softc *rs; @@ -862,10 +847,7 @@ raidread(dev, uio, flags) /* ARGSUSED */ int -raidwrite(dev, uio, flags) - dev_t dev; - struct uio *uio; - int flags; +raidwrite(dev_t dev, struct uio *uio, int flags) { int unit = raidunit(dev); struct raid_softc *rs; @@ -881,12 +863,7 @@ raidwrite(dev, uio, flags) } int -raidioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +raidioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { int unit = raidunit(dev); int error = 0; @@ -965,19 +942,19 @@ raidioctl(dev, cmd, data, flag, p) if ((rs->sc_flags & RAIDF_INITED) == 0) return (ENXIO); } - + switch (cmd) { - /* Configure the system */ + /* Configure the system. */ case RAIDFRAME_CONFIGURE: if (raidPtr->valid) { - /* There is a valid RAID set running on this unit! */ + /* There is a valid RAID set running on this unit ! */ printf("raid%d: Device already configured!\n",unit); return(EINVAL); } /* - * Copy-in the configuration information + * Copy-in the configuration information. * data points to a pointer to the configuration structure. */ u_cfg = *((RF_Config_t **)data); @@ -998,7 +975,7 @@ raidioctl(dev, cmd, data, flag, p) */ if (k_cfg->layoutSpecificSize) { if (k_cfg->layoutSpecificSize > 10000) { - /* sanity check */ + /* Sanity check. */ RF_Free(k_cfg, sizeof(RF_Config_t)); return (EINVAL); } @@ -1012,38 +989,40 @@ raidioctl(dev, cmd, data, flag, p) (caddr_t)specific_buf, k_cfg->layoutSpecificSize); if (retcode) { RF_Free(k_cfg, sizeof(RF_Config_t)); - RF_Free(specific_buf, + RF_Free(specific_buf, k_cfg->layoutSpecificSize); return (retcode); } } else specific_buf = NULL; k_cfg->layoutSpecific = specific_buf; - + /* * We should do some kind of sanity check on the * configuration. - * Store the sum of all the bytes in the last byte? + * Store the sum of all the bytes in the last byte ? */ /* * Clear the entire RAID descriptor, just to make sure - * there is no stale data left in the case of a - * reconfiguration + * there is no stale data left in the case of a + * reconfiguration. */ bzero((char *) raidPtr, sizeof(RF_Raid_t)); - /* configure the system */ + /* Configure the system. */ raidPtr->raidid = unit; retcode = rf_Configure(raidPtr, k_cfg, NULL); if (retcode == 0) { - /* allow this many simultaneous IO's to - this RAID device */ + /* + * Allow this many simultaneous IO's to + * this RAID device. + */ raidPtr->openings = RAIDOUTSTANDING; - + raidinit(raidPtr); rf_markalldirty(raidPtr); } @@ -1053,12 +1032,12 @@ raidioctl(dev, cmd, data, flag, p) RF_Free(specific_buf, k_cfg->layoutSpecificSize); } RF_Free(k_cfg, sizeof (RF_Config_t)); - + return (retcode); - + case RAIDFRAME_SHUTDOWN: - /* Shutdown the system */ - + /* Shutdown the system. */ + if ((error = raidlock(rs)) != 0) return (error); @@ -1093,14 +1072,18 @@ raidioctl(dev, cmd, data, flag, p) raidunlock(rs); return (retcode); - + case RAIDFRAME_GET_COMPONENT_LABEL: clabel_ptr = (RF_ComponentLabel_t **) data; - /* need to read the component label for the disk indicated - by row,column in clabel */ + /* + * We need to read the component label for the disk indicated + * by row,column in clabel. + */ - /* For practice, let's get it directly fromdisk, rather - than from the in-core copy */ + /* + * For practice, let's get it directly from disk, rather + * than from the in-core copy. + */ RF_Malloc( clabel, sizeof( RF_ComponentLabel_t ), (RF_ComponentLabel_t *)); if (clabel == NULL) @@ -1108,14 +1091,14 @@ raidioctl(dev, cmd, data, flag, p) bzero((char *) clabel, sizeof(RF_ComponentLabel_t)); - retcode = copyin( *clabel_ptr, clabel, + retcode = copyin( *clabel_ptr, clabel, sizeof(RF_ComponentLabel_t)); if (retcode) { RF_Free( clabel, sizeof(RF_ComponentLabel_t)); return(retcode); } - + row = clabel->row; column = clabel->column; @@ -1124,12 +1107,10 @@ raidioctl(dev, cmd, data, flag, p) return(EINVAL); } - raidread_component_label( - raidPtr->Disks[row][column].dev, - raidPtr->raid_cinfo[row][column].ci_vp, - clabel ); + raidread_component_label(raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, clabel ); - retcode = copyout((caddr_t) clabel, + retcode = copyout((caddr_t) clabel, (caddr_t) *clabel_ptr, sizeof(RF_ComponentLabel_t)); RF_Free( clabel, sizeof(RF_ComponentLabel_t)); @@ -1139,10 +1120,11 @@ raidioctl(dev, cmd, data, flag, p) clabel = (RF_ComponentLabel_t *) data; /* XXX check the label for valid stuff... */ - /* Note that some things *should not* get modified -- - the user should be re-initing the labels instead of - trying to patch things. - */ + /* + * Note that some things *should not* get modified -- + * the user should be re-initing the labels instead of + * trying to patch things. + */ #ifdef RAIDDEBUG printf("Got component label:\n"); @@ -1155,7 +1137,7 @@ raidioctl(dev, cmd, data, flag, p) printf("Num Columns: %d\n", clabel->num_columns); printf("Clean: %d\n", clabel->clean); printf("Status: %d\n", clabel->status); -#endif +#endif /* RAIDDEBUG */ row = clabel->row; column = clabel->column; @@ -1168,24 +1150,22 @@ raidioctl(dev, cmd, data, flag, p) /* XXX this isn't allowed to do anything for now :-) */ #if 0 - raidwrite_component_label( - raidPtr->Disks[row][column].dev, - raidPtr->raid_cinfo[row][column].ci_vp, - clabel ); + raidwrite_component_label(raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, clabel ); #endif return (0); - case RAIDFRAME_INIT_LABELS: + case RAIDFRAME_INIT_LABELS: clabel = (RF_ComponentLabel_t *) data; - /* - we only want the serial number from - the above. We get all the rest of the information - from the config that was used to create this RAID - set. - */ + /* + * We only want the serial number from the above. + * We get all the rest of the information from + * the config that was used to create this RAID + * set. + */ raidPtr->serial_number = clabel->serial_number; - + raid_init_component_label(raidPtr, &ci_label); ci_label.serial_number = clabel->serial_number; @@ -1197,27 +1177,27 @@ raidioctl(dev, cmd, data, flag, p) ci_label.partitionSize = diskPtr->partitionSize; ci_label.column = column; - raidwrite_component_label( - raidPtr->Disks[row][column].dev, - raidPtr->raid_cinfo[row][column].ci_vp, + raidwrite_component_label( + raidPtr->Disks[row][column].dev, + raidPtr->raid_cinfo[row][column].ci_vp, &ci_label ); } } } return (retcode); - + case RAIDFRAME_REWRITEPARITY: if (raidPtr->Layout.map->faultsTolerated == 0) { - /* Parity for RAID 0 is trivially correct */ + /* Parity for RAID 0 is trivially correct. */ raidPtr->parity_good = RF_RAID_CLEAN; return(0); } - + if (raidPtr->parity_rewrite_in_progress == 1) { - /* Re-write is already in progress! */ + /* Re-write is already in progress ! */ return(EINVAL); } @@ -1251,14 +1231,14 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_DELETE_COMPONENT: componentPtr = (RF_SingleComponent_t *)data; - memcpy( &component, componentPtr, + memcpy( &component, componentPtr, sizeof(RF_SingleComponent_t)); retcode = rf_delete_component(raidPtr, &component); return(retcode); case RAIDFRAME_INCORPORATE_HOT_SPARE: componentPtr = (RF_SingleComponent_t *)data; - memcpy( &component, componentPtr, + memcpy( &component, componentPtr, sizeof(RF_SingleComponent_t)); retcode = rf_incorporate_hot_spare(raidPtr, &component); return(retcode); @@ -1266,17 +1246,17 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_REBUILD_IN_PLACE: if (raidPtr->Layout.map->faultsTolerated == 0) { - /* Can't do this on a RAID 0!! */ + /* Can't do this on a RAID 0 !! */ return(EINVAL); } if (raidPtr->recon_in_progress == 1) { - /* a reconstruct is already in progress! */ + /* A reconstruct is already in progress ! */ return(EINVAL); } componentPtr = (RF_SingleComponent_t *) data; - memcpy( &component, componentPtr, + memcpy( &component, componentPtr, sizeof(RF_SingleComponent_t)); row = component.row; column = component.column; @@ -1345,7 +1325,7 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_RESET_ACCTOTALS: bzero(&raidPtr->acc_totals, sizeof(raidPtr->acc_totals)); return (0); - + case RAIDFRAME_GET_ACCTOTALS: totals = (RF_AccTotals_t *) data; *totals = raidPtr->acc_totals; @@ -1354,25 +1334,25 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_KEEP_ACCTOTALS: raidPtr->keep_acc_totals = *(int *)data; return (0); - + case RAIDFRAME_GET_SIZE: *(int *) data = raidPtr->totalSectors; return (0); - /* fail a disk & optionally start reconstruction */ + /* Fail a disk & optionally start reconstruction. */ case RAIDFRAME_FAIL_DISK: rr = (struct rf_recon_req *)data; - + if (rr->row < 0 || rr->row >= raidPtr->numRow || rr->col < 0 || rr->col >= raidPtr->numCol) return (EINVAL); db1_printf(("raid%d: Failing the disk: row: %d col: %d\n", - unit, rr->row, rr->col)); - + unit, rr->row, rr->col)); + /* * Make a copy of the recon request so that we don't - * rely on the user's buffer + * rely on the user's buffer. */ RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *)); if (rrcopy == NULL) @@ -1384,32 +1364,34 @@ raidioctl(dev, cmd, data, flag, p) rf_ReconThread, rrcopy,"raid_recon"); return (0); - + /* * Invoke a copyback operation after recon on whatever * disk needs it, if any. */ - case RAIDFRAME_COPYBACK: + case RAIDFRAME_COPYBACK: if (raidPtr->Layout.map->faultsTolerated == 0) { - /* This makes no sense on a RAID 0!! */ + /* This makes no sense on a RAID 0 !! */ return(EINVAL); } - + if (raidPtr->copyback_in_progress == 1) { - /* Copyback is already in progress! */ + /* Copyback is already in progress ! */ return(EINVAL); } - + retcode = RF_CREATE_THREAD(raidPtr->copyback_thread, rf_CopybackThread, raidPtr,"raid_copyback"); return (retcode); - /* Return the percentage completion of reconstruction */ + /* Return the percentage completion of reconstruction. */ case RAIDFRAME_CHECK_RECON_STATUS: if (raidPtr->Layout.map->faultsTolerated == 0) { - /* This makes no sense on a RAID 0, so tell the - user it's done. */ + /* + * This makes no sense on a RAID 0, so tell the + * user it's done. + */ *(int *) data = 100; return(0); } @@ -1429,9 +1411,9 @@ raidioctl(dev, cmd, data, flag, p) progressInfo.completed = 100; progressInfo.total = 100; } else { - progressInfo.total = + progressInfo.total = raidPtr->reconControl[row]->numRUsTotal; - progressInfo.completed = + progressInfo.completed = raidPtr->reconControl[row]->numRUsComplete; progressInfo.remaining = progressInfo.total - progressInfo.completed; @@ -1443,14 +1425,16 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_CHECK_PARITYREWRITE_STATUS: if (raidPtr->Layout.map->faultsTolerated == 0) { - /* This makes no sense on a RAID 0, so tell the - user it's done. */ + /* + * This makes no sense on a RAID 0, so tell the + * user it's done. + */ *(int *) data = 100; return(0); } if (raidPtr->parity_rewrite_in_progress == 1) { - *(int *) data = 100 * - raidPtr->parity_rewrite_stripes_done / + *(int *) data = 100 * + raidPtr->parity_rewrite_stripes_done / raidPtr->Layout.numStripe; } else { *(int *) data = 100; @@ -1461,7 +1445,7 @@ raidioctl(dev, cmd, data, flag, p) progressInfoPtr = (RF_ProgressInfo_t **) data; if (raidPtr->parity_rewrite_in_progress == 1) { progressInfo.total = raidPtr->Layout.numStripe; - progressInfo.completed = + progressInfo.completed = raidPtr->parity_rewrite_stripes_done; progressInfo.remaining = progressInfo.total - progressInfo.completed; @@ -1477,7 +1461,7 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_CHECK_COPYBACK_STATUS: if (raidPtr->Layout.map->faultsTolerated == 0) { - /* This makes no sense on a RAID 0 */ + /* This makes no sense on a RAID 0 !! */ *(int *) data = 100; return(0); } @@ -1493,7 +1477,7 @@ raidioctl(dev, cmd, data, flag, p) progressInfoPtr = (RF_ProgressInfo_t **) data; if (raidPtr->copyback_in_progress == 1) { progressInfo.total = raidPtr->Layout.numStripe; - progressInfo.completed = + progressInfo.completed = raidPtr->copyback_stripes_done; progressInfo.remaining = progressInfo.total - progressInfo.completed; @@ -1529,12 +1513,12 @@ raidioctl(dev, cmd, data, flag, p) waitreq = rf_sparet_wait_queue; rf_sparet_wait_queue = rf_sparet_wait_queue->next; RF_UNLOCK_MUTEX(rf_sparet_wait_mutex); - + *((RF_SparetWait_t *)data) = *waitreq; - + RF_Free(waitreq, sizeof *waitreq); return (0); - + case RAIDFRAME_ABORT_SPARET_WAIT: /* * Wakes up a process waiting on SPARET_WAIT and puts an @@ -1552,15 +1536,15 @@ raidioctl(dev, cmd, data, flag, p) case RAIDFRAME_SEND_SPARET: /* * Used by the spare table daemon to deliver a spare table - * into the kernel + * into the kernel. */ - - /* Install the spare table */ + + /* Install the spare table. */ retcode = rf_SetSpareTable(raidPtr,*(void **)data); - + /* - * Respond to the requestor. the return status of the - * spare table installation is passed in the "fcol" field + * Respond to the requestor. The return status of the + * spare table installation is passed in the "fcol" field. */ RF_Malloc(waitreq, sizeof *waitreq, (RF_SparetWait_t *)); waitreq->fcol = retcode; @@ -1569,17 +1553,17 @@ raidioctl(dev, cmd, data, flag, p) rf_sparet_resp_queue = waitreq; wakeup(&rf_sparet_resp_queue); RF_UNLOCK_MUTEX(rf_sparet_wait_mutex); - + return (retcode); #endif - /* fall through to the os-specific code below */ + /* Fall through to the os-specific code below. */ default: break; } - + if (!raidPtr->valid) return (EINVAL); - + /* * Add support for "regular" device ioctls here. */ @@ -1633,7 +1617,7 @@ raidioctl(dev, cmd, data, flag, p) case DIOCGPDINFO: raidgetdefaultlabel(raidPtr, rs, (struct disklabel *) data); break; - + default: retcode = ENOTTY; } @@ -1642,35 +1626,34 @@ raidioctl(dev, cmd, data, flag, p) } /* - * raidinit -- complete the rest of the initialization for the + * raidinit -- Complete the rest of the initialization for the * RAIDframe device. */ void -raidinit(raidPtr) - RF_Raid_t *raidPtr; +raidinit(RF_Raid_t *raidPtr) { struct raid_softc *rs; struct cfdata *cf; - int unit; + int unit; unit = raidPtr->raidid; rs = &raid_softc[unit]; pool_init(&rs->sc_cbufpool, sizeof(struct raidbuf), 0, 0, 0, "raidpl", NULL); - + /* XXX should check return code first... */ rs->sc_flags |= RAIDF_INITED; - /* XXX doesn't check bounds.*/ + /* XXX doesn't check bounds. */ sprintf(rs->sc_xname, "raid%d", unit); - rs->sc_dkdev.dk_name = rs->sc_xname; + rs->sc_dkdev.dk_name = rs->sc_xname; /* * disk_attach actually creates space for the CPU disklabel, among - * other things, so it's critical to call this *BEFORE* we - * try putzing with disklabels. + * other things, so it's critical to call this *BEFORE* we try + * putzing with disklabels. */ disk_attach(&rs->sc_dkdev); @@ -1699,18 +1682,17 @@ raidinit(raidPtr) } /* - * Wake up the daemon & tell it to get us a spare table + * Wake up the daemon & tell it to get us a spare table. * XXX - * The entries in the queues should be tagged with the raidPtr so that in the - * extremely rare case that two recons happen at once, we know for - * which device were requesting a spare table. + * The entries in the queues should be tagged with the raidPtr so that + * in the extremely rare case that two recons happen at once, we know + * which devices were requesting a spare table. * XXX - * + * * XXX This code is not currently used. GO */ int -rf_GetSpareTableFromDaemon(req) - RF_SparetWait_t *req; +rf_GetSpareTableFromDaemon(RF_SparetWait_t *req) { int retcode; @@ -1719,39 +1701,38 @@ rf_GetSpareTableFromDaemon(req) rf_sparet_wait_queue = req; wakeup(&rf_sparet_wait_queue); - /* mpsleep unlocks the mutex */ + /* mpsleep unlocks the mutex. */ while (!rf_sparet_resp_queue) { tsleep(&rf_sparet_resp_queue, PRIBIO, - "raidframe getsparetable", 0); + "RAIDframe getsparetable", 0); } req = rf_sparet_resp_queue; rf_sparet_resp_queue = req->next; RF_UNLOCK_MUTEX(rf_sparet_wait_mutex); retcode = req->fcol; - /* this is not the same req as we alloc'd */ + /* This is not the same req as we alloc'd. */ RF_Free(req, sizeof *req); return (retcode); } /* * A wrapper around rf_DoAccess that extracts appropriate info from the - * bp & passes it down. - * Any calls originating in the kernel must use non-blocking I/O - * do some extra sanity checking to return "appropriate" error values for - * certain conditions (to make some standard utilities work) - * + * bp and passes it down. + * Any calls originating in the kernel must use non-blocking I/O. + * Do some extra sanity checking to return "appropriate" error values for + * certain conditions (to make some standard utilities work). + * * Formerly known as: rf_DoAccessKernel */ void -raidstart(raidPtr) - RF_Raid_t *raidPtr; +raidstart(RF_Raid_t *raidPtr) { RF_SectorCount_t num_blocks, pb, sum; RF_RaidAddr_t raid_addr; int retcode; struct partition *pp; - daddr_t blocknum; + daddr_t blocknum; int unit; struct raid_softc *rs; int do_async; @@ -1760,10 +1741,10 @@ raidstart(raidPtr) unit = raidPtr->raidid; rs = &raid_softc[unit]; - /* quick check to see if anything has died recently */ + /* Quick check to see if anything has died recently. */ RF_LOCK_MUTEX(raidPtr->mutex); if (raidPtr->numNewFailures > 0) { - rf_update_component_labels(raidPtr, + rf_update_component_labels(raidPtr, RF_NORMAL_COMPONENT_UPDATE); raidPtr->numNewFailures--; } @@ -1773,41 +1754,45 @@ raidstart(raidPtr) RF_LOCK_MUTEX(raidPtr->mutex); while (raidPtr->openings > 0) { RF_UNLOCK_MUTEX(raidPtr->mutex); - + bp = rs->sc_q.b_actf; if (bp == NULL) { - /* nothing more to do */ + /* Nothing more to do. */ return; } rs->sc_q.b_actf = bp->b_actf; - /* Ok, for the bp we have here, bp->b_blkno is relative to the - * partition.. Need to make it absolute to the underlying - * device.. */ - + /* + * Ok, for the bp we have here, bp->b_blkno is relative to the + * partition... We need to make it absolute to the underlying + * device... + */ + blocknum = bp->b_blkno; if (DISKPART(bp->b_dev) != RAW_PART) { pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]; blocknum += pp->p_offset; } - - db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno, + + db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno, (int) blocknum)); - + db1_printf(("bp->b_bcount = %d\n", (int) bp->b_bcount)); db1_printf(("bp->b_resid = %d\n", (int) bp->b_resid)); - - /* *THIS* is where we adjust what block we're going to... - * but DO NOT TOUCH bp->b_blkno!!! */ + + /* + * *THIS* is where we adjust what block we're going to... + * But DO NOT TOUCH bp->b_blkno !!! + */ raid_addr = blocknum; - + num_blocks = bp->b_bcount >> raidPtr->logBytesPerSector; pb = (bp->b_bcount & raidPtr->sectorMask) ? 1 : 0; sum = raid_addr + num_blocks + pb; if (1 || rf_debugKernelAccess) { - db1_printf(("raid_addr=%d sum=%d num_blocks=%d(+%d) (%d)\n", - (int) raid_addr, (int) sum, (int) num_blocks, - (int) pb, (int) bp->b_resid)); + db1_printf(("raid_addr=%d sum=%d num_blocks=%d(+%d)" + " (%d)\n", (int)raid_addr, (int)sum, + (int)num_blocks, (int)pb, (int)bp->b_resid)); } if ((sum > raidPtr->totalSectors) || (sum < raid_addr) || (sum < num_blocks) || (sum < pb)) { @@ -1815,31 +1800,31 @@ raidstart(raidPtr) bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; /* db1_printf(("%s: Calling biodone on 0x%x\n", - __func__, bp)); */ + __func__, bp)); */ splassert(IPL_BIO); biodone(bp); RF_LOCK_MUTEX(raidPtr->mutex); continue; } /* - * XXX rf_DoAccess() should do this, not just DoAccessKernel() + * XXX rf_DoAccess() should do this, not just DoAccessKernel(). */ - + if (bp->b_bcount & raidPtr->sectorMask) { bp->b_error = EINVAL; bp->b_flags |= B_ERROR; bp->b_resid = bp->b_bcount; /* db1_printf(("%s: Calling biodone on 0x%x\n", - __func__, bp)); */ + __func__, bp)); */ splassert(IPL_BIO); biodone(bp); RF_LOCK_MUTEX(raidPtr->mutex); continue; - + } db1_printf(("Calling DoAccess..\n")); - - + + RF_LOCK_MUTEX(raidPtr->mutex); raidPtr->openings--; RF_UNLOCK_MUTEX(raidPtr->mutex); @@ -1848,19 +1833,23 @@ raidstart(raidPtr) * Everything is async. */ do_async = 1; - + disk_busy(&rs->sc_dkdev); - - /* XXX we're still at splbio() here... do we *really* - * need to be? */ - /* don't ever condition on bp->b_flags & B_WRITE. - * always condition on B_READ instead */ + /* + * XXX we're still at splbio() here... Do we *really* + * need to be ? + */ + + /* + * Don't ever condition on bp->b_flags & B_WRITE. + * Always condition on B_READ instead. + */ retcode = rf_DoAccess(raidPtr, (bp->b_flags & B_READ) ? RF_IO_TYPE_READ : RF_IO_TYPE_WRITE, do_async, raid_addr, num_blocks, - bp->b_data, bp, NULL, NULL, + bp->b_data, bp, NULL, NULL, RF_DAG_NONBLOCKING_IO, NULL, NULL, NULL); RF_LOCK_MUTEX(raidPtr->mutex); @@ -1868,29 +1857,24 @@ raidstart(raidPtr) RF_UNLOCK_MUTEX(raidPtr->mutex); } -/* Invoke an I/O from kernel mode. Disk queue should be locked upon entry */ +/* Invoke an I/O from kernel mode. Disk queue should be locked upon entry. */ int -rf_DispatchKernelIO(queue, req) - RF_DiskQueue_t *queue; - RF_DiskQueueData_t *req; +rf_DispatchKernelIO(RF_DiskQueue_t *queue, RF_DiskQueueData_t *req) { int op = (req->type == RF_IO_TYPE_READ) ? B_READ : B_WRITE; struct buf *bp; struct raidbuf *raidbp = NULL; struct raid_softc *rs; int unit; - int s; - - s=0; - /* s = splbio();*/ /* want to test this */ - + /*int s = splbio();*/ /* Want to test this. */ + /* * XXX along with the vnode, we also need the softc associated with - * this device.. + * this device... */ req->queue = queue; - + unit = queue->raidPtr->raidid; db1_printf(("DispatchKernelIO unit: %d\n", unit)); @@ -1907,10 +1891,10 @@ rf_DispatchKernelIO(queue, req) #if 1 /* * XXX When there is a physical disk failure, someone is passing - * us a buffer that contains old stuff!! Attempt to deal with + * us a buffer that contains old stuff !! Attempt to deal with * this problem without taking a performance hit... - * (not sure where the real bug is. It's buried in RAIDframe - * somewhere) :-( GO ) + * (not sure where the real bug is; it's buried in RAIDframe + * somewhere) :-( GO ) */ if (bp->b_flags & B_ERROR) { bp->b_flags &= ~B_ERROR; @@ -1922,10 +1906,10 @@ rf_DispatchKernelIO(queue, req) raidbp = RAIDGETBUF(rs); - raidbp->rf_flags = 0; /* XXX not really used anywhere... */ + raidbp->rf_flags = 0; /* XXX not really used anywhere... */ /* - * context for raidiodone + * Context for raidiodone. */ raidbp->rf_obp = bp; raidbp->req = req; @@ -1939,7 +1923,7 @@ rf_DispatchKernelIO(queue, req) db1_printf(("rf_DispatchKernelIO: NOP to r %d c %d\n", queue->row, queue->col)); - /* XXX need to do something extra here.. */ + /* XXX need to do something extra here... */ /* * I'm leaving this in, as I've never actually seen it @@ -1948,11 +1932,11 @@ rf_DispatchKernelIO(queue, req) db1_printf(("WAKEUP CALLED\n")); queue->numOutstanding++; - /* XXX need to glue the original buffer into this?? */ + /* XXX need to glue the original buffer into this ?? */ rf_KernelWakeupFunc(&raidbp->rf_buf); break; - + case RF_IO_TYPE_READ: case RF_IO_TYPE_WRITE: if (req->tracerec) { @@ -1962,7 +1946,7 @@ rf_DispatchKernelIO(queue, req) rf_InitBP(&raidbp->rf_buf, queue->rf_cinfo->ci_vp, op | bp->b_flags, queue->rf_cinfo->ci_dev, req->sectorOffset, req->numSector, - req->buf, rf_KernelWakeupFunc, (void *)req, + req->buf, rf_KernelWakeupFunc, (void *)req, queue->raidPtr->logBytesPerSector, req->b_proc); if (rf_debugKernelAccess) { @@ -1990,12 +1974,12 @@ rf_DispatchKernelIO(queue, req) VOP_STRATEGY(&raidbp->rf_buf); break; - + default: panic("bad req->type in rf_DispatchKernelIO"); } db1_printf(("Exiting from DispatchKernelIO\n")); - /* splx(s); */ /* want to test this */ + /*splx(s);*/ /* want to test this */ return (0); } @@ -2004,8 +1988,7 @@ rf_DispatchKernelIO(queue, req) * kernel code. */ void -rf_KernelWakeupFunc(vbp) - struct buf *vbp; +rf_KernelWakeupFunc(struct buf *vbp) { RF_DiskQueueData_t *req = NULL; RF_DiskQueue_t *queue; @@ -2046,12 +2029,12 @@ rf_KernelWakeupFunc(vbp) RF_UNLOCK_MUTEX(rf_tracing_mutex); } - bp->b_bcount = raidbp->rf_buf.b_bcount;/* XXXX ?? */ + bp->b_bcount = raidbp->rf_buf.b_bcount; /* XXXX ?? */ - unit = queue->raidPtr->raidid; /* *Much* simpler :-> */ + unit = queue->raidPtr->raidid; /* *Much* simpler :-> */ /* - * XXX Ok, let's get aggressive... If B_ERROR is set, let's go + * XXX Ok, let's get aggressive... If B_ERROR is set, let's go * ballistic, and mark the component as hosed... */ if (bp->b_flags & B_ERROR) { @@ -2086,29 +2069,29 @@ rf_KernelWakeupFunc(vbp) * Initialize a buf structure for doing an I/O in the kernel. */ void -rf_InitBP(bp, b_vp, rw_flag, dev, startSect, numSect, buf, cbFunc, cbArg, - logBytesPerSector, b_proc) - struct buf *bp; - struct vnode *b_vp; - unsigned rw_flag; - dev_t dev; - RF_SectorNum_t startSect; - RF_SectorCount_t numSect; - caddr_t buf; - void (*cbFunc)(struct buf *); - void *cbArg; - int logBytesPerSector; - struct proc *b_proc; +rf_InitBP( + struct buf *bp, + struct vnode *b_vp, + unsigned rw_flag, + dev_t dev, + RF_SectorNum_t startSect, + RF_SectorCount_t numSect, + caddr_t buf, + void (*cbFunc)(struct buf *), + void *cbArg, + int logBytesPerSector, + struct proc *b_proc +) { - /* bp->b_flags = B_PHYS | rw_flag; */ - bp->b_flags = B_CALL | rw_flag; /* XXX need B_PHYS here too??? */ + /*bp->b_flags = B_PHYS | rw_flag;*/ + bp->b_flags = B_CALL | rw_flag; /* XXX need B_PHYS here too ??? */ bp->b_bcount = numSect << logBytesPerSector; bp->b_bufsize = bp->b_bcount; bp->b_error = 0; bp->b_dev = dev; bp->b_data = buf; bp->b_blkno = startSect; - bp->b_resid = bp->b_bcount; /* XXX is this right!??!?!! */ + bp->b_resid = bp->b_bcount; /* XXX is this right !??!?!! */ if (bp->b_bcount == 0) { panic("bp->b_bcount is zero in rf_InitBP!!"); } @@ -2119,21 +2102,19 @@ rf_InitBP(bp, b_vp, rw_flag, dev, startSect, numSect, buf, cbFunc, cbArg, } void -raidgetdefaultlabel(raidPtr, rs, lp) - RF_Raid_t *raidPtr; - struct raid_softc *rs; - struct disklabel *lp; +raidgetdefaultlabel(RF_Raid_t *raidPtr, struct raid_softc *rs, + struct disklabel *lp) { db1_printf(("Building a default label...\n")); bzero(lp, sizeof(*lp)); - /* fabricate a label... */ + /* Fabricate a label... */ lp->d_secperunit = raidPtr->totalSectors; lp->d_secsize = raidPtr->bytesPerSector; lp->d_nsectors = raidPtr->Layout.dataSectorsPerStripe; lp->d_ntracks = 4 * raidPtr->numCol; - lp->d_ncylinders = raidPtr->totalSectors / - (lp->d_nsectors * lp->d_ntracks); + lp->d_ncylinders = raidPtr->totalSectors / + (lp->d_nsectors * lp->d_ntracks); lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors; strncpy(lp->d_typename, "raid", sizeof(lp->d_typename)); @@ -2154,12 +2135,11 @@ raidgetdefaultlabel(raidPtr, rs, lp) } /* - * Read the disklabel from the raid device. If one is not present, fake one - * up. + * Read the disklabel from the raid device. + * If one is not present, fake one up. */ void -raidgetdisklabel(dev) - dev_t dev; +raidgetdisklabel(dev_t dev) { int unit = raidunit(dev); struct raid_softc *rs = &raid_softc[unit]; @@ -2186,7 +2166,7 @@ raidgetdisklabel(dev) if (errstring) { printf("%s: %s\n", rs->sc_xname, errstring); return; - /*raidmakedisklabel(rs); */ + /*raidmakedisklabel(rs);*/ } /* @@ -2218,8 +2198,7 @@ raidgetdisklabel(dev) * that a disklabel isn't present. */ void -raidmakedisklabel(rs) - struct raid_softc *rs; +raidmakedisklabel(struct raid_softc *rs) { struct disklabel *lp = rs->sc_dkdev.dk_label; db1_printf(("Making a label..\n")); @@ -2243,10 +2222,11 @@ raidmakedisklabel(rs) * You'll find the original of this in ccd.c */ int -raidlookup(path, p, vpp) - char *path; - struct proc *p; - struct vnode **vpp; /* result */ +raidlookup( + char *path, + struct proc *p, + struct vnode **vpp /* result */ +) { struct nameidata nd; struct vnode *vp; @@ -2290,8 +2270,7 @@ raidlookup(path, p, vpp) * (Hmm... where have we seen this warning before :-> GO ) */ int -raidlock(rs) - struct raid_softc *rs; +raidlock(struct raid_softc *rs) { int error; @@ -2308,8 +2287,7 @@ raidlock(rs) * Unlock and wake up any waiters. */ void -raidunlock(rs) - struct raid_softc *rs; +raidunlock(struct raid_softc *rs) { rs->sc_flags &= ~RAIDF_LOCKED; if ((rs->sc_flags & RAIDF_WANTED) != 0) { @@ -2317,12 +2295,12 @@ raidunlock(rs) wakeup(rs); } } - -#define RF_COMPONENT_INFO_OFFSET 16384 /* bytes */ -#define RF_COMPONENT_INFO_SIZE 1024 /* bytes */ -int +#define RF_COMPONENT_INFO_OFFSET 16384 /* bytes */ +#define RF_COMPONENT_INFO_SIZE 1024 /* bytes */ + +int raidmarkclean(dev_t dev, struct vnode *b_vp, int mod_counter) { RF_ComponentLabel_t clabel; @@ -2334,7 +2312,7 @@ raidmarkclean(dev_t dev, struct vnode *b_vp, int mod_counter) } -int +int raidmarkdirty(dev_t dev, struct vnode *b_vp, int mod_counter) { RF_ComponentLabel_t clabel; @@ -2347,28 +2325,30 @@ raidmarkdirty(dev_t dev, struct vnode *b_vp, int mod_counter) /* ARGSUSED */ int -raidread_component_label(dev, b_vp, clabel) - dev_t dev; - struct vnode *b_vp; - RF_ComponentLabel_t *clabel; +raidread_component_label(dev_t dev, struct vnode *b_vp, + RF_ComponentLabel_t *clabel) { struct buf *bp; int error; - - /* XXX should probably ensure that we don't try to do this if - someone has changed rf_protected_sectors. */ + + /* + * XXX should probably ensure that we don't try to do this if + * someone has changed rf_protected_sectors. + */ if (b_vp == NULL) { - /* For whatever reason, this component is not valid. - Don't try to read a component label from it. */ + /* + * For whatever reason, this component is not valid. + * Don't try to read a component label from it. + */ return(EINVAL); } - /* get a block of the appropriate size... */ + /* Get a block of the appropriate size... */ bp = geteblk((int)RF_COMPONENT_INFO_SIZE); bp->b_dev = dev; - /* get our ducks in a row for the read */ + /* Get our ducks in a row for the read. */ bp->b_blkno = RF_COMPONENT_INFO_OFFSET / DEV_BSIZE; bp->b_bcount = RF_COMPONENT_INFO_SIZE; bp->b_flags |= B_READ; @@ -2376,37 +2356,34 @@ raidread_component_label(dev, b_vp, clabel) (*bdevsw[major(bp->b_dev)].d_strategy)(bp); - error = biowait(bp); + error = biowait(bp); if (!error) { - memcpy(clabel, bp->b_data, - sizeof(RF_ComponentLabel_t)); + memcpy(clabel, bp->b_data, sizeof(RF_ComponentLabel_t)); #if 0 rf_print_component_label( clabel ); #endif - } else { + } else { db1_printf(("Failed to read RAID component label!\n")); } - brelse(bp); + brelse(bp); return(error); } /* ARGSUSED */ -int -raidwrite_component_label(dev, b_vp, clabel) - dev_t dev; - struct vnode *b_vp; - RF_ComponentLabel_t *clabel; +int +raidwrite_component_label(dev_t dev, struct vnode *b_vp, + RF_ComponentLabel_t *clabel) { struct buf *bp; int error; - /* get a block of the appropriate size... */ + /* Get a block of the appropriate size... */ bp = geteblk((int)RF_COMPONENT_INFO_SIZE); bp->b_dev = dev; - /* get our ducks in a row for the write */ + /* Get our ducks in a row for the write. */ bp->b_blkno = RF_COMPONENT_INFO_OFFSET / DEV_BSIZE; bp->b_bcount = RF_COMPONENT_INFO_SIZE; bp->b_flags |= B_WRITE; @@ -2417,7 +2394,7 @@ raidwrite_component_label(dev, b_vp, clabel) memcpy(bp->b_data, clabel, sizeof(RF_ComponentLabel_t)); (*bdevsw[major(bp->b_dev)].d_strategy)(bp); - error = biowait(bp); + error = biowait(bp); brelse(bp); if (error) { printf("Failed to write RAID component info!\n"); @@ -2426,9 +2403,8 @@ raidwrite_component_label(dev, b_vp, clabel) return(error); } -void -rf_markalldirty(raidPtr) - RF_Raid_t *raidPtr; +void +rf_markalldirty(RF_Raid_t *raidPtr) { RF_ComponentLabel_t clabel; int r,c; @@ -2436,57 +2412,56 @@ rf_markalldirty(raidPtr) raidPtr->mod_counter++; for (r = 0; r < raidPtr->numRow; r++) { for (c = 0; c < raidPtr->numCol; c++) { - /* we don't want to touch (at all) a disk that has - failed */ + /* + * We don't want to touch (at all) a disk that has + * failed. + */ if (!RF_DEAD_DISK(raidPtr->Disks[r][c].status)) { raidread_component_label( - raidPtr->Disks[r][c].dev, - raidPtr->raid_cinfo[r][c].ci_vp, - &clabel); + raidPtr->Disks[r][c].dev, + raidPtr->raid_cinfo[r][c].ci_vp, &clabel); if (clabel.status == rf_ds_spared) { - /* XXX do something special... - but whatever you do, don't - try to access it!! */ + /* + * XXX do something special... + * But whatever you do, don't + * try to access it !!! + */ } else { #if 0 - clabel.status = - raidPtr->Disks[r][c].status; - raidwrite_component_label( - raidPtr->Disks[r][c].dev, - raidPtr->raid_cinfo[r][c].ci_vp, - &clabel); + clabel.status = + raidPtr->Disks[r][c].status; + raidwrite_component_label( + raidPtr->Disks[r][c].dev, + raidPtr->raid_cinfo[r][c].ci_vp, + &clabel); #endif - raidmarkdirty( - raidPtr->Disks[r][c].dev, - raidPtr->raid_cinfo[r][c].ci_vp, - raidPtr->mod_counter); + raidmarkdirty( + raidPtr->Disks[r][c].dev, + raidPtr->raid_cinfo[r][c].ci_vp, + raidPtr->mod_counter); } } - } + } } - /* printf("Component labels marked dirty.\n"); */ + /*printf("Component labels marked dirty.\n");*/ #if 0 for( c = 0; c < raidPtr->numSpare ; c++) { sparecol = raidPtr->numCol + c; if (raidPtr->Disks[r][sparecol].status == rf_ds_used_spare) { - /* - - XXX this is where we get fancy and map this spare - into it's correct spot in the array. - + /* + * XXX This is where we get fancy and map this spare + * into it's correct spot in the array. */ - /* - - we claim this disk is "optimal" if it's - rf_ds_used_spare, as that means it should be - directly substitutable for the disk it replaced. - We note that too... - + /* + * We claim this disk is "optimal" if it's + * rf_ds_used_spare, as that means it should be + * directly substitutable for the disk it replaced. + * We note that too... */ for(i=0;i<raidPtr->numRow;i++) { for(j=0;j<raidPtr->numCol;j++) { - if ((raidPtr->Disks[i][j].spareRow == + if ((raidPtr->Disks[i][j].spareRow == r) && (raidPtr->Disks[i][j].spareCol == sparecol)) { @@ -2496,27 +2471,25 @@ rf_markalldirty(raidPtr) } } } - - raidread_component_label( - raidPtr->Disks[r][sparecol].dev, - raidPtr->raid_cinfo[r][sparecol].ci_vp, - &clabel); - /* make sure status is noted */ - clabel.version = RF_COMPONENT_LABEL_VERSION; + + raidread_component_label( + raidPtr->Disks[r][sparecol].dev, + raidPtr->raid_cinfo[r][sparecol].ci_vp, &clabel); + /* Make sure status is noted. */ + clabel.version = RF_COMPONENT_LABEL_VERSION; clabel.mod_counter = raidPtr->mod_counter; clabel.serial_number = raidPtr->serial_number; clabel.row = srow; clabel.column = scol; clabel.num_rows = raidPtr->numRow; clabel.num_columns = raidPtr->numCol; - clabel.clean = RF_RAID_DIRTY; /* changed in a bit*/ + clabel.clean = RF_RAID_DIRTY; /* Changed in a bit. */ clabel.status = rf_ds_optimal; raidwrite_component_label( - raidPtr->Disks[r][sparecol].dev, - raidPtr->raid_cinfo[r][sparecol].ci_vp, - &clabel); - raidmarkclean( raidPtr->Disks[r][sparecol].dev, - raidPtr->raid_cinfo[r][sparecol].ci_vp); + raidPtr->Disks[r][sparecol].dev, + raidPtr->raid_cinfo[r][sparecol].ci_vp, &clabel); + raidmarkclean( raidPtr->Disks[r][sparecol].dev, + raidPtr->raid_cinfo[r][sparecol].ci_vp); } } @@ -2525,9 +2498,7 @@ rf_markalldirty(raidPtr) void -rf_update_component_labels(raidPtr, final) - RF_Raid_t *raidPtr; - int final; +rf_update_component_labels(RF_Raid_t *raidPtr, int final) { RF_ComponentLabel_t clabel; int sparecol; @@ -2538,8 +2509,10 @@ rf_update_component_labels(raidPtr, final) srow = -1; scol = -1; - /* XXX should do extra checks to make sure things really are clean, - rather than blindly setting the clean bit... */ + /* + * XXX should do extra checks to make sure things really are clean, + * rather than blindly setting the clean bit... + */ raidPtr->mod_counter++; @@ -2550,43 +2523,43 @@ rf_update_component_labels(raidPtr, final) raidPtr->Disks[r][c].dev, raidPtr->raid_cinfo[r][c].ci_vp, &clabel); - /* make sure status is noted */ + /* Make sure status is noted. */ clabel.status = rf_ds_optimal; - /* bump the counter */ + /* Bump the counter. */ clabel.mod_counter = raidPtr->mod_counter; - raidwrite_component_label( + raidwrite_component_label( raidPtr->Disks[r][c].dev, raidPtr->raid_cinfo[r][c].ci_vp, &clabel); if (final == RF_FINAL_COMPONENT_UPDATE) { - if (raidPtr->parity_good == RF_RAID_CLEAN) { - raidmarkclean( - raidPtr->Disks[r][c].dev, - raidPtr->raid_cinfo[r][c].ci_vp, - raidPtr->mod_counter); + if (raidPtr->parity_good == + RF_RAID_CLEAN) { + raidmarkclean( + raidPtr->Disks[r][c].dev, + raidPtr-> + raid_cinfo[r][c].ci_vp, + raidPtr->mod_counter); } } - } - /* else we don't touch it.. */ - } + } + /* Else we don't touch it... */ + } } for( c = 0; c < raidPtr->numSpare ; c++) { sparecol = raidPtr->numCol + c; if (raidPtr->Disks[0][sparecol].status == rf_ds_used_spare) { - /* - - we claim this disk is "optimal" if it's - rf_ds_used_spare, as that means it should be - directly substitutable for the disk it replaced. - We note that too... - + /* + * We claim this disk is "optimal" if it's + * rf_ds_used_spare, as that means it should be + * directly substitutable for the disk it replaced. + * We note that too... */ for(i=0;i<raidPtr->numRow;i++) { for(j=0;j<raidPtr->numCol;j++) { - if ((raidPtr->Disks[i][j].spareRow == + if ((raidPtr->Disks[i][j].spareRow == 0) && (raidPtr->Disks[i][j].spareCol == sparecol)) { @@ -2596,13 +2569,12 @@ rf_update_component_labels(raidPtr, final) } } } - - /* XXX shouldn't *really* need this... */ - raidread_component_label( - raidPtr->Disks[0][sparecol].dev, - raidPtr->raid_cinfo[0][sparecol].ci_vp, - &clabel); - /* make sure status is noted */ + + /* XXX Shouldn't *really* need this... */ + raidread_component_label( + raidPtr->Disks[0][sparecol].dev, + raidPtr->raid_cinfo[0][sparecol].ci_vp, &clabel); + /* Make sure status is noted. */ raid_init_component_label(raidPtr, &clabel); @@ -2612,26 +2584,24 @@ rf_update_component_labels(raidPtr, final) clabel.status = rf_ds_optimal; raidwrite_component_label( - raidPtr->Disks[0][sparecol].dev, - raidPtr->raid_cinfo[0][sparecol].ci_vp, - &clabel); + raidPtr->Disks[0][sparecol].dev, + raidPtr->raid_cinfo[0][sparecol].ci_vp, &clabel); if (final == RF_FINAL_COMPONENT_UPDATE) { if (raidPtr->parity_good == RF_RAID_CLEAN) { - raidmarkclean( raidPtr->Disks[0][sparecol].dev, - raidPtr->raid_cinfo[0][sparecol].ci_vp, - raidPtr->mod_counter); + raidmarkclean(raidPtr-> + Disks[0][sparecol].dev, + raidPtr-> + raid_cinfo[0][sparecol].ci_vp, + raidPtr->mod_counter); } } } } - /* printf("Component labels updated\n"); */ + /*printf("Component labels updated\n");*/ } void -rf_close_component(raidPtr, vp, auto_configured) - RF_Raid_t *raidPtr; - struct vnode *vp; - int auto_configured; +rf_close_component(RF_Raid_t *raidPtr, struct vnode *vp, int auto_configured) { struct proc *p; @@ -2642,8 +2612,8 @@ rf_close_component(raidPtr, vp, auto_configured) if (auto_configured == 1) { VOP_CLOSE(vp, FREAD | FWRITE, NOCRED, 0); vrele(vp); - - } else { + + } else { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); } @@ -2654,15 +2624,14 @@ rf_close_component(raidPtr, vp, auto_configured) void -rf_UnconfigureVnodes(raidPtr) - RF_Raid_t *raidPtr; +rf_UnconfigureVnodes(RF_Raid_t *raidPtr) { - int r,c; + int r,c; struct vnode *vp; int acd; - /* We take this opportunity to close the vnodes like we should.. */ + /* We take this opportunity to close the vnodes like we should... */ for (r = 0; r < raidPtr->numRow; r++) { for (c = 0; c < raidPtr->numCol; c++) { @@ -2686,11 +2655,10 @@ rf_UnconfigureVnodes(raidPtr) } -void -rf_ReconThread(req) - struct rf_recon_req *req; +void +rf_ReconThread(struct rf_recon_req *req) { - int s; + int s; RF_Raid_t *raidPtr; s = splbio(); @@ -2700,19 +2668,18 @@ rf_ReconThread(req) rf_FailDisk((RF_Raid_t *) req->raidPtr, req->row, req->col, ((req->flags & RF_FDFLAGS_RECON) ? 1 : 0)); - /* XXX get rid of this! we don't need it at all.. */ + /* XXX Get rid of this! we don't need it at all... */ RF_Free(req, sizeof(*req)); raidPtr->recon_in_progress = 0; splx(s); /* That's all... */ - kthread_exit(0); /* does not return */ + kthread_exit(0); /* Does not return. */ } void -rf_RewriteParityThread(raidPtr) - RF_Raid_t *raidPtr; +rf_RewriteParityThread(RF_Raid_t *raidPtr) { int retcode; int s; @@ -2723,27 +2690,28 @@ rf_RewriteParityThread(raidPtr) if (retcode) { printf("raid%d: Error re-writing parity!\n",raidPtr->raidid); } else { - /* set the clean bit! If we shutdown correctly, - the clean bit on each component label will get - set */ + /* + * Set the clean bit ! If we shutdown correctly, + * the clean bit on each component label will get + * set. + */ raidPtr->parity_good = RF_RAID_CLEAN; } raidPtr->parity_rewrite_in_progress = 0; splx(s); - /* Anyone waiting for us to stop? If so, inform them... */ + /* Anyone waiting for us to stop ? If so, inform them... */ if (raidPtr->waitShutdown) { wakeup(&raidPtr->parity_rewrite_in_progress); } /* That's all... */ - kthread_exit(0); /* does not return */ + kthread_exit(0); /* Does not return. */ } void -rf_CopybackThread(raidPtr) - RF_Raid_t *raidPtr; +rf_CopybackThread(RF_Raid_t *raidPtr) { int s; @@ -2754,18 +2722,17 @@ rf_CopybackThread(raidPtr) splx(s); /* That's all... */ - kthread_exit(0); /* does not return */ + kthread_exit(0); /* Does not return. */ } void -rf_ReconstructInPlaceThread(req) - struct rf_recon_req *req; +rf_ReconstructInPlaceThread(struct rf_recon_req *req) { int retcode; int s; RF_Raid_t *raidPtr; - + s = splbio(); raidPtr = req->raidPtr; raidPtr->recon_in_progress = 1; @@ -2775,14 +2742,14 @@ rf_ReconstructInPlaceThread(req) splx(s); /* That's all... */ - kthread_exit(0); /* does not return */ + kthread_exit(0); /* Does not return. */ } RF_AutoConfig_t * -rf_find_raid_components() +rf_find_raid_components(void) { -#ifdef RAID_AUTOCONFIG +#ifdef RAID_AUTOCONFIG int major; struct vnode *vp; struct disklabel label; @@ -2793,32 +2760,34 @@ rf_find_raid_components() int good_one; RF_ComponentLabel_t *clabel; RF_AutoConfig_t *ac; -#endif +#endif /* RAID_AUTOCONFIG */ RF_AutoConfig_t *ac_list; - /* initialize the AutoConfig list */ + /* Initialize the AutoConfig list. */ ac_list = NULL; -#ifdef RAID_AUTOCONFIG - /* we begin by trolling through *all* the devices on the system */ +#ifdef RAID_AUTOCONFIG + /* We begin by trolling through *all* the devices on the system. */ - for (dv = alldevs.tqh_first; dv != NULL; - dv = dv->dv_list.tqe_next) { + for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) { - /* we are only interested in disks... */ + /* We are only interested in disks... */ if (dv->dv_class != DV_DISK) continue; - /* we don't care about floppies... */ + /* We don't care about floppies... */ if (!strcmp(dv->dv_cfdata->cf_driver->cd_name,"fd")) { continue; } - - /* need to find the device_name_to_block_device_major stuff */ + + /* + * We need to find the device_name_to_block_device_major + * stuff. + */ major = findblkmajor(dv); - /* get a vnode for the raw partition of this disk */ + /* Get a vnode for the raw partition of this disk. */ dev = MAKEDISKDEV(major, dv->dv_unit, RAW_PART); if (bdevvp(dev, &vp)) @@ -2827,34 +2796,40 @@ rf_find_raid_components() error = VOP_OPEN(vp, FREAD, NOCRED, 0); if (error) { - /* "Who cares." Continue looking - for something that exists*/ + /* + * "Who cares." Continue looking + * for something that exists. + */ vput(vp); continue; } /* Ok, the disk exists. Go get the disklabel. */ - error = VOP_IOCTL(vp, DIOCGDINFO, (caddr_t)&label, + error = VOP_IOCTL(vp, DIOCGDINFO, (caddr_t)&label, FREAD, NOCRED, 0); if (error) { /* * XXX can't happen - open() would - * have errored out (or faked up one) + * have errored out (or faked up one). */ printf("can't get label for dev %s%c (%d)!?!?\n", - dv->dv_xname, 'a' + RAW_PART, error); + dv->dv_xname, 'a' + RAW_PART, error); } - /* don't need this any more. We'll allocate it again - a little later if we really do... */ + /* + * We don't need this any more. We'll allocate it again + * a little later if we really do... + */ VOP_CLOSE(vp, FREAD | FWRITE, NOCRED, 0); vrele(vp); for (i=0; i < label.d_npartitions; i++) { - /* We only support partitions marked as RAID. */ - /* Aside on sparc/sparc64 where FS_RAID doesn't */ - /* fit in the SUN disklabel and we need to look */ - /* into each and every partition !!! */ + /* + * We only support partitions marked as RAID. + * Except on sparc/sparc64 where FS_RAID doesn't + * fit in the SUN disklabel and we need to look + * into each and every partition !!! + */ #if !defined(__sparc__) && !defined(__sparc64__) && !defined(__sun3__) if (label.d_partitions[i].p_fstype != FS_RAID) continue; @@ -2877,37 +2852,38 @@ rf_find_raid_components() good_one = 0; - clabel = (RF_ComponentLabel_t *) - malloc(sizeof(RF_ComponentLabel_t), - M_RAIDFRAME, M_NOWAIT); + clabel = (RF_ComponentLabel_t *) + malloc(sizeof(RF_ComponentLabel_t), M_RAIDFRAME, + M_NOWAIT); if (clabel == NULL) { - /* XXX CLEANUP HERE */ + /* XXX CLEANUP HERE. */ printf("RAID auto config: out of memory!\n"); - return(NULL); /* XXX probably should panic? */ + return(NULL); /* XXX probably should panic ? */ } if (!raidread_component_label(dev, vp, clabel)) { - /* Got the label. Does it look reasonable? */ + /* Got the label. Does it look reasonable ? */ if (rf_reasonable_label(clabel) && - (clabel->partitionSize <= + (clabel->partitionSize <= label.d_partitions[i].p_size)) { #ifdef RAIDDEBUG - printf("Component on: %s%c: %d\n", - dv->dv_xname, 'a'+i, - label.d_partitions[i].p_size); + printf("Component on: %s%c: %d\n", + dv->dv_xname, 'a'+i, + label.d_partitions[i].p_size); rf_print_component_label(clabel); -#endif - /* if it's reasonable, add it, - else ignore it. */ +#endif /* RAIDDEBUG */ + /* + * If it's reasonable, add it, + * else ignore it. + */ ac = (RF_AutoConfig_t *) malloc(sizeof(RF_AutoConfig_t), - M_RAIDFRAME, - M_NOWAIT); + M_RAIDFRAME, M_NOWAIT); if (ac == NULL) { - /* XXX should panic?? */ + /* XXX should panic ??? */ return(NULL); } - + sprintf(ac->devname, "%s%c", dv->dv_xname, 'a'+i); ac->dev = dev; @@ -2916,75 +2892,68 @@ rf_find_raid_components() ac->next = ac_list; ac_list = ac; good_one = 1; - } + } } if (!good_one) { - /* cleanup */ + /* Cleanup. */ free(clabel, M_RAIDFRAME); VOP_CLOSE(vp, FREAD | FWRITE, NOCRED, 0); vrele(vp); } } } -#endif -return(ac_list); +#endif /* RAID_AUTOCONFIG */ + return(ac_list); } - -#ifdef RAID_AUTOCONFIG + +#ifdef RAID_AUTOCONFIG int -rf_reasonable_label(clabel) - RF_ComponentLabel_t *clabel; +rf_reasonable_label(RF_ComponentLabel_t *clabel) { - + if (((clabel->version==RF_COMPONENT_LABEL_VERSION_1) || (clabel->version==RF_COMPONENT_LABEL_VERSION)) && ((clabel->clean == RF_RAID_CLEAN) || (clabel->clean == RF_RAID_DIRTY)) && - clabel->row >=0 && - clabel->column >= 0 && + clabel->row >=0 && + clabel->column >= 0 && clabel->num_rows > 0 && clabel->num_columns > 0 && - clabel->row < clabel->num_rows && + clabel->row < clabel->num_rows && clabel->column < clabel->num_columns && clabel->blockSize > 0 && clabel->numBlocks > 0) { - /* label looks reasonable enough... */ + /* Label looks reasonable enough... */ return(1); } return(0); } -#endif +#endif /* RAID_AUTOCONFIG */ void -rf_print_component_label(clabel) - RF_ComponentLabel_t *clabel; +rf_print_component_label(RF_ComponentLabel_t *clabel) { printf(" Row: %d Column: %d Num Rows: %d Num Columns: %d\n", - clabel->row, clabel->column, - clabel->num_rows, clabel->num_columns); + clabel->row, clabel->column, clabel->num_rows, clabel->num_columns); printf(" Version: %d Serial Number: %d Mod Counter: %d\n", - clabel->version, clabel->serial_number, - clabel->mod_counter); - printf(" Clean: %s Status: %d\n", - clabel->clean ? "Yes" : "No", clabel->status ); + clabel->version, clabel->serial_number, clabel->mod_counter); + printf(" Clean: %s Status: %d\n", clabel->clean ? "Yes" : "No", + clabel->status ); printf(" sectPerSU: %d SUsPerPU: %d SUsPerRU: %d\n", - clabel->sectPerSU, clabel->SUsPerPU, clabel->SUsPerRU); + clabel->sectPerSU, clabel->SUsPerPU, clabel->SUsPerRU); printf(" RAID Level: %c blocksize: %d numBlocks: %d\n", - (char) clabel->parityConfig, clabel->blockSize, - clabel->numBlocks); + (char) clabel->parityConfig, clabel->blockSize, clabel->numBlocks); printf(" Autoconfig: %s\n", clabel->autoconfigure ? "Yes" : "No" ); - printf(" Contains root partition: %s\n", - clabel->root_partition ? "Yes" : "No" ); + printf(" Contains root partition: %s\n", clabel->root_partition ? + "Yes" : "No" ); printf(" Last configured as: raid%d\n", clabel->last_unit ); #if 0 printf(" Config order: %d\n", clabel->config_order); #endif - } RF_ConfigSet_t * -rf_create_auto_sets(ac_list) - RF_AutoConfig_t *ac_list; +rf_create_auto_sets(RF_AutoConfig_t *ac_list) { RF_AutoConfig_t *ac; RF_ConfigSet_t *config_sets; @@ -2994,33 +2963,37 @@ rf_create_auto_sets(ac_list) config_sets = NULL; - /* Go through the AutoConfig list, and figure out which components - belong to what sets. */ + /* + * Go through the AutoConfig list, and figure out which components + * belong to what sets. + */ ac = ac_list; while(ac!=NULL) { - /* we're going to putz with ac->next, so save it here - for use at the end of the loop */ + /* + * We're going to putz with ac->next, so save it here + * for use at the end of the loop. + */ ac_next = ac->next; if (config_sets == NULL) { - /* will need at least this one... */ + /* We will need at least this one... */ config_sets = (RF_ConfigSet_t *) - malloc(sizeof(RF_ConfigSet_t), - M_RAIDFRAME, M_NOWAIT); + malloc(sizeof(RF_ConfigSet_t), M_RAIDFRAME, + M_NOWAIT); if (config_sets == NULL) { panic("rf_create_auto_sets: No memory!"); } - /* this one is easy :) */ + /* This one is easy :) */ config_sets->ac = ac; config_sets->next = NULL; config_sets->rootable = 0; ac->next = NULL; } else { - /* which set does this component fit into? */ + /* Which set does this component fit into ? */ cset = config_sets; while(cset!=NULL) { if (rf_does_it_fit(cset, ac)) { - /* looks like it matches... */ + /* Looks like it matches... */ ac->next = cset->ac; cset->ac = ac; break; @@ -3028,10 +3001,10 @@ rf_create_auto_sets(ac_list) cset = cset->next; } if (cset==NULL) { - /* didn't find a match above... new set..*/ + /* Didn't find a match above... new set... */ cset = (RF_ConfigSet_t *) - malloc(sizeof(RF_ConfigSet_t), - M_RAIDFRAME, M_NOWAIT); + malloc(sizeof(RF_ConfigSet_t), + M_RAIDFRAME, M_NOWAIT); if (cset == NULL) { panic("rf_create_auto_sets: No memory!"); } @@ -3050,36 +3023,36 @@ rf_create_auto_sets(ac_list) } int -rf_does_it_fit(cset, ac) - RF_ConfigSet_t *cset; - RF_AutoConfig_t *ac; +rf_does_it_fit(RF_ConfigSet_t *cset, RF_AutoConfig_t *ac) { RF_ComponentLabel_t *clabel1, *clabel2; - /* If this one matches the *first* one in the set, that's good - enough, since the other members of the set would have been - through here too... */ - /* note that we are not checking partitionSize here.. - - Note that we are also not checking the mod_counters here. - If everything else matches execpt the mod_counter, that's - good enough for this test. We will deal with the mod_counters - a little later in the autoconfiguration process. - - (clabel1->mod_counter == clabel2->mod_counter) && - - The reason we don't check for this is that failed disks - will have lower modification counts. If those disks are - not added to the set they used to belong to, then they will - form their own set, which may result in 2 different sets, - for example, competing to be configured at raid0, and - perhaps competing to be the root filesystem set. If the - wrong ones get configured, or both attempt to become /, - weird behaviour and or serious lossage will occur. Thus we - need to bring them into the fold here, and kick them out at - a later point. - - */ + /* + * If this one matches the *first* one in the set, that's good + * enough, since the other members of the set would have been + * through here too... + */ + /* + * Note that we are not checking partitionSize here... + * + * Note that we are also not checking the mod_counters here. + * If everything else matches except the mod_counter, that's + * good enough for this test. We will deal with the mod_counters + * a little later in the autoconfiguration process. + * + * (clabel1->mod_counter == clabel2->mod_counter) && + * + * The reason we don't check for this is that failed disks + * will have lower modification counts. If those disks are + * not added to the set they used to belong to, then they will + * form their own set, which may result in 2 different sets, + * for example, competing to be configured at raid0, and + * perhaps competing to be the root filesystem set. If the + * wrong ones get configured, or both attempt to become /, + * weird behaviour and or serious lossage will occur. Thus we + * need to bring them into the fold here, and kick them out at + * a later point. + */ clabel1 = cset->ac->clabel; clabel2 = ac->clabel; @@ -3098,19 +3071,17 @@ rf_does_it_fit(cset, ac) (clabel1->root_partition == clabel2->root_partition) && (clabel1->last_unit == clabel2->last_unit) && (clabel1->config_order == clabel2->config_order)) { - /* if it get's here, it almost *has* to be a match */ + /* If it get's here, it almost *has* to be a match. */ } else { - /* it's not consistent with somebody in the set.. - punt */ + /* It's not consistent with somebody in the set... Punt. */ return(0); } - /* all was fine.. it must fit... */ + /* All was fine.. It must fit... */ return(1); } int -rf_have_enough_components(cset) - RF_ConfigSet_t *cset; +rf_have_enough_components(RF_ConfigSet_t *cset) { RF_AutoConfig_t *ac; RF_AutoConfig_t *auto_config; @@ -3123,16 +3094,18 @@ rf_have_enough_components(cset) int mod_counter_found; int even_pair_failed; char parity_type; - - /* check to see that we have enough 'live' components - of this set. If so, we can configure it if necessary */ + + /* + * Check to see that we have enough 'live' components + * of this set. If so, we can configure it if necessary. + */ num_rows = cset->ac->clabel->num_rows; num_cols = cset->ac->clabel->num_columns; parity_type = cset->ac->clabel->parityConfig; - /* XXX Check for duplicate components!?!?!? */ + /* XXX Check for duplicate components !?!?!? */ /* Determine what the mod_counter is supposed to be for this set. */ @@ -3160,44 +3133,50 @@ rf_have_enough_components(cset) ac = auto_config; while(ac!=NULL) { if ((ac->clabel->row == r) && - (ac->clabel->column == c) && + (ac->clabel->column == c) && (ac->clabel->mod_counter == mod_counter)) { - /* it's this one... */ + /* It's this one... */ #ifdef RAIDDEBUG printf("Found: %s at %d,%d\n", - ac->devname,r,c); -#endif + ac->devname,r,c); +#endif /* RAIDDEBUG */ break; } ac=ac->next; } if (ac==NULL) { /* Didn't find one here! */ - /* special case for RAID 1, especially - where there are more than 2 - components (where RAIDframe treats - things a little differently :( ) */ + /* + * Special case for RAID 1, especially + * where there are more than 2 + * components (where RAIDframe treats + * things a little differently :( ) + */ if (parity_type == '1') { - if (c%2 == 0) { /* even component */ + if (c%2 == 0) { /* Even component. */ even_pair_failed = 1; - } else { /* odd component. If - we're failed, and - so is the even - component, it's - "Good Night, Charlie" */ + } else { /* + * Odd component. + * If we're failed, + * and so is the even + * component, it's + * "Good Night, Charlie" + */ if (even_pair_failed == 1) { return(0); } } } else { - /* normal accounting */ + /* Normal accounting. */ num_missing++; } } if ((parity_type == '1') && (c%2 == 1)) { - /* Just did an even component, and we didn't - bail.. reset the even_pair_failed flag, - and go on to the next component.... */ + /* + * Just did an even component, and we didn't + * bail... Reset the even_pair_failed flag, + * and go on to the next component... + */ even_pair_failed = 0; } } @@ -3208,30 +3187,30 @@ rf_have_enough_components(cset) if (((clabel->parityConfig == '0') && (num_missing > 0)) || ((clabel->parityConfig == '4') && (num_missing > 1)) || ((clabel->parityConfig == '5') && (num_missing > 1))) { - /* XXX this needs to be made *much* more general */ - /* Too many failures */ + /* XXX This needs to be made *much* more general. */ + /* Too many failures. */ return(0); } - /* otherwise, all is well, and we've got enough to take a kick - at autoconfiguring this set */ + /* + * Otherwise, all is well, and we've got enough to take a kick + * at autoconfiguring this set. + */ return(1); } void -rf_create_configuration(ac,config,raidPtr) - RF_AutoConfig_t *ac; - RF_Config_t *config; - RF_Raid_t *raidPtr; +rf_create_configuration(RF_AutoConfig_t *ac, RF_Config_t *config, + RF_Raid_t *raidPtr) { RF_ComponentLabel_t *clabel; int i; clabel = ac->clabel; - /* 1. Fill in the common stuff */ + /* 1. Fill in the common stuff. */ config->numRow = clabel->num_rows; config->numCol = clabel->num_columns; - config->numSpare = 0; /* XXX should this be set here? */ + config->numSpare = 0; /* XXX Should this be set here ? */ config->sectPerSU = clabel->sectPerSU; config->SUsPerPU = clabel->SUsPerPU; config->SUsPerRU = clabel->SUsPerRU; @@ -3239,13 +3218,15 @@ rf_create_configuration(ac,config,raidPtr) /* XXX... */ strcpy(config->diskQueueType,"fifo"); config->maxOutstandingDiskReqs = clabel->maxOutstanding; - config->layoutSpecificSize = 0; /* XXX ?? */ + config->layoutSpecificSize = 0; /* XXX ?? */ while(ac!=NULL) { - /* row/col values will be in range due to the checks - in reasonable_label() */ + /* + * row/col values will be in range due to the checks + * in reasonable_label(). + */ strcpy(config->devnames[ac->clabel->row][ac->clabel->column], - ac->devname); + ac->devname); ac = ac->next; } @@ -3253,106 +3234,116 @@ rf_create_configuration(ac,config,raidPtr) config->debugVars[i][0] = NULL; } -#ifdef RAID_DEBUG_ALL -#ifdef RF_DBG_OPTION -#undef RF_DBG_OPTION -#endif +#ifdef RAID_DEBUG_ALL + +#ifdef RF_DBG_OPTION +#undef RF_DBG_OPTION +#endif /* RF_DBG_OPTION */ -#ifdef __STDC__ -#define RF_DBG_OPTION(_option_,_val_) \ - snprintf(&(config->debugVars[i++][0]), 50, \ - "%s %ld", #_option_, _val_); -#else /* __STDC__ */ -#define RF_DBG_OPTION(_option_,_val_) \ - snprintf(&(config->debugVars[i++][0]), 50, \ - "%s %ld", "/**/_option_/**/", _val_); -#endif /* __STDC__ */ +#ifdef __STDC__ +#define RF_DBG_OPTION(_option_,_val_) do { \ + snprintf(&(config->debugVars[i++][0]), 50, "%s %ld", \ + #_option_, _val_); \ +} while (0) +#else /* __STDC__ */ +#define RF_DBG_OPTION(_option_,_val_) do { \ + snprintf(&(config->debugVars[i++][0]), 50, "%s %ld", \ + "/**/_option_/**/", _val_); \ +} while (0) +#endif /* __STDC__ */ i = 0; -/* RF_DBG_OPTION(accessDebug, 0) */ -/* RF_DBG_OPTION(accessTraceBufSize, 0) */ - RF_DBG_OPTION(cscanDebug, 1) /* debug CSCAN sorting */ - RF_DBG_OPTION(dagDebug, 1) -/* RF_DBG_OPTION(debugPrintUseBuffer, 0) */ - RF_DBG_OPTION(degDagDebug, 1) - RF_DBG_OPTION(disableAsyncAccs, 1) - RF_DBG_OPTION(diskDebug, 1) - RF_DBG_OPTION(enableAtomicRMW, 0) /* this debug var enables - * locking of the disk arm - * during small-write - * operations. Setting this - * variable to anything other - * than 0 will result in - * deadlock. (wvcii) */ - RF_DBG_OPTION(engineDebug, 1) - RF_DBG_OPTION(fifoDebug, 1) /* debug fifo queueing */ -/* RF_DBG_OPTION(floatingRbufDebug, 1) */ -/* RF_DBG_OPTION(forceHeadSepLimit, -1) */ -/* RF_DBG_OPTION(forceNumFloatingReconBufs, -1) */ /* wire down number of - * extra recon buffers - * to use */ -/* RF_DBG_OPTION(keepAccTotals, 1) */ /* turn on keep_acc_totals */ - RF_DBG_OPTION(lockTableSize, RF_DEFAULT_LOCK_TABLE_SIZE) - RF_DBG_OPTION(mapDebug, 1) - RF_DBG_OPTION(maxNumTraces, -1) - -/* RF_DBG_OPTION(memChunkDebug, 1) */ -/* RF_DBG_OPTION(memDebug, 1) */ -/* RF_DBG_OPTION(memDebugAddress, 1) */ -/* RF_DBG_OPTION(numBufsToAccumulate, 1) */ /* number of buffers to - * accumulate before - * doing XOR */ - RF_DBG_OPTION(prReconSched, 0) - RF_DBG_OPTION(printDAGsDebug, 1) - RF_DBG_OPTION(printStatesDebug, 1) - RF_DBG_OPTION(protectedSectors, 64L) /* # of sectors at start - * of disk to exclude - * from RAID address - * space */ - RF_DBG_OPTION(pssDebug, 1) - RF_DBG_OPTION(queueDebug, 1) - RF_DBG_OPTION(quiesceDebug, 1) - RF_DBG_OPTION(raidSectorOffset, 0) /* added to all incoming sectors - * to debug alignment problems */ - RF_DBG_OPTION(reconDebug, 1) - RF_DBG_OPTION(reconbufferDebug, 1) - RF_DBG_OPTION(scanDebug, 1) /* debug SCAN sorting */ - RF_DBG_OPTION(showXorCallCounts, 0) /* show n-way Xor call counts */ - RF_DBG_OPTION(shutdownDebug, 1) /* show shutdown calls */ - RF_DBG_OPTION(sizePercentage, 100) - RF_DBG_OPTION(sstfDebug, 1) /* turn on debugging info for sstf - * queueing */ - RF_DBG_OPTION(stripeLockDebug, 1) - RF_DBG_OPTION(suppressLocksAndLargeWrites, 0) - RF_DBG_OPTION(suppressTraceDelays, 0) - RF_DBG_OPTION(useMemChunks, 1) - RF_DBG_OPTION(validateDAGDebug, 1) - RF_DBG_OPTION(validateVisitedDebug, 1) /* XXX turn to zero by - * default? */ - RF_DBG_OPTION(verifyParityDebug, 1) - RF_DBG_OPTION(debugKernelAccess, 1) /* DoAccessKernel debugging */ - -#if 0 /* RF_INCLUDE_PARITYLOGGING > 0 */ - RF_DBG_OPTION(forceParityLogReint, 0) - RF_DBG_OPTION(numParityRegions, 0) /* number of regions in the - * array */ - RF_DBG_OPTION(numReintegrationThreads, 1) - RF_DBG_OPTION(parityLogDebug, 1) /* if nonzero, enables debugging - * of parity logging */ - RF_DBG_OPTION(totalInCoreLogCapacity, 1024 * 1024) /* target bytes - * available for - * in-core - * logs */ -#endif /* RF_INCLUDE_PARITYLOGGING > 0 */ - -#endif /* RAID_DEBUG_ALL */ +/* RF_DBG_OPTION(accessDebug, 0); */ +/* RF_DBG_OPTION(accessTraceBufSize, 0); */ + RF_DBG_OPTION(cscanDebug, 1); /* Debug CSCAN sorting. */ + RF_DBG_OPTION(dagDebug, 1); +/* RF_DBG_OPTION(debugPrintUseBuffer, 0); */ + RF_DBG_OPTION(degDagDebug, 1); + RF_DBG_OPTION(disableAsyncAccs, 1); + RF_DBG_OPTION(diskDebug, 1); + RF_DBG_OPTION(enableAtomicRMW, 0); + /* + * This debug variable enables locking of the + * disk arm during small-write operations. + * Setting this variable to anything other than + * 0 will result in deadlock. (wvcii) + */ + RF_DBG_OPTION(engineDebug, 1); + RF_DBG_OPTION(fifoDebug, 1); /* Debug fifo queueing. */ +/* RF_DBG_OPTION(floatingRbufDebug, 1); */ +/* RF_DBG_OPTION(forceHeadSepLimit, -1); */ +/* RF_DBG_OPTION(forceNumFloatingReconBufs, -1); */ + /* + * Wire down the number of extra recon buffers + * to use. + */ +/* RF_DBG_OPTION(keepAccTotals, 1); */ + /* Turn on keep_acc_totals. */ + RF_DBG_OPTION(lockTableSize, RF_DEFAULT_LOCK_TABLE_SIZE); + RF_DBG_OPTION(mapDebug, 1); + RF_DBG_OPTION(maxNumTraces, -1); + +/* RF_DBG_OPTION(memChunkDebug, 1); */ +/* RF_DBG_OPTION(memDebug, 1); */ +/* RF_DBG_OPTION(memDebugAddress, 1); */ +/* RF_DBG_OPTION(numBufsToAccumulate, 1); */ + /* + * Number of buffers to accumulate before + * doing XOR. + */ + RF_DBG_OPTION(prReconSched, 0); + RF_DBG_OPTION(printDAGsDebug, 1); + RF_DBG_OPTION(printStatesDebug, 1); + RF_DBG_OPTION(protectedSectors, 64L); + /* + * Number of sectors at start of disk to exclude + * from RAID address space. + */ + RF_DBG_OPTION(pssDebug, 1); + RF_DBG_OPTION(queueDebug, 1); + RF_DBG_OPTION(quiesceDebug, 1); + RF_DBG_OPTION(raidSectorOffset, 0); + /* + * Value added to all incoming sectors to debug + * alignment problems. + */ + RF_DBG_OPTION(reconDebug, 1); + RF_DBG_OPTION(reconbufferDebug, 1); + RF_DBG_OPTION(scanDebug, 1); /* Debug SCAN sorting. */ + RF_DBG_OPTION(showXorCallCounts, 0); + /* Show n-way Xor call counts. */ + RF_DBG_OPTION(shutdownDebug, 1); /* Show shutdown calls. */ + RF_DBG_OPTION(sizePercentage, 100); + RF_DBG_OPTION(sstfDebug, 1); + /* Turn on debugging info for sstf queueing. */ + RF_DBG_OPTION(stripeLockDebug, 1); + RF_DBG_OPTION(suppressLocksAndLargeWrites, 0); + RF_DBG_OPTION(suppressTraceDelays, 0); + RF_DBG_OPTION(useMemChunks, 1); + RF_DBG_OPTION(validateDAGDebug, 1); + RF_DBG_OPTION(validateVisitedDebug, 1); + /* XXX turn to zero by default ? */ + RF_DBG_OPTION(verifyParityDebug, 1); + RF_DBG_OPTION(debugKernelAccess, 1); + /* DoAccessKernel debugging. */ + +#if RF_INCLUDE_PARITYLOGGING > 0 + RF_DBG_OPTION(forceParityLogReint, 0); + RF_DBG_OPTION(numParityRegions, 0); + /* Number of regions in the array. */ + RF_DBG_OPTION(numReintegrationThreads, 1); + RF_DBG_OPTION(parityLogDebug, 1); + /* If nonzero, enables debugging of parity logging. */ + RF_DBG_OPTION(totalInCoreLogCapacity, 1024 * 1024); + /* Target bytes available for in-core logs. */ +#endif /* RF_INCLUDE_PARITYLOGGING > 0 */ + +#endif /* RAID_DEBUG_ALL */ } int -rf_set_autoconfig(raidPtr, new_value) - RF_Raid_t *raidPtr; - int new_value; +rf_set_autoconfig(RF_Raid_t *raidPtr, int new_value) { RF_ComponentLabel_t clabel; struct vnode *vp; @@ -3362,7 +3353,7 @@ rf_set_autoconfig(raidPtr, new_value) raidPtr->autoconfigure = new_value; for(row=0; row<raidPtr->numRow; row++) { for(column=0; column<raidPtr->numCol; column++) { - if (raidPtr->Disks[row][column].status == + if (raidPtr->Disks[row][column].status == rf_ds_optimal) { dev = raidPtr->Disks[row][column].dev; vp = raidPtr->raid_cinfo[row][column].ci_vp; @@ -3376,9 +3367,7 @@ rf_set_autoconfig(raidPtr, new_value) } int -rf_set_rootpartition(raidPtr, new_value) - RF_Raid_t *raidPtr; - int new_value; +rf_set_rootpartition(RF_Raid_t *raidPtr, int new_value) { RF_ComponentLabel_t clabel; struct vnode *vp; @@ -3388,7 +3377,7 @@ rf_set_rootpartition(raidPtr, new_value) raidPtr->root_partition = new_value; for(row=0; row<raidPtr->numRow; row++) { for(column=0; column<raidPtr->numCol; column++) { - if (raidPtr->Disks[row][column].status == + if (raidPtr->Disks[row][column].status == rf_ds_optimal) { dev = raidPtr->Disks[row][column].dev; vp = raidPtr->raid_cinfo[row][column].ci_vp; @@ -3402,14 +3391,13 @@ rf_set_rootpartition(raidPtr, new_value) } void -rf_release_all_vps(cset) - RF_ConfigSet_t *cset; +rf_release_all_vps(RF_ConfigSet_t *cset) { RF_AutoConfig_t *ac; - + ac = cset->ac; while(ac!=NULL) { - /* Close the vp, and give it back */ + /* Close the vp, and give it back. */ if (ac->vp) { VOP_CLOSE(ac->vp, FREAD, NOCRED, 0); vrele(ac->vp); @@ -3421,41 +3409,38 @@ rf_release_all_vps(cset) void -rf_cleanup_config_set(cset) - RF_ConfigSet_t *cset; +rf_cleanup_config_set(RF_ConfigSet_t *cset) { RF_AutoConfig_t *ac; RF_AutoConfig_t *next_ac; - + ac = cset->ac; while(ac!=NULL) { next_ac = ac->next; - /* nuke the label */ + /* Nuke the label. */ free(ac->clabel, M_RAIDFRAME); - /* cleanup the config structure */ + /* Cleanup the config structure. */ free(ac, M_RAIDFRAME); - /* "next.." */ + /* "next..." */ ac = next_ac; } - /* and, finally, nuke the config set */ + /* And, finally, nuke the config set. */ free(cset, M_RAIDFRAME); } void -raid_init_component_label(raidPtr, clabel) - RF_Raid_t *raidPtr; - RF_ComponentLabel_t *clabel; +raid_init_component_label(RF_Raid_t *raidPtr, RF_ComponentLabel_t *clabel) { - /* current version number */ - clabel->version = RF_COMPONENT_LABEL_VERSION; + /* Current version number. */ + clabel->version = RF_COMPONENT_LABEL_VERSION; clabel->serial_number = raidPtr->serial_number; clabel->mod_counter = raidPtr->mod_counter; clabel->num_rows = raidPtr->numRow; clabel->num_columns = raidPtr->numCol; - clabel->clean = RF_RAID_DIRTY; /* not clean */ - clabel->status = rf_ds_optimal; /* "It's good!" */ - + clabel->clean = RF_RAID_DIRTY; /* Not clean. */ + clabel->status = rf_ds_optimal; /* "It's good !" */ + clabel->sectPerSU = raidPtr->Layout.sectorsPerStripeUnit; clabel->SUsPerPU = raidPtr->Layout.SUsPerPU; clabel->SUsPerRU = raidPtr->Layout.SUsPerRU; @@ -3463,7 +3448,7 @@ raid_init_component_label(raidPtr, clabel) clabel->blockSize = raidPtr->bytesPerSector; clabel->numBlocks = raidPtr->sectorsPerDisk; - /* XXX not portable */ + /* XXX Not portable. */ clabel->parityConfig = raidPtr->Layout.map->parityConfig; clabel->maxOutstanding = raidPtr->maxOutstanding; clabel->autoconfigure = raidPtr->autoconfigure; @@ -3473,9 +3458,7 @@ raid_init_component_label(raidPtr, clabel) } int -rf_auto_config_set(cset,unit) - RF_ConfigSet_t *cset; - int *unit; +rf_auto_config_set(RF_ConfigSet_t *cset, int *unit) { RF_Raid_t *raidPtr; RF_Config_t *config; @@ -3487,78 +3470,79 @@ rf_auto_config_set(cset,unit) retcode = 0; *unit = -1; - /* 1. Create a config structure */ + /* 1. Create a config structure. */ - config = (RF_Config_t *)malloc(sizeof(RF_Config_t), - M_RAIDFRAME, - M_NOWAIT); + config = (RF_Config_t *)malloc(sizeof(RF_Config_t), M_RAIDFRAME, + M_NOWAIT); if (config==NULL) { printf("Out of mem!?!?\n"); - /* XXX do something more intelligent here. */ + /* XXX Do something more intelligent here. */ return(1); } memset(config, 0, sizeof(RF_Config_t)); - /* XXX raidID needs to be set correctly.. */ + /* XXX raidID needs to be set correctly... */ - /* - 2. Figure out what RAID ID this one is supposed to live at - See if we can get the same RAID dev that it was configured - on last time.. - */ + /* + * 2. Figure out what RAID ID this one is supposed to live at. + * See if we can get the same RAID dev that it was configured + * on last time... + */ raidID = cset->ac->clabel->last_unit; if ((raidID < 0) || (raidID >= numraid)) { - /* let's not wander off into lala land. */ + /* Let's not wander off into lala land. */ raidID = numraid - 1; } if (raidPtrs[raidID]->valid != 0) { - /* - Nope... Go looking for an alternative... - Start high so we don't immediately use raid0 if that's - not taken. - */ + /* + * Nope... Go looking for an alternative... + * Start high so we don't immediately use raid0 if that's + * not taken. + */ for(raidID = numraid - 1; raidID >= 0; raidID--) { if (raidPtrs[raidID]->valid == 0) { - /* can use this one! */ + /* We can use this one ! */ break; } } } if (raidID < 0) { - /* punt... */ + /* Punt... */ printf("Unable to auto configure this set!\n"); printf("(Out of RAID devs!)\n"); return(1); } raidPtr = raidPtrs[raidID]; - /* XXX all this stuff should be done SOMEWHERE ELSE! */ + /* XXX All this stuff should be done SOMEWHERE ELSE ! */ raidPtr->raidid = raidID; raidPtr->openings = RAIDOUTSTANDING; - /* 3. Build the configuration structure */ + /* 3. Build the configuration structure. */ rf_create_configuration(cset->ac, config, raidPtr); - /* 4. Do the configuration */ + /* 4. Do the configuration. */ retcode = rf_Configure(raidPtr, config, cset->ac); - + if (retcode == 0) { raidinit(raidPtrs[raidID]); rf_markalldirty(raidPtrs[raidID]); - raidPtrs[raidID]->autoconfigure = 1; /* XXX do this here? */ + raidPtrs[raidID]->autoconfigure = 1; /* XXX Do this here ? */ if (cset->ac->clabel->root_partition==1) { - /* everything configured just fine. Make a note - that this set is eligible to be root. */ + /* + * Everything configured just fine. Make a note + * that this set is eligible to be root. + */ cset->rootable = 1; - /* XXX do this here? */ - raidPtrs[raidID]->root_partition = 1; + /* XXX Do this here ? */ + raidPtrs[raidID]->root_partition = 1; } } @@ -3569,20 +3553,19 @@ rf_auto_config_set(cset,unit) (1 << raidPtrs[raidID]->logBytesPerSector) / 1024), raidPtrs[raidID]->root_partition ? " as root" : ""); - /* 5. Cleanup */ + /* 5. Cleanup. */ free(config, M_RAIDFRAME); - + *unit = raidID; return(retcode); } void -rf_disk_unbusy(desc) - RF_RaidAccessDesc_t *desc; +rf_disk_unbusy(RF_RaidAccessDesc_t *desc) { struct buf *bp; bp = (struct buf *)desc->bp; - disk_unbusy(&raid_softc[desc->raidPtr->raidid].sc_dkdev, + disk_unbusy(&raid_softc[desc->raidPtr->raidid].sc_dkdev, (bp->b_bcount - bp->b_resid)); } |