xref: /netbsd-src/sys/dev/raidframe/rf_psstatus.h (revision 481fca6e59249d8ffcf24fef7cfbe7b131bfb080)
1 /*	$NetBSD: rf_psstatus.h,v 1.3 1999/02/05 00:06:15 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@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 #ifndef _RF__RF_PSSTATUS_H_
40 #define _RF__RF_PSSTATUS_H_
41 
42 #include "rf_types.h"
43 #include "rf_threadstuff.h"
44 #include "rf_callback.h"
45 
46 #define RF_PS_MAX_BUFS 10	/* max number of bufs we'll accumulate before
47 				 * we do an XOR */
48 
49 #define RF_PSS_DEFAULT_TABLESIZE 200
50 
51 /*
52  * Macros to acquire/release the mutex lock on a parity stripe status
53  * descriptor. Note that we use just one lock for the whole hash chain.
54  */
55 #define RF_HASH_PSID(_raid_,_psid_) ( (_psid_) % ((_raid_)->pssTableSize) )	/* simple hash function */
56 #define RF_LOCK_PSS_MUTEX(_raidPtr, _row, _psid) \
57   RF_LOCK_MUTEX((_raidPtr)->reconControl[_row]->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex)
58 #define RF_UNLOCK_PSS_MUTEX(_raidPtr, _row, _psid) \
59   RF_UNLOCK_MUTEX((_raidPtr)->reconControl[_row]->pssTable[ RF_HASH_PSID(_raidPtr,_psid) ].mutex)
60 
61 struct RF_ReconParityStripeStatus_s {
62 	RF_StripeNum_t parityStripeID;	/* the parity stripe ID */
63 	RF_ReconUnitNum_t which_ru;	/* which reconstruction unit with the
64 					 * indicated parity stripe */
65 	RF_PSSFlags_t flags;	/* flags indicating various conditions */
66 	void   *rbuf;		/* this is the accumulating xor sum */
67 	void   *writeRbuf;	/* DEBUG ONLY:  a pointer to the rbuf after it
68 				 * has filled & been sent to disk */
69 	void   *rbufsForXor[RF_PS_MAX_BUFS];	/* these are buffers still to
70 						 * be xored into the
71 						 * accumulating sum */
72 	int     xorBufCount;	/* num buffers waiting to be xored */
73 	int     blockCount;	/* count of # proc that have blocked recon on
74 				 * this parity stripe */
75 	char   *issued;		/* issued[i]==1 <=> column i has already
76 				 * issued a read request for the indicated RU */
77 	RF_CallbackDesc_t *procWaitList;	/* list of user procs waiting
78 						 * for recon to be done */
79 	RF_CallbackDesc_t *blockWaitList;	/* list of disks blocked
80 						 * waiting for user write to
81 						 * complete */
82 	RF_CallbackDesc_t *bufWaitList;	/* list of disks blocked waiting to
83 					 * acquire a buffer for this RU */
84 	RF_ReconParityStripeStatus_t *next;
85 };
86 
87 struct RF_PSStatusHeader_s {
88 	RF_DECLARE_MUTEX(mutex)	/* mutex for this hash chain */
89 	RF_ReconParityStripeStatus_t *chain;	/* the hash chain */
90 };
91 /* masks for the "flags" field above */
92 #define RF_PSS_NONE            0x00000000	/* no flags */
93 #define RF_PSS_UNDER_RECON     0x00000001	/* this parity stripe is
94 						 * currently under
95 						 * reconstruction */
96 #define RF_PSS_FORCED_ON_WRITE 0x00000002	/* indicates a recon was
97 						 * forced due to a user-write
98 						 * operation */
99 #define RF_PSS_FORCED_ON_READ  0x00000004	/* ditto for read, but not
100 						 * currently implemented */
101 #define RF_PSS_RECON_BLOCKED   0x00000008	/* reconstruction is currently
102 						 * blocked due to a pending
103 						 * user I/O */
104 #define RF_PSS_CREATE          0x00000010	/* tells LookupRUStatus to
105 						 * create the entry */
106 #define RF_PSS_BUFFERWAIT      0x00000020	/* someone is waiting for a
107 						 * buffer for this RU */
108 
109 int
110 rf_ConfigurePSStatus(RF_ShutdownList_t ** listp, RF_Raid_t * raidPtr,
111     RF_Config_t * cfgPtr);
112 
113 RF_PSStatusHeader_t *rf_MakeParityStripeStatusTable(RF_Raid_t * raidPtr);
114 void
115 rf_FreeParityStripeStatusTable(RF_Raid_t * raidPtr,
116     RF_PSStatusHeader_t * pssTable);
117 RF_ReconParityStripeStatus_t *
118 rf_LookupRUStatus(RF_Raid_t * raidPtr,
119     RF_PSStatusHeader_t * pssTable, RF_StripeNum_t psID,
120     RF_ReconUnitNum_t which_ru, RF_PSSFlags_t flags, int *created);
121 void
122 rf_PSStatusDelete(RF_Raid_t * raidPtr, RF_PSStatusHeader_t * pssTable,
123     RF_ReconParityStripeStatus_t * pssPtr);
124 void
125 rf_RemoveFromActiveReconTable(RF_Raid_t * raidPtr, RF_RowCol_t row,
126     RF_StripeNum_t psid, RF_ReconUnitNum_t which_ru);
127 RF_ReconParityStripeStatus_t *rf_AllocPSStatus(RF_Raid_t * raidPtr);
128 void    rf_FreePSStatus(RF_Raid_t * raidPtr, RF_ReconParityStripeStatus_t * p);
129 void    rf_PrintPSStatusTable(RF_Raid_t * raidPtr, RF_RowCol_t row);
130 
131 #endif				/* !_RF__RF_PSSTATUS_H_ */
132