📄 mscp_bbr.c
字号:
#ifndef lintstatic char *sccsid = "@(#)mscp_bbr.c 4.3 (ULTRIX) 12/20/90";#endif lint/************************************************************************ * * * Copyright (c) 1987 - 1989 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************ * * * Facility: Systems Communication Architecture * Disk Class Driver * * Abstract: This module contains functions which implement host * initiated bad block replacement for the disk variant * of MSCP. * * mscp_multi_read Initiate read of multicopy structure * mscp_multi_read_cont Continue read of multicopy structure * mscp_multi_write Initiate write of multicopy structure * mscp_multi_write_cont Continue write of multicopy structure * * Author: David E. Eiche Creation Date: October 15, 1987 * * History: * * 4-Dec-1990 Brian Nadeau * Clear out flags in mscp_bbr_step14/16 before we use it. This * will stop lint from complaining about using flags before we * set it. * * 28-Aug-1990 Matthew Sacks * Changed mscp_multi_write_cont so that it will NOT log the no * multi-copy protection warning if the unit always had just one * copy of the RCT anyway; this is for cases like the ESE20 which * have exactly one copy (albeit a fake one) of the RCT. * * 31-Aug-1989 David E. Eiche DEE0077 * Fix synchronization bug in step 1 wherein processing on * a new BBR request was begun before processing on the * previous request had terminated. * * 21-Jul-1989 David E. Eiche DEE0070 * Change reference from MSLG_FM_DSK_TRN to MSLG_FM_DISK_TRN. * * 17-Mar-1989 Tim Burke * Changed queue manipulations to use the following macros: * insque ..... Insert_entry * remque ..... Remove_entry * remqck ..... Remove_entry and check to see if any elements on queue. * * 07-Mar-1989 Todd M. Katz TMK0001 * 1. Include header file ../vaxmsi/msisysap.h. * 2. Use the ../machine link to refer to machine specific header files. * * 19-Aug-1988 Pete Keilty * Corrected the error event code for multi-copy warning to * MSCP_ST_MFMTE. * * 27-Jul-1988 Pete Keilty * Made changes or corrections to the following routines bbr_log * grant, force, step1, step12a, step8 during bbr verification. * * 02-Jun-1988 Ricky S. Palmer * Removed inclusion of header file ../vaxmsi/msisysap.h * * 17-Apr-1988 Ricky S. Palmer * Include header file "../vaxmsi/msisysap.h". * *//**//* Libraries and Include Files. */#include "../h/types.h"#include "../h/time.h"#include "../h/param.h"#include "../h/kmalloc.h"#include "../h/buf.h"#include "../h/errno.h"#include "../h/ioctl.h"#include "../h/devio.h"#include "../h/file.h"#ifdef mips#include "../h/systm.h"#endif mips#include "../fs/ufs/fs.h"#include "../h/errlog.h"#include "../h/smp_lock.h"#include "../machine/pte.h"#include "../h/vmmac.h"#include "../h/config.h"#include "../io/scs/sca.h"#include "../io/ci/cippdsysap.h"#include "../io/ci/cisysap.h"#include "../io/msi/msisysap.h"#include "../io/ci/ciadapter.h"#include "../io/bi/bvpsysap.h"#include "../io/gvp/gvpsysap.h"#include "../io/uba/uqsysap.h"#include "../io/sysap/sysap.h"#include "../io/uba/ubavar.h"#include "../io/sysap/mscp_msg.h"#include "../io/sysap/mscp_defs.h"#include "../io/sysap/mscp_bbrdefs.h"/**//* Routine Definitions */void mscp_bbr_lock(), mscp_bbr_grant();u_long mscp_rct_search(), mscp_test_descr(), mscp_multi_read(), mscp_multi_write(), mscp_bbr_read(), mscp_bbr_write(), mscp_bbr_log();/* External Variables and Routines. */extern STATE mscp_bbr_states[];extern void mscp_logerr();/* Define debugging stuff. */int bbrdebug=0;#define BBRDEBUG#ifdef BBRDEBUG#define Cprintf if(bbrdebug)cprintf#define Dprintf if( bbrdebug >= 2 )cprintf#else#define Cprintf ;#define Dprintf ;#endif/**//* * * Name: mscp_bbr_init - Allocate/initialize BBR work area * * Abstract: This function is entered from connection establishment * or recovery to allocate and initialize the the bad block * work area. * * Inputs: IPL_SCS * cp Connection block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: EV_NULL */voidmscp_bbr_init( cp ) register CONNB *cp;{ register BBRB *bbrp = cp->bbrb; register REQB *rp; /* If the BBR block doesn't exist, allocate it now. */ if( bbrp == NULL ) KM_ALLOC( bbrp, BBRB *, sizeof( BBRB ), KM_SCA, KM_NOW_CL_CA ); /* If the allocation succeeded or the BBRB was already in place, * initialize it. */ if( bbrp != NULL ) { cp->bbrb = bbrp; bbrp->bbr_wq.flink = ( REQB * )&bbrp->bbr_wq.flink; bbrp->bbr_wq.blink = ( REQB * )&bbrp->bbr_wq.flink; bbrp->cur_reqb = NULL; rp = ( REQB * )&bbrp->bbr_reqb; rp->unitb = NULL; rp->connb = cp; rp->classb = cp->classb; rp->bufptr = ( struct buf * )&bbrp->bbr_buf; rp->p1 = 0; rp->p2 = 0; rp->op_seq_num = 0; rp->flags.perm_reqb = 1; rp->state_tbl = mscp_bbr_states; /*** TEMP Replace with timed retry ***/ } else { panic( "mscp_bbr_init: couldn't allocate BBRB\n" ); } return;}/**//* * * Name: mscp_bbr_online - Complete possible partial replacement * * Abstract: This function is the entry point into BBR during online * processing. It is used to complete any BBR operation * that may have been in progress when the unit went offline. * * Inputs: IPL_SCS * cur_rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: NONE */u_longmscp_bbr_online( cur_rp ) register REQB *cur_rp;{ Cprintf("mscp_bbr_online: entered\n"); cur_rp->flags.online = 1; mscp_bbr_lock( cur_rp ); return( EV_NULL );}/**//* * * Name: mscp_bbr_replace - Perform bad block replacement * * Abstract: This function is the entry point into BBR when a * bad block has been detected during a data transfer * operation. * * Inputs: IPL_SCS * cur_rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: NONE */u_longmscp_bbr_replace( cur_rp ) register REQB *cur_rp;{ mscp_bbr_lock( cur_rp ); return( EV_NULL );}/**//* * * Name: mscp_bbr_force - Force bad block replacement * * Abstract: This function is the entry point into BBR when a * replace operation is requested via the DKIOACC ioctl. * This is generated from the radisk utility. * * Inputs: IPL_SCS * cur_rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: NONE */u_longmscp_bbr_force( cur_rp ) register REQB *cur_rp;{ register BBRB *bbrp = cur_rp->connb->bbrb; Cprintf("mscp_bbr_force: entered\n"); if( bbrp == NULL ) panic( "mscp_bbr_force: no BBR work area allocated\n" ); cur_rp->flags.force = 1; mscp_bbr_lock( cur_rp ); return( EV_NULL );}/**//* * * Name: mscp_bbr_lock - * * Abstract: This function * * Inputs: IPL_SCS * cur_rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: NONE */voidmscp_bbr_lock( cur_rp ) register REQB *cur_rp;{ register BBRB *bbrp = cur_rp->connb->bbrb; Cprintf("mscp_bbr_lock: entered\n"); /* Check to see that the BBR work area block is present. */ if( bbrp == NULL ) panic( "mscp_bbr_lock: no BBR work area allocated\n" ); /* If there are no BBR requests active on the connection, set the * BBR lock and start the replacement process. Otherwise, queue the * request block for later processing. */ if( !bbrp->flags.bit.busy ) { bbrp->flags.bit.busy = 1; mscp_bbr_grant( cur_rp ); } else { Insert_entry( cur_rp->flink, bbrp->bbr_wq ); } /* Stall requests for the unit until the replacement process * completes. */ Incr_rwait( cur_rp ); return;}/**//* * * Name: mscp_bbr_unlock - * * Abstract: This function * * Inputs: IPL_SCS * rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: NONE */voidmscp_bbr_unlock( rp ) register REQB *rp;{ register BBRB *bbrp = rp->connb->bbrb; register REQB *cur_rp = bbrp->cur_reqb; /* Dispatch the current request with an error recovery complete * event, decrement the stall count and unstall the unit if * appropriate. Clear all BBR flags except for busy. * Then process the next replacement request, if any. * If no replacement requests remain, reset the BBR busy bit. */ Decr_rwait( cur_rp ); mscp_dispatch( EV_ERRECOV, cur_rp ); bbrp->cur_reqb = NULL; mscp_dealloc_all( rp ); bbrp->flags.mask &= BBR_FL_BUSY; if(( cur_rp = bbrp->bbr_wq.flink ) != ( REQB * )&bbrp->bbr_wq ) { Remove_entry( cur_rp->flink ); mscp_bbr_grant( cur_rp ); } else { bbrp->flags.bit.busy = 0; } return;}/**//* * * Name: mscp_bbr_grant - * * Abstract: This function * * Inputs: IPL_SCS * cur_rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: NONE */voidmscp_bbr_grant( cur_rp ) REQB *cur_rp;{ BBRB *bbrp = cur_rp->connb->bbrb; REQB *rp = &bbrp->bbr_reqb; Cprintf("mscp_bbr_grant entered\n"); /* Store the current request packet address in the BBR block, * propogate the unit block address and RSPID into the BBR * permanent request block, and dispatch based on the type * of request. */ bbrp->cur_reqb = cur_rp; bbrp->recursion_ct = 2; bbrp->rbn = 0; rp->unitb = cur_rp->unitb; if( cur_rp->flags.online ) rp->state = ST_BB_ONLINIT; else rp->state = ST_BB_REPINIT; mscp_dispatch( EV_INITIAL, rp ); return;}/**//* * * Name: mscp_bbr_step0 - * * Abstract: This function reads RCT sector 0 * * Inputs: IPL_SCS * event Event code * rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: EV_NULL */u_longmscp_bbr_step0( event, rp ) u_long event; register REQB *rp;{ register BBRB *bbrp = rp->connb->bbrb; register UNITB *up = rp->unitb; Cprintf("mscp_bbr_step0: entered\n"); /* 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_step0a - * * Abstract: This function reads RCT sector 1 * * Inputs: IPL_SCS * event Event code * rp Request block pointer * * Implicit * Inputs: * * Outputs: * * * Return * Values: EV_NULL */u_longmscp_bbr_step0a( event, rp ) u_long event; register REQB *rp;{ register BBRB *bbrp = rp->connb->bbrb; register UNITB *up = rp->unitb; Cprintf("mscp_bbr_step0a: entered\n"); /* Set up the buffer address and RCT sector 1 logical block * number and start the multicopy read. */ bbrp->multi_buf = bbrp->buf1; rp->p1 = up->unt_size + 1; return( mscp_multi_read( rp ));}/**//*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -