1 /*	$OpenBSD: rf_dagutils.h,v 1.3 2002/12/16 07:01:03 tdeval Exp $	*/
2 /*	$NetBSD: rf_dagutils.h,v 1.3 1999/02/05 00:06:08 oster Exp $	*/
3 
4 /*
5  * Copyright (c) 1995 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Mark Holland, William V. Courtright II
9  *
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  *
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  *
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30 
31 /*****************************************************************************
32  *
33  * rf_dagutils.h -- Header file for utility routines for manipulating DAGs.
34  *
35  *****************************************************************************/
36 
37 
38 #include "rf_types.h"
39 #include "rf_dagfuncs.h"
40 #include "rf_general.h"
41 
42 #ifndef	_RF__RF_DAGUTILS_H_
43 #define	_RF__RF_DAGUTILS_H_
44 
45 struct RF_RedFuncs_s {
46 	int	(*regular) (RF_DagNode_t *);
47 	char	 *RegularName;
48 	int	(*simple) (RF_DagNode_t *);
49 	char	 *SimpleName;
50 };
51 
52 extern RF_RedFuncs_t rf_xorFuncs;
53 extern RF_RedFuncs_t rf_xorRecoveryFuncs;
54 
55 void rf_InitNode(RF_DagNode_t *, RF_NodeStatus_t, int, int (*) (RF_DagNode_t *),
56 	int (*) (RF_DagNode_t *), int (*) (RF_DagNode_t *, int), int, int, int,
57 	int, RF_DagHeader_t *, char *, RF_AllocListElem_t *);
58 
59 void rf_FreeDAG(RF_DagHeader_t *);
60 
61 RF_PropHeader_t *rf_MakePropListEntry(RF_DagHeader_t *, int, int,
62 RF_PropHeader_t *, RF_AllocListElem_t *);
63 
64 int  rf_ConfigureDAGs(RF_ShutdownList_t **);
65 
66 RF_DagHeader_t *rf_AllocDAGHeader(void);
67 
68 void rf_FreeDAGHeader(RF_DagHeader_t *);
69 
70 void *rf_AllocBuffer(RF_Raid_t *, RF_DagHeader_t *, RF_PhysDiskAddr_t *,
71 	RF_AllocListElem_t *);
72 
73 char *rf_NodeStatusString(RF_DagNode_t *);
74 
75 void rf_PrintNodeInfoString(RF_DagNode_t *);
76 
77 int  rf_AssignNodeNums(RF_DagHeader_t *);
78 
79 int  rf_RecurAssignNodeNums(RF_DagNode_t *, int, int);
80 
81 void rf_ResetDAGHeaderPointers(RF_DagHeader_t *, RF_DagHeader_t *);
82 
83 void rf_RecurResetDAGHeaderPointers(RF_DagNode_t *, RF_DagHeader_t *);
84 
85 void rf_PrintDAGList(RF_DagHeader_t *);
86 
87 int  rf_ValidateDAG(RF_DagHeader_t *);
88 
89 void rf_redirect_asm(RF_Raid_t *, RF_AccessStripeMap_t *);
90 
91 void rf_MapUnaccessedPortionOfStripe(RF_Raid_t *, RF_RaidLayout_t *,
92 	RF_AccessStripeMap_t *, RF_DagHeader_t *, RF_AccessStripeMapHeader_t **,
93 	int *, char **, char **, RF_AllocListElem_t *);
94 
95 int  rf_PDAOverlap(RF_RaidLayout_t *, RF_PhysDiskAddr_t *, RF_PhysDiskAddr_t *);
96 
97 void rf_GenerateFailedAccessASMs(RF_Raid_t *, RF_AccessStripeMap_t *,
98 	RF_PhysDiskAddr_t *, RF_DagHeader_t *, RF_AccessStripeMapHeader_t **,
99 	int *, char **, char *, RF_AllocListElem_t *);
100 
101 /* Flags used by RangeRestrictPDA. */
102 #define	RF_RESTRICT_NOBUFFER	0
103 #define	RF_RESTRICT_DOBUFFER	1
104 
105 void rf_RangeRestrictPDA(RF_Raid_t *, RF_PhysDiskAddr_t *, RF_PhysDiskAddr_t *,
106 	int, int);
107 
108 int  rf_compute_workload_shift(RF_Raid_t *, RF_PhysDiskAddr_t *);
109 void rf_SelectMirrorDiskIdle(RF_DagNode_t *);
110 void rf_SelectMirrorDiskPartition(RF_DagNode_t *);
111 
112 #endif	/* ! _RF__RF_DAGUTILS_H_ */
113