diff options
| author | oster <oster@NetBSD.org> | 1999-01-26 03:56:21 +0000 |
|---|---|---|
| committer | oster <oster@NetBSD.org> | 1999-01-26 03:56:21 +0000 |
| commit | c52883118d004d4ca4042dc2b84f7fb698e0ec19 (patch) | |
| tree | bdc9bbdc562988a31673174c529104fc42ebbb25 /sys/dev/raidframe | |
| parent | a37be855297bc2fc6e328accf45e4a5148efedbb (diff) | |
This stuff is no longer needed. Mostly simulator bits.
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_demo.c | 442 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_diskevent.c | 234 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_diskevent.h | 54 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_heap.c | 243 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_heap.h | 127 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_randmacros.h | 38 |
6 files changed, 0 insertions, 1138 deletions
diff --git a/sys/dev/raidframe/rf_demo.c b/sys/dev/raidframe/rf_demo.c deleted file mode 100644 index fa673858cb3..00000000000 --- a/sys/dev/raidframe/rf_demo.c +++ /dev/null @@ -1,442 +0,0 @@ -/* $NetBSD: rf_demo.c,v 1.2 1999/01/26 02:33:55 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Mark Holland, Khalil Amiri - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/********************************************************************************** - * - * rf_demo.c -- code for supporting demos. this is not actually part of the driver. - * - **********************************************************************************/ - -#include "rf_archs.h" - -#if RF_DEMO > 0 - -#include <stdio.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <strings.h> -#include <unistd.h> -#include <sys/time.h> -#include <signal.h> - -#include "rf_threadstuff.h" -#include "rf_demo.h" -#include "rf_utils.h" -#include "rf_general.h" -#include "rf_options.h" - - -static int doMax = 0; /* currently no way to set this */ - -/**************************************************************************************** - * fault-free demo code - ***************************************************************************************/ - -static int user_iops_meter = -1; -static int disk_iops_meter = -1; -static int max_user_meter = -1; -static int max_disk_meter = -1; -static int recon_pctg_meter = -1; -static int avg_resp_time_meter = -1; -static int recon_time_meter = -1; -static int ff_avg_resp_time_meter = -1; -static int deg_avg_resp_time_meter = -1; -static int recon_avg_resp_time_meter = -1; -static int user_ios_ff=0; -static int user_ios_deg=0; -static int user_ios_recon=0; -static long user_resp_time_sum_ff = 0; -static long user_resp_time_sum_deg = 0; -static long user_resp_time_sum_recon = 0; - -int rf_demo_op_mode = 0; - -RF_DECLARE_STATIC_MUTEX(iops_mutex) -static int user_ios_so_far, disk_ios_so_far, max_user, max_disk; -static long user_resp_time_sum_ms; -static int recon_pctg; -static struct timeval iops_starttime; -#ifndef SIMULATE -static RF_Thread_t update_thread_desc; -#endif /* !SIMULATE */ -static int meter_update_terminate; - -static int meter_update_interval = 2; /* seconds between meter updates */ -static int iops_initialized = 0, recon_initialized = 0; - -static char *demoMeterTags[] = {"FF", "Degr", "Recon"}; - -static int vpos=0; - -static int rf_CreateMeter(char *title, char *geom, char *color); -static void rf_UpdateMeter(int meterid, int value); -static void rf_DestroyMeter(int meterid, int killproc); - -void rf_startup_iops_demo(meter_vpos, C, G) - int meter_vpos; - int C; - int G; -{ - char buf[100], title[100]; - int rc; - - vpos = meter_vpos; - sprintf(buf, "%dx%d-0+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"%s %d/%d User IOs/sec",demoMeterTags[rf_demoMeterTag],C,G); - user_iops_meter = rf_CreateMeter(title, buf, "black"); - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING,vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"%s %d/%d Disk IOs/sec",demoMeterTags[rf_demoMeterTag],C,G); - disk_iops_meter = rf_CreateMeter(title, buf, "red"); - if (doMax) { - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, 2*(RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING),vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"%s %d/%d Avg User IOs/s",demoMeterTags[rf_demoMeterTag],C,G); - max_user_meter = rf_CreateMeter(title, buf, "black"); - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, 3*(RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"%s %d/%d Avg Disk IOs/s",demoMeterTags[rf_demoMeterTag],C,G); - max_disk_meter = rf_CreateMeter(title, buf, "red"); - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, 4*(RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - } else { - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, 2*(RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - } - sprintf(title,"%s %d/%d Avg User Resp Time (ms)",demoMeterTags[rf_demoMeterTag],C,G); - avg_resp_time_meter = rf_CreateMeter(title, buf, "blue"); - rc = rf_mutex_init(&iops_mutex); - if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); - return; - } - user_ios_so_far = disk_ios_so_far = max_user = max_disk = 0; - user_resp_time_sum_ms = 0; - - meter_update_terminate = 0; -#ifndef SIMULATE - pthread_create(&update_thread_desc, raidframe_attr_default, (pthread_startroutine_t)rf_meter_update_thread, NULL); -#endif /* !SIMULATE */ - gettimeofday(&iops_starttime, NULL); - iops_initialized = 1; -} - - -void rf_update_user_stats(resptime) - int resptime; -{ - if (!iops_initialized && !recon_initialized) return; - RF_LOCK_MUTEX(iops_mutex); - user_ios_so_far++; - user_resp_time_sum_ms += resptime; - RF_UNLOCK_MUTEX(iops_mutex); -} - -void rf_update_disk_iops(val) - int val; -{ - if (!iops_initialized) return; - RF_LOCK_MUTEX(iops_mutex); - disk_ios_so_far += val; - RF_UNLOCK_MUTEX(iops_mutex); -} - -void rf_meter_update_thread() -{ - struct timeval now, diff; - int iops, resptime; - float secs; - -#ifndef SIMULATE - while (!meter_update_terminate) { - gettimeofday(&now, NULL); - RF_TIMEVAL_DIFF(&iops_starttime, &now, &diff); - secs = ((float) diff.tv_sec) + ((float) diff.tv_usec)/1000000.0; -#else /* !SIMULATE */ - secs = rf_cur_time; -#endif /* !SIMULATE */ - if (user_iops_meter >= 0) { - iops = (secs!=0.0) ? (int) (((float) user_ios_so_far) / secs) : 0; - rf_UpdateMeter(user_iops_meter, iops); - if (max_user_meter && iops > max_user) {max_user = iops; rf_UpdateMeter(max_user_meter, iops);} - } - - if (disk_iops_meter >= 0) { - iops = (secs!=0.0) ? (int) (((float) disk_ios_so_far) / secs) : 0; - rf_UpdateMeter(disk_iops_meter, iops); - if (max_disk_meter && iops > max_disk) {max_disk = iops; rf_UpdateMeter(max_disk_meter, iops);} - } - - if (recon_pctg_meter >= 0) { - rf_UpdateMeter(recon_pctg_meter, recon_pctg); - } - - switch (rf_demo_op_mode){ - case RF_DEMO_FAULT_FREE: - resptime = (user_ios_so_far != 0) ? user_resp_time_sum_ms / user_ios_so_far : 0; - if (resptime && (ff_avg_resp_time_meter >=0)) - rf_UpdateMeter(ff_avg_resp_time_meter, resptime); - user_ios_ff += user_ios_so_far; - user_resp_time_sum_ff += user_resp_time_sum_ms; - break; - case RF_DEMO_DEGRADED: - resptime = (user_ios_so_far != 0) ? user_resp_time_sum_ms / user_ios_so_far : 0; - if (resptime &&(deg_avg_resp_time_meter >=0)) - rf_UpdateMeter(deg_avg_resp_time_meter, resptime); - user_ios_deg += user_ios_so_far; - user_resp_time_sum_deg += user_resp_time_sum_ms; - case RF_DEMO_RECON: - resptime = (user_ios_so_far != 0) ? user_resp_time_sum_ms / user_ios_so_far : 0; - if (resptime && (recon_avg_resp_time_meter >= 0)) - rf_UpdateMeter(recon_avg_resp_time_meter, resptime); - user_ios_recon += user_ios_so_far; - user_resp_time_sum_recon += user_resp_time_sum_ms; - break; - default: printf("WARNING: demo meter update thread: Invalid op mode! \n"); - } - user_ios_so_far = 0; - user_resp_time_sum_ms = 0; -#ifndef SIMULATE - RF_DELAY_THREAD(1,0); - } -#endif /* !SIMULATE */ -} - -void rf_finish_iops_demo() -{ - long status; - - if (!iops_initialized) return; - iops_initialized = 0; /* make sure any subsequent update calls don't do anything */ - meter_update_terminate = 1; -#ifndef SIMULATE - pthread_join(update_thread_desc, (pthread_addr_t)&status); -#endif /* !SIMULATE */ - - rf_DestroyMeter(user_iops_meter, (doMax) ? 1 : 0); - rf_DestroyMeter(disk_iops_meter, (doMax) ? 1 : 0); - rf_DestroyMeter(max_user_meter, 0); - rf_DestroyMeter(max_disk_meter, 0); - rf_DestroyMeter(avg_resp_time_meter, 0); - rf_mutex_destroy(&iops_mutex); -} - -void rf_demo_update_mode(arg_mode) - int arg_mode; -{ - int hpos; - char buf[100], title[100]; - - switch (rf_demo_op_mode = arg_mode) { - case RF_DEMO_DEGRADED: - - /* freeze fault-free response time meter; create degraded mode meter */ - hpos=rf_demoMeterHpos+2; - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, hpos * (RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"Degraded Mode Average Response Time (ms)",demoMeterTags[rf_demoMeterTag]); - deg_avg_resp_time_meter = rf_CreateMeter(title, buf, "purple"); - rf_UpdateMeter(ff_avg_resp_time_meter, (user_ios_ff == 0)? 0: user_resp_time_sum_ff/user_ios_ff); - break; - - case RF_DEMO_RECON: - - /* freeze degraded mode response time meter; create recon meters */ - hpos = rf_demoMeterHpos+1; - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, hpos * (RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"Reconstruction Average Response Time (ms)",demoMeterTags[rf_demoMeterTag]); - recon_avg_resp_time_meter = rf_CreateMeter(title, buf, "darkgreen"); - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, (rf_demoMeterHpos) * (RF_DEMO_METER_WIDTH + RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"Percent Complete / Recon Time"); - recon_pctg_meter = rf_CreateMeter(title,buf,"red"); - rf_UpdateMeter(deg_avg_resp_time_meter, (user_ios_deg == 0)? 0: user_resp_time_sum_deg/user_ios_deg); - break; - - default: /*do nothing -- finish_recon_demo will update rest of meters */; - } - -} - - -/**************************************************************************************** - * reconstruction demo code - ***************************************************************************************/ - - -void rf_startup_recon_demo(meter_vpos, C, G, init) - int meter_vpos; - int C; - int G; - int init; -{ - char buf[100], title[100]; - int rc; - - vpos = meter_vpos; - if (init) { - /* init demo -- display ff resp time meter */ - sprintf(buf, "%dx%d-%d+%d",RF_DEMO_METER_WIDTH, RF_DEMO_METER_HEIGHT, (rf_demoMeterHpos+3) * (RF_DEMO_METER_WIDTH+RF_DEMO_METER_SPACING), vpos * (RF_DEMO_METER_HEIGHT+RF_DEMO_METER_VSPACE)); - sprintf(title,"%s %d/%d Fault-Free Avg User Resp Time (ms)",demoMeterTags[rf_demoMeterTag],C,G); - ff_avg_resp_time_meter = rf_CreateMeter(title, buf, "blue"); - } - rc = rf_mutex_init(&iops_mutex); - if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); - } - - meter_update_terminate = 0; -#ifndef SIMULATE - pthread_create(&update_thread_desc, raidframe_attr_default, (pthread_startroutine_t)rf_meter_update_thread, NULL); -#endif /* !SIMULATE */ - gettimeofday(&iops_starttime, NULL); - recon_initialized = 1; -} - -void rf_update_recon_meter(val) - int val; -{ - recon_pctg = val; -} - - -void rf_finish_recon_demo(etime) - struct timeval *etime; -{ - long status; - int hpos; - - hpos = rf_demoMeterHpos; - - recon_initialized = 0; /* make sure any subsequent - update calls don't do anything */ - recon_pctg = etime->tv_sec; /* display recon time on meter */ - - rf_UpdateMeter(recon_avg_resp_time_meter, (user_ios_recon == 0)? 0: user_resp_time_sum_recon/user_ios_recon); - - rf_UpdateMeter(recon_pctg_meter, etime->tv_sec); - - meter_update_terminate = 1; - -#ifndef SIMULATE - pthread_join(update_thread_desc, (pthread_addr_t)&status); /* join the meter update thread */ -#endif /* !SIMULATE */ - rf_DestroyMeter(recon_pctg_meter, 0); - rf_DestroyMeter(ff_avg_resp_time_meter, 0); - rf_DestroyMeter(deg_avg_resp_time_meter, 0); - rf_DestroyMeter(recon_avg_resp_time_meter, 0); - rf_mutex_destroy(&iops_mutex); -} - - -/**************************************************************************************** - * meter manipulation code - ***************************************************************************************/ - -#define MAXMETERS 50 -static struct meter_info { int sd; int pid; char name[100]; } minfo[MAXMETERS]; -static int meter_num = 0; - -int rf_ConfigureMeters() -{ - int i; - for (i=0; i<MAXMETERS; i++) - minfo[i].sd = -1; - return(0); -} - -/* forks a dmeter process to create a 4-digit meter window - * "title" appears in the title bar of the meter window - * returns an integer handle (really a socket descriptor) by which - * the new meter can be accessed. - */ -static int rf_CreateMeter(title, geom, color) - char *title; - char *geom; - char *color; -{ - char geombuf[100], *clr; - int sd, pid, i, status; - struct sockaddr sa; - - if (!geom) sprintf(geombuf,"120x40-0+%d", 50*meter_num); else sprintf(geombuf, "%s", geom); - clr = (color) ? color : "black"; - sprintf(minfo[meter_num].name,"/tmp/xm_%d",meter_num); - unlink(minfo[meter_num].name); - - if ( !(pid = fork()) ) { - execlp("dmeter","dmeter","-noscroll","-t",title,"-geometry",geombuf,"-sa",minfo[meter_num].name,"-fg",clr,NULL); - perror("rf_CreateMeter: exec failed"); - return(-1); - } - - sd = socket(AF_UNIX,SOCK_STREAM,0); - sa.sa_family = AF_UNIX; - strcpy(sa.sa_data, minfo[meter_num].name); - for (i=0; i<50; i++) { /* this give us 25 seconds to get the meter running */ - if ( (status = connect(sd,&sa,sizeof(sa))) != -1) break; -#ifdef SIMULATE - sleep (1); -#else /* SIMULATE */ - RF_DELAY_THREAD(0, 500); -#endif /* SIMULATE */ - } - if (status == -1) { - perror("Unable to connect to meter"); - exit(1); - } - minfo[meter_num].sd = sd; - minfo[meter_num].pid = pid; - return(meter_num++); -} - -/* causes the meter to display the given value */ -void rf_UpdateMeter(meterid, value) - int meterid; - int value; -{ - if (write(minfo[meterid].sd, &value, sizeof(int)) < sizeof(int)) { - fprintf(stderr,"Unable to write to meter %d\n",meterid); - } -} - -void rf_DestroyMeter(meterid, killproc) - int meterid; - int killproc; -{ - close(minfo[meterid].sd); - if (killproc) kill(minfo[meterid].pid, SIGTERM); - minfo[meterid].sd = -1; -} - -int rf_ShutdownAllMeters() -{ - int i; - - for (i=0; i<MAXMETERS; i++) - if (minfo[i].sd >= 0) - rf_DestroyMeter(i, 0); - return(0); -} - -#endif /* RF_DEMO > 0 */ diff --git a/sys/dev/raidframe/rf_diskevent.c b/sys/dev/raidframe/rf_diskevent.c deleted file mode 100644 index 23e2fd1adba..00000000000 --- a/sys/dev/raidframe/rf_diskevent.c +++ /dev/null @@ -1,234 +0,0 @@ -/* $NetBSD: rf_diskevent.c,v 1.2 1999/01/26 02:33:56 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Rachad Youssef - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* - * rf_diskevent. - support for disk device, by managing a heap of future events - * adapted from original code by David Kotz, Song Bac Toh (1994) - */ - -#include "rf_types.h" -#include "rf_heap.h" -#include "rf_diskevent.h" -#include "rf_general.h" -#include "rf_dag.h" -#include "rf_diskthreads.h" -#include "rf_states.h" -#include "rf_shutdown.h" - -/* trace printing can be turned on/off in the Makefile */ - -RF_TICS_t rf_cur_time; -static RF_Owner_t cur_owner; -static RF_Heap_t heap; - -static void rf_DDEventShutdown(ignored) - void *ignored; -{ - rf_FreeHeap(heap); -} - -/* ======================================================================== */ -/* DDEventInit - * - * Initialize the event heap. - */ -int rf_DDEventInit(listp) - RF_ShutdownList_t **listp; -{ - int rc; - - heap = rf_InitHeap(RF_HEAP_MAX); /* initialize the heap */ - if (heap == NULL) - return(ENOMEM); - rc = rf_ShutdownCreate(listp, rf_DDEventShutdown, NULL); - if (rc) { - RF_ERRORMSG3("RAIDFRAME: failed creating shutdown event file %s line %d rc=%d\n", - __FILE__, __LINE__, rc); - rf_FreeHeap(heap); - return(rc); - } - rf_cur_time=(RF_TICS_t)0; - return(0); -} - - - -/* DDEventRequest - * - * Put an event request into the event heap. - */ -void rf_DDEventRequest( - RF_TICS_t eventTime, - int (*CompleteFunc)(), - void *argument, - RF_Owner_t owner, - RF_RowCol_t row, - RF_RowCol_t col, - RF_Raid_t *raidPtr, - void *diskid) -{ - RF_HeapData_t *hpdat; - - RF_Malloc(hpdat,sizeof(RF_HeapData_t),(RF_HeapData_t *) ); - if (hpdat == NULL) { - fprintf(stderr, "DDEventRequest: malloc failed\n"); - RF_PANIC(); - } - - hpdat->eventTime = eventTime; - hpdat->CompleteFunc = CompleteFunc; - hpdat->argument = argument; - hpdat->owner = owner; - hpdat->row = row; - hpdat->col = col; - hpdat->raidPtr = raidPtr; - hpdat->diskid = diskid; - rf_AddHeap(heap, hpdat, (hpdat->eventTime)); -} - -void rf_DAGEventRequest( - RF_TICS_t eventTime, - RF_Owner_t owner, - RF_RowCol_t row, - RF_RowCol_t col, - RF_RaidAccessDesc_t *desc, - RF_Raid_t *raidPtr) -{ - RF_HeapData_t *hpdat; - - RF_Malloc(hpdat,sizeof(RF_HeapData_t),(RF_HeapData_t *) ); - if (hpdat == NULL) { - fprintf(stderr, "DDEventRequest: malloc failed\n"); - RF_PANIC(); - } - - hpdat->eventTime = eventTime; - hpdat->CompleteFunc = NULL; - hpdat->argument = NULL; - hpdat->owner = owner; - hpdat->row = row; - hpdat->col = col; - hpdat->desc=desc; - hpdat->raidPtr = raidPtr; - - rf_AddHeap(heap, hpdat, (hpdat->eventTime)); -} - - -/* ------------------------------------------------------------------------ */ -/* @SUBTITLE "Print out the request queue" */ -/* There is only 1 request queue so no argument is needed for this - function */ -void rf_DDPrintRequests() -{ - RF_HeapData_t *Hpdat; - RF_HeapKey_t Hpkey; - RF_Heap_t tempHp; - - printf("Events on heap:\n"); - - tempHp = rf_InitHeap(RF_HEAP_MAX); - while (rf_RemHeap(heap, &Hpdat, &Hpkey) != RF_HEAP_NONE) - { - printf ("at %5g HpKey there is: something for owner %d at disk %d %d\n",Hpkey, - Hpdat->owner,Hpdat->row,Hpdat->col); - rf_AddHeap(tempHp, Hpdat, Hpdat->eventTime); - } - - printf("END heap:\n"); - rf_FreeHeap(heap); /* free the empty old heap */ - - heap = tempHp; /* restore the recycled heap */ -} -/* ------------------------------------------------------------------------ */ - -int rf_ProcessEvent() -{ - RF_HeapData_t *Hpdat; - RF_HeapKey_t Hpkey; - int retcode; - - retcode = rf_RemHeap(heap, &Hpdat, &Hpkey); - - if (retcode==RF_HEAP_FOUND) { - if (rf_eventDebug) { - rf_DDPrintRequests(); - printf ("Now processing: at %5g something for owner %d at disk %d %d\n", - Hpkey, Hpdat->owner, Hpdat->row, Hpdat->col); - } - rf_cur_time=Hpkey; - - rf_SetCurrentOwner(Hpdat->owner); - - if (Hpdat->row>=0) {/* ongoing dag event */ - rf_SetDiskIdle (Hpdat->raidPtr, Hpdat->row, Hpdat->col); - if (Hpdat->diskid != NULL) { - rf_simulator_complete_io(Hpdat->diskid); - } - retcode=(Hpdat->CompleteFunc)(Hpdat->argument,0); - if (retcode==RF_HEAP_FOUND) - (((RF_DagNode_t *) (Hpdat->argument))->dagHdr->cbFunc)(((RF_DagNode_t *) (Hpdat->argument))->dagHdr->cbArg); - RF_Free(Hpdat,sizeof(RF_HeapData_t)); - return(retcode); - } - else { - /* this is a dag event or reconstruction event */ - if (Hpdat->row==RF_DD_DAGEVENT_ROW){ /* dag event */ - rf_ContinueRaidAccess(Hpdat->desc); - retcode = RF_FALSE; - RF_Free(Hpdat,sizeof(RF_HeapData_t)); - return (RF_FALSE); - } - else { - /* recon event */ - retcode=(Hpdat->CompleteFunc)(Hpdat->argument,0); - retcode = RF_FALSE; - RF_Free(Hpdat,sizeof(RF_HeapData_t)); - return (RF_FALSE); - } - } - } - if (rf_eventDebug) - printf("HEAP is empty\n"); - return(RF_DD_NOTHING_THERE); -} - -RF_Owner_t rf_GetCurrentOwner() -{ - return(cur_owner); -} - -void rf_SetCurrentOwner(RF_Owner_t owner) -{ - cur_owner=owner; -} - -RF_TICS_t rf_CurTime() -{ - return(rf_cur_time); -} diff --git a/sys/dev/raidframe/rf_diskevent.h b/sys/dev/raidframe/rf_diskevent.h deleted file mode 100644 index 502243bb918..00000000000 --- a/sys/dev/raidframe/rf_diskevent.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: rf_diskevent.h,v 1.2 1999/01/26 02:33:56 oster Exp $ */ -/* - * rf_diskevent.h - * Adapted from original code by David Kotz (1994) - * - * The disk-device module is event driven. This module keeps the event - * request mechanism, which is based on proteus SimRequests, - * abstracted away from the bulk of the disk device code. - * - * Functions - * DDEventInit - * DDEventRequest - * DDEventPrint - * DDEventCancel - */ - -#ifndef _RF__RF_DISKEVENT_H_ -#define _RF__RF_DISKEVENT_H_ - -#include "rf_types.h" -#include "rf_heap.h" - -#define RF_DD_NOTHING_THERE (-1) -#define RF_DD_DAGEVENT_ROW (-3) -#define RF_DD_DAGEVENT_COL RF_DD_DAGEVENT_ROW - -extern RF_TICS_t rf_cur_time; - -/* - * list of disk-device request types, - * initialized in diskdevice.c, - * used in diskevent.c - */ -typedef void (*RF_DDhandler)(int disk, RF_TICS_t eventTime); -struct RF_dd_handlers_s { - RF_DDhandler handler; /* function implementing this event type */ - char name[20]; /* name of that event type */ -}; -extern struct RF_dd_handlers_s rf_DDhandlers[]; - -int rf_DDEventInit(RF_ShutdownList_t **listp); -void rf_DDEventRequest(RF_TICS_t eventTime, int (*CompleteFunc)(), - void *argument, RF_Owner_t owner, RF_RowCol_t row, RF_RowCol_t col, - RF_Raid_t *raidPtr, void *diskid); -void rf_DAGEventRequest(RF_TICS_t eventTime, RF_Owner_t owner, - RF_RowCol_t row, RF_RowCol_t col, RF_RaidAccessDesc_t *desc, - RF_Raid_t *raidPtr); -void rf_DDPrintRequests(void); -int rf_ProcessEvent(void); -RF_Owner_t rf_GetCurrentOwner(void); -void rf_SetCurrentOwner(RF_Owner_t owner); -RF_TICS_t rf_CurTime(void); - -#endif /* !_RF__RF_DISKEVENT_H_ */ diff --git a/sys/dev/raidframe/rf_heap.c b/sys/dev/raidframe/rf_heap.c deleted file mode 100644 index eccc63635e2..00000000000 --- a/sys/dev/raidframe/rf_heap.c +++ /dev/null @@ -1,243 +0,0 @@ -/* $NetBSD: rf_heap.c,v 1.2 1999/01/26 02:33:58 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Mark Holland - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* We manage a heap of data,key pairs, where the key a simple data type - * and the data is any singular data type. We allow the caller to add - * pairs, remote pairs, peek at the top pair, and do delete/add combinations. - * The latter are efficient because we only reheap once. - * - * David Kotz 1990? and 1993 - * - * Modify the heap to work with events, with the smallest time on the top. - * Song Bac Toh, 1994 - */ - -#include "rf_types.h" -#include "rf_heap.h" -#include "rf_general.h" - -/* return RF_TRUE if the two requests in the heap match */ -#define Matching_REQUESTS(HeapData1, HeapData2) \ -((HeapData1->disk == HeapData2->disk) && \ - (HeapData1->req_code == HeapData2->req_code)) - -/* getting around in the heap */ -/* we don't use the 0th element of the array */ -#define ROOT 1 -#define LCHILD(p) (2 * (p)) -#define RCHILD(p) (2 * (p) + 1) -#define PARENT(c) ((c) / 2) - -/* @SUBTITLE "Debugging macros" */ -/* The following are used for debugging our callers - * as well as internal stuff - */ - -#define CHECK_INVARIANTS 1 - -#ifdef CHECK_INVARIANTS -#define INVARIANT2(x, y) \ -{ \ - if (!(x)) { \ - fprintf(stderr, "INVARIANT false: in \"%s\", line %d\n", \ - __FILE__, __LINE__); \ - fprintf(stderr, (y)); \ - exit(1); \ - } \ -} - -/* -#define INVARIANT3(x, y, z) \ - { \ - if (!(x)) { \ - fprintf(stderr, "INVARIANT false: in \"%s\", line %d\n", \ - __FILE__, __LINE__); \ - fprintf(stderr, (y), (z)); \ - exit(1); \ - } \ - } - */ -#else /* CHECK_INVARIANTS */ -/* #define INVARIANT2(x, y) */ -/* #define INVARIANT3(x, y, z) already defined in modularize.h */ -#endif /* CHECK_INVARIANTS */ - -/**** Rachad, must add to general debug structure */ - - -/* @SUBTITLE "InitHeap: Allocate a new heap" */ -/* might return NULL if no free memory */ -RF_Heap_t rf_InitHeap(int maxsize) -{ - RF_Heap_t hp; - - RF_ASSERT(maxsize > 0); - RF_Malloc(hp, sizeof(struct RF_Heap_s),(RF_Heap_t)); - if (hp == NULL) { - fprintf(stderr, "InitHeap: No memory for heap\n"); - return(NULL); - } - - RF_Malloc(hp->heap,sizeof(RF_HeapEntry_t)*(maxsize+1),(RF_HeapEntry_t *)); - if (hp->heap == NULL) { - fprintf(stderr, "InitHeap: No memory for heap of %d elements\n", - maxsize); - RF_Free(hp,-1); /* -1 means don't cause an error if the size does not match */ - return(NULL); - } - - hp->numheap = 0; - hp->maxsize = maxsize; - - return(hp); -} - -/* @SUBTITLE "FreeHeap: delete a heap" */ -void rf_FreeHeap(RF_Heap_t hp) -{ - if (hp != NULL) { - RF_Free(hp->heap,sizeof(RF_HeapEntry_t)*(hp->maxsize+1)); - RF_Free(hp,sizeof(struct RF_Heap_s)); - } -} - -/* @SUBTITLE "AddHeap: Add an element to the heap" */ -void rf_AddHeap(RF_Heap_t hp, RF_HeapData_t *data, RF_HeapKey_t key) -{ - int node; - - INVARIANT2(hp != NULL, "AddHeap: NULL heap\n"); - INVARIANT2((hp->numheap < RF_HEAP_MAX), "AddHeap: Heap overflowed\n"); - - /* use new space end of heap */ - node = ++(hp->numheap); - - /* and reheap */ - while (node != ROOT && hp->heap[PARENT(node)].key > key) { - hp->heap[node] = hp->heap[PARENT(node)]; - node = PARENT(node); - } - - hp->heap[node].data = data; - hp->heap[node].key = key; -} - -/* @SUBTITLE "TopHeap: Return top element of heap" */ -int rf_TopHeap(RF_Heap_t hp, RF_HeapData_t **data, RF_HeapKey_t *key) -{ - INVARIANT2(hp != NULL, "TopHeap: NULL heap\n"); - - if (hp->numheap > 0) { - if (data) - *data = hp->heap[ROOT].data; - if (key) - *key = hp->heap[ROOT].key; - return(RF_HEAP_FOUND); - } - else { - return(RF_HEAP_NONE); - } -} - -/* @SUBTITLE "RepHeap: Replace top of heap with given element and reheap" */ -/* note that hp->numheap does not change, and should already be > 0 */ -void rf_RepHeap(RF_Heap_t hp, RF_HeapData_t *data, RF_HeapKey_t key) -{ - int node; /* node in heap */ - int lchild, rchild; /* left and right children of node */ - int left, right; /* left and right children exist? */ - int swapped; /* swap was made? */ - RF_HeapEntry_t *heap; /* pointer to the base of this heap array */ - - INVARIANT2(hp != NULL, "RepHeap: NULL heap\n"); - - /* If heap is empty just add this element */ - /* if used properly this case should never come up */ - if (hp->numheap == 0) { - rf_AddHeap(hp, data, key); - - return; - } - - heap = hp->heap; /* cache the heap base pointer */ - - node = ROOT; - - do { - lchild = LCHILD(node); - rchild = RCHILD(node); - left = (lchild <= hp->numheap); - right = (rchild <= hp->numheap); - - /* Both children exist: which is smaller? */ - if (left && right) - if (heap[lchild].key < heap[rchild].key) - right = RF_HEAP_NONE; - else - left = RF_HEAP_NONE; - - /* Now only one of left and right is true. compare it with us */ - if (left && heap[lchild].key < key) { - /* swap with left child */ - heap[node] = heap[lchild]; - node = lchild; - swapped = RF_HEAP_FOUND; - } else if (right && heap[rchild].key < key) { - /* swap with right child */ - heap[node] = heap[rchild]; - node = rchild; - swapped = RF_HEAP_FOUND; - } else - swapped = RF_HEAP_NONE; - } while (swapped); - - /* final resting place for new element */ - heap[node].key = key; - heap[node].data = data; -} - -/* @SUBTITLE "RemHeap: Remove top element and reheap" */ -int rf_RemHeap(RF_Heap_t hp, RF_HeapData_t **data, RF_HeapKey_t *key) -{ - int node; - - /* we don't check hp's validity because TopHeap will do it for us */ - - /* get the top element into data and key, if any */ - if (rf_TopHeap(hp, data, key)) { - /* there was something there, so replace top with last element */ - node = hp->numheap--; - if (hp->numheap > 0) - rf_RepHeap(hp, hp->heap[node].data, hp->heap[node].key); - - return(RF_HEAP_FOUND); - } else{ - return(RF_HEAP_NONE); - } -} - diff --git a/sys/dev/raidframe/rf_heap.h b/sys/dev/raidframe/rf_heap.h deleted file mode 100644 index 3ede3ba532e..00000000000 --- a/sys/dev/raidframe/rf_heap.h +++ /dev/null @@ -1,127 +0,0 @@ -/* $NetBSD: rf_heap.h,v 1.1 1998/11/13 04:20:30 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Mark Holland - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* @TITLE "heap.h - interface to heap management implementation */ -/* We manage a heap of data,key pairs, where the key could be any - * simple data type - * and the data is any pointer data type. We allow the caller to add - * pairs, remote pairs, peek at the top pair, and do delete/add combinations. - * The latter are efficient because we only reheap once. - * - * David Kotz 1990? and 1993 - */ - -/* : - * Log: rf_heap.h,v - * Revision 1.8 1996/05/30 11:29:41 jimz - * Numerous bug fixes. Stripe lock release code disagreed with the taking code - * about when stripes should be locked (I made it consistent: no parity, no lock) - * There was a lot of extra serialization of I/Os which I've removed- a lot of - * it was to calculate values for the cache code, which is no longer with us. - * More types, function, macro cleanup. Added code to properly quiesce the array - * on shutdown. Made a lot of stuff array-specific which was (bogusly) general - * before. Fixed memory allocation, freeing bugs. - * - * Revision 1.7 1996/05/27 18:56:37 jimz - * more code cleanup - * better typing - * compiles in all 3 environments - * - * Revision 1.6 1996/05/23 21:46:35 jimz - * checkpoint in code cleanup (release prep) - * lots of types, function names have been fixed - * - * Revision 1.5 1995/12/01 19:04:07 root - * added copyright info - * - */ - -#ifndef _RF__RF_HEAP_H_ -#define _RF__RF_HEAP_H_ - -#include "rf_types.h" -#include "rf_raid.h" -#include "rf_dag.h" -#include "rf_desc.h" - -#define RF_HEAP_MAX 10240 - -#define RF_HEAP_FOUND 1 -#define RF_HEAP_NONE 0 - -typedef RF_TICS_t RF_HeapKey_t; - -typedef struct RF_HeapData_s RF_HeapData_t; -typedef struct RF_Heap_s *RF_Heap_t; -typedef struct RF_HeapEntry_s RF_HeapEntry_t; - -/* heap data */ -struct RF_HeapData_s { - RF_TICS_t eventTime; - int disk; - int (*CompleteFunc)(); /* function to be called upon completion */ - void *argument; /* argument to be passed to CompleteFunc */ - int owner; /* which task is resposable for this request */ - int row; - int col; /* coordinates of disk */ - RF_Raid_t *raidPtr; - void *diskid; - /* Dag event */ - RF_RaidAccessDesc_t *desc; -}; - -struct RF_HeapEntry_s { - RF_HeapData_t *data; /* the arbitrary data */ - RF_HeapKey_t key; /* key for comparison */ -}; - -struct RF_Heap_s { - RF_HeapEntry_t *heap; /* the heap in use (an array) */ - int numheap; /* number of elements in heap */ - int maxsize; -}; - -/* set up heap to hold maxsize nodes */ -RF_Heap_t rf_InitHeap(int maxsize); - -/* delete a heap data structure */ -void rf_FreeHeap(RF_Heap_t hp); - -/* add the element to the heap */ -void rf_AddHeap(RF_Heap_t hp, RF_HeapData_t *data, RF_HeapKey_t key); - -/* return top of the heap, without removing it from heap (FALSE if empty) */ -int rf_TopHeap(RF_Heap_t hp, RF_HeapData_t **data, RF_HeapKey_t *key); - -/* replace the heap's top item with a new item, and reheap */ -void rf_RepHeap(RF_Heap_t hp, RF_HeapData_t *data, RF_HeapKey_t key); - -/* remove the heap's top item, if any (FALSE if empty heap) */ -int rf_RemHeap(RF_Heap_t hp, RF_HeapData_t **data, RF_HeapKey_t *key); - -#endif /* !_RF__RF_HEAP_H_ */ diff --git a/sys/dev/raidframe/rf_randmacros.h b/sys/dev/raidframe/rf_randmacros.h deleted file mode 100644 index 7a07f302b8f..00000000000 --- a/sys/dev/raidframe/rf_randmacros.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: rf_randmacros.h,v 1.2 1999/01/26 02:34:01 oster Exp $ */ -/* - * Copyright (c) 1995 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Mark Holland - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -/* rf_randmacros.h - * some macros to simplify using random in a multithreaded environment - */ - - -#ifndef _RF__RF_RANDMACROS_H_ -#define _RF__RF_RANDMACROS_H_ - - -#endif /* !_RF__RF_RANDMACROS_H_ */ |
