Home | History | Annotate | Line # | Download | only in raidframe
rf_dagfuncs.c revision 1.18
      1  1.18     oster /*	$NetBSD: rf_dagfuncs.c,v 1.18 2004/01/10 17:04:44 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, William V. Courtright II
      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  * dagfuncs.c -- DAG node execution routines
     31   1.1     oster  *
     32   1.1     oster  * Rules:
     33   1.1     oster  * 1. Every DAG execution function must eventually cause node->status to
     34   1.1     oster  *    get set to "good" or "bad", and "FinishNode" to be called. In the
     35   1.1     oster  *    case of nodes that complete immediately (xor, NullNodeFunc, etc),
     36   1.1     oster  *    the node execution function can do these two things directly. In
     37   1.1     oster  *    the case of nodes that have to wait for some event (a disk read to
     38   1.1     oster  *    complete, a lock to be released, etc) to occur before they can
     39   1.1     oster  *    complete, this is typically achieved by having whatever module
     40   1.1     oster  *    is doing the operation call GenericWakeupFunc upon completion.
     41   1.1     oster  * 2. DAG execution functions should check the status in the DAG header
     42   1.1     oster  *    and NOP out their operations if the status is not "enable". However,
     43   1.1     oster  *    execution functions that release resources must be sure to release
     44   1.1     oster  *    them even when they NOP out the function that would use them.
     45   1.1     oster  *    Functions that acquire resources should go ahead and acquire them
     46   1.1     oster  *    even when they NOP, so that a downstream release node will not have
     47   1.1     oster  *    to check to find out whether or not the acquire was suppressed.
     48   1.1     oster  */
     49   1.8     lukem 
     50   1.8     lukem #include <sys/cdefs.h>
     51  1.18     oster __KERNEL_RCSID(0, "$NetBSD: rf_dagfuncs.c,v 1.18 2004/01/10 17:04:44 oster Exp $");
     52   1.1     oster 
     53   1.7       mrg #include <sys/param.h>
     54   1.1     oster #include <sys/ioctl.h>
     55   1.1     oster 
     56   1.1     oster #include "rf_archs.h"
     57   1.1     oster #include "rf_raid.h"
     58   1.1     oster #include "rf_dag.h"
     59   1.1     oster #include "rf_layout.h"
     60   1.1     oster #include "rf_etimer.h"
     61   1.1     oster #include "rf_acctrace.h"
     62   1.1     oster #include "rf_diskqueue.h"
     63   1.1     oster #include "rf_dagfuncs.h"
     64   1.1     oster #include "rf_general.h"
     65   1.1     oster #include "rf_engine.h"
     66   1.1     oster #include "rf_dagutils.h"
     67   1.1     oster 
     68   1.1     oster #include "rf_kintf.h"
     69   1.1     oster 
     70   1.1     oster #if RF_INCLUDE_PARITYLOGGING > 0
     71   1.1     oster #include "rf_paritylog.h"
     72   1.3     oster #endif				/* RF_INCLUDE_PARITYLOGGING > 0 */
     73   1.1     oster 
     74   1.3     oster int     (*rf_DiskReadFunc) (RF_DagNode_t *);
     75   1.3     oster int     (*rf_DiskWriteFunc) (RF_DagNode_t *);
     76   1.3     oster int     (*rf_DiskReadUndoFunc) (RF_DagNode_t *);
     77   1.3     oster int     (*rf_DiskWriteUndoFunc) (RF_DagNode_t *);
     78   1.3     oster int     (*rf_DiskUnlockFunc) (RF_DagNode_t *);
     79   1.3     oster int     (*rf_DiskUnlockUndoFunc) (RF_DagNode_t *);
     80   1.3     oster int     (*rf_RegularXorUndoFunc) (RF_DagNode_t *);
     81   1.3     oster int     (*rf_SimpleXorUndoFunc) (RF_DagNode_t *);
     82   1.3     oster int     (*rf_RecoveryXorUndoFunc) (RF_DagNode_t *);
     83   1.1     oster 
     84  1.14     oster /*****************************************************************************
     85   1.1     oster  * main (only) configuration routine for this module
     86  1.14     oster  ****************************************************************************/
     87   1.3     oster int
     88  1.15     oster rf_ConfigureDAGFuncs(RF_ShutdownList_t **listp)
     89   1.3     oster {
     90  1.14     oster 	RF_ASSERT(((sizeof(long) == 8) && RF_LONGSHIFT == 3) ||
     91  1.14     oster 		  ((sizeof(long) == 4) && RF_LONGSHIFT == 2));
     92   1.3     oster 	rf_DiskReadFunc = rf_DiskReadFuncForThreads;
     93   1.3     oster 	rf_DiskReadUndoFunc = rf_DiskUndoFunc;
     94   1.3     oster 	rf_DiskWriteFunc = rf_DiskWriteFuncForThreads;
     95   1.3     oster 	rf_DiskWriteUndoFunc = rf_DiskUndoFunc;
     96   1.3     oster 	rf_DiskUnlockFunc = rf_DiskUnlockFuncForThreads;
     97   1.3     oster 	rf_DiskUnlockUndoFunc = rf_NullNodeUndoFunc;
     98   1.3     oster 	rf_RegularXorUndoFunc = rf_NullNodeUndoFunc;
     99   1.3     oster 	rf_SimpleXorUndoFunc = rf_NullNodeUndoFunc;
    100   1.3     oster 	rf_RecoveryXorUndoFunc = rf_NullNodeUndoFunc;
    101   1.3     oster 	return (0);
    102   1.1     oster }
    103   1.1     oster 
    104   1.1     oster 
    105   1.1     oster 
    106  1.14     oster /*****************************************************************************
    107   1.1     oster  * the execution function associated with a terminate node
    108  1.14     oster  ****************************************************************************/
    109   1.3     oster int
    110  1.15     oster rf_TerminateFunc(RF_DagNode_t *node)
    111   1.1     oster {
    112   1.3     oster 	RF_ASSERT(node->dagHdr->numCommits == node->dagHdr->numCommitNodes);
    113   1.3     oster 	node->status = rf_good;
    114   1.3     oster 	return (rf_FinishNode(node, RF_THREAD_CONTEXT));
    115   1.1     oster }
    116   1.1     oster 
    117   1.3     oster int
    118  1.15     oster rf_TerminateUndoFunc(RF_DagNode_t *node)
    119   1.1     oster {
    120   1.3     oster 	return (0);
    121   1.1     oster }
    122   1.1     oster 
    123   1.1     oster 
    124  1.15     oster /*****************************************************************************
    125   1.1     oster  * execution functions associated with a mirror node
    126   1.1     oster  *
    127   1.1     oster  * parameters:
    128   1.1     oster  *
    129   1.1     oster  * 0 - physical disk addres of data
    130   1.1     oster  * 1 - buffer for holding read data
    131   1.1     oster  * 2 - parity stripe ID
    132   1.1     oster  * 3 - flags
    133   1.1     oster  * 4 - physical disk address of mirror (parity)
    134   1.1     oster  *
    135  1.15     oster  ****************************************************************************/
    136   1.1     oster 
    137   1.3     oster int
    138  1.15     oster rf_DiskReadMirrorIdleFunc(RF_DagNode_t *node)
    139   1.1     oster {
    140   1.3     oster 	/* select the mirror copy with the shortest queue and fill in node
    141   1.3     oster 	 * parameters with physical disk address */
    142   1.1     oster 
    143   1.3     oster 	rf_SelectMirrorDiskIdle(node);
    144   1.3     oster 	return (rf_DiskReadFunc(node));
    145   1.1     oster }
    146   1.1     oster 
    147  1.11     oster #if (RF_INCLUDE_CHAINDECLUSTER > 0) || (RF_INCLUDE_INTERDECLUSTER > 0) || (RF_DEBUG_VALIDATE_DAG > 0)
    148   1.3     oster int
    149  1.15     oster rf_DiskReadMirrorPartitionFunc(RF_DagNode_t *node)
    150   1.1     oster {
    151   1.3     oster 	/* select the mirror copy with the shortest queue and fill in node
    152   1.3     oster 	 * parameters with physical disk address */
    153   1.1     oster 
    154   1.3     oster 	rf_SelectMirrorDiskPartition(node);
    155   1.3     oster 	return (rf_DiskReadFunc(node));
    156   1.1     oster }
    157  1.11     oster #endif
    158   1.1     oster 
    159   1.3     oster int
    160  1.15     oster rf_DiskReadMirrorUndoFunc(RF_DagNode_t *node)
    161   1.1     oster {
    162   1.3     oster 	return (0);
    163   1.1     oster }
    164   1.1     oster 
    165   1.1     oster 
    166   1.1     oster 
    167   1.1     oster #if RF_INCLUDE_PARITYLOGGING > 0
    168  1.14     oster /*****************************************************************************
    169   1.1     oster  * the execution function associated with a parity log update node
    170  1.14     oster  ****************************************************************************/
    171   1.3     oster int
    172  1.15     oster rf_ParityLogUpdateFunc(RF_DagNode_t *node)
    173   1.3     oster {
    174   1.3     oster 	RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;
    175   1.3     oster 	caddr_t buf = (caddr_t) node->params[1].p;
    176   1.3     oster 	RF_ParityLogData_t *logData;
    177   1.3     oster 	RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
    178   1.3     oster 	RF_Etimer_t timer;
    179   1.3     oster 
    180   1.3     oster 	if (node->dagHdr->status == rf_enable) {
    181   1.3     oster 		RF_ETIMER_START(timer);
    182   1.3     oster 		logData = rf_CreateParityLogData(RF_UPDATE, pda, buf,
    183   1.3     oster 		    (RF_Raid_t *) (node->dagHdr->raidPtr),
    184   1.3     oster 		    node->wakeFunc, (void *) node,
    185   1.3     oster 		    node->dagHdr->tracerec, timer);
    186   1.3     oster 		if (logData)
    187   1.3     oster 			rf_ParityLogAppend(logData, RF_FALSE, NULL, RF_FALSE);
    188   1.3     oster 		else {
    189   1.3     oster 			RF_ETIMER_STOP(timer);
    190   1.3     oster 			RF_ETIMER_EVAL(timer);
    191   1.3     oster 			tracerec->plog_us += RF_ETIMER_VAL_US(timer);
    192   1.3     oster 			(node->wakeFunc) (node, ENOMEM);
    193   1.3     oster 		}
    194   1.1     oster 	}
    195   1.3     oster 	return (0);
    196   1.1     oster }
    197   1.1     oster 
    198   1.1     oster 
    199  1.15     oster /*****************************************************************************
    200   1.1     oster  * the execution function associated with a parity log overwrite node
    201  1.15     oster  ****************************************************************************/
    202   1.3     oster int
    203  1.15     oster rf_ParityLogOverwriteFunc(RF_DagNode_t *node)
    204   1.3     oster {
    205   1.3     oster 	RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;
    206   1.3     oster 	caddr_t buf = (caddr_t) node->params[1].p;
    207   1.3     oster 	RF_ParityLogData_t *logData;
    208   1.3     oster 	RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
    209   1.3     oster 	RF_Etimer_t timer;
    210   1.3     oster 
    211   1.3     oster 	if (node->dagHdr->status == rf_enable) {
    212   1.3     oster 		RF_ETIMER_START(timer);
    213  1.14     oster 		logData = rf_CreateParityLogData(RF_OVERWRITE, pda, buf,
    214  1.14     oster (RF_Raid_t *) (node->dagHdr->raidPtr),
    215   1.3     oster 		    node->wakeFunc, (void *) node, node->dagHdr->tracerec, timer);
    216   1.3     oster 		if (logData)
    217   1.3     oster 			rf_ParityLogAppend(logData, RF_FALSE, NULL, RF_FALSE);
    218   1.3     oster 		else {
    219   1.3     oster 			RF_ETIMER_STOP(timer);
    220   1.3     oster 			RF_ETIMER_EVAL(timer);
    221   1.3     oster 			tracerec->plog_us += RF_ETIMER_VAL_US(timer);
    222   1.3     oster 			(node->wakeFunc) (node, ENOMEM);
    223   1.3     oster 		}
    224   1.1     oster 	}
    225   1.3     oster 	return (0);
    226   1.1     oster }
    227   1.1     oster 
    228   1.3     oster int
    229  1.15     oster rf_ParityLogUpdateUndoFunc(RF_DagNode_t *node)
    230   1.1     oster {
    231   1.3     oster 	return (0);
    232   1.1     oster }
    233   1.1     oster 
    234   1.3     oster int
    235  1.15     oster rf_ParityLogOverwriteUndoFunc(RF_DagNode_t *node)
    236   1.1     oster {
    237   1.3     oster 	return (0);
    238   1.1     oster }
    239  1.10     oster #endif				/* RF_INCLUDE_PARITYLOGGING > 0 */
    240  1.10     oster 
    241  1.14     oster /*****************************************************************************
    242   1.1     oster  * the execution function associated with a NOP node
    243  1.14     oster  ****************************************************************************/
    244   1.3     oster int
    245  1.15     oster rf_NullNodeFunc(RF_DagNode_t *node)
    246   1.1     oster {
    247   1.3     oster 	node->status = rf_good;
    248   1.3     oster 	return (rf_FinishNode(node, RF_THREAD_CONTEXT));
    249   1.1     oster }
    250   1.1     oster 
    251   1.3     oster int
    252  1.15     oster rf_NullNodeUndoFunc(RF_DagNode_t *node)
    253   1.1     oster {
    254   1.3     oster 	node->status = rf_undone;
    255   1.3     oster 	return (rf_FinishNode(node, RF_THREAD_CONTEXT));
    256   1.1     oster }
    257   1.1     oster 
    258   1.1     oster 
    259  1.14     oster /*****************************************************************************
    260   1.1     oster  * the execution function associated with a disk-read node
    261  1.14     oster  ****************************************************************************/
    262   1.3     oster int
    263  1.15     oster rf_DiskReadFuncForThreads(RF_DagNode_t *node)
    264   1.3     oster {
    265   1.3     oster 	RF_DiskQueueData_t *req;
    266   1.3     oster 	RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;
    267   1.3     oster 	caddr_t buf = (caddr_t) node->params[1].p;
    268   1.3     oster 	RF_StripeNum_t parityStripeID = (RF_StripeNum_t) node->params[2].v;
    269   1.3     oster 	unsigned priority = RF_EXTRACT_PRIORITY(node->params[3].v);
    270   1.3     oster 	unsigned which_ru = RF_EXTRACT_RU(node->params[3].v);
    271   1.3     oster 	RF_IoType_t iotype = (node->dagHdr->status == rf_enable) ? RF_IO_TYPE_READ : RF_IO_TYPE_NOP;
    272  1.13     oster 	RF_DiskQueue_t *dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues;
    273   1.3     oster 	void   *b_proc = NULL;
    274   1.1     oster 
    275   1.3     oster 	if (node->dagHdr->bp)
    276   1.3     oster 		b_proc = (void *) ((struct buf *) node->dagHdr->bp)->b_proc;
    277   1.1     oster 
    278   1.3     oster 	req = rf_CreateDiskQueueData(iotype, pda->startSector, pda->numSector,
    279   1.3     oster 	    buf, parityStripeID, which_ru,
    280   1.3     oster 	    (int (*) (void *, int)) node->wakeFunc,
    281   1.3     oster 	    node, NULL, node->dagHdr->tracerec,
    282  1.18     oster 	    (void *) (node->dagHdr->raidPtr), 0, b_proc);
    283   1.3     oster 	if (!req) {
    284   1.3     oster 		(node->wakeFunc) (node, ENOMEM);
    285   1.3     oster 	} else {
    286   1.3     oster 		node->dagFuncData = (void *) req;
    287  1.13     oster 		rf_DiskIOEnqueue(&(dqs[pda->col]), req, priority);
    288   1.3     oster 	}
    289   1.3     oster 	return (0);
    290   1.1     oster }
    291   1.1     oster 
    292   1.1     oster 
    293  1.14     oster /*****************************************************************************
    294   1.1     oster  * the execution function associated with a disk-write node
    295  1.14     oster  ****************************************************************************/
    296   1.3     oster int
    297  1.15     oster rf_DiskWriteFuncForThreads(RF_DagNode_t *node)
    298   1.3     oster {
    299   1.3     oster 	RF_DiskQueueData_t *req;
    300   1.3     oster 	RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;
    301   1.3     oster 	caddr_t buf = (caddr_t) node->params[1].p;
    302   1.3     oster 	RF_StripeNum_t parityStripeID = (RF_StripeNum_t) node->params[2].v;
    303   1.3     oster 	unsigned priority = RF_EXTRACT_PRIORITY(node->params[3].v);
    304   1.3     oster 	unsigned which_ru = RF_EXTRACT_RU(node->params[3].v);
    305   1.3     oster 	RF_IoType_t iotype = (node->dagHdr->status == rf_enable) ? RF_IO_TYPE_WRITE : RF_IO_TYPE_NOP;
    306  1.13     oster 	RF_DiskQueue_t *dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues;
    307   1.3     oster 	void   *b_proc = NULL;
    308   1.1     oster 
    309   1.3     oster 	if (node->dagHdr->bp)
    310   1.3     oster 		b_proc = (void *) ((struct buf *) node->dagHdr->bp)->b_proc;
    311   1.1     oster 
    312   1.3     oster 	/* normal processing (rollaway or forward recovery) begins here */
    313   1.3     oster 	req = rf_CreateDiskQueueData(iotype, pda->startSector, pda->numSector,
    314   1.3     oster 	    buf, parityStripeID, which_ru,
    315   1.3     oster 	    (int (*) (void *, int)) node->wakeFunc,
    316   1.3     oster 	    (void *) node, NULL,
    317   1.3     oster 	    node->dagHdr->tracerec,
    318   1.3     oster 	    (void *) (node->dagHdr->raidPtr),
    319  1.18     oster 	    0, b_proc);
    320   1.3     oster 
    321   1.3     oster 	if (!req) {
    322   1.3     oster 		(node->wakeFunc) (node, ENOMEM);
    323   1.3     oster 	} else {
    324   1.3     oster 		node->dagFuncData = (void *) req;
    325  1.13     oster 		rf_DiskIOEnqueue(&(dqs[pda->col]), req, priority);
    326   1.3     oster 	}
    327   1.3     oster 
    328   1.3     oster 	return (0);
    329   1.1     oster }
    330  1.14     oster /*****************************************************************************
    331   1.1     oster  * the undo function for disk nodes
    332   1.1     oster  * Note:  this is not a proper undo of a write node, only locks are released.
    333   1.1     oster  *        old data is not restored to disk!
    334  1.14     oster  ****************************************************************************/
    335   1.3     oster int
    336  1.15     oster rf_DiskUndoFunc(RF_DagNode_t *node)
    337   1.3     oster {
    338   1.3     oster 	RF_DiskQueueData_t *req;
    339   1.3     oster 	RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;
    340  1.13     oster 	RF_DiskQueue_t *dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues;
    341   1.3     oster 
    342   1.3     oster 	req = rf_CreateDiskQueueData(RF_IO_TYPE_NOP,
    343   1.3     oster 	    0L, 0, NULL, 0L, 0,
    344   1.3     oster 	    (int (*) (void *, int)) node->wakeFunc,
    345   1.3     oster 	    (void *) node,
    346   1.3     oster 	    NULL, node->dagHdr->tracerec,
    347   1.3     oster 	    (void *) (node->dagHdr->raidPtr),
    348   1.3     oster 	    RF_UNLOCK_DISK_QUEUE, NULL);
    349   1.3     oster 	if (!req)
    350   1.3     oster 		(node->wakeFunc) (node, ENOMEM);
    351   1.3     oster 	else {
    352   1.3     oster 		node->dagFuncData = (void *) req;
    353  1.13     oster 		rf_DiskIOEnqueue(&(dqs[pda->col]), req, RF_IO_NORMAL_PRIORITY);
    354   1.3     oster 	}
    355   1.1     oster 
    356   1.3     oster 	return (0);
    357   1.1     oster }
    358  1.14     oster /*****************************************************************************
    359   1.1     oster  * the execution function associated with an "unlock disk queue" node
    360  1.14     oster  ****************************************************************************/
    361   1.3     oster int
    362  1.15     oster rf_DiskUnlockFuncForThreads(RF_DagNode_t *node)
    363   1.3     oster {
    364   1.3     oster 	RF_DiskQueueData_t *req;
    365   1.3     oster 	RF_PhysDiskAddr_t *pda = (RF_PhysDiskAddr_t *) node->params[0].p;
    366  1.13     oster 	RF_DiskQueue_t *dqs = ((RF_Raid_t *) (node->dagHdr->raidPtr))->Queues;
    367   1.3     oster 
    368   1.3     oster 	req = rf_CreateDiskQueueData(RF_IO_TYPE_NOP,
    369   1.3     oster 	    0L, 0, NULL, 0L, 0,
    370   1.3     oster 	    (int (*) (void *, int)) node->wakeFunc,
    371   1.3     oster 	    (void *) node,
    372   1.3     oster 	    NULL, node->dagHdr->tracerec,
    373   1.3     oster 	    (void *) (node->dagHdr->raidPtr),
    374   1.3     oster 	    RF_UNLOCK_DISK_QUEUE, NULL);
    375   1.3     oster 	if (!req)
    376   1.3     oster 		(node->wakeFunc) (node, ENOMEM);
    377   1.3     oster 	else {
    378   1.3     oster 		node->dagFuncData = (void *) req;
    379  1.13     oster 		rf_DiskIOEnqueue(&(dqs[pda->col]), req, RF_IO_NORMAL_PRIORITY);
    380   1.3     oster 	}
    381   1.1     oster 
    382   1.3     oster 	return (0);
    383   1.1     oster }
    384  1.14     oster /*****************************************************************************
    385  1.14     oster  * Callback routine for DiskRead and DiskWrite nodes.  When the disk
    386  1.14     oster  * op completes, the routine is called to set the node status and
    387  1.14     oster  * inform the execution engine that the node has fired.
    388  1.14     oster  ****************************************************************************/
    389   1.3     oster int
    390  1.15     oster rf_GenericWakeupFunc(RF_DagNode_t *node, int status)
    391   1.3     oster {
    392  1.15     oster 
    393   1.3     oster 	switch (node->status) {
    394   1.3     oster 	case rf_bwd1:
    395   1.3     oster 		node->status = rf_bwd2;
    396   1.3     oster 		if (node->dagFuncData)
    397   1.3     oster 			rf_FreeDiskQueueData((RF_DiskQueueData_t *) node->dagFuncData);
    398   1.3     oster 		return (rf_DiskWriteFuncForThreads(node));
    399   1.3     oster 	case rf_fired:
    400   1.3     oster 		if (status)
    401   1.3     oster 			node->status = rf_bad;
    402   1.3     oster 		else
    403   1.3     oster 			node->status = rf_good;
    404   1.3     oster 		break;
    405   1.3     oster 	case rf_recover:
    406   1.3     oster 		/* probably should never reach this case */
    407   1.3     oster 		if (status)
    408   1.3     oster 			node->status = rf_panic;
    409   1.3     oster 		else
    410   1.3     oster 			node->status = rf_undone;
    411   1.3     oster 		break;
    412   1.3     oster 	default:
    413   1.4     oster 		printf("rf_GenericWakeupFunc:");
    414   1.4     oster 		printf("node->status is %d,", node->status);
    415   1.4     oster 		printf("status is %d \n", status);
    416   1.3     oster 		RF_PANIC();
    417   1.3     oster 		break;
    418   1.3     oster 	}
    419   1.3     oster 	if (node->dagFuncData)
    420   1.3     oster 		rf_FreeDiskQueueData((RF_DiskQueueData_t *) node->dagFuncData);
    421   1.3     oster 	return (rf_FinishNode(node, RF_INTR_CONTEXT));
    422   1.1     oster }
    423   1.1     oster 
    424   1.1     oster 
    425  1.14     oster /*****************************************************************************
    426  1.14     oster  * there are three distinct types of xor nodes:
    427  1.14     oster 
    428  1.14     oster  * A "regular xor" is used in the fault-free case where the access
    429  1.14     oster  * spans a complete stripe unit.  It assumes that the result buffer is
    430  1.14     oster  * one full stripe unit in size, and uses the stripe-unit-offset
    431  1.14     oster  * values that it computes from the PDAs to determine where within the
    432  1.14     oster  * stripe unit to XOR each argument buffer.
    433  1.14     oster  *
    434  1.14     oster  * A "simple xor" is used in the fault-free case where the access
    435  1.14     oster  * touches only a portion of one (or two, in some cases) stripe
    436  1.14     oster  * unit(s).  It assumes that all the argument buffers are of the same
    437  1.14     oster  * size and have the same stripe unit offset.
    438  1.14     oster  *
    439  1.14     oster  * A "recovery xor" is used in the degraded-mode case.  It's similar
    440  1.14     oster  * to the regular xor function except that it takes the failed PDA as
    441  1.14     oster  * an additional parameter, and uses it to determine what portions of
    442  1.14     oster  * the argument buffers need to be xor'd into the result buffer, and
    443  1.14     oster  * where in the result buffer they should go.
    444  1.14     oster  ****************************************************************************/
    445   1.1     oster 
    446   1.1     oster /* xor the params together and store the result in the result field.
    447  1.14     oster  * assume the result field points to a buffer that is the size of one
    448  1.14     oster  * SU, and use the pda params to determine where within the buffer to
    449  1.14     oster  * XOR the input buffers.  */
    450   1.3     oster int
    451  1.15     oster rf_RegularXorFunc(RF_DagNode_t *node)
    452   1.3     oster {
    453   1.3     oster 	RF_Raid_t *raidPtr = (RF_Raid_t *) node->params[node->numParams - 1].p;
    454   1.3     oster 	RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
    455   1.3     oster 	RF_Etimer_t timer;
    456   1.3     oster 	int     i, retcode;
    457   1.1     oster 
    458   1.3     oster 	retcode = 0;
    459   1.3     oster 	if (node->dagHdr->status == rf_enable) {
    460   1.3     oster 		/* don't do the XOR if the input is the same as the output */
    461   1.3     oster 		RF_ETIMER_START(timer);
    462   1.3     oster 		for (i = 0; i < node->numParams - 1; i += 2)
    463   1.3     oster 			if (node->params[i + 1].p != node->results[0]) {
    464   1.3     oster 				retcode = rf_XorIntoBuffer(raidPtr, (RF_PhysDiskAddr_t *) node->params[i].p,
    465  1.17     oster 							   (char *) node->params[i + 1].p, (char *) node->results[0]);
    466   1.3     oster 			}
    467   1.3     oster 		RF_ETIMER_STOP(timer);
    468   1.3     oster 		RF_ETIMER_EVAL(timer);
    469   1.3     oster 		tracerec->xor_us += RF_ETIMER_VAL_US(timer);
    470   1.3     oster 	}
    471   1.3     oster 	return (rf_GenericWakeupFunc(node, retcode));	/* call wake func
    472   1.3     oster 							 * explicitly since no
    473   1.3     oster 							 * I/O in this node */
    474   1.1     oster }
    475   1.1     oster /* xor the inputs into the result buffer, ignoring placement issues */
    476   1.3     oster int
    477  1.15     oster rf_SimpleXorFunc(RF_DagNode_t *node)
    478   1.3     oster {
    479   1.3     oster 	RF_Raid_t *raidPtr = (RF_Raid_t *) node->params[node->numParams - 1].p;
    480   1.3     oster 	int     i, retcode = 0;
    481   1.3     oster 	RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
    482   1.3     oster 	RF_Etimer_t timer;
    483   1.1     oster 
    484   1.3     oster 	if (node->dagHdr->status == rf_enable) {
    485   1.3     oster 		RF_ETIMER_START(timer);
    486   1.3     oster 		/* don't do the XOR if the input is the same as the output */
    487   1.3     oster 		for (i = 0; i < node->numParams - 1; i += 2)
    488   1.3     oster 			if (node->params[i + 1].p != node->results[0]) {
    489   1.3     oster 				retcode = rf_bxor((char *) node->params[i + 1].p, (char *) node->results[0],
    490  1.17     oster 				    rf_RaidAddressToByte(raidPtr, ((RF_PhysDiskAddr_t *) node->params[i].p)->numSector));
    491   1.3     oster 			}
    492   1.3     oster 		RF_ETIMER_STOP(timer);
    493   1.3     oster 		RF_ETIMER_EVAL(timer);
    494   1.3     oster 		tracerec->xor_us += RF_ETIMER_VAL_US(timer);
    495   1.3     oster 	}
    496   1.3     oster 	return (rf_GenericWakeupFunc(node, retcode));	/* call wake func
    497   1.3     oster 							 * explicitly since no
    498   1.3     oster 							 * I/O in this node */
    499   1.1     oster }
    500  1.14     oster /* this xor is used by the degraded-mode dag functions to recover lost
    501  1.14     oster  * data.  the second-to-last parameter is the PDA for the failed
    502  1.14     oster  * portion of the access.  the code here looks at this PDA and assumes
    503  1.14     oster  * that the xor target buffer is equal in size to the number of
    504  1.14     oster  * sectors in the failed PDA.  It then uses the other PDAs in the
    505  1.14     oster  * parameter list to determine where within the target buffer the
    506  1.14     oster  * corresponding data should be xored.  */
    507   1.3     oster int
    508  1.15     oster rf_RecoveryXorFunc(RF_DagNode_t *node)
    509   1.3     oster {
    510   1.3     oster 	RF_Raid_t *raidPtr = (RF_Raid_t *) node->params[node->numParams - 1].p;
    511   1.3     oster 	RF_RaidLayout_t *layoutPtr = (RF_RaidLayout_t *) & raidPtr->Layout;
    512   1.3     oster 	RF_PhysDiskAddr_t *failedPDA = (RF_PhysDiskAddr_t *) node->params[node->numParams - 2].p;
    513   1.3     oster 	int     i, retcode = 0;
    514   1.3     oster 	RF_PhysDiskAddr_t *pda;
    515   1.3     oster 	int     suoffset, failedSUOffset = rf_StripeUnitOffset(layoutPtr, failedPDA->startSector);
    516   1.3     oster 	char   *srcbuf, *destbuf;
    517   1.3     oster 	RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;
    518   1.3     oster 	RF_Etimer_t timer;
    519   1.1     oster 
    520   1.3     oster 	if (node->dagHdr->status == rf_enable) {
    521   1.3     oster 		RF_ETIMER_START(timer);
    522   1.3     oster 		for (i = 0; i < node->numParams - 2; i += 2)
    523   1.3     oster 			if (node->params[i + 1].p != node->results[0]) {
    524   1.3     oster 				pda = (RF_PhysDiskAddr_t *) node->params[i].p;
    525   1.3     oster 				srcbuf = (char *) node->params[i + 1].p;
    526   1.3     oster 				suoffset = rf_StripeUnitOffset(layoutPtr, pda->startSector);
    527   1.3     oster 				destbuf = ((char *) node->results[0]) + rf_RaidAddressToByte(raidPtr, suoffset - failedSUOffset);
    528  1.17     oster 				retcode = rf_bxor(srcbuf, destbuf, rf_RaidAddressToByte(raidPtr, pda->numSector));
    529   1.3     oster 			}
    530   1.3     oster 		RF_ETIMER_STOP(timer);
    531   1.3     oster 		RF_ETIMER_EVAL(timer);
    532   1.3     oster 		tracerec->xor_us += RF_ETIMER_VAL_US(timer);
    533   1.3     oster 	}
    534   1.3     oster 	return (rf_GenericWakeupFunc(node, retcode));
    535   1.1     oster }
    536  1.14     oster /*****************************************************************************
    537  1.14     oster  * The next three functions are utilities used by the above
    538  1.14     oster  * xor-execution functions.
    539  1.14     oster  ****************************************************************************/
    540   1.1     oster 
    541   1.1     oster 
    542   1.1     oster /*
    543  1.14     oster  * this is just a glorified buffer xor.  targbuf points to a buffer
    544  1.14     oster  * that is one full stripe unit in size.  srcbuf points to a buffer
    545  1.14     oster  * that may be less than 1 SU, but never more.  When the access
    546  1.14     oster  * described by pda is one SU in size (which by implication means it's
    547  1.14     oster  * SU-aligned), all that happens is (targbuf) <- (srcbuf ^ targbuf).
    548  1.14     oster  * When the access is less than one SU in size the XOR occurs on only
    549  1.14     oster  * the portion of targbuf identified in the pda.  */
    550   1.1     oster 
    551   1.3     oster int
    552  1.15     oster rf_XorIntoBuffer(RF_Raid_t *raidPtr, RF_PhysDiskAddr_t *pda,
    553  1.17     oster 		 char *srcbuf, char *targbuf)
    554   1.3     oster {
    555   1.3     oster 	char   *targptr;
    556   1.3     oster 	int     sectPerSU = raidPtr->Layout.sectorsPerStripeUnit;
    557   1.3     oster 	int     SUOffset = pda->startSector % sectPerSU;
    558   1.3     oster 	int     length, retcode = 0;
    559   1.3     oster 
    560   1.3     oster 	RF_ASSERT(pda->numSector <= sectPerSU);
    561   1.3     oster 
    562   1.3     oster 	targptr = targbuf + rf_RaidAddressToByte(raidPtr, SUOffset);
    563   1.3     oster 	length = rf_RaidAddressToByte(raidPtr, pda->numSector);
    564  1.17     oster 	retcode = rf_bxor(srcbuf, targptr, length);
    565   1.3     oster 	return (retcode);
    566   1.1     oster }
    567  1.14     oster /* it really should be the case that the buffer pointers (returned by
    568  1.14     oster  * malloc) are aligned to the natural word size of the machine, so
    569  1.14     oster  * this is the only case we optimize for.  The length should always be
    570  1.14     oster  * a multiple of the sector size, so there should be no problem with
    571  1.14     oster  * leftover bytes at the end.  */
    572   1.3     oster int
    573  1.17     oster rf_bxor(char *src, char *dest, int len)
    574   1.3     oster {
    575   1.3     oster 	unsigned mask = sizeof(long) - 1, retcode = 0;
    576   1.3     oster 
    577  1.14     oster 	if (!(((unsigned long) src) & mask) &&
    578  1.14     oster 	    !(((unsigned long) dest) & mask) && !(len & mask)) {
    579  1.14     oster 		retcode = rf_longword_bxor((unsigned long *) src,
    580  1.14     oster 					   (unsigned long *) dest,
    581  1.17     oster 					   len >> RF_LONGSHIFT);
    582   1.3     oster 	} else {
    583   1.3     oster 		RF_ASSERT(0);
    584   1.3     oster 	}
    585   1.3     oster 	return (retcode);
    586   1.1     oster }
    587   1.1     oster 
    588  1.14     oster /* When XORing in kernel mode, we need to map each user page to kernel
    589  1.14     oster  * space before we can access it.  We don't want to assume anything
    590  1.14     oster  * about which input buffers are in kernel/user space, nor about their
    591  1.14     oster  * alignment, so in each loop we compute the maximum number of bytes
    592  1.14     oster  * that we can xor without crossing any page boundaries, and do only
    593  1.15     oster  * this many bytes before the next remap.
    594  1.15     oster  *
    595  1.15     oster  * len - is in longwords
    596  1.15     oster  */
    597   1.3     oster int
    598  1.17     oster rf_longword_bxor(unsigned long *src, unsigned long *dest, int len)
    599   1.3     oster {
    600   1.6  augustss 	unsigned long *end = src + len;
    601   1.6  augustss 	unsigned long d0, d1, d2, d3, s0, s1, s2, s3;	/* temps */
    602  1.14     oster 	unsigned long *pg_src, *pg_dest;   /* per-page source/dest pointers */
    603   1.3     oster 	int     longs_this_time;/* # longwords to xor in the current iteration */
    604   1.3     oster 
    605  1.16     oster 	pg_src = src;
    606  1.16     oster 	pg_dest = dest;
    607   1.3     oster 	if (!pg_src || !pg_dest)
    608   1.3     oster 		return (EFAULT);
    609   1.3     oster 
    610   1.3     oster 	while (len >= 4) {
    611   1.3     oster 		longs_this_time = RF_MIN(len, RF_MIN(RF_BLIP(pg_src), RF_BLIP(pg_dest)) >> RF_LONGSHIFT);	/* note len in longwords */
    612   1.3     oster 		src += longs_this_time;
    613   1.3     oster 		dest += longs_this_time;
    614   1.3     oster 		len -= longs_this_time;
    615   1.3     oster 		while (longs_this_time >= 4) {
    616   1.3     oster 			d0 = pg_dest[0];
    617   1.3     oster 			d1 = pg_dest[1];
    618   1.3     oster 			d2 = pg_dest[2];
    619   1.3     oster 			d3 = pg_dest[3];
    620   1.3     oster 			s0 = pg_src[0];
    621   1.3     oster 			s1 = pg_src[1];
    622   1.3     oster 			s2 = pg_src[2];
    623   1.3     oster 			s3 = pg_src[3];
    624   1.3     oster 			pg_dest[0] = d0 ^ s0;
    625   1.3     oster 			pg_dest[1] = d1 ^ s1;
    626   1.3     oster 			pg_dest[2] = d2 ^ s2;
    627   1.3     oster 			pg_dest[3] = d3 ^ s3;
    628   1.3     oster 			pg_src += 4;
    629   1.3     oster 			pg_dest += 4;
    630   1.3     oster 			longs_this_time -= 4;
    631   1.3     oster 		}
    632   1.3     oster 		while (longs_this_time > 0) {	/* cannot cross any page
    633   1.3     oster 						 * boundaries here */
    634   1.3     oster 			*pg_dest++ ^= *pg_src++;
    635   1.3     oster 			longs_this_time--;
    636   1.3     oster 		}
    637   1.3     oster 
    638   1.3     oster 		/* either we're done, or we've reached a page boundary on one
    639   1.3     oster 		 * (or possibly both) of the pointers */
    640   1.3     oster 		if (len) {
    641   1.3     oster 			if (RF_PAGE_ALIGNED(src))
    642  1.16     oster 				pg_src = src;
    643   1.3     oster 			if (RF_PAGE_ALIGNED(dest))
    644  1.16     oster 				pg_dest = dest;
    645   1.3     oster 			if (!pg_src || !pg_dest)
    646   1.3     oster 				return (EFAULT);
    647   1.3     oster 		}
    648   1.3     oster 	}
    649   1.3     oster 	while (src < end) {
    650   1.3     oster 		*pg_dest++ ^= *pg_src++;
    651   1.3     oster 		src++;
    652   1.3     oster 		dest++;
    653   1.3     oster 		len--;
    654   1.3     oster 		if (RF_PAGE_ALIGNED(src))
    655  1.16     oster 			pg_src = src;
    656   1.3     oster 		if (RF_PAGE_ALIGNED(dest))
    657  1.16     oster 			pg_dest = dest;
    658   1.3     oster 	}
    659   1.3     oster 	RF_ASSERT(len == 0);
    660   1.3     oster 	return (0);
    661   1.1     oster }
    662   1.1     oster 
    663   1.9     oster #if 0
    664   1.1     oster /*
    665   1.1     oster    dst = a ^ b ^ c;
    666   1.1     oster    a may equal dst
    667   1.1     oster    see comment above longword_bxor
    668  1.15     oster    len is length in longwords
    669   1.1     oster */
    670   1.3     oster int
    671  1.15     oster rf_longword_bxor3(unsigned long *dst, unsigned long *a, unsigned long *b,
    672  1.15     oster 		  unsigned long *c, int len, void *bp)
    673   1.3     oster {
    674   1.3     oster 	unsigned long a0, a1, a2, a3, b0, b1, b2, b3;
    675   1.6  augustss 	unsigned long *pg_a, *pg_b, *pg_c, *pg_dst;	/* per-page source/dest
    676   1.3     oster 								 * pointers */
    677   1.3     oster 	int     longs_this_time;/* # longs to xor in the current iteration */
    678   1.3     oster 	char    dst_is_a = 0;
    679   1.3     oster 
    680  1.16     oster 	pg_a = a;
    681  1.16     oster 	pg_b = b;
    682  1.16     oster 	pg_c = c;
    683   1.3     oster 	if (a == dst) {
    684   1.3     oster 		pg_dst = pg_a;
    685   1.3     oster 		dst_is_a = 1;
    686   1.3     oster 	} else {
    687  1.16     oster 		pg_dst = dst;
    688   1.3     oster 	}
    689   1.3     oster 
    690   1.3     oster 	/* align dest to cache line.  Can't cross a pg boundary on dst here. */
    691   1.3     oster 	while ((((unsigned long) pg_dst) & 0x1f)) {
    692   1.3     oster 		*pg_dst++ = *pg_a++ ^ *pg_b++ ^ *pg_c++;
    693   1.3     oster 		dst++;
    694   1.3     oster 		a++;
    695   1.3     oster 		b++;
    696   1.3     oster 		c++;
    697   1.3     oster 		if (RF_PAGE_ALIGNED(a)) {
    698  1.16     oster 			pg_a = a;
    699   1.3     oster 			if (!pg_a)
    700   1.3     oster 				return (EFAULT);
    701   1.3     oster 		}
    702   1.3     oster 		if (RF_PAGE_ALIGNED(b)) {
    703  1.16     oster 			pg_b = a;
    704   1.3     oster 			if (!pg_b)
    705   1.3     oster 				return (EFAULT);
    706   1.3     oster 		}
    707   1.3     oster 		if (RF_PAGE_ALIGNED(c)) {
    708  1.16     oster 			pg_c = a;
    709   1.3     oster 			if (!pg_c)
    710   1.3     oster 				return (EFAULT);
    711   1.3     oster 		}
    712   1.3     oster 		len--;
    713   1.3     oster 	}
    714   1.3     oster 
    715   1.3     oster 	while (len > 4) {
    716   1.3     oster 		longs_this_time = RF_MIN(len, RF_MIN(RF_BLIP(a), RF_MIN(RF_BLIP(b), RF_MIN(RF_BLIP(c), RF_BLIP(dst)))) >> RF_LONGSHIFT);
    717   1.3     oster 		a += longs_this_time;
    718   1.3     oster 		b += longs_this_time;
    719   1.3     oster 		c += longs_this_time;
    720   1.3     oster 		dst += longs_this_time;
    721   1.3     oster 		len -= longs_this_time;
    722   1.3     oster 		while (longs_this_time >= 4) {
    723   1.3     oster 			a0 = pg_a[0];
    724   1.3     oster 			longs_this_time -= 4;
    725   1.3     oster 
    726   1.3     oster 			a1 = pg_a[1];
    727   1.3     oster 			a2 = pg_a[2];
    728   1.3     oster 
    729   1.3     oster 			a3 = pg_a[3];
    730   1.3     oster 			pg_a += 4;
    731   1.3     oster 
    732   1.3     oster 			b0 = pg_b[0];
    733   1.3     oster 			b1 = pg_b[1];
    734   1.3     oster 
    735   1.3     oster 			b2 = pg_b[2];
    736   1.3     oster 			b3 = pg_b[3];
    737   1.3     oster 			/* start dual issue */
    738   1.3     oster 			a0 ^= b0;
    739   1.3     oster 			b0 = pg_c[0];
    740   1.3     oster 
    741   1.3     oster 			pg_b += 4;
    742   1.3     oster 			a1 ^= b1;
    743   1.3     oster 
    744   1.3     oster 			a2 ^= b2;
    745   1.3     oster 			a3 ^= b3;
    746   1.3     oster 
    747   1.3     oster 			b1 = pg_c[1];
    748   1.3     oster 			a0 ^= b0;
    749   1.3     oster 
    750   1.3     oster 			b2 = pg_c[2];
    751   1.3     oster 			a1 ^= b1;
    752   1.3     oster 
    753   1.3     oster 			b3 = pg_c[3];
    754   1.3     oster 			a2 ^= b2;
    755   1.3     oster 
    756   1.3     oster 			pg_dst[0] = a0;
    757   1.3     oster 			a3 ^= b3;
    758   1.3     oster 			pg_dst[1] = a1;
    759   1.3     oster 			pg_c += 4;
    760   1.3     oster 			pg_dst[2] = a2;
    761   1.3     oster 			pg_dst[3] = a3;
    762   1.3     oster 			pg_dst += 4;
    763   1.3     oster 		}
    764   1.3     oster 		while (longs_this_time > 0) {	/* cannot cross any page
    765   1.3     oster 						 * boundaries here */
    766   1.3     oster 			*pg_dst++ = *pg_a++ ^ *pg_b++ ^ *pg_c++;
    767   1.3     oster 			longs_this_time--;
    768   1.3     oster 		}
    769   1.3     oster 
    770   1.3     oster 		if (len) {
    771   1.3     oster 			if (RF_PAGE_ALIGNED(a)) {
    772  1.16     oster 				pg_a = a;
    773   1.3     oster 				if (!pg_a)
    774   1.3     oster 					return (EFAULT);
    775   1.3     oster 				if (dst_is_a)
    776   1.3     oster 					pg_dst = pg_a;
    777   1.3     oster 			}
    778   1.3     oster 			if (RF_PAGE_ALIGNED(b)) {
    779  1.16     oster 				pg_b = b;
    780   1.3     oster 				if (!pg_b)
    781   1.3     oster 					return (EFAULT);
    782   1.3     oster 			}
    783   1.3     oster 			if (RF_PAGE_ALIGNED(c)) {
    784  1.16     oster 				pg_c = c;
    785   1.3     oster 				if (!pg_c)
    786   1.3     oster 					return (EFAULT);
    787   1.3     oster 			}
    788   1.3     oster 			if (!dst_is_a)
    789   1.3     oster 				if (RF_PAGE_ALIGNED(dst)) {
    790  1.16     oster 					pg_dst = dst;
    791   1.3     oster 					if (!pg_dst)
    792   1.3     oster 						return (EFAULT);
    793   1.3     oster 				}
    794   1.3     oster 		}
    795   1.3     oster 	}
    796   1.3     oster 	while (len) {
    797   1.3     oster 		*pg_dst++ = *pg_a++ ^ *pg_b++ ^ *pg_c++;
    798   1.3     oster 		dst++;
    799   1.3     oster 		a++;
    800   1.3     oster 		b++;
    801   1.3     oster 		c++;
    802   1.3     oster 		if (RF_PAGE_ALIGNED(a)) {
    803  1.16     oster 			pg_a = a;
    804   1.3     oster 			if (!pg_a)
    805   1.3     oster 				return (EFAULT);
    806   1.3     oster 			if (dst_is_a)
    807   1.3     oster 				pg_dst = pg_a;
    808   1.3     oster 		}
    809   1.3     oster 		if (RF_PAGE_ALIGNED(b)) {
    810  1.16     oster 			pg_b = b;
    811   1.3     oster 			if (!pg_b)
    812   1.3     oster 				return (EFAULT);
    813   1.3     oster 		}
    814   1.3     oster 		if (RF_PAGE_ALIGNED(c)) {
    815  1.16     oster 			pg_c = c;
    816   1.3     oster 			if (!pg_c)
    817   1.3     oster 				return (EFAULT);
    818   1.3     oster 		}
    819   1.3     oster 		if (!dst_is_a)
    820   1.3     oster 			if (RF_PAGE_ALIGNED(dst)) {
    821  1.16     oster 				pg_dst = dst;
    822   1.3     oster 				if (!pg_dst)
    823   1.3     oster 					return (EFAULT);
    824   1.3     oster 			}
    825   1.3     oster 		len--;
    826   1.3     oster 	}
    827   1.3     oster 	return (0);
    828   1.3     oster }
    829   1.3     oster 
    830   1.3     oster int
    831  1.15     oster rf_bxor3(unsigned char *dst, unsigned char *a, unsigned char *b,
    832  1.15     oster 	 unsigned char *c, unsigned long len, void *bp)
    833   1.1     oster {
    834   1.3     oster 	RF_ASSERT(((RF_UL(dst) | RF_UL(a) | RF_UL(b) | RF_UL(c) | len) & 0x7) == 0);
    835   1.1     oster 
    836   1.3     oster 	return (rf_longword_bxor3((unsigned long *) dst, (unsigned long *) a,
    837   1.3     oster 		(unsigned long *) b, (unsigned long *) c, len >> RF_LONGSHIFT, bp));
    838   1.1     oster }
    839   1.9     oster #endif
    840