Subject: df can hang system, standalone TMSCP driver fails to compile (#288) Index: sys/ufs_syscalls2.c,pdpstand/tmscp.c,pdpuba/tmscpreg.h 2.11BSD Description: Running 'df' using the directory form "df /" (or "df /usr/src") will put the system to sleep. The TMSCP driver in pdpstand/ generates errors during compilation. Repeat-By: df / cd /sys/pdpstand make Fix: The patch below fixes both problems. To install the patch, cut where indicated and save to a file (/tmp/288). Then: patch -p0 < /tmp/288 cd /sys/GENERIC make mv unix /genunix cd /sys/YOUR_KERNEL make make install fastboot The system would hang when "df" would do 'statfs' call. Statfs calls 'namei()' to resolve the pathname to an inode. 2.11's namei() (which is derived from 4.3BSD's) returns a pointer to a *locked* inode which means that "iput()" is normally used instead of "irele()" when freeing the inode. 4.4BSD-Lite's namei() by default returns a pointer to an *unlocked* vnode and thus can use 'vrele' instead of 'vput' to free the vnode. When the 'statfs' functionality was ported from 4.4-Lite the 'vrele' call should have been replaced with a 'iput' call instead of 'irele'. This will unlock the inode and prevent the system from going to sleep waiting for an inode to come free. The standalone TMSCP driver was overlooked during the recent restructuring of the kernel's TMSCP driver. Several defines and structure definitions are not in a 'common' include file and should have been removed from pdpstand/tmscp.c And this _really_ is the last 2.11BSD update for 1995! ;-) As always, this update along with all previous updates are available via anonymous FTP to FTP.IIPO.GTEGSC.COM in the /pub/2.11BSD. Happy New Year! ===========================cut here======================= *** /usr/src/sys/pdpuba/tmscpreg.h.old Thu Dec 14 21:35:05 1995 --- /usr/src/sys/pdpuba/tmscpreg.h Sun Dec 31 10:58:11 1995 *************** *** 1,6 **** /* @(#)tmscpreg.h 7.1 (Berkeley) 6/5/86 */ ! /* @(#)tmscpreg.h 1.2 (2.11BSD) 1995/12/14 */ /**************************************************************** * * --- 1,6 ---- /* @(#)tmscpreg.h 7.1 (Berkeley) 6/5/86 */ ! /* @(#)tmscpreg.h 1.3 (2.11BSD) 1995/12/31 */ /**************************************************************** * * *************** *** 63,70 **** --- 63,75 ---- * These defines were moved here so they could be shared between the * driver and the crash dump module. */ + #ifndef NRSPL2 #define NRSPL2 3 /* log2 number of response packets */ + #endif + #ifndef NCMDL2 #define NCMDL2 3 /* log2 number of command packets */ + #endif + #define NRSP (1<i_fs - offsetof(struct mount, m_filsys)); ! irele(ip); u.u_error = statfs1(mp, uap->buf); return(u.u_error); } --- 31,37 ---- if (!ip) return(u.u_error); mp = (struct mount *)((int)ip->i_fs - offsetof(struct mount, m_filsys)); ! iput(ip); u.u_error = statfs1(mp, uap->buf); return(u.u_error); } *** /usr/src/sys/pdpstand/tmscp.c.old Thu Jun 8 19:37:52 1995 --- /usr/src/sys/pdpstand/tmscp.c Sun Dec 31 11:00:10 1995 *************** *** 1,4 **** ! /* @(#)tmscp.c 7.1.2 (2.11BSD GTE) 1995/06/08 */ /**************************************************************** * Licensed from Digital Equipment Corporation * --- 1,4 ---- ! /* @(#)tmscp.c 7.1.3 (2.11BSD GTE) 1995/12/31 */ /**************************************************************** * Licensed from Digital Equipment Corporation * *************** *** 50,65 **** * Parameters for the communications area * (Only 1 cmd & 1 rsp packet) */ ! #define NRSPL2 0 ! #define NCMDL2 0 ! #define NRSP (1<> 3) & 3) /* unused for now */ struct tmscpdevice *TMScsr[NTMS + 1] = { --- 50,63 ---- * Parameters for the communications area * (Only 1 cmd & 1 rsp packet) */ ! #define NRSPL2 0 /* Define these before including */ ! #define NCMDL2 0 /* tmscpreg.h and tmscp.h below */ + #include "sys/buf.h" #include "../pdpuba/tmscpreg.h" #include "../pdp/tmscp.h" #define NTMS 2 struct tmscpdevice *TMScsr[NTMS + 1] = { *************** *** 68,78 **** (struct tmscpdevice *)-1 }; ! struct tmscp { ! struct tmscpca tmscp_ca; ! struct mscp tmscp_rsp; ! struct mscp tmscp_cmd; ! } tmscp[NTMS]; u_char tmsoffline[NTMS] = {1, 1}; /* Flag to prevent multiple STCON */ u_char tms_offline[NTMS][4] = {{1,1,1,1}, --- 66,72 ---- (struct tmscpdevice *)-1 }; ! struct tmscp tmscp[NTMS]; u_char tmsoffline[NTMS] = {1, 1}; /* Flag to prevent multiple STCON */ u_char tms_offline[NTMS][4] = {{1,1,1,1}, *************** *** 144,150 **** } tmsoffline[ctlr] = 0; } ! tms->tmscp_cmd.mscp_unit = unit; /* * Has this unit been issued an ONLIN? */ --- 138,144 ---- } tmsoffline[ctlr] = 0; } ! tms->tmscp_cmd[0].mscp_unit = unit; /* * Has this unit been issued an ONLIN? */ *************** *** 163,173 **** * Skip forward the appropriate number of files on the tape. */ { ! tms->tmscp_cmd.mscp_tmkcnt = io->i_part; ! tms->tmscp_cmd.mscp_buffer_h = 0; ! tms->tmscp_cmd.mscp_bytecnt = 0; tmscpcmd(ctlr, M_OP_REPOS, 0); ! tms->tmscp_cmd.mscp_tmkcnt = 0; } return(0); } --- 157,167 ---- * Skip forward the appropriate number of files on the tape. */ { ! tms->tmscp_cmd[0].mscp_tmkcnt = io->i_part; ! tms->tmscp_cmd[0].mscp_buffer_h = 0; ! tms->tmscp_cmd[0].mscp_bytecnt = 0; tmscpcmd(ctlr, M_OP_REPOS, 0); ! tms->tmscp_cmd[0].mscp_tmkcnt = 0; } return(0); } *************** *** 180,189 **** { register struct tmscp *tms = &tmscp[io->i_ctlr]; ! tms->tmscp_cmd.mscp_buffer_l = 0; /* tmkcnt */ ! tms->tmscp_cmd.mscp_buffer_h = 0; ! tms->tmscp_cmd.mscp_bytecnt = 0; ! tms->tmscp_cmd.mscp_unit = io->i_unit; tmscpcmd(io->i_ctlr, M_OP_REPOS, M_MD_REWND | M_MD_CLSEX); } --- 174,183 ---- { register struct tmscp *tms = &tmscp[io->i_ctlr]; ! tms->tmscp_cmd[0].mscp_buffer_l = 0; /* tmkcnt */ ! tms->tmscp_cmd[0].mscp_buffer_h = 0; ! tms->tmscp_cmd[0].mscp_bytecnt = 0; ! tms->tmscp_cmd[0].mscp_unit = io->i_unit; tmscpcmd(io->i_ctlr, M_OP_REPOS, M_MD_REWND | M_MD_CLSEX); } *************** *** 203,227 **** /* * Init cmd & rsp area */ ! iomapadr(&tms->tmscp_cmd.mscp_cmdref, &bae, &lo16); tms->tmscp_ca.ca_cmddsc[0].lsh = lo16; tms->tmscp_ca.ca_cmddsc[0].hsh = bae; ! tms->tmscp_cmd.mscp_dscptr = (long *)tms->tmscp_ca.ca_cmddsc; ! tms->tmscp_cmd.mscp_header.tmscp_vcid = 1; /* for tape */ ! iomapadr(&tms->tmscp_rsp.mscp_cmdref, &bae, &lo16); tms->tmscp_ca.ca_rspdsc[0].lsh = lo16; tms->tmscp_ca.ca_rspdsc[0].hsh = bae; ! tms->tmscp_rsp.mscp_dscptr = (long *)tms->tmscp_ca.ca_rspdsc; ! tms->tmscp_cmd.mscp_cntflgs = 0; ! tms->tmscp_cmd.mscp_opcode = op; ! tms->tmscp_cmd.mscp_modifier = mod; ! tms->tmscp_cmd.mscp_header.tmscp_msglen = mscp_msglen; tms->tmscp_ca.ca_cmddsc[0].hsh |= TMSCP_OWN; /* | TMSCP_INT */ ! tms->tmscp_rsp.mscp_header.tmscp_msglen = mscp_msglen; tms->tmscp_ca.ca_rspdsc[0].hsh |= TMSCP_OWN; /* | TMSCP_INT */ ! tms->tmscp_cmd.mscp_zzz2 = 0; i = TMScsr[ctlr]->tmscpip; for (;;) --- 197,221 ---- /* * Init cmd & rsp area */ ! iomapadr(&tms->tmscp_cmd[0].mscp_cmdref, &bae, &lo16); tms->tmscp_ca.ca_cmddsc[0].lsh = lo16; tms->tmscp_ca.ca_cmddsc[0].hsh = bae; ! tms->tmscp_cmd[0].mscp_dscptr = (long *)tms->tmscp_ca.ca_cmddsc; ! tms->tmscp_cmd[0].mscp_header.tmscp_vcid = 1; /* for tape */ ! iomapadr(&tms->tmscp_rsp[0].mscp_cmdref, &bae, &lo16); tms->tmscp_ca.ca_rspdsc[0].lsh = lo16; tms->tmscp_ca.ca_rspdsc[0].hsh = bae; ! tms->tmscp_rsp[0].mscp_dscptr = (long *)tms->tmscp_ca.ca_rspdsc; ! tms->tmscp_cmd[0].mscp_cntflgs = 0; ! tms->tmscp_cmd[0].mscp_opcode = op; ! tms->tmscp_cmd[0].mscp_modifier = mod; ! tms->tmscp_cmd[0].mscp_header.tmscp_msglen = mscp_msglen; tms->tmscp_ca.ca_cmddsc[0].hsh |= TMSCP_OWN; /* | TMSCP_INT */ ! tms->tmscp_rsp[0].mscp_header.tmscp_msglen = mscp_msglen; tms->tmscp_ca.ca_rspdsc[0].hsh |= TMSCP_OWN; /* | TMSCP_INT */ ! tms->tmscp_cmd[0].mscp_zzz2 = 0; i = TMScsr[ctlr]->tmscpip; for (;;) *************** *** 248,254 **** break; } tms->tmscp_ca.ca_rspint = 0; ! mp = &tms->tmscp_rsp; if (mp->mscp_opcode != (op|M_OP_END) || (mp->mscp_status&M_ST_MASK) != M_ST_SUCC) { /* Detect hitting tape mark. This signifies the end of the --- 242,248 ---- break; } tms->tmscp_ca.ca_rspint = 0; ! mp = &tms->tmscp_rsp[0]; if (mp->mscp_opcode != (op|M_OP_END) || (mp->mscp_status&M_ST_MASK) != M_ST_SUCC) { /* Detect hitting tape mark. This signifies the end of the *************** *** 279,285 **** register struct tmscp *tms = &tmscp[ctlr]; register struct mscp *mp; ! mp = &tms->tmscp_cmd; mp->mscp_lbn_l = loint(io->i_bn); mp->mscp_lbn_h = hiint(io->i_bn); mp->mscp_unit = unit; --- 273,279 ---- register struct tmscp *tms = &tmscp[ctlr]; register struct mscp *mp; ! mp = &tms->tmscp_cmd[0]; mp->mscp_lbn_l = loint(io->i_bn); mp->mscp_lbn_h = hiint(io->i_bn); mp->mscp_unit = unit; *************** *** 314,323 **** } else mod = 0; ! tms->tmscp_cmd.mscp_buffer_l = 0; ! tms->tmscp_cmd.mscp_buffer_h = 0; ! tms->tmscp_cmd.mscp_unit = io->i_unit; ! tms->tmscp_cmd.mscp_reccnt = space; tmscpcmd(io->i_ctlr, M_OP_REPOS, mod | M_MD_OBJCT); return(0); } --- 308,317 ---- } else mod = 0; ! tms->tmscp_cmd[0].mscp_buffer_l = 0; ! tms->tmscp_cmd[0].mscp_buffer_h = 0; ! tms->tmscp_cmd[0].mscp_unit = io->i_unit; ! tms->tmscp_cmd[0].mscp_reccnt = space; tmscpcmd(io->i_ctlr, M_OP_REPOS, mod | M_MD_OBJCT); return(0); } *** /VERSION.old Fri Dec 29 21:19:38 1995 --- /VERSION Sun Dec 31 12:11:36 1995 *************** *** 1,4 **** ! Current Patch Level: 287 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 288 2.11 BSD ============