1 /* $OpenBSD: rf_cvscan.h,v 1.3 2002/12/16 07:01:03 tdeval Exp $ */ 2 /* $NetBSD: rf_cvscan.h,v 1.3 1999/02/05 00:06:07 oster Exp $ */ 3 4 /* 5 * Copyright (c) 1995 Carnegie-Mellon University. 6 * All rights reserved. 7 * 8 * Author: Mark Holland 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 */ 30 31 /* 32 * Disk scheduling by CVSCAN( N, r ) 33 * 34 * Given a set of requests, partition them into one set on each 35 * side of the current arm position. The trick is to pick which 36 * side you are going to service next; once a side is picked you will 37 * service the closest request. 38 * Let there be n1 requests on one side and n2 requests on the other 39 * side. If one of n1 or n2 is zero, select the other side. 40 * If both n1 and n2 are nonzero, select a "range" for examination 41 * that is N' = min( n1, n2, N ). Average the distance from the 42 * current position to the nearest N' requests on each side giving 43 * d1 and d2. 44 * Suppose the last decision was to move toward set 2, then the 45 * current direction is toward set 2, and you will only switch to set 46 * 1 if d1+R < d2 where R is r*(total number of cylinders), r in [0,1]. 47 * 48 * I extend this by applying only to the set of requests that all 49 * share the same, highest priority level. 50 */ 51 52 #ifndef _RF__RF_CVSCAN_H_ 53 #define _RF__RF_CVSCAN_H_ 54 55 #include "rf_diskqueue.h" 56 57 typedef enum RF_CvscanArmDir_e { 58 rf_cvscan_LEFT, 59 rf_cvscan_RIGHT 60 } RF_CvscanArmDir_t; 61 62 typedef struct RF_CvscanHeader_s { 63 long range_for_avg; /* CVSCAN param N */ 64 long change_penalty; /* CVSCAN param R */ 65 RF_CvscanArmDir_t direction; 66 RF_SectorNum_t cur_block; 67 int nxt_priority; 68 RF_DiskQueueData_t *left; 69 int left_cnt; 70 RF_DiskQueueData_t *right; 71 int right_cnt; 72 RF_DiskQueueData_t *burner; 73 } RF_CvscanHeader_t; 74 75 int rf_CvscanConfigure(void); 76 void *rf_CvscanCreate(RF_SectorCount_t, RF_AllocListElem_t *, 77 RF_ShutdownList_t **); 78 void rf_CvscanEnqueue(void *, RF_DiskQueueData_t *, int); 79 RF_DiskQueueData_t *rf_CvscanDequeue(void *); 80 RF_DiskQueueData_t *rf_CvscanPeek(void *); 81 int rf_CvscanPromote(void *, RF_StripeNum_t, RF_ReconUnitNum_t); 82 83 #endif /* !_RF__RF_CVSCAN_H_ */