Annotation of sys/dev/raidframe/rf_paritylog.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: rf_paritylog.h,v 1.3 2002/12/16 07:01:04 tdeval Exp $ */
2: /* $NetBSD: rf_paritylog.h,v 1.3 1999/02/05 00:06:14 oster Exp $ */
3:
4: /*
5: * Copyright (c) 1995 Carnegie-Mellon University.
6: * All rights reserved.
7: *
8: * Author: William V. Courtright II
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: * Header file for parity log.
33: */
34:
35: #ifndef _RF__RF_PARITYLOG_H_
36: #define _RF__RF_PARITYLOG_H_
37:
38: #include "rf_types.h"
39:
40: #define RF_DEFAULT_NUM_SECTORS_PER_LOG 64
41:
42: typedef int RF_RegionId_t;
43:
44: typedef enum RF_ParityRecordType_e {
45: RF_STOP,
46: RF_UPDATE,
47: RF_OVERWRITE
48: } RF_ParityRecordType_t;
49:
50: struct RF_CommonLogData_s {
51: RF_DECLARE_MUTEX(mutex); /* Protects cnt. */
52: int cnt; /* When 0, time to call wakeFunc. */
53: RF_Raid_t *raidPtr;
54: /* int (*wakeFunc) (struct buf *); */
55: int (*wakeFunc) (RF_DagNode_t *, int);
56: void *wakeArg;
57: RF_AccTraceEntry_t *tracerec;
58: RF_Etimer_t startTime;
59: caddr_t bufPtr;
60: RF_ParityRecordType_t operation;
61: RF_CommonLogData_t *next;
62: };
63:
64: struct RF_ParityLogData_s {
65: RF_RegionId_t regionID; /*
66: * This struct guaranteed to
67: * span a single region.
68: */
69: int bufOffset; /*
70: * Offset from common->bufPtr.
71: */
72: RF_PhysDiskAddr_t diskAddress;
73: RF_CommonLogData_t *common; /*
74: * Info shared by one or more
75: * parityLogData structs.
76: */
77: RF_ParityLogData_t *next;
78: RF_ParityLogData_t *prev;
79: };
80:
81: struct RF_ParityLogAppendQueue_s {
82: RF_DECLARE_MUTEX(mutex);
83: };
84:
85: struct RF_ParityLogRecord_s {
86: RF_PhysDiskAddr_t parityAddr;
87: RF_ParityRecordType_t operation;
88: };
89:
90: struct RF_ParityLog_s {
91: RF_RegionId_t regionID;
92: int numRecords;
93: int diskOffset;
94: RF_ParityLogRecord_t *records;
95: caddr_t bufPtr;
96: RF_ParityLog_t *next;
97: };
98:
99: struct RF_ParityLogQueue_s {
100: RF_DECLARE_MUTEX(mutex);
101: RF_ParityLog_t *parityLogs;
102: };
103:
104: struct RF_RegionBufferQueue_s {
105: RF_DECLARE_MUTEX(mutex);
106: RF_DECLARE_COND(cond);
107: int bufferSize;
108: int totalBuffers; /* Size of array 'buffers'. */
109: int availableBuffers; /* Num available 'buffers'. */
110: int emptyBuffersIndex; /* Stick next freed buffer here. */
111: int availBuffersIndex; /* Grab next buffer from here. */
112: caddr_t *buffers; /* Array buffers used to hold parity. */
113: };
114: #define RF_PLOG_CREATED (1<<0) /* Thread is created. */
115: #define RF_PLOG_RUNNING (1<<1) /* Thread is running. */
116: #define RF_PLOG_TERMINATE (1<<2) /* Thread is terminated (should exit).*/
117: #define RF_PLOG_SHUTDOWN (1<<3) /* Thread is aware and exiting/exited.*/
118:
119: struct RF_ParityLogDiskQueue_s {
120: RF_DECLARE_MUTEX(mutex); /* Protects all vars in this struct. */
121: RF_DECLARE_COND(cond);
122: int threadState; /*
123: * Is thread running, should it
124: * shutdown ? (see above)
125: */
126: RF_ParityLog_t *flushQueue; /*
127: * List of parity logs to be
128: * flushed to log disk.
129: */
130: RF_ParityLog_t *reintQueue; /*
131: * List of parity logs waiting
132: * to be reintegrated.
133: */
134: RF_ParityLogData_t *bufHead; /*
135: * Head of FIFO list of log
136: * data, waiting on a buffer.
137: */
138: RF_ParityLogData_t *bufTail; /*
139: * Tail of FIFO list of log
140: * data, waiting on a buffer.
141: */
142: RF_ParityLogData_t *reintHead; /*
143: * Head of FIFO list of
144: * log data, waiting on
145: * reintegration.
146: */
147: RF_ParityLogData_t *reintTail; /*
148: * Tail of FIFO list of
149: * log data, waiting on
150: * reintegration.
151: */
152: RF_ParityLogData_t *logBlockHead; /*
153: * Queue of work, blocked
154: * until a log is available.
155: */
156: RF_ParityLogData_t *logBlockTail;
157: RF_ParityLogData_t *reintBlockHead;/*
158: * Queue of work, blocked
159: * until reintegration is
160: * complete.
161: */
162: RF_ParityLogData_t *reintBlockTail;
163: RF_CommonLogData_t *freeCommonList;/*
164: * List of unused common
165: * data structs.
166: */
167: RF_ParityLogData_t *freeDataList; /*
168: * List of unused log
169: * data structs.
170: */
171: };
172:
173: struct RF_DiskMap_s {
174: RF_PhysDiskAddr_t parityAddr;
175: RF_ParityRecordType_t operation;
176: };
177:
178: struct RF_RegionInfo_s {
179: RF_DECLARE_MUTEX(mutex); /*
180: * Protects: diskCount, diskMap,
181: * loggingEnabled, coreLog.
182: */
183: RF_DECLARE_MUTEX(reintMutex); /* Protects: reintInProgress. */
184: int reintInProgress; /*
185: * Flag used to suspend flushing
186: * operations.
187: */
188: RF_SectorCount_t capacity; /*
189: * Capacity of this region
190: * in sectors.
191: */
192: RF_SectorNum_t regionStartAddr; /*
193: * Starting disk address for
194: * this region.
195: */
196: RF_SectorNum_t parityStartAddr; /*
197: * Starting disk address for
198: * this region.
199: */
200: RF_SectorCount_t numSectorsParity; /*
201: * Number of parity sectors
202: * protected by this region.
203: */
204: RF_SectorCount_t diskCount; /*
205: * Num of sectors written to
206: * this region's disk log.
207: */
208: RF_DiskMap_t *diskMap; /*
209: * In-core map of what's in
210: * this region's disk log.
211: */
212: int loggingEnabled; /*
213: * Logging enable for this
214: * region.
215: */
216: RF_ParityLog_t *coreLog; /*
217: * In-core log for this region.
218: */
219: };
220:
221: RF_ParityLogData_t *rf_CreateParityLogData(RF_ParityRecordType_t,
222: RF_PhysDiskAddr_t *, caddr_t, RF_Raid_t *,
223: int (*) (RF_DagNode_t *, int), void *,
224: RF_AccTraceEntry_t *, RF_Etimer_t);
225: RF_ParityLogData_t *rf_SearchAndDequeueParityLogData(RF_Raid_t *, RF_RegionId_t,
226: RF_ParityLogData_t **, RF_ParityLogData_t **, int);
227: void rf_ReleaseParityLogs(RF_Raid_t *, RF_ParityLog_t *);
228: int rf_ParityLogAppend(RF_ParityLogData_t *, int, RF_ParityLog_t **, int);
229: void rf_EnableParityLogging(RF_Raid_t *);
230:
231: #endif /* !_RF__RF_PARITYLOG_H_ */
CVSweb