rf_paritylog.h revision 1.1 1 1.1 oster /* $NetBSD: rf_paritylog.h,v 1.1 1998/11/13 04:20:31 oster Exp $ */
2 1.1 oster /*
3 1.1 oster * Copyright (c) 1995 Carnegie-Mellon University.
4 1.1 oster * All rights reserved.
5 1.1 oster *
6 1.1 oster * Author: William V. Courtright II
7 1.1 oster *
8 1.1 oster * Permission to use, copy, modify and distribute this software and
9 1.1 oster * its documentation is hereby granted, provided that both the copyright
10 1.1 oster * notice and this permission notice appear in all copies of the
11 1.1 oster * software, derivative works or modified versions, and any portions
12 1.1 oster * thereof, and that both notices appear in supporting documentation.
13 1.1 oster *
14 1.1 oster * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 1.1 oster * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 1.1 oster * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 1.1 oster *
18 1.1 oster * Carnegie Mellon requests users of this software to return to
19 1.1 oster *
20 1.1 oster * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 1.1 oster * School of Computer Science
22 1.1 oster * Carnegie Mellon University
23 1.1 oster * Pittsburgh PA 15213-3890
24 1.1 oster *
25 1.1 oster * any improvements or extensions that they make and grant Carnegie the
26 1.1 oster * rights to redistribute these changes.
27 1.1 oster */
28 1.1 oster
29 1.1 oster /* header file for parity log
30 1.1 oster *
31 1.1 oster * :
32 1.1 oster * Log: rf_paritylog.h,v
33 1.1 oster * Revision 1.21 1996/07/17 21:00:58 jimz
34 1.1 oster * clean up timer interface, tracing
35 1.1 oster *
36 1.1 oster * Revision 1.20 1996/07/15 17:22:18 jimz
37 1.1 oster * nit-pick code cleanup
38 1.1 oster * resolve stdlib problems on DEC OSF
39 1.1 oster *
40 1.1 oster * Revision 1.19 1996/06/11 10:17:57 jimz
41 1.1 oster * definitions and run state for parity logging thread
42 1.1 oster *
43 1.1 oster * Revision 1.18 1996/06/07 21:33:04 jimz
44 1.1 oster * begin using consistent types for sector numbers,
45 1.1 oster * stripe numbers, row+col numbers, recon unit numbers
46 1.1 oster *
47 1.1 oster * Revision 1.17 1996/06/05 18:06:02 jimz
48 1.1 oster * Major code cleanup. The Great Renaming is now done.
49 1.1 oster * Better modularity. Better typing. Fixed a bunch of
50 1.1 oster * synchronization bugs. Made a lot of global stuff
51 1.1 oster * per-desc or per-array. Removed dead code.
52 1.1 oster *
53 1.1 oster * Revision 1.16 1996/06/02 17:31:48 jimz
54 1.1 oster * Moved a lot of global stuff into array structure, where it belongs.
55 1.1 oster * Fixed up paritylogging, pss modules in this manner. Some general
56 1.1 oster * code cleanup. Removed lots of dead code, some dead files.
57 1.1 oster *
58 1.1 oster * Revision 1.15 1996/05/31 22:26:54 jimz
59 1.1 oster * fix a lot of mapping problems, memory allocation problems
60 1.1 oster * found some weird lock issues, fixed 'em
61 1.1 oster * more code cleanup
62 1.1 oster *
63 1.1 oster * Revision 1.14 1996/05/30 11:29:41 jimz
64 1.1 oster * Numerous bug fixes. Stripe lock release code disagreed with the taking code
65 1.1 oster * about when stripes should be locked (I made it consistent: no parity, no lock)
66 1.1 oster * There was a lot of extra serialization of I/Os which I've removed- a lot of
67 1.1 oster * it was to calculate values for the cache code, which is no longer with us.
68 1.1 oster * More types, function, macro cleanup. Added code to properly quiesce the array
69 1.1 oster * on shutdown. Made a lot of stuff array-specific which was (bogusly) general
70 1.1 oster * before. Fixed memory allocation, freeing bugs.
71 1.1 oster *
72 1.1 oster * Revision 1.13 1996/05/23 00:33:23 jimz
73 1.1 oster * code cleanup: move all debug decls to rf_options.c, all extern
74 1.1 oster * debug decls to rf_options.h, all debug vars preceded by rf_
75 1.1 oster *
76 1.1 oster * Revision 1.12 1996/05/18 19:51:34 jimz
77 1.1 oster * major code cleanup- fix syntax, make some types consistent,
78 1.1 oster * add prototypes, clean out dead code, et cetera
79 1.1 oster *
80 1.1 oster * Revision 1.11 1995/12/06 20:54:58 wvcii
81 1.1 oster * added prototyping
82 1.1 oster *
83 1.1 oster * Revision 1.10 1995/11/30 16:05:50 wvcii
84 1.1 oster * added copyright info
85 1.1 oster *
86 1.1 oster * Revision 1.9 1995/10/07 05:09:27 wvcii
87 1.1 oster * removed #define BYTESPERSECTOR 512
88 1.1 oster *
89 1.1 oster * Revision 1.8 1995/09/06 19:27:52 wvcii
90 1.1 oster * added startTime to commonLogData
91 1.1 oster *
92 1.1 oster * Revision 1.7 1995/07/07 00:13:42 wvcii
93 1.1 oster * this version free from deadlock, fails parity verification
94 1.1 oster *
95 1.1 oster */
96 1.1 oster
97 1.1 oster #ifndef _RF__RF_PARITYLOG_H_
98 1.1 oster #define _RF__RF_PARITYLOG_H_
99 1.1 oster
100 1.1 oster #include "rf_types.h"
101 1.1 oster
102 1.1 oster #define RF_DEFAULT_NUM_SECTORS_PER_LOG 64
103 1.1 oster
104 1.1 oster typedef int RF_RegionId_t;
105 1.1 oster
106 1.1 oster typedef enum RF_ParityRecordType_e {
107 1.1 oster RF_STOP,
108 1.1 oster RF_UPDATE,
109 1.1 oster RF_OVERWRITE
110 1.1 oster } RF_ParityRecordType_t;
111 1.1 oster
112 1.1 oster struct RF_CommonLogData_s {
113 1.1 oster RF_DECLARE_MUTEX(mutex) /* protects cnt */
114 1.1 oster int cnt; /* when 0, time to call wakeFunc */
115 1.1 oster RF_Raid_t *raidPtr;
116 1.1 oster /* int (*wakeFunc)(struct buf *); */
117 1.1 oster int (*wakeFunc)(RF_DagNode_t *node, int status);
118 1.1 oster void *wakeArg;
119 1.1 oster RF_AccTraceEntry_t *tracerec;
120 1.1 oster RF_Etimer_t startTime;
121 1.1 oster caddr_t bufPtr;
122 1.1 oster RF_ParityRecordType_t operation;
123 1.1 oster RF_CommonLogData_t *next;
124 1.1 oster };
125 1.1 oster
126 1.1 oster struct RF_ParityLogData_s {
127 1.1 oster RF_RegionId_t regionID; /* this struct guaranteed to span a single region */
128 1.1 oster int bufOffset; /* offset from common->bufPtr */
129 1.1 oster RF_PhysDiskAddr_t diskAddress;
130 1.1 oster RF_CommonLogData_t *common; /* info shared by one or more parityLogData structs */
131 1.1 oster RF_ParityLogData_t *next;
132 1.1 oster RF_ParityLogData_t *prev;
133 1.1 oster };
134 1.1 oster
135 1.1 oster struct RF_ParityLogAppendQueue_s {
136 1.1 oster RF_DECLARE_MUTEX(mutex)
137 1.1 oster };
138 1.1 oster
139 1.1 oster struct RF_ParityLogRecord_s {
140 1.1 oster RF_PhysDiskAddr_t parityAddr;
141 1.1 oster RF_ParityRecordType_t operation;
142 1.1 oster };
143 1.1 oster
144 1.1 oster struct RF_ParityLog_s {
145 1.1 oster RF_RegionId_t regionID;
146 1.1 oster int numRecords;
147 1.1 oster int diskOffset;
148 1.1 oster RF_ParityLogRecord_t *records;
149 1.1 oster caddr_t bufPtr;
150 1.1 oster RF_ParityLog_t *next;
151 1.1 oster };
152 1.1 oster
153 1.1 oster struct RF_ParityLogQueue_s {
154 1.1 oster RF_DECLARE_MUTEX(mutex)
155 1.1 oster RF_ParityLog_t *parityLogs;
156 1.1 oster };
157 1.1 oster
158 1.1 oster struct RF_RegionBufferQueue_s {
159 1.1 oster RF_DECLARE_MUTEX(mutex)
160 1.1 oster RF_DECLARE_COND(cond)
161 1.1 oster int bufferSize;
162 1.1 oster int totalBuffers; /* size of array 'buffers' */
163 1.1 oster int availableBuffers; /* num available 'buffers' */
164 1.1 oster int emptyBuffersIndex; /* stick next freed buffer here */
165 1.1 oster int availBuffersIndex; /* grab next buffer from here */
166 1.1 oster caddr_t *buffers; /* array buffers used to hold parity */
167 1.1 oster };
168 1.1 oster
169 1.1 oster #define RF_PLOG_CREATED (1<<0) /* thread is created */
170 1.1 oster #define RF_PLOG_RUNNING (1<<1) /* thread is running */
171 1.1 oster #define RF_PLOG_TERMINATE (1<<2) /* thread is terminated (should exit) */
172 1.1 oster #define RF_PLOG_SHUTDOWN (1<<3) /* thread is aware and exiting/exited */
173 1.1 oster
174 1.1 oster struct RF_ParityLogDiskQueue_s {
175 1.1 oster RF_DECLARE_MUTEX(mutex) /* protects all vars in this struct */
176 1.1 oster RF_DECLARE_COND(cond)
177 1.1 oster int threadState; /* is thread running, should it shutdown (see above) */
178 1.1 oster RF_ParityLog_t *flushQueue; /* list of parity logs to be flushed to log disk */
179 1.1 oster RF_ParityLog_t *reintQueue; /* list of parity logs waiting to be reintegrated */
180 1.1 oster RF_ParityLogData_t *bufHead; /* head of FIFO list of log data, waiting on a buffer */
181 1.1 oster RF_ParityLogData_t *bufTail; /* tail of FIFO list of log data, waiting on a buffer */
182 1.1 oster RF_ParityLogData_t *reintHead; /* head of FIFO list of log data, waiting on reintegration */
183 1.1 oster RF_ParityLogData_t *reintTail; /* tail of FIFO list of log data, waiting on reintegration */
184 1.1 oster RF_ParityLogData_t *logBlockHead; /* queue of work, blocked until a log is available */
185 1.1 oster RF_ParityLogData_t *logBlockTail;
186 1.1 oster RF_ParityLogData_t *reintBlockHead; /* queue of work, blocked until reintegration is complete */
187 1.1 oster RF_ParityLogData_t *reintBlockTail;
188 1.1 oster RF_CommonLogData_t *freeCommonList; /* list of unused common data structs */
189 1.1 oster RF_ParityLogData_t *freeDataList; /* list of unused log data structs */
190 1.1 oster };
191 1.1 oster
192 1.1 oster struct RF_DiskMap_s {
193 1.1 oster RF_PhysDiskAddr_t parityAddr;
194 1.1 oster RF_ParityRecordType_t operation;
195 1.1 oster };
196 1.1 oster
197 1.1 oster struct RF_RegionInfo_s {
198 1.1 oster RF_DECLARE_MUTEX(mutex) /* protects: diskCount, diskMap, loggingEnabled, coreLog */
199 1.1 oster RF_DECLARE_MUTEX(reintMutex) /* protects: reintInProgress */
200 1.1 oster int reintInProgress; /* flag used to suspend flushing operations */
201 1.1 oster RF_SectorCount_t capacity; /* capacity of this region in sectors */
202 1.1 oster RF_SectorNum_t regionStartAddr; /* starting disk address for this region */
203 1.1 oster RF_SectorNum_t parityStartAddr; /* starting disk address for this region */
204 1.1 oster RF_SectorCount_t numSectorsParity; /* number of parity sectors protected by this region */
205 1.1 oster RF_SectorCount_t diskCount; /* num of sectors written to this region's disk log */
206 1.1 oster RF_DiskMap_t *diskMap; /* in-core map of what's in this region's disk log */
207 1.1 oster int loggingEnabled; /* logging enable for this region */
208 1.1 oster RF_ParityLog_t *coreLog; /* in-core log for this region */
209 1.1 oster };
210 1.1 oster
211 1.1 oster RF_ParityLogData_t *rf_CreateParityLogData(RF_ParityRecordType_t operation,
212 1.1 oster RF_PhysDiskAddr_t *pda, caddr_t bufPtr, RF_Raid_t *raidPtr,
213 1.1 oster int (*wakeFunc)(RF_DagNode_t *node, int status),
214 1.1 oster void *wakeArg, RF_AccTraceEntry_t *tracerec,
215 1.1 oster RF_Etimer_t startTime);
216 1.1 oster RF_ParityLogData_t *rf_SearchAndDequeueParityLogData(RF_Raid_t *raidPtr,
217 1.1 oster RF_RegionId_t regionID, RF_ParityLogData_t **head,
218 1.1 oster RF_ParityLogData_t **tail, int ignoreLocks);
219 1.1 oster void rf_ReleaseParityLogs(RF_Raid_t *raidPtr, RF_ParityLog_t *firstLog);
220 1.1 oster int rf_ParityLogAppend(RF_ParityLogData_t *logData, int finish,
221 1.1 oster RF_ParityLog_t **incomingLog, int clearReintFlag);
222 1.1 oster void rf_EnableParityLogging(RF_Raid_t *raidPtr);
223 1.1 oster
224 1.1 oster #endif /* !_RF__RF_PARITYLOG_H_ */
225