/* * Called to shut down an array. */ int rf_Shutdown(RF_Raid_t *raidPtr) { if (!raidPtr->valid) { RF_ERRORMSG("Attempt to shut down unconfigured RAIDframe driver. Aborting shutdown\n"); return (EINVAL); } /* * wait for outstanding IOs to land * As described in rf_raid.h, we use the rad_freelist lock * to protect the per-array info about outstanding descs * since we need to do freelist locking anyway, and this * cuts down on the amount of serialization we've got going * on. */ RF_LOCK_MUTEX(rf_rad_lock); if (raidPtr->waitShutdown) { RF_UNLOCK_MUTEX(rf_rad_lock); return (EBUSY); } raidPtr->waitShutdown = 1; while (raidPtr->nAccOutstanding) { RF_WAIT_COND(raidPtr->outstandingCond, rf_rad_lock); } RF_UNLOCK_MUTEX(rf_rad_lock); /* Wait for any parity re-writes to stop... */ while (raidPtr->parity_rewrite_in_progress) { printf("raid%d: Waiting for parity re-write to exit...\n", raidPtr->raidid); tsleep(&raidPtr->parity_rewrite_in_progress, PRIBIO, "rfprwshutdown", 0); } /* Wait for any reconstruction to stop... */ while (raidPtr->reconInProgress) { printf("raid%d: Waiting for reconstruction to stop...\n", raidPtr->raidid); tsleep(&raidPtr->waitForReconCond, PRIBIO, "rfreshutdown",0); } raidPtr->valid = 0; if (raidPtr->parity_map != NULL) rf_paritymap_detach(raidPtr); rf_update_component_labels(raidPtr, RF_FINAL_COMPONENT_UPDATE); rf_UnconfigureVnodes(raidPtr); rf_FreeEmergBuffers(raidPtr); rf_ShutdownList(&raidPtr->shutdownList); rf_UnconfigureArray(); return (0); }
/* * Called whenever an array is shutdown */ static void rf_UnconfigureArray() { int rc; RF_LOCK_MUTEX(configureMutex); if (--configureCount == 0) { /* if no active configurations, shut * everything down */ isconfigged = 0; rc = rf_ShutdownList(&globalShutdown); if (rc) { RF_ERRORMSG1("RAIDFRAME: unable to do global shutdown, rc=%d\n", rc); } rf_shutdown_threadid(); /* * We must wait until now, because the AllocList module * uses the DebugMem module. */ if (rf_memDebug) rf_print_unfreed(); } RF_UNLOCK_MUTEX(configureMutex); }
/* * Called whenever an array is shutdown */ static void rf_UnconfigureArray() { RF_LOCK_LKMGR_MUTEX(configureMutex); if (--configureCount == 0) { /* if no active configurations, shut * everything down */ isconfigged = 0; rf_ShutdownList(&globalShutdown); /* * We must wait until now, because the AllocList module * uses the DebugMem module. */ #if RF_DEBUG_MEM if (rf_memDebug) rf_print_unfreed(); #endif } RF_UNLOCK_LKMGR_MUTEX(configureMutex); }