Home | History | Annotate | Line # | Download | only in raidframe
rf_dag.h revision 1.13
      1 /*	$NetBSD: rf_dag.h,v 1.13 2004/03/19 15:16:18 oster Exp $	*/
      2 /*
      3  * Copyright (c) 1995 Carnegie-Mellon University.
      4  * All rights reserved.
      5  *
      6  * Author: William V. Courtright II, 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  * dag.h -- header file for DAG-related data structures                     *
     32  *                                                                          *
     33  ****************************************************************************/
     34 
     35 #ifndef _RF__RF_DAG_H_
     36 #define _RF__RF_DAG_H_
     37 
     38 #include <dev/raidframe/raidframevar.h>
     39 
     40 #include "rf_threadstuff.h"
     41 #include "rf_alloclist.h"
     42 #include "rf_stripelocks.h"
     43 #include "rf_layout.h"
     44 #include "rf_dagflags.h"
     45 #include "rf_acctrace.h"
     46 
     47 #define RF_THREAD_CONTEXT   0	/* we were invoked from thread context */
     48 #define RF_INTR_CONTEXT     1	/* we were invoked from interrupt context */
     49 #define RF_MAX_ANTECEDENTS 20	/* max num of antecedents a node may posses */
     50 
     51 #include <sys/buf.h>
     52 
     53 struct RF_PropHeader_s {	/* structure for propagation of results */
     54 	int     paramNum;	/* to parameter # paramNum */
     55 	RF_PropHeader_t *next;	/* linked list for multiple results/params */
     56 };
     57 
     58 typedef enum RF_NodeStatus_e {
     59 	rf_wait,		/* node is waiting to be executed */
     60 	rf_fired,		/* node is currently executing its do function */
     61 	rf_good,		/* node successfully completed execution of
     62 				 * its do function */
     63 	rf_bad,			/* node failed to successfully execute its do
     64 				 * function */
     65 	rf_skipped,		/* not used anymore, used to imply a node was
     66 				 * not executed */
     67 	rf_recover,		/* node is currently executing its undo
     68 				 * function */
     69 	rf_panic,		/* node failed to successfully execute its
     70 				 * undo function */
     71 	rf_undone		/* node successfully executed its undo
     72 				 * function */
     73 }       RF_NodeStatus_t;
     74 /*
     75  * These were used to control skipping a node.
     76  * Now, these are only used as comments.
     77  */
     78 typedef enum RF_AntecedentType_e {
     79 	rf_trueData,
     80 	rf_antiData,
     81 	rf_outputData,
     82 	rf_control
     83 }       RF_AntecedentType_t;
     84 #define RF_DAG_PTRCACHESIZE   40
     85 #define RF_DAG_PARAMCACHESIZE 12
     86 
     87 typedef RF_uint8 RF_DagNodeFlags_t;
     88 
     89 struct RF_DagNode_s {
     90 	RF_NodeStatus_t status;	/* current status of this node */
     91 	int     (*doFunc) (RF_DagNode_t *);	/* normal function */
     92 	int     (*undoFunc) (RF_DagNode_t *);	/* func to remove effect of
     93 						 * doFunc */
     94 	int     (*wakeFunc) (RF_DagNode_t *, int status);	/* func called when the
     95 								 * node completes an I/O */
     96 	int     numParams;	/* number of parameters required by *funcPtr */
     97 	int     numResults;	/* number of results produced by *funcPtr */
     98 	int     numAntecedents;	/* number of antecedents */
     99 	int     numAntDone;	/* number of antecedents which have finished */
    100 	int     numSuccedents;	/* number of succedents */
    101 	int     numSuccFired;	/* incremented when a succedent is fired
    102 				 * during forward execution */
    103 	int     numSuccDone;	/* incremented when a succedent finishes
    104 				 * during rollBackward */
    105 	int     commitNode;	/* boolean flag - if true, this is a commit
    106 				 * node */
    107 	RF_DagNode_t **succedents;	/* succedents, array size
    108 					 * numSuccedents */
    109 	RF_DagNode_t **antecedents;	/* antecedents, array size
    110 					 * numAntecedents */
    111 	RF_AntecedentType_t antType[RF_MAX_ANTECEDENTS];	/* type of each
    112 								 * antecedent */
    113 	void  **results;	/* array of results produced by *funcPtr */
    114 	RF_DagParam_t *params;	/* array of parameters required by *funcPtr */
    115 	RF_PropHeader_t **propList;	/* propagation list, size
    116 					 * numSuccedents */
    117 	RF_DagHeader_t *dagHdr;	/* ptr to head of dag containing this node */
    118 	void   *dagFuncData;	/* dag execution func uses this for whatever
    119 				 * it wants */
    120 	RF_DagNode_t *next;     /* next in terms of propagating results */
    121 	RF_DagNode_t *list_next; /* next in the list of DAG nodes for this DAG */
    122 	int     nodeNum;	/* used by PrintDAG for debug only */
    123 	int     visited;	/* used to avoid re-visiting nodes on DAG
    124 				 * walks */
    125 	/* ANY CODE THAT USES THIS FIELD MUST MAINTAIN THE PROPERTY THAT AFTER
    126 	 * IT FINISHES, ALL VISITED FLAGS IN THE DAG ARE IDENTICAL */
    127 	char   *name;		/* debug only */
    128 	RF_DagNodeFlags_t flags;/* see below */
    129 	RF_DagNode_t *dag_ptrs[RF_DAG_PTRCACHESIZE];	/* cache for performance */
    130 	RF_DagParam_t dag_params[RF_DAG_PARAMCACHESIZE];	/* cache for performance */
    131 };
    132 /*
    133  * Bit values for flags field of RF_DagNode_t
    134  */
    135 #define RF_DAGNODE_FLAG_NONE  0x00
    136 #define RF_DAGNODE_FLAG_YIELD 0x01	/* in the kernel, yield the processor
    137 					 * before firing this node */
    138 
    139 /* enable - DAG ready for normal execution, no errors encountered
    140  * rollForward - DAG encountered an error after commit point, rolling forward
    141  * rollBackward - DAG encountered an error prior to commit point, rolling backward
    142  */
    143 typedef enum RF_DagStatus_e {
    144 	rf_enable,
    145 	rf_rollForward,
    146 	rf_rollBackward
    147 }       RF_DagStatus_t;
    148 #define RF_MAX_HDR_SUCC 1
    149 
    150 struct RF_DagHeader_s {
    151 	RF_DagStatus_t status;	/* status of this DAG */
    152 	int     numSuccedents;	/* DAG may be a tree, i.e. may have > 1 root */
    153 	int     numCommitNodes;	/* number of commit nodes in graph */
    154 	int     numCommits;	/* number of commit nodes which have been
    155 				 * fired  */
    156 	RF_DagNode_t *succedents[RF_MAX_HDR_SUCC];	/* array of succedents,
    157 							 * size numSuccedents */
    158 	RF_DagHeader_t *next;	/* ptr to allow a list of dags */
    159 	RF_AllocListElem_t *allocList;	/* ptr to list of ptrs to be freed
    160 					 * prior to freeing DAG */
    161 	RF_AccessStripeMapHeader_t *asmList;	/* list of access stripe maps
    162 						 * to be freed */
    163 	int     nodeNum;	/* used by PrintDAG for debug only */
    164 	int     numNodesCompleted;
    165 #if RF_ACC_TRACE > 0
    166 	RF_AccTraceEntry_t *tracerec;	/* perf mon only */
    167 #endif
    168 	void    (*cbFunc) (void *);	/* function to call when the dag
    169 					 * completes */
    170 	void   *cbArg;		/* argument for cbFunc */
    171 	char   *creator;	/* name of function used to create this dag */
    172 	RF_DagNode_t *nodes;    /* linked list of nodes used in this DAG */
    173 	RF_PhysDiskAddr_t *pda_cleanup_list; /* for PDAs that can't get
    174 						cleaned up any other way... */
    175 	RF_Raid_t *raidPtr;	/* the descriptor for the RAID device this DAG
    176 				 * is for */
    177 	void   *bp;		/* the bp for this I/O passed down from the
    178 				 * file system. ignored outside kernel */
    179 };
    180 
    181 struct RF_DagList_s {
    182 	/* common info for a list of dags which will be fired sequentially */
    183 	int     numDags;	/* number of dags in the list */
    184 	int     numDagsFired;	/* number of dags in list which have initiated
    185 				 * execution */
    186 	int     numDagsDone;	/* number of dags in list which have completed
    187 				 * execution */
    188 	RF_DagHeader_t *dags;	/* list of dags */
    189 	RF_RaidAccessDesc_t *desc;	/* ptr to descriptor for this access */
    190 	RF_AccTraceEntry_t tracerec;	/* perf mon info for dags (not user
    191 					 * info) */
    192 	struct RF_DagList_s *next;     /* next DagList, if any */
    193 };
    194 
    195 /* convience macro for declaring a create dag function */
    196 
    197 #define RF_CREATE_DAG_FUNC_DECL(_name_) \
    198 void _name_ ( \
    199 	RF_Raid_t             *raidPtr, \
    200 	RF_AccessStripeMap_t  *asmap, \
    201 	RF_DagHeader_t        *dag_h, \
    202 	void                  *bp, \
    203 	RF_RaidAccessFlags_t   flags, \
    204 	RF_AllocListElem_t    *allocList)
    205 
    206 #endif				/* !_RF__RF_DAG_H_ */
    207