No empty .Rs/.Re
[netbsd-mini2440.git] / sys / dev / raidframe / rf_psstatus.h
blob0a2b7ad1084de7a3b47d31eca610c96f3b98f95e
1 /* $NetBSD: rf_psstatus.h,v 1.12 2005/12/11 12:23:37 christos Exp $ */
2 /*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
6 * Author: Mark Holland
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 /*****************************************************************************
31 * psstatus.h
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.
37 *****************************************************************************/
39 #ifndef _RF__RF_PSSTATUS_H_
40 #define _RF__RF_PSSTATUS_H_
42 #include <dev/raidframe/raidframevar.h>
44 #include "rf_threadstuff.h"
45 #include "rf_callback.h"
47 #define RF_PS_MAX_BUFS 10 /* max number of bufs we'll accumulate before
48 * we do an XOR */
50 #define RF_PSS_DEFAULT_TABLESIZE 200
53 * Macros to acquire/release the mutex lock on a parity stripe status
54 * descriptor. Note that we use just one lock for the whole hash chain.
56 #define RF_HASH_PSID(_raid_,_psid_) ( (_psid_) % ((_raid_)->pssTableSize) ) /* simple hash function */
57 #define RF_LOCK_PSS_MUTEX(_raidPtr, _psid) \
58 do { \
59 RF_LOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex); \
60 while((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock) { \
61 ltsleep(&(_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock, \
62 PRIBIO, "rflockpss", 0, \
63 &(_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex); \
64 } \
65 (_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock = 1; \
66 RF_UNLOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex); \
67 } while (0);
69 #define RF_UNLOCK_PSS_MUTEX(_raidPtr, _psid) \
70 RF_LOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex); \
71 (_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock = 0; \
72 wakeup(&(_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].lock); \
73 RF_UNLOCK_MUTEX((_raidPtr)->reconControl->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex);
75 struct RF_ReconParityStripeStatus_s {
76 RF_StripeNum_t parityStripeID; /* the parity stripe ID */
77 RF_ReconUnitNum_t which_ru; /* which reconstruction unit with the
78 * indicated parity stripe */
79 RF_PSSFlags_t flags; /* flags indicating various conditions */
80 void *rbuf; /* this is the accumulating xor sum */
81 void *writeRbuf; /* DEBUG ONLY: a pointer to the rbuf after it
82 * has filled & been sent to disk */
83 void *rbufsForXor[RF_PS_MAX_BUFS]; /* these are buffers still to
84 * be xored into the
85 * accumulating sum */
86 int xorBufCount; /* num buffers waiting to be xored */
87 int blockCount; /* count of # proc that have blocked recon on
88 * this parity stripe */
89 char issued[RF_MAXCOL]; /* issued[i]==1 <=> column i has already
90 * issued a read request for the indicated RU */
91 RF_CallbackDesc_t *procWaitList; /* list of user procs waiting
92 * for recon to be done */
93 RF_CallbackDesc_t *blockWaitList; /* list of disks blocked
94 * waiting for user write to
95 * complete */
96 RF_CallbackDesc_t *bufWaitList; /* list of disks blocked waiting to
97 * acquire a buffer for this RU */
98 RF_ReconParityStripeStatus_t *next;
101 struct RF_PSStatusHeader_s {
102 RF_DECLARE_MUTEX(mutex) /* mutex for this hash chain */
103 int lock; /* 1 if this hash chain is locked,
104 0 otherwise */
105 RF_ReconParityStripeStatus_t *chain; /* the hash chain */
107 /* masks for the "flags" field above */
108 #define RF_PSS_NONE 0x00000000 /* no flags */
109 #define RF_PSS_UNDER_RECON 0x00000001 /* this parity stripe is
110 * currently under
111 * reconstruction */
112 #define RF_PSS_FORCED_ON_WRITE 0x00000002 /* indicates a recon was
113 * forced due to a user-write
114 * operation */
115 #define RF_PSS_FORCED_ON_READ 0x00000004 /* ditto for read, but not
116 * currently implemented */
117 #define RF_PSS_RECON_BLOCKED 0x00000008 /* reconstruction is currently
118 * blocked due to a pending
119 * user I/O */
120 #define RF_PSS_CREATE 0x00000010 /* tells LookupRUStatus to
121 * create the entry */
122 #define RF_PSS_BUFFERWAIT 0x00000020 /* someone is waiting for a
123 * buffer for this RU */
125 int rf_ConfigurePSStatus(RF_ShutdownList_t **);
126 void rf_InitPSStatus(RF_Raid_t *);
127 RF_PSStatusHeader_t *rf_MakeParityStripeStatusTable(RF_Raid_t *);
128 void rf_FreeParityStripeStatusTable(RF_Raid_t *, RF_PSStatusHeader_t *);
129 RF_ReconParityStripeStatus_t *rf_LookupRUStatus(RF_Raid_t *, RF_PSStatusHeader_t *,
130 RF_StripeNum_t, RF_ReconUnitNum_t,
131 RF_PSSFlags_t,
132 RF_ReconParityStripeStatus_t *);
133 void rf_PSStatusDelete(RF_Raid_t *, RF_PSStatusHeader_t *,
134 RF_ReconParityStripeStatus_t *);
135 void rf_RemoveFromActiveReconTable(RF_Raid_t *, RF_StripeNum_t, RF_ReconUnitNum_t);
136 RF_ReconParityStripeStatus_t *rf_AllocPSStatus(RF_Raid_t *);
137 void rf_FreePSStatus(RF_Raid_t *, RF_ReconParityStripeStatus_t *);
138 void rf_PrintPSStatusTable(RF_Raid_t *);
140 #endif /* !_RF__RF_PSSTATUS_H_ */