Module Name: src Committed By: christos Date: Sat Apr 27 21:18:43 UTC 2013
Modified Files: src/sys/dev/raidframe: rf_engine.c rf_netbsd.h rf_netbsdkintf.c rf_raid.h Log Message: allocate devices dynamically. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/dev/raidframe/rf_engine.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/raidframe/rf_netbsd.h cvs rdiff -u -r1.299 -r1.300 src/sys/dev/raidframe/rf_netbsdkintf.c cvs rdiff -u -r1.43 -r1.44 src/sys/dev/raidframe/rf_raid.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/raidframe/rf_engine.c diff -u src/sys/dev/raidframe/rf_engine.c:1.47 src/sys/dev/raidframe/rf_engine.c:1.48 --- src/sys/dev/raidframe/rf_engine.c:1.47 Wed Sep 7 03:46:45 2011 +++ src/sys/dev/raidframe/rf_engine.c Sat Apr 27 17:18:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_engine.c,v 1.47 2011/09/07 07:46:45 mbalmer Exp $ */ +/* $NetBSD: rf_engine.c,v 1.48 2013/04/27 21:18:42 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -55,7 +55,7 @@ ****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.47 2011/09/07 07:46:45 mbalmer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_engine.c,v 1.48 2013/04/27 21:18:42 christos Exp $"); #include <sys/errno.h> @@ -862,7 +862,7 @@ rf_RaidIOThread(RF_ThreadArg_t arg) while (!raidPtr->shutdown_raidio) { /* if there is nothing to do, then snooze. */ if (TAILQ_EMPTY(&(raidPtr->iodone)) && - rf_buf_queue_check(raidPtr->raidid)) { + rf_buf_queue_check(raidPtr)) { rf_wait_cond2(raidPtr->iodone_cv, raidPtr->iodone_lock); } Index: src/sys/dev/raidframe/rf_netbsd.h diff -u src/sys/dev/raidframe/rf_netbsd.h:1.29 src/sys/dev/raidframe/rf_netbsd.h:1.30 --- src/sys/dev/raidframe/rf_netbsd.h:1.29 Mon Apr 28 16:23:56 2008 +++ src/sys/dev/raidframe/rf_netbsd.h Sat Apr 27 17:18:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsd.h,v 1.29 2008/04/28 20:23:56 martin Exp $ */ +/* $NetBSD: rf_netbsd.h,v 1.30 2013/04/27 21:18:42 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -83,7 +83,7 @@ struct RF_Pools_s { extern struct RF_Pools_s rf_pools; void rf_pool_init(struct pool *, size_t, const char *, size_t, size_t); -int rf_buf_queue_check(int); +int rf_buf_queue_check(RF_Raid_t *); /* XXX probably belongs in a different .h file. */ typedef struct RF_AutoConfig_s { Index: src/sys/dev/raidframe/rf_netbsdkintf.c diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.299 src/sys/dev/raidframe/rf_netbsdkintf.c:1.300 --- src/sys/dev/raidframe/rf_netbsdkintf.c:1.299 Mon Feb 18 14:42:54 2013 +++ src/sys/dev/raidframe/rf_netbsdkintf.c Sat Apr 27 17:18:42 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_netbsdkintf.c,v 1.299 2013/02/18 19:42:54 oster Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.300 2013/04/27 21:18:42 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.299 2013/02/18 19:42:54 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.300 2013/04/27 21:18:42 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -159,8 +159,6 @@ int rf_kdebug_level = 0; #define db1_printf(a) { } #endif /* DEBUG */ -static RF_Raid_t **raidPtrs; /* global raid device descriptors */ - #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) static rf_declare_mutex2(rf_sparet_wait_mutex); static rf_declare_cond2(rf_sparet_wait_cv); @@ -179,7 +177,8 @@ static void KernelWakeupFunc(struct buf static void InitBP(struct buf *, struct vnode *, unsigned, dev_t, RF_SectorNum_t, RF_SectorCount_t, void *, void (*) (struct buf *), void *, int, struct proc *); -static void raidinit(RF_Raid_t *); +struct raid_softc; +static void raidinit(struct raid_softc *); void raidattach(int); static int raid_match(device_t, cfdata_t, void *); @@ -218,18 +217,17 @@ const struct cdevsw raid_cdevsw = { static struct dkdriver rf_dkdriver = { raidstrategy, minphys }; -/* XXX Not sure if the following should be replacing the raidPtrs above, - or if it should be used in conjunction with that... -*/ - struct raid_softc { device_t sc_dev; + int sc_unit; int sc_flags; /* flags */ int sc_cflags; /* configuration flags */ uint64_t sc_size; /* size of the raid device */ char sc_xname[20]; /* XXX external name */ struct disk sc_dkdev; /* generic disk device info */ struct bufq_state *buf_queue; /* used for the device queue */ + RF_Raid_t sc_r; + LIST_ENTRY(raid_softc) sc_link; }; /* sc_flags */ #define RAIDF_INITED 0x01 /* unit has been initialized */ @@ -240,7 +238,6 @@ struct raid_softc { #define RAIDF_LOCKED 0x80 /* unit is locked */ #define raidunit(x) DISKUNIT(x) -int numraid = 0; extern struct cfdriver raid_cd; CFATTACH_DECL3_NEW(raid, sizeof(struct raid_softc), @@ -272,7 +269,6 @@ CFATTACH_DECL3_NEW(raid, sizeof(struct r (MAKEDISKDEV(major((dev)), raidunit((dev)), RAW_PART)) /* declared here, and made public, for the benefit of KVM stuff.. */ -struct raid_softc *raid_softc; static void raidgetdefaultlabel(RF_Raid_t *, struct raid_softc *, struct disklabel *); @@ -304,7 +300,7 @@ int rf_set_rootpartition(RF_Raid_t *, in 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 *); +struct raid_softc *rf_auto_config_set(RF_ConfigSet_t *); static void rf_fix_old_label_size(RF_ComponentLabel_t *, uint64_t); /* @@ -321,30 +317,68 @@ static bool raidautoconfigdone = false; struct RF_Pools_s rf_pools; -void -raidattach(int num) -{ - int raidID; - int i, rc; +static LIST_HEAD(, raid_softc) raids = LIST_HEAD_INITIALIZER(raids); +static kmutex_t raid_lock; - aprint_debug("raidattach: Asked for %d units\n", num); - - if (num <= 0) { +static struct raid_softc * +raidcreate(int unit) { + struct raid_softc *sc = kmem_zalloc(sizeof(*sc), KM_SLEEP); + if (sc == NULL) { #ifdef DIAGNOSTIC - panic("raidattach: count <= 0"); + printf("%s: out of memory\n", __func__); #endif - return; + return NULL; } - /* This is where all the initialization stuff gets done. */ - - numraid = num; + sc->sc_unit = unit; + sc->sc_r.softc = sc; + bufq_alloc(&sc->buf_queue, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK); + return sc; +} - /* Make some space for requested number of units... */ +static void +raiddestroy(struct raid_softc *sc) { + bufq_free(sc->buf_queue); + kmem_free(sc, sizeof(*sc)); +} - RF_Malloc(raidPtrs, num * sizeof(RF_Raid_t *), (RF_Raid_t **)); - if (raidPtrs == NULL) { - panic("raidPtrs is NULL!!"); +static struct raid_softc * +raidget(int unit) { + struct raid_softc *sc; + if (unit < 0) { +#ifdef DIAGNOSTIC + panic("%s: unit %d!", __func__, unit); +#endif + return NULL; } + mutex_enter(&raid_lock); + LIST_FOREACH(sc, &raids, sc_link) { + if (sc->sc_unit == unit) { + mutex_exit(&raid_lock); + return sc; + } + } + mutex_exit(&raid_lock); + if ((sc = raidcreate(unit)) == NULL) + return NULL; + mutex_enter(&raid_lock); + LIST_INSERT_HEAD(&raids, sc, sc_link); + mutex_exit(&raid_lock); + return sc; +} + +static void +raidput(struct raid_softc *sc) { + mutex_enter(&raid_lock); + LIST_REMOVE(sc, sc_link); + mutex_exit(&raid_lock); + raiddestroy(sc); +} + +void +raidattach(int num) +{ + mutex_init(&raid_lock, MUTEX_DEFAULT, IPL_NONE); + /* This is where all the initialization stuff gets done. */ #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) rf_init_mutex2(rf_sparet_wait_mutex, IPL_VM); @@ -354,39 +388,11 @@ raidattach(int num) rf_sparet_wait_queue = rf_sparet_resp_queue = NULL; #endif - for (i = 0; i < num; i++) - raidPtrs[i] = NULL; - rc = rf_BootRaidframe(); - if (rc == 0) + if (rf_BootRaidframe() == 0) aprint_verbose("Kernelized RAIDframe activated\n"); else panic("Serious error booting RAID!!"); - /* 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); - if (raid_softc == NULL) { - aprint_error("WARNING: no memory for RAIDframe driver\n"); - return; - } - - memset(raid_softc, 0, num * sizeof(struct raid_softc)); - - for (raidID = 0; raidID < num; raidID++) { - bufq_alloc(&raid_softc[raidID].buf_queue, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK); - - RF_Malloc(raidPtrs[raidID], sizeof(RF_Raid_t), - (RF_Raid_t *)); - if (raidPtrs[raidID] == NULL) { - aprint_error("WARNING: raidPtrs[%d] is NULL\n", raidID); - numraid = raidID; - return; - } - } - if (config_cfattach_attach(raid_cd.cd_name, &raid_ca)) { aprint_error("raidattach: config_cfattach_attach failed?\n"); } @@ -434,30 +440,29 @@ rf_buildroothack(RF_ConfigSet_t *config_ { RF_ConfigSet_t *cset; RF_ConfigSet_t *next_cset; - int retcode; - int raidID; - int rootID; int col; int num_root; char *devname; + struct raid_softc *sc, *rsc; - rootID = 0; + sc = rsc = NULL; num_root = 0; cset = config_sets; while (cset != NULL) { next_cset = cset->next; if (rf_have_enough_components(cset) && - cset->ac->clabel->autoconfigure==1) { - retcode = rf_auto_config_set(cset,&raidID); - if (!retcode) { - aprint_debug("raid%d: configured ok\n", raidID); + cset->ac->clabel->autoconfigure == 1) { + sc = rf_auto_config_set(cset); + if (sc != NULL) { + aprint_debug("raid%d: configured ok\n", + sc->sc_unit); if (cset->rootable) { - rootID = raidID; + rsc = sc; num_root++; } } else { /* The autoconfig didn't work :( */ - aprint_debug("Autoconfig failed with code %d for raid%d\n", retcode, raidID); + aprint_debug("Autoconfig failed\n"); rf_release_all_vps(cset); } } else { @@ -479,14 +484,14 @@ rf_buildroothack(RF_ConfigSet_t *config_ /* we found something bootable... */ if (num_root == 1) { - if (raid_softc[rootID].sc_dkdev.dk_nwedges != 0) { + if (rsc->sc_dkdev.dk_nwedges != 0) { /* XXX: How do we find the real root partition? */ char cname[sizeof(cset->ac->devname)]; snprintf(cname, sizeof(cname), "%s%c", - device_xname(raid_softc[rootID].sc_dev), 'a'); + device_xname(rsc->sc_dev), 'a'); booted_device = dkwedge_find_by_wname(cname); } else - booted_device = raid_softc[rootID].sc_dev; + booted_device = rsc->sc_dev; } else if (num_root > 1) { /* @@ -502,28 +507,31 @@ rf_buildroothack(RF_ConfigSet_t *config_ return; num_root = 0; - for (raidID = 0; raidID < numraid; raidID++) { - if (raidPtrs[raidID]->valid == 0) + mutex_enter(&raid_lock); + LIST_FOREACH(sc, &raids, sc_link) { + RF_Raid_t *r = &sc->sc_r; + if (r->valid == 0) continue; - if (raidPtrs[raidID]->root_partition == 0) + if (r->root_partition == 0) continue; - for (col = 0; col < raidPtrs[raidID]->numCol; col++) { - devname = raidPtrs[raidID]->Disks[col].devname; + for (col = 0; col < r->numCol; col++) { + devname = r->Disks[col].devname; devname += sizeof("/dev/") - 1; if (strncmp(devname, device_xname(booted_device), strlen(device_xname(booted_device))) != 0) continue; aprint_debug("raid%d includes boot device %s\n", - raidID, devname); + sc->sc_unit, devname); num_root++; - rootID = raidID; + rsc = sc; } } + mutex_exit(&raid_lock); if (num_root == 1) { - booted_device = raid_softc[rootID].sc_dev; + booted_device = rsc->sc_dev; } else { /* we can't guess.. require the user to answer... */ boothowto |= RB_ASKNAME; @@ -540,10 +548,8 @@ raidsize(dev_t dev) int part, unit, omask, size; unit = raidunit(dev); - if (unit >= numraid) - return (-1); - rs = &raid_softc[unit]; - + if ((rs = raidget(unit)) == NULL) + return -1; if ((rs->sc_flags & RAIDF_INITED) == 0) return (-1); @@ -579,11 +585,10 @@ raiddump(dev_t dev, daddr_t blkno, void int part, c, sparecol, j, scol, dumpto; int error = 0; - if (unit >= numraid) - return (ENXIO); + if ((rs = raidget(unit)) == NULL) + return ENXIO; - rs = &raid_softc[unit]; - raidPtr = raidPtrs[unit]; + raidPtr = &rs->sc_r; if ((rs->sc_flags & RAIDF_INITED) == 0) return ENXIO; @@ -715,10 +720,8 @@ raidopen(dev_t dev, int flags, int fmt, int part, pmask; int error = 0; - if (unit >= numraid) - return (ENXIO); - rs = &raid_softc[unit]; - + if ((rs = raidget(unit)) == NULL) + return ENXIO; if ((error = raidlock(rs)) != 0) return (error); @@ -776,7 +779,7 @@ raidopen(dev_t dev, int flags, int fmt, 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(&rs->sc_r); } @@ -799,9 +802,8 @@ raidclose(dev_t dev, int flags, int fmt, int error = 0; int part; - if (unit >= numraid) - return (ENXIO); - rs = &raid_softc[unit]; + if ((rs = raidget(unit)) == NULL) + return ENXIO; if ((error = raidlock(rs)) != 0) return (error); @@ -828,7 +830,7 @@ raidclose(dev_t dev, int flags, int fmt, clean bits if RAIDF_INITED is not set mark things as clean... */ - rf_update_component_labels(raidPtrs[unit], + rf_update_component_labels(&rs->sc_r, RF_FINAL_COMPONENT_UPDATE); /* If the kernel is shutting down, it will detach @@ -844,20 +846,20 @@ raidclose(dev_t dev, int flags, int fmt, void raidstrategy(struct buf *bp) { - unsigned int raidID = raidunit(bp->b_dev); + unsigned int unit = raidunit(bp->b_dev); RF_Raid_t *raidPtr; - struct raid_softc *rs = &raid_softc[raidID]; int wlabel; + struct raid_softc *rs; - if ((rs->sc_flags & RAIDF_INITED) ==0) { + if ((rs = raidget(unit)) == NULL) { bp->b_error = ENXIO; goto done; } - if (raidID >= numraid || !raidPtrs[raidID]) { - bp->b_error = ENODEV; + if ((rs->sc_flags & RAIDF_INITED) == 0) { + bp->b_error = ENXIO; goto done; } - raidPtr = raidPtrs[raidID]; + raidPtr = &rs->sc_r; if (!raidPtr->valid) { bp->b_error = ENODEV; goto done; @@ -918,9 +920,8 @@ raidread(dev_t dev, struct uio *uio, int int unit = raidunit(dev); struct raid_softc *rs; - if (unit >= numraid) - return (ENXIO); - rs = &raid_softc[unit]; + if ((rs = raidget(unit)) == NULL) + return ENXIO; if ((rs->sc_flags & RAIDF_INITED) == 0) return (ENXIO); @@ -935,9 +936,8 @@ raidwrite(dev_t dev, struct uio *uio, in int unit = raidunit(dev); struct raid_softc *rs; - if (unit >= numraid) - return (ENXIO); - rs = &raid_softc[unit]; + if ((rs = raidget(unit)) == NULL) + return ENXIO; if ((rs->sc_flags & RAIDF_INITED) == 0) return (ENXIO); @@ -952,7 +952,7 @@ raid_detach_unlocked(struct raid_softc * int error; RF_Raid_t *raidPtr; - raidPtr = raidPtrs[device_unit(rs->sc_dev)]; + raidPtr = &rs->sc_r; /* * If somebody has a partition mounted, we shouldn't @@ -1008,10 +1008,9 @@ raidioctl(dev_t dev, u_long cmd, void *d #endif struct dkwedge_info *dkw; - if (unit >= numraid) - return (ENXIO); - rs = &raid_softc[unit]; - raidPtr = raidPtrs[unit]; + if ((rs = raidget(unit)) == NULL) + return ENXIO; + raidPtr = &rs->sc_r; db1_printf(("raidioctl: %d %d %d %lu\n", (int) dev, (int) DISKPART(dev), (int) unit, cmd)); @@ -1180,7 +1179,7 @@ raidioctl(dev_t dev, u_long cmd, void *d this RAID device */ raidPtr->openings = RAIDOUTSTANDING; - raidinit(raidPtr); + raidinit(rs); rf_markalldirty(raidPtr); } /* free the buffers. No return code here. */ @@ -1916,15 +1915,14 @@ raidioctl(dev_t dev, u_long cmd, void *d static void -raidinit(RF_Raid_t *raidPtr) +raidinit(struct raid_softc *rs) { cfdata_t cf; - struct raid_softc *rs; int unit; + RF_Raid_t *raidPtr = &rs->sc_r; unit = raidPtr->raidid; - rs = &raid_softc[unit]; /* XXX should check return code first... */ rs->sc_flags |= RAIDF_INITED; @@ -2017,15 +2015,12 @@ raidstart(RF_Raid_t *raidPtr) RF_RaidAddr_t raid_addr; struct partition *pp; daddr_t blocknum; - int unit; struct raid_softc *rs; int do_async; struct buf *bp; int rc; - unit = raidPtr->raidid; - rs = &raid_softc[unit]; - + rs = raidPtr->softc; /* quick check to see if anything has died recently */ rf_lock_mutex2(raidPtr->mutex); if (raidPtr->numNewFailures > 0) { @@ -2347,17 +2342,23 @@ static void raidgetdisklabel(dev_t dev) { int unit = raidunit(dev); - struct raid_softc *rs = &raid_softc[unit]; + struct raid_softc *rs; const char *errstring; - struct disklabel *lp = rs->sc_dkdev.dk_label; - struct cpu_disklabel *clp = rs->sc_dkdev.dk_cpulabel; + struct disklabel *lp; + struct cpu_disklabel *clp; RF_Raid_t *raidPtr; + if ((rs = raidget(unit)) == NULL) + return; + + lp = rs->sc_dkdev.dk_label; + clp = rs->sc_dkdev.dk_cpulabel; + db1_printf(("Getting the disklabel...\n")); memset(clp, 0, sizeof(*clp)); - raidPtr = raidPtrs[unit]; + raidPtr = &rs->sc_r; raidgetdefaultlabel(raidPtr, rs, lp); @@ -3699,34 +3700,26 @@ raid_init_component_label(RF_Raid_t *rai #endif } -int -rf_auto_config_set(RF_ConfigSet_t *cset, int *unit) +struct raid_softc * +rf_auto_config_set(RF_ConfigSet_t *cset) { RF_Raid_t *raidPtr; RF_Config_t *config; int raidID; - int retcode; + struct raid_softc *sc; #ifdef DEBUG printf("RAID autoconfigure\n"); #endif - retcode = 0; - *unit = -1; - /* 1. Create a config structure */ - - config = (RF_Config_t *)malloc(sizeof(RF_Config_t), - M_RAIDFRAME, - M_NOWAIT); - if (config==NULL) { + config = malloc(sizeof(*config), M_RAIDFRAME, M_NOWAIT|M_ZERO); + if (config == NULL) { printf("Out of mem!?!?\n"); /* XXX do something more intelligent here. */ - return(1); + return NULL; } - memset(config, 0, sizeof(RF_Config_t)); - /* 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 @@ -3734,39 +3727,13 @@ rf_auto_config_set(RF_ConfigSet_t *cset, */ raidID = cset->ac->clabel->last_unit; - if ((raidID < 0) || (raidID >= numraid)) { - /* 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. - */ - - for(raidID = numraid - 1; raidID >= 0; raidID--) { - if (raidPtrs[raidID]->valid == 0) { - /* can use this one! */ - break; - } - } - } - - if (raidID < 0) { - /* punt... */ - printf("Unable to auto configure this set!\n"); - printf("(Out of RAID devs!)\n"); - free(config, M_RAIDFRAME); - return(1); - } - + for (sc = raidget(raidID); sc->sc_r.valid != 0; sc = raidget(++raidID)) + continue; #ifdef DEBUG printf("Configuring raid%d:\n",raidID); #endif - raidPtr = raidPtrs[raidID]; + raidPtr = &sc->sc_r; /* XXX all this stuff should be done SOMEWHERE ELSE! */ raidPtr->raidid = raidID; @@ -3776,38 +3743,38 @@ rf_auto_config_set(RF_ConfigSet_t *cset, rf_create_configuration(cset->ac, config, raidPtr); /* 4. Do the configuration */ - retcode = rf_Configure(raidPtr, config, cset->ac); + if (rf_Configure(raidPtr, config, cset->ac) == 0) { + raidinit(sc); - if (retcode == 0) { - - raidinit(raidPtrs[raidID]); - - rf_markalldirty(raidPtrs[raidID]); - raidPtrs[raidID]->autoconfigure = 1; /* XXX do this here? */ + rf_markalldirty(raidPtr); + raidPtr->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. */ cset->rootable = 1; /* XXX do this here? */ - raidPtrs[raidID]->root_partition = 1; + raidPtr->root_partition = 1; } + } else { + raidput(sc); + sc = NULL; } /* 5. Cleanup */ free(config, M_RAIDFRAME); - - *unit = raidID; - return(retcode); + return sc; } void rf_disk_unbusy(RF_RaidAccessDesc_t *desc) { struct buf *bp; + struct raid_softc *rs; bp = (struct buf *)desc->bp; - disk_unbusy(&raid_softc[desc->raidPtr->raidid].sc_dkdev, - (bp->b_bcount - bp->b_resid), (bp->b_flags & B_READ)); + rs = desc->raidPtr->softc; + disk_unbusy(&rs->sc_dkdev, (bp->b_bcount - bp->b_resid), + (bp->b_flags & B_READ)); } void @@ -3821,7 +3788,7 @@ rf_pool_init(struct pool *p, size_t size } /* - * rf_buf_queue_check(int raidid) -- looks into the buf_queue to see + * rf_buf_queue_check(RF_Raid_t raidPtr) -- looks into the buf_queue to see * if there is IO pending and if that IO could possibly be done for a * given RAID set. Returns 0 if IO is waiting and can be done, 1 * otherwise. @@ -3829,10 +3796,10 @@ rf_pool_init(struct pool *p, size_t size */ int -rf_buf_queue_check(int raidid) +rf_buf_queue_check(RF_Raid_t *raidPtr) { - if ((bufq_peek(raid_softc[raidid].buf_queue) != NULL) && - raidPtrs[raidid]->openings > 0) { + struct raid_softc *rs = raidPtr->softc; + if ((bufq_peek(rs->buf_queue) != NULL) && raidPtr->openings > 0) { /* there is work to do */ return 0; } @@ -3874,7 +3841,7 @@ static int raid_detach(device_t self, int flags) { int error; - struct raid_softc *rs = &raid_softc[device_unit(self)]; + struct raid_softc *rs = device_private(self); if ((error = raidlock(rs)) != 0) return (error); Index: src/sys/dev/raidframe/rf_raid.h diff -u src/sys/dev/raidframe/rf_raid.h:1.43 src/sys/dev/raidframe/rf_raid.h:1.44 --- src/sys/dev/raidframe/rf_raid.h:1.43 Wed May 11 14:13:12 2011 +++ src/sys/dev/raidframe/rf_raid.h Sat Apr 27 17:18:43 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_raid.h,v 1.43 2011/05/11 18:13:12 mrg Exp $ */ +/* $NetBSD: rf_raid.h,v 1.44 2013/04/27 21:18:43 christos Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -260,6 +260,7 @@ struct RF_Raid_s { RF_DiskId_t **diskids; int raidid; + void *softc; RF_AccTotals_t acc_totals; int keep_acc_totals;