📄 mscp_tape.c
字号:
#ifndef lint static char *sccsid = "@(#)mscp_tape.c 4.5 (ULTRIX) 12/20/90";#endif lint/************************************************************************ * * * Copyright (c) 1987 - 1990 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 * Tape Class Driver * * Abstract: This module contains the * routines specific to the tape * variant of MSCP. * * Author: Robin Lewis 3/2/1987 * * History: * * 08-Dec-1990 Tom Tierney * Fixed recovery problem: removed checks for recovery state in * tmscp_availcm. In this way, available commands will be issued * to units failing recovery and available end message processing * will mark the unit appropriately and then continue recovery * processing. The mscp_restart_next routine should only be called * after all previously online units had attempted recovery. * * Also updated get unit status recovery table so that an online * error (EV_ONLERROR) will cause available processing to occur and * updated online end message processing to return EV_ONLERROR * when online fails during the unit recovery process. * * 4-Dec-1990 Brian Nadeau * Add a return to tmscpioctl so lint will not complain. * * 26-Nov-1990 Brian Nadeau * Ignore mscp_byte_cnt value when a serious exception occurs. * Some controllers like the TQK50 fail to zero it after the * exception. * * 05-Nov-1990 Tom Tierney * Corrected transferem routine to copy byte count from the * response packet's byte count field for all transfer commands * except for "access" commands which get their byte count from * the end packet's tape record field. * * 18-Dec-1989 Tim Burke * Increase the timeout period of reposition commands from 20 minutes * to 60 minutes. * * 06-Nov-1989 Tim Burke * Set the exclusive access modifier in the setunitcm routine. * * 11-Sep-1989 Tim Burke * Provide support for the following TA90 densities: * MSCP_TF_NDCP, MSCP_TF_ENHD, and MSCP_TF_EDCP. * * 23-Aug-1989 Tim Burke * Software workaround to a TU81+ microcode bug. Do not allow the TU81 * to use caching because the command issued after the flush command will * hang in the drive. * * 18-Aug-1989 Tim Burke * In tmscp_setunitcm() only specify a tape format if positioned at * BOT. This prevents the command from being rejected with an invalid * command, invalid format subcode. * * 01-Aug-1989 Tim Burke * Fixed assignment of the mt_dsreg in mtiocget to properly contain the * tms_flags field in the upper 8 bits of the field. * * 21-Jul-1989 David E. Eiche DEE0070 * Changed various field names to conform to the T/MSCP preferred * mnemonics, eliminate multiple levels of qualification, and * eliminate multiple names for the same field. * * 20-Jun-1989 Tim Burke * Added TQK7L support. This consists of loader present bit and * logging of loader errors. Changed debugging printf's to be run off * levels as specified by the tmscpdebug variable. Added the kernel * variable tmscptestcache which when set forces the drive to always run * in caching mode, this is intended for debug and analysis usage only. * * 05-May-1989 Tim Burke * Merged 3.1 deltas into pu and isis pools. * Bug fix: In transfercm if a non-nbuf read is being done and the * previous read hit a tape mark, clear the serious exception to allow * the next read to be done on the first record of the next file. * * 14-Apr-1989 Tim Burke * Added caching support to allow the use of controller read-ahead and * write-behind caching. Changes involve adding MTFLUSH mtop, checking * cache status in close routine, and keeping track of when writes could * be pending in the controller's write back cache. * * 15-Mar-1989 Tim Burke * Changed splx( IPL_SCS ) to Splscs(); * * 07-Mar-1989 Todd M. Katz TMK0002 * Include header file ../vaxmsi/msisysap.h. * * 28-Feb-1989 Tim Burke * Prevent panics in recovery code. Previously a panic would occur if * more than one unit was online and needs recovery. The fix involved * recycling the rspid in tmscp_recovnext, and changing the recovery * state table entries associated with the EV_ONLDONEXT from tmscp_invevent * to tmscp_onlinecm. This change was done on states 3 and 4. * * 27-Feb-1989 Tim Burke * Prevent panics in recovery code by properly returning from the * tmscp_availcm routine if the reposition to last known position command * fails. Return to prevent sending a message when no resources are * allocated to do so. * * 02-Feb-1989 Tim Burke * Clear the up->Tflags.tms_wait flag in the tmscp_setunitem routine to * prevent hanging in the tmscpopen routine. Add a check in tmscpopen to * see if the unit goes available unexpectadly. Add missing subcode of * MSCP_SC_EXUSE to the offline status code in check_return. * * 05-Jan-1988 Tim Burke * In the transferem routine setup rp->p1 with the resid count so that it * can be stuffed back into the buf struct in mscp_dealloc_reqb. Also in * this routine do not clear the BOM flag if you are still at BOT (if the * operation fails). * * Added the Time_Check macro to log an error if the end message does not * come back within the propper time interval. * * Initilize the tms_status field in the unit block which will cause ioctls * to fail if the device goes offline after it is opened. * * Clear the serious exception state in the MTFSR and MTBSR ioctls if a * tape mark has been encountered. * * Added MSCP_ST_LOADR case to the check_return() routine. * * 20-Dec-1988 Tim Burke * Change MTFSR and MTBSR to move tape records and not tape objects. This * is done to be consistent with other drivers which don't traverse tape * marks with record movement commands. Change to return the propper * resid field in MTIOCGET. * * 03-Oct-1988 Tim Burke * Added state table and command routine for the set unit command. * In tmscpopen() if the device is already online at position 0, * set the density. This is a software workaround to the TU81+ * failing to clear the online status via the avail command. * * 29-Sep-1988 Tim Burke * Don't clear tms_category_flags in the onlineinit routine. This would * cause the tape density returned in DEVIOCGET to be wrong if the tape * wasn't sitting at BOT. * * 14-Sep-1988 Tim Burke * Clear tape written flag when a reposition command has changed the * present position. This prevents the close routine from improperly * laying down tape marks in the wrong place. * * 17-Aug-1988 David E. Eiche DEE0051 * Change state definitions to use ST_CMN_INITIAL so that * recovery can rely on the initial state in any state table * to be the same. Also change unused events in the recovery * state table to dispatch to the invalid event routine. * * 10-Aug-1988 David E. Eiche DEE0050 * Change routines tmscp_recov_init and tmscp_recov_next * to store the tape unit position only after finding a * tape unit in the appropriate state. * * 05-Aug-1988 Tim Burke * Maintain one copy of the online/offline status instead of using * up->tms_flags with DEV_OFFLINE and up->flags.online; only keep * up->flags.online current and setup tms_flags in the ioctl routines * as needed. * * 18-Jul-1988 Tim Burke * In the open routine, derive the online status directly from the * get unit status command. Set inuse early in open routine to avoid * race condition. Allow for handling of non-EOT serious exceptions. * * 17-Jul-1988 David E. Eiche DEE0045 * Change get device information ioctl to get model name from * the connection block. * * 23-Jun-1988 Tim Burke * Allow MTCLX and MTCLS ioctls by SU only. Don't zero out tape * attributes in the end message. * * 09-Jun-1988 Robin * Added code that:stopped panic by setting a pointer value before it * is used; returnes from ioctl calls with the correct status; sets up * the hardware cache the correct way. * * 02-Jun-1988 Ricky S. Palmer * Removed inclusion of header file ../vaxmsi/msisysap.h * * 20-Apr-1988 Tim Burke * Setup residual count on partial writes in tmscp_transferem. * * 08-Apr-1988 Robin * added some debug prints around tape density code. * * 04-Mar-1988 Robin * In checking returns the write lock condition was set but it was only * reset in close. Now I reset the write lock flags and then reset them * if the unit is still write locked. * * 01-Mar-1988 Robin * We have a bug in the TU81+ which causes the path to crash if we * issue two available commands and then do a get_command-status * on the second. The command status returned is zero (unknown command) * and thats a problem. To work around the problem I now must wait for * the tape to rewind before letting close finish. * * 22-Feb-1988 Robin * Changes the open routine to wait for the get unit status to finish. * also changed the ioctl calls to get a rspid to check the return * values. * * The connection recovery code was added to bring a unit back online * and reposition to a know position on the tape; then the outstanding * I/O requests are re-issued. Everything continues as before after * the conection is recovered. * * * 02-Feb-1988 David E. Eiche DEE0011 * Change tmscpstrategy to sleep if the request block is not * available immediately. Also remove code that initialized * unused request block wait queue. * * 27-Jan-1988 Robin * Removed the initialization routine calls in the open routine. This * will be done is start_sysap and mscp_systm_poll will break if we * continue to do this. * * 15-Jan-1988 Todd M. Katz TMK0001 * Include new header file ../vaxmsi/msisysap.h. * * 22-DEC-1987 Robin * added B_error debug prints and fixed the DEVIOCGET ioctl * DEV_CSE flag, it was set in the wrong word. *//* Libraries and Include Files. */#include "../h/types.h"#include "../h/time.h"#include "../h/param.h"#include "../h/buf.h"#include "../h/errno.h"#include "../h/ioctl.h"#include "../h/devio.h"#include "../h/mtio.h"#include "../h/file.h"#include "../h/dump.h"#include "../h/systm.h"#include "../fs/ufs/fs.h"#include "../h/errlog.h"#include "../io/scs/sca.h"#include "../io/ci/cippdsysap.h"#include "../io/ci/cisysap.h"#include "../io/msi/msisysap.h"#include "../io/bi/bvpsysap.h"#include "../io/gvp/gvpsysap.h"#include "../io/uba/uqsysap.h"#include "../io/uba/ubavar.h"#include "../io/sysap/sysap.h"#include "../io/sysap/mscp_msg.h"#include "../io/sysap/mscp_defs.h"/* * Caching control variable. Setting this variable will always cause caching * to be used on this driver reguardless of calls to mtcache/mtnocache. This * could prove useful at determining theoretical utility performance if they * utilized caching support. Note that this should be used for debugging * and analysis because it opens a window of data integrity for utilities which * do not use mtflush; here there may be no indication of cache data loss to * the utility. */int tmscptestcache = 0;/* Debugging variables. This value determines the debugging output level. * the larger the number, the more output. */int tmscpdebug = 0;#define TMSCPDEBUG#ifdef TMSCPDEBUG/* * Provide various levels of debugging printouts based on the value of * tmscpdebug. */#define Dprint1 if ( tmscpdebug ) printf /* Highest priority */#define Dprint2 if ( tmscpdebug > 1 ) printf#define Dprint3 if ( tmscpdebug > 2 ) printf#define Dprint4 if ( tmscpdebug > 3 ) printf#define Dprint5 if ( tmscpdebug > 4 ) printf#define Dprint6 if ( tmscpdebug > 5 ) printf#define Dprint7 if ( tmscpdebug > 6 ) printf#define Dprint8 if ( tmscpdebug > 7 ) printf /* Lowest priority *//* * This macro is used to see if the timer has expired before the bit that * we are waiting for has cleared. Typically the driver is waiting for an * end message for a particular command. To prevent hanging you only wait * so long before giving up. */#define Time_Check( Wait_For, Retry_Count, Error_String) { \ if ((Wait_For) && ((Retry_Count) < 0)) { \ mprintf("tmscp driver error: no end message for %s\n", \ (Error_String)); \ }} #else#define Dprint1 ;#define Dprint2 ;#define Dprint3 ;#define Dprint4 ;#define Dprint5 ;#define Dprint6 ;#define Dprint7 ;#define Dprint8 ;#define Time_Check ;#endif/* * Evaluates to 1 if the unit in question is a TU81 drive. This is being * done to provide software workarounds to hardware problems, hack, hack. */#define IS_TU81_DRIVE( drive_model_name ) \ (strncmp( drive_model_name, DEV_TU81, strlen(drive_model_name)) == 0)/* * There have been cases where no end messages appear for outstanding commands. * As a result the utility program would end up hung in an unkillable state. * To avoid this problem (which shouldn't happen in the first place) impose * timers on how long to wait for the end message to return. * * Give reposition type commands a long time to complete. On the TK70 a * forward skip command could take up to 57 minutes to complete (WOW). This * is calculated as (600feet * 48tracks * 12inches) / (100ips * 60sec) = 57min. * Actual timing reveals that using 60 minutes is not enough to forward skip * file from the beginning to the last tape mark at the end of the tape. So * use a value of 70 minutes to allow the needed time. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -