rf_psstatus.h revision 1.1 1 /* $NetBSD: rf_psstatus.h,v 1.1 1998/11/13 04:20:32 oster Exp $ */
2 /*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Mark Holland
7 *
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.
13 *
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.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29 /*****************************************************************************
30 *
31 * psstatus.h
32 *
33 * The reconstruction code maintains a bunch of status related to the parity
34 * stripes that are currently under reconstruction. This header file defines
35 * the status structures.
36 *
37 *****************************************************************************/
38
39 /* :
40 * Log: rf_psstatus.h,v
41 * Revision 1.16 1996/06/10 11:55:47 jimz
42 * Straightened out some per-array/not-per-array distinctions, fixed
43 * a couple bugs related to confusion. Added shutdown lists. Removed
44 * layout shutdown function (now subsumed by shutdown lists).
45 *
46 * Revision 1.15 1996/06/07 22:26:27 jimz
47 * type-ify which_ru (RF_ReconUnitNum_t)
48 *
49 * Revision 1.14 1996/06/07 21:33:04 jimz
50 * begin using consistent types for sector numbers,
51 * stripe numbers, row+col numbers, recon unit numbers
52 *
53 * Revision 1.13 1996/06/05 18:06:02 jimz
54 * Major code cleanup. The Great Renaming is now done.
55 * Better modularity. Better typing. Fixed a bunch of
56 * synchronization bugs. Made a lot of global stuff
57 * per-desc or per-array. Removed dead code.
58 *
59 * Revision 1.12 1996/06/02 17:31:48 jimz
60 * Moved a lot of global stuff into array structure, where it belongs.
61 * Fixed up paritylogging, pss modules in this manner. Some general
62 * code cleanup. Removed lots of dead code, some dead files.
63 *
64 * Revision 1.11 1996/05/24 22:17:04 jimz
65 * continue code + namespace cleanup
66 * typed a bunch of flags
67 *
68 * Revision 1.10 1996/05/23 21:46:35 jimz
69 * checkpoint in code cleanup (release prep)
70 * lots of types, function names have been fixed
71 *
72 * Revision 1.9 1996/05/23 00:33:23 jimz
73 * code cleanup: move all debug decls to rf_options.c, all extern
74 * debug decls to rf_options.h, all debug vars preceded by rf_
75 *
76 * Revision 1.8 1996/05/18 19:51:34 jimz
77 * major code cleanup- fix syntax, make some types consistent,
78 * add prototypes, clean out dead code, et cetera
79 *
80 * Revision 1.7 1995/11/30 16:17:28 wvcii
81 * added copyright info
82 *
83 */
84
85 #ifndef _RF__RF_PSSTATUS_H_
86 #define _RF__RF_PSSTATUS_H_
87
88 #include "rf_types.h"
89 #include "rf_threadstuff.h"
90 #include "rf_callback.h"
91
92 #define RF_PS_MAX_BUFS 10 /* max number of bufs we'll accumulate before we do an XOR */
93
94 #define RF_PSS_DEFAULT_TABLESIZE 200
95
96 /*
97 * Macros to acquire/release the mutex lock on a parity stripe status
98 * descriptor. Note that we use just one lock for the whole hash chain.
99 */
100 #define RF_HASH_PSID(_raid_,_psid_) ( (_psid_) % ((_raid_)->pssTableSize) ) /* simple hash function */
101 #define RF_LOCK_PSS_MUTEX(_raidPtr, _row, _psid) \
102 RF_LOCK_MUTEX((_raidPtr)->reconControl[_row]->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex)
103 #define RF_UNLOCK_PSS_MUTEX(_raidPtr, _row, _psid) \
104 RF_UNLOCK_MUTEX((_raidPtr)->reconControl[_row]->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex)
105
106 struct RF_ReconParityStripeStatus_s {
107 RF_StripeNum_t parityStripeID; /* the parity stripe ID */
108 RF_ReconUnitNum_t which_ru; /* which reconstruction unit with the indicated parity stripe */
109 RF_PSSFlags_t flags; /* flags indicating various conditions */
110 void *rbuf; /* this is the accumulating xor sum */
111 void *writeRbuf; /* DEBUG ONLY: a pointer to the rbuf after it has filled & been sent to disk */
112 void *rbufsForXor[RF_PS_MAX_BUFS]; /* these are buffers still to be xored into the accumulating sum */
113 int xorBufCount; /* num buffers waiting to be xored */
114 int blockCount; /* count of # proc that have blocked recon on this parity stripe */
115 char *issued; /* issued[i]==1 <=> column i has already issued a read request for the indicated RU */
116 RF_CallbackDesc_t *procWaitList; /* list of user procs waiting for recon to be done */
117 RF_CallbackDesc_t *blockWaitList;/* list of disks blocked waiting for user write to complete */
118 RF_CallbackDesc_t *bufWaitList; /* list of disks blocked waiting to acquire a buffer for this RU */
119 RF_ReconParityStripeStatus_t *next;
120 };
121
122 struct RF_PSStatusHeader_s {
123 RF_DECLARE_MUTEX(mutex) /* mutex for this hash chain */
124 RF_ReconParityStripeStatus_t *chain; /* the hash chain */
125 };
126
127 /* masks for the "flags" field above */
128 #define RF_PSS_NONE 0x00000000 /* no flags */
129 #define RF_PSS_UNDER_RECON 0x00000001 /* this parity stripe is currently under reconstruction */
130 #define RF_PSS_FORCED_ON_WRITE 0x00000002 /* indicates a recon was forced due to a user-write operation */
131 #define RF_PSS_FORCED_ON_READ 0x00000004 /* ditto for read, but not currently implemented */
132 #define RF_PSS_RECON_BLOCKED 0x00000008 /* reconstruction is currently blocked due to a pending user I/O */
133 #define RF_PSS_CREATE 0x00000010 /* tells LookupRUStatus to create the entry */
134 #define RF_PSS_BUFFERWAIT 0x00000020 /* someone is waiting for a buffer for this RU */
135
136 int rf_ConfigurePSStatus(RF_ShutdownList_t **listp, RF_Raid_t *raidPtr,
137 RF_Config_t *cfgPtr);
138
139 RF_PSStatusHeader_t *rf_MakeParityStripeStatusTable(RF_Raid_t *raidPtr);
140 void rf_FreeParityStripeStatusTable(RF_Raid_t *raidPtr,
141 RF_PSStatusHeader_t *pssTable);
142 RF_ReconParityStripeStatus_t *rf_LookupRUStatus(RF_Raid_t *raidPtr,
143 RF_PSStatusHeader_t *pssTable, RF_StripeNum_t psID,
144 RF_ReconUnitNum_t which_ru, RF_PSSFlags_t flags, int *created);
145 void rf_PSStatusDelete(RF_Raid_t *raidPtr, RF_PSStatusHeader_t *pssTable,
146 RF_ReconParityStripeStatus_t *pssPtr);
147 void rf_RemoveFromActiveReconTable(RF_Raid_t *raidPtr, RF_RowCol_t row,
148 RF_StripeNum_t psid, RF_ReconUnitNum_t which_ru);
149 RF_ReconParityStripeStatus_t *rf_AllocPSStatus(RF_Raid_t *raidPtr);
150 void rf_FreePSStatus(RF_Raid_t *raidPtr, RF_ReconParityStripeStatus_t *p);
151 void rf_PrintPSStatusTable(RF_Raid_t *raidPtr, RF_RowCol_t row);
152
153 #endif /* !_RF__RF_PSSTATUS_H_ */
154