Subject: buffer flush incomplete at reboot / raising vi max editable filesize Index: src/sys/pdp/machdep2.c,src/sys/sys/ufs_subr.c,src/ucb/ex/ex_temp.h,ex_tune.h Description: 1. The filesystem clean logic implemented in patch #459 introduced a bug that could result in buffer flusing not completing before a reboot is done. 2. Using 'vi' to edit patch #460 would result in the error "Tmp file too large". Repeat-By: 1. Noticed during the development/testing of a DECTape driver. Tapes being slow would not have completed the flushing of the filesystem (superblock) before the bus reset and reboot happened. 2. Attempt to edit a file more than 256KB in size (the patchfile for #460 is a good example). Observe the Tmp file too large error. Fix: 1. Move the updating of the "filesystem clean" flag to the proper location. 2. The configuration values to allow vi to edit larger files were already present but commented out. This patch adds a compile time flag to OPTIONS line in the Makefile - this option enables the ability of vi to edit files up to 512K. Larger files need more 'undo' buffer space so a slight decrease in maximum screen size (from 80 to 70 lines) was done to free up mempry for the "undo" buffer. To apply this patch cut where indicated and save to a file (/tmp/461). Then: cd / patch -p0 < /tmp/461 cd /usr/src/ucb/ex make make install make clean A kernel recompile is needed for the filesystem changes to be installed. cd /sys/YOUR_KERNEL make (install kernel using local conventions) # Optional: If you maintain a copy of the GENERIC kernel then recompile that # kernel also cd /sys/GENERIC make (install the generic kernel using local conventions) This and previous updates to 2.11BSD are available at the following locations: ftp://ftp.update.uu.se/pub/pdp11/2.11BSD https://www.tuhs.org/Archive/Distributions/UCB/2.11BSD/Patches/ ftp://ftp.2bsd.com/2.11BSD ---------------------------cut here-------------------- *** ./usr/src/sys/sys/ufs_subr.c.old Tue Dec 17 08:43:44 2019 --- ./usr/src/sys/sys/ufs_subr.c Mon Jan 20 11:19:16 2020 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_subr.c 1.7 (2.11BSD) 2019/12/17 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ufs_subr.c 1.8 (2.11BSD) 2020/1/20 */ #include "param.h" *************** *** 50,55 **** --- 50,59 ---- /* * Go through the mount table marking filesystems clean. + * This function is identical to sync() except that it also + * marks the filesystem clean if it was clean before it was mounted. + * + * This routine is used only by the reboot code. */ fsclean() { *************** *** 67,81 **** fs = &mp->m_filsys; if (fs->fs_ronly == 1 || fs->fs_ilock || fs->fs_flock) continue; ! if (fs->fs_flags & MNT_WASCLEAN) { ! async = mp->m_flags & MNT_ASYNC; ! mp->m_flags &= ~MNT_ASYNC; fs->fs_flags |= MNT_CLEAN; fs->fs_fmod = 1; ufs_sync(mp); fs->fs_flags &= ~MNT_CLEAN; mp->m_flags |= async; ! } } updlock = 0; } --- 71,90 ---- fs = &mp->m_filsys; if (fs->fs_ronly == 1 || fs->fs_ilock || fs->fs_flock) continue; ! if (fs->fs_flags & MNT_WASCLEAN) ! { fs->fs_flags |= MNT_CLEAN; fs->fs_fmod = 1; + } + if (fs->fs_fmod) + { + async = mp->m_flags & MNT_ASYNC; + mp->m_flags &= ~MNT_ASYNC; + fs->fs_time = time.tv_sec; ufs_sync(mp); fs->fs_flags &= ~MNT_CLEAN; mp->m_flags |= async; ! } } updlock = 0; } *** ./usr/src/sys/pdp/machdep2.c.old Mon Nov 18 07:59:08 2019 --- ./usr/src/sys/pdp/machdep2.c Mon Jan 20 09:24:45 2020 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)machdep2.c 2.10 (2.11BSD) 2019/11/18 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)machdep2.c 2.11 (2.11BSD) 2020/1/20 */ #include "param.h" *************** *** 395,401 **** * Release inodes held by texts before update. */ xumount(NODEV); ! sync(); { register struct buf *bp; int iter, nbusy; --- 395,401 ---- * Release inodes held by texts before update. */ xumount(NODEV); ! fsclean(); { register struct buf *bp; int iter, nbusy; *************** *** 411,417 **** } } printf("done\n"); - fsclean(); } (void) _splhigh(); if (howto & RB_HALT) { --- 411,416 ---- *** ./usr/src/ucb/ex/ex_temp.h.old Tue Feb 17 00:07:29 1987 --- ./usr/src/ucb/ex/ex_temp.h Mon Jan 20 11:51:08 2020 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ex_temp.h 7.4 (Berkeley) 5/31/85 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ex_temp.h 7.5 (2.11BSD) 2020/1/21 */ /* *************** *** 26,39 **** * each time you create a new line in the temporary file you get a unique * number back, and this is a property used by marks. * ! * The following temp file parameters allow 256k bytes in the temporary ! * file. By changing to the numbers in comments you can get 512k. * For VMUNIX you get more than you could ever want. * VMUNIX uses long (32 bit) integers giving much more * space in the temp file and no waste. This doubles core * requirements but allows files of essentially unlimited size to be edited. */ #ifndef VMUNIX #define BLKMSK 0777 /* 01777 */ #define BNDRY 8 /* 16 */ #define INCRMT 0200 /* 0100 */ --- 26,54 ---- * each time you create a new line in the temporary file you get a unique * number back, and this is a property used by marks. * ! * If -DTEMP512K is set in the Makefile OPTIONS line you get 512KB in the ! * temporary file. If that option is not set you get 256KB (the previous/old ! * default value). ! * * For VMUNIX you get more than you could ever want. * VMUNIX uses long (32 bit) integers giving much more * space in the temp file and no waste. This doubles core * requirements but allows files of essentially unlimited size to be edited. */ + #ifndef VMUNIX + + #ifdef TEMP512K + #define BLKMSK 01777 + #define BNDRY 16 + #define INCRMT 0100 + #define LBTMSK 0760 + #define NMBLKS 1018 + #define OFFBTS 6 + #define OFFMSK 077 + #define SHFT 3 + #else + /* Old values allowed only 256KB temporary filesize */ #define BLKMSK 0777 /* 01777 */ #define BNDRY 8 /* 16 */ #define INCRMT 0200 /* 0100 */ *************** *** 42,48 **** --- 57,66 ---- #define OFFBTS 7 /* 6 */ #define OFFMSK 0177 /* 077 */ #define SHFT 2 /* 3 */ + #endif /* TEMP512K */ + #else + #define BLKMSK 077777 #define BNDRY 2 #define INCRMT 02000 *************** *** 51,57 **** #define OFFBTS 10 #define OFFMSK 01777 #define SHFT 0 ! #endif /* * The editor uses three buffers into the temporary file (ed uses two --- 69,75 ---- #define OFFBTS 10 #define OFFMSK 01777 #define SHFT 0 ! #endif /* VMUNIX */ /* * The editor uses three buffers into the temporary file (ed uses two *** ./usr/src/ucb/ex/Makefile.old Sun Oct 27 00:26:38 1996 --- ./usr/src/ucb/ex/Makefile Mon Jan 20 11:45:30 2020 *************** *** 3,9 **** # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile 7.13.1.3 (2.11BSD GTE) 1996/10/23 # VERSION=3.7 # --- 3,9 ---- # All rights reserved. The Berkeley software License Agreement # specifies the terms and conditions for redistribution. # ! # @(#)Makefile 7.13.2 (2.11BSD) 2020/1/21 # VERSION=3.7 # *************** *** 33,39 **** NONDEBUGFLAGS= -O DEB= ${NONDEBUGFLAGS} # or ${DEBUGFLAGS} to to debug #OPTIONS= -DLISPCODE -DCHDIR -DVFORK -DVMUNIX -DFASTTAG ! OPTIONS= -DLISPCODE -DCHDIR -DVFORK -DFASTTAG CFLAGS= -DTABS=8 ${OPTIONS} ${DEB} LDFLAGS= -X SEPFLAG= -i --- 33,39 ---- NONDEBUGFLAGS= -O DEB= ${NONDEBUGFLAGS} # or ${DEBUGFLAGS} to to debug #OPTIONS= -DLISPCODE -DCHDIR -DVFORK -DVMUNIX -DFASTTAG ! OPTIONS= -DLISPCODE -DCHDIR -DVFORK -DFASTTAG -DTEMP512K CFLAGS= -DTABS=8 ${OPTIONS} ${DEB} LDFLAGS= -X SEPFLAG= -i No differences encountered *** ./usr/src/ucb/ex/ex_tune.h.old Sat May 6 03:54:44 2000 --- ./usr/src/ucb/ex/ex_tune.h Mon Jan 20 21:26:15 2020 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ex_tune.h 7.8.2 (2.11BSD) 2000/5/6 */ /* --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)ex_tune.h 7.8.3 (2.11BSD) 2020/1/20 */ /* *************** *** 100,108 **** * hardcopy mode when a line gets longer than 80 characters. */ #ifndef VMUNIX ! #define TUBELINES 80 /* Number of screen lines for visual */ #define TUBECOLS 160 /* Number of screen columns for visual */ ! #define TUBESIZE 6400 /* Maximum screen size for visual (80x80)*/ #else #define TUBELINES 70 #define TUBECOLS 160 --- 100,108 ---- * hardcopy mode when a line gets longer than 80 characters. */ #ifndef VMUNIX ! #define TUBELINES 70 /* Number of screen lines for visual */ #define TUBECOLS 160 /* Number of screen columns for visual */ ! #define TUBESIZE 5600 /* Maximum screen size for visual (70x80)*/ #else #define TUBELINES 70 #define TUBECOLS 160 *** ./VERSION.old Tue Jan 7 13:55:41 2020 --- ./VERSION Mon Jan 20 20:37:14 2020 *************** *** 1,5 **** ! Current Patch Level: 460 ! Date: January 7, 2020 2.11 BSD ============ --- 1,5 ---- ! Current Patch Level: 461 ! Date: January 21, 2020 2.11 BSD ============