1 /* $NetBSD: rf_paritylog.h,v 1.4 2001/10/04 15:58:55 oster Exp $ */
3 * Copyright (c) 1995 Carnegie-Mellon University.
6 * Author: William V. Courtright II
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 * Carnegie Mellon requests users of this software to return to
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
29 /* header file for parity log
33 #ifndef _RF__RF_PARITYLOG_H_
34 #define _RF__RF_PARITYLOG_H_
36 #include <dev/raidframe/raidframevar.h>
38 #define RF_DEFAULT_NUM_SECTORS_PER_LOG 64
40 typedef int RF_RegionId_t
;
42 typedef enum RF_ParityRecordType_e
{
46 } RF_ParityRecordType_t
;
48 struct RF_CommonLogData_s
{
49 RF_DECLARE_MUTEX(mutex
) /* protects cnt */
50 int cnt
; /* when 0, time to call wakeFunc */
52 /* int (*wakeFunc)(struct buf *); */
53 int (*wakeFunc
) (RF_DagNode_t
* node
, int status
);
55 RF_AccTraceEntry_t
*tracerec
;
56 RF_Etimer_t startTime
;
58 RF_ParityRecordType_t operation
;
59 RF_CommonLogData_t
*next
;
62 struct RF_ParityLogData_s
{
63 RF_RegionId_t regionID
; /* this struct guaranteed to span a single
65 int bufOffset
; /* offset from common->bufPtr */
66 RF_PhysDiskAddr_t diskAddress
;
67 RF_CommonLogData_t
*common
; /* info shared by one or more
68 * parityLogData structs */
69 RF_ParityLogData_t
*next
;
70 RF_ParityLogData_t
*prev
;
73 struct RF_ParityLogAppendQueue_s
{
74 RF_DECLARE_MUTEX(mutex
)
77 struct RF_ParityLogRecord_s
{
78 RF_PhysDiskAddr_t parityAddr
;
79 RF_ParityRecordType_t operation
;
82 struct RF_ParityLog_s
{
83 RF_RegionId_t regionID
;
86 RF_ParityLogRecord_t
*records
;
91 struct RF_ParityLogQueue_s
{
92 RF_DECLARE_MUTEX(mutex
)
93 RF_ParityLog_t
*parityLogs
;
96 struct RF_RegionBufferQueue_s
{
97 RF_DECLARE_MUTEX(mutex
)
100 int totalBuffers
; /* size of array 'buffers' */
101 int availableBuffers
; /* num available 'buffers' */
102 int emptyBuffersIndex
; /* stick next freed buffer here */
103 int availBuffersIndex
; /* grab next buffer from here */
104 void **buffers
; /* array buffers used to hold parity */
106 #define RF_PLOG_CREATED (1<<0)/* thread is created */
107 #define RF_PLOG_RUNNING (1<<1)/* thread is running */
108 #define RF_PLOG_TERMINATE (1<<2)/* thread is terminated (should exit) */
109 #define RF_PLOG_SHUTDOWN (1<<3)/* thread is aware and exiting/exited */
111 struct RF_ParityLogDiskQueue_s
{
112 RF_DECLARE_MUTEX(mutex
) /* protects all vars in this struct */
113 RF_DECLARE_COND(cond
)
114 int threadState
; /* is thread running, should it shutdown (see
116 RF_ParityLog_t
*flushQueue
; /* list of parity logs to be flushed
118 RF_ParityLog_t
*reintQueue
; /* list of parity logs waiting to be
120 RF_ParityLogData_t
*bufHead
; /* head of FIFO list of log data,
121 * waiting on a buffer */
122 RF_ParityLogData_t
*bufTail
; /* tail of FIFO list of log data,
123 * waiting on a buffer */
124 RF_ParityLogData_t
*reintHead
; /* head of FIFO list of log data,
125 * waiting on reintegration */
126 RF_ParityLogData_t
*reintTail
; /* tail of FIFO list of log data,
127 * waiting on reintegration */
128 RF_ParityLogData_t
*logBlockHead
; /* queue of work, blocked
129 * until a log is available */
130 RF_ParityLogData_t
*logBlockTail
;
131 RF_ParityLogData_t
*reintBlockHead
; /* queue of work, blocked
132 * until reintegration is
134 RF_ParityLogData_t
*reintBlockTail
;
135 RF_CommonLogData_t
*freeCommonList
; /* list of unused common data
137 RF_ParityLogData_t
*freeDataList
; /* list of unused log data
141 struct RF_DiskMap_s
{
142 RF_PhysDiskAddr_t parityAddr
;
143 RF_ParityRecordType_t operation
;
146 struct RF_RegionInfo_s
{
147 RF_DECLARE_MUTEX(mutex
) /* protects: diskCount, diskMap,
148 * loggingEnabled, coreLog */
149 RF_DECLARE_MUTEX(reintMutex
) /* protects: reintInProgress */
150 int reintInProgress
;/* flag used to suspend flushing operations */
151 RF_SectorCount_t capacity
; /* capacity of this region in sectors */
152 RF_SectorNum_t regionStartAddr
; /* starting disk address for this
154 RF_SectorNum_t parityStartAddr
; /* starting disk address for this
156 RF_SectorCount_t numSectorsParity
; /* number of parity sectors
157 * protected by this region */
158 RF_SectorCount_t diskCount
; /* num of sectors written to this
159 * region's disk log */
160 RF_DiskMap_t
*diskMap
; /* in-core map of what's in this region's disk
162 int loggingEnabled
; /* logging enable for this region */
163 RF_ParityLog_t
*coreLog
;/* in-core log for this region */
167 rf_CreateParityLogData(RF_ParityRecordType_t operation
,
168 RF_PhysDiskAddr_t
* pda
, void *bufPtr
, RF_Raid_t
* raidPtr
,
169 int (*wakeFunc
) (RF_DagNode_t
* node
, int status
),
170 void *wakeArg
, RF_AccTraceEntry_t
* tracerec
,
171 RF_Etimer_t startTime
);
172 RF_ParityLogData_t
*rf_SearchAndDequeueParityLogData(RF_Raid_t
* raidPtr
,
173 RF_RegionId_t regionID
, RF_ParityLogData_t
** head
,
174 RF_ParityLogData_t
** tail
, int ignoreLocks
);
175 void rf_ReleaseParityLogs(RF_Raid_t
* raidPtr
, RF_ParityLog_t
* firstLog
);
176 int rf_ParityLogAppend(RF_ParityLogData_t
* logData
, int finish
,
177 RF_ParityLog_t
** incomingLog
, int clearReintFlag
);
178 void rf_EnableParityLogging(RF_Raid_t
* raidPtr
);
180 #endif /* !_RF__RF_PARITYLOG_H_ */