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