⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mscp_bbr.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
 * *   Name:	mscp_bbr_step0b -  * *   Abstract:	This function updates RCT sector 0 using  *		multicopy write. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step0b( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register UNITB		*up = rp->unitb;    register RCT_SECTOR_0	*sp = ( RCT_SECTOR_0 * )bbrp->buf0;    Cprintf("mscp_bbr_step0b: entered\n");    /* If multi-read failed then handle it set the FE bit before     * rewrite.     */    if( event == EV_BBRERROR) 	sp->flags |= RCT_S0_FE;    /* Set up the buffer address and RCT sector 0 logical block      * number and start the multicopy write.     */    bbrp->multi_buf = bbrp->buf0;    rp->p1 = up->unt_size;    return( mscp_multi_write( rp ));}/**//* * *   Name:	mscp_bbr_step0c -  * *   Abstract:	This function updates RCT sector 1 * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step0c( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register UNITB		*up = rp->unitb;    register RCT_SECTOR_0	*sp = ( RCT_SECTOR_0 * )bbrp->buf0;    Cprintf("mscp_bbr_step0c: entered\n");    /* Set up the buffer address and RCT sector 0 logical block      * number and start the multicopy write.     */    bbrp->multi_buf = bbrp->buf1;    rp->p1 = up->unt_size + 1;    return( mscp_multi_write( rp ));}/**//* * *   Name:	mscp_bbr_step1 -  * *   Abstract:	This function checks if BBR was in progress. If BBR was *		in progress it dispatches to the correct step to continue *		the BBR.  If BBR was not in progress it unlocks and returns *		to ONLINE processing. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step1( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register UNITB		*up = rp->unitb;    register RCT_SECTOR_0	*sp = ( RCT_SECTOR_0 * )bbrp->buf0;    register u_long		new_event = EV_INITIAL;    u_long			primary_rbn;    Cprintf("mscp_bbr_step1: entered\n");    if (sp->flags & RCT_S0_P1) {	if (sp->flags & RCT_S0_P2) {		/* corrupt RCT */		new_event = EV_BBRERROR;	}	else	    rp->state = ST_BB_STEP7;    }    else if (sp->flags & RCT_S0_P2) {	    if (sp->flags & RCT_S0_P1) {		/* corrupt RCT */		new_event = EV_BBRERROR;	    }	    else {		bbrp->rbn = sp->rbn;		bbrp->flags.bit.p2recov = 1;		if( sp->flags & RCT_S0_BR ) {		    bbrp->match_rbn = sp->badrbn;		    bbrp->flags.bit.match = 1;	        }	        rp->state = ST_BB_STEP11;	    }    }    else {	/* No BBR in progress	*/	Cprintf("No BBR in progress\n");	mscp_bbr_unlock( rp );	new_event = EV_NULL;	return( new_event );    }	/* *	Check for corrupt lbn */    if ((sp->lbn >= up->unt_size) || (sp->lbn < 0)) {	new_event = EV_BBRERROR;    }     		    else {	bbrp->lbn = sp->lbn;	if (bbrp->flags.bit.p2recov) {	    primary_rbn = (bbrp->lbn/up->track) * up->rbns;	    if (primary_rbn != bbrp->rbn)		bbrp->flags.bit.nonprim = 1;	    else		bbrp->flags.bit.nonprim = 0;	}	if ( sp->flags & RCT_S0_FE )		bbrp->flags.bit.fe = 1;    }    if( new_event == EV_BBRERROR ) {	bbrp->flags.bit.corrupt = 1;	rp->state = ST_BB_STEP1;    }    return(new_event);}/**//* * *   Name:	mscp_bbr_step4 - Read data from bad block * *   Abstract:	This function attempts to recover the data *		from the bad block. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step4( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register MSCP		*mp = bbrp->cur_reqb->msgptr;    Cprintf("mscp_bbr_step4: entered lbn=%x\n", bbrp->lbn);    /* Clear the data buffer in case no data can be transferred, and     * start the first read attempt.     */    bbrp->loop_ct1 = 4;    bbrp->flags.bit.fe = 0;    if (bbrp->cur_reqb->flags.force == 1)        bbrp->flags.bit.force = 1;    ( void )bzero( bbrp->buf1, 512 );    /* Retrieve the reported bad block from the mscp packet */    bbrp->lbn = mp->mscp_lbn;    rp->p1 = bbrp->lbn;    rp->p2 = 0;    Cprintf("Bad lbn = %x\n", bbrp->lbn);    return( mscp_bbr_read( rp, bbrp->buf1 ));}/**//* * *   Name:	mscp_bbr_step4a - Read data from bad block, continued * *   Abstract:	This function attempts to recover the data *		from the bad block. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step4a( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register MSCP		*mp = rp->msgptr;    u_long			new_event = EV_BBRSUCCESS;    u_long			code = mp->mscp_status & MSCP_ST_MASK;    u_long			subcode = mp->mscp_status >> MSCP_ST_SBBIT;    Cprintf("mscp_bbr_step4a: entered, Event = %x lbn=%x\n", event, bbrp->lbn);    /* If the read completed with forced error status, remember the     * fact for step 6.     */    if(( code == MSCP_ST_DATA ) && ( subcode == MSCP_SC_FRCER ))	bbrp->flags.bit.fe = 1;    /* If the read completed with some other error and the retry count     * has not gone to zero, try to read the data again.  If no retries     * remain, set the forced error flag for step 6.     */    else if( code != MSCP_ST_SUCC ) {        if( --bbrp->loop_ct1 ) {	    new_event = mscp_bbr_read( rp, bbrp->buf1 );	}	else	    bbrp->flags.bit.fe = 1;    }    return( new_event );}/**//* * *   Name:	mscp_bbr_step5 - Save bad block data in RCT sector 1 * *   Abstract:	This function writes the bad block data read in step 4 *		into RCT sector 1, using multicopy protection. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step5( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register MSCP		*mp = rp->msgptr;    register UNITB		*up = rp->unitb;    Cprintf("mscp_bbr_step5: entered lbn=%x\n", bbrp->lbn);    /* Set up the buffer address and RCT1 logical block number     * and start the multicopy write.     */    bbrp->multi_buf = bbrp->buf1;    rp->p1 = up->unt_size + 1;    return( mscp_multi_write( rp ));}/**//* * *   Name:	mscp_bbr_step6 - Phase 1 update to RCT sector 0 * *   Abstract:	This function reads RCT sector 0 so that it can be *		updated to reflect the phase 1 state. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step6( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register UNITB		*up = rp->unitb;    Cprintf("mscp_bbr_step6: entered lbn=%x\n", bbrp->lbn);    /* Set up the buffer address and RCT sector 0 logical block      * number and start the multicopy read.     */    bbrp->multi_buf = bbrp->buf0;    rp->p1 = up->unt_size;    return( mscp_multi_read( rp ));}/**//* * *   Name:	mscp_bbr_step6a - Phase 1 update to RCT sector 0, continued * *   Abstract:	This function updates RCT sector 0 to reflect the  *		phase 1 state.	The sector, read in the first part *		of step 6, is modified and rewritten to the RCT.   *		This copy of RCT sector 0 is used for all subsequent *		sector 0 updates. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step6a( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register UNITB		*up = rp->unitb;    register RCT_SECTOR_0	*sp = ( RCT_SECTOR_0 * )bbrp->buf0;    Cprintf("mscp_bbr_step6a: entered lbn=%x\n", bbrp->lbn);    /* Update RCT sector 0 by storing the bad block LBN, clearing     * the BR flag, setting the P1 flag, and setting or clearing the FE     * flag depending on whether a forced error was seen in step 4.     */    sp->lbn = bbrp->lbn;    sp->flags &= ~( RCT_S0_FE | RCT_S0_BR );    sp->flags |=  RCT_S0_P1;    if( bbrp->flags.bit.fe )	sp->flags |=  RCT_S0_FE;    /* Set up the buffer address and RCT sector 0 logical block      * number and start the multicopy write.     */    bbrp->multi_buf = bbrp->buf0;    rp->p1 = up->unt_size;    return( mscp_multi_write( rp ));}/**//* * *   Name:	mscp_bbr_step7 - Stress test bad block * *   Abstract:	Step 7 of the bad block replacement algorithm *		issues reads and writes with correction and error *		recovery disabled to test the block in question. *		This function performs step 7 initialization and *		does the first read. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step7( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register u_char		*buf1p = bbrp->buf1;    register u_char		*buf2p = bbrp->buf2;    register int		i;    u_long			new_event;    Cprintf("mscp_bbr_step7: entered, lbn=%x\n", bbrp->lbn);    /* If we are forcing the replace( from radisk ) then go directly to     * step 9.     */    if( bbrp->flags.bit.force ) {	rp->state = ST_BB_STEP9;	return( EV_INITIAL );    }    /* Copy and invert the bad block data saved during step 4     * into buf2.     */    for( i = 0; i < 128; i++ )	*buf2p++ = ~( *buf1p++ );    /* Initialize the read retry counter, set up and issue the     * first stress read of the bad block.     */    /* TODO fix loop counts to be parameter names and fix the     * comment above to include both.     */    bbrp->loop_ct1 = 4;    bbrp->loop_ct2 = 8;    rp->p1 = bbrp->lbn;    rp->p2 = MSCP_MD_SECOR | MSCP_MD_SEREC;    new_event = mscp_bbr_read( rp, bbrp->buf3 );    return( new_event );}/**//* * *   Name:	mscp_bbr_step7a - Stress test bad block, continued * *   Abstract:	Step 7 of the bad block replacement algorithm *		issues reads and writes with correction and error *		recovery disabled to test the block in question. *		This function performs step 7 initialization. * *   Inputs:	IPL_SCS *		event			Event code *		rp			Request block pointer * *   Implicit *   Inputs:	 * *   Outputs: * * *   Return	 *   Values:	EV_NULL */u_longmscp_bbr_step7a( event, rp )    u_long			event;    register REQB		*rp;{    register BBRB		*bbrp = rp->connb->bbrb;    register MSCP		*mp = rp->msgptr;    u_long			code = mp->mscp_status & MSCP_ST_MASK;    u_long			subcode = mp->mscp_status >> MSCP_ST_SBBIT;    u_long			new_event = EV_NULL;    Dprintf("mscp_bbr_step7a: entered, Event = %x\n", event);    /* If the end message status is success and the bad block reported     * flag is set or the status is a data error other than forced error,     * the stress test has failed.  Set an error flag and set the return     * status accordingly.     */    if( (( code == MSCP_ST_SUCC )  && ( mp->mscp_flags & MSCP_EF_BBLKR ))  ||	(( code == MSCP_ST_DATA ) && ( subcode != MSCP_SC_FRCER )) ) {	bbrp->flags.bit.error = 1;	new_event = EV_BBRERROR;    /* If the read succeeded and there are more reads to do, issue the     * next one.     */    } else if( --bbrp->loop_ct1 ) {	rp->p1 = bbrp->lbn;	rp->p2 = MSCP_MD_SECOR | MSCP_MD_SEREC;	new_event = mscp_bbr_read( rp, bbrp->buf3 );    /* All of the initial stress reads succeeded.  Continue on to the     * next substep.     */    } else {	new_event = EV_BBRSUCCESS;    }    return( new_event );}/**/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -