[comp.bugs.4bsd.ucb-fixes] V1.40

bostic@OKEEFFE.BERKELEY.EDU (Keith Bostic) (11/13/87)

Subject: fodkluster() and pagein() fixes
Index: sys/sys/vm_page.c 4.3BSD

Description:
	Fodkluster() can walk backwards past the 0 page, and
	pagein() doesn't correctly flush the buffer cache when
	it wants to page data in.
Repeat-By:
	These aren't real repeatable.  The first can happen, although
	very rarely; the second never fails on 4.3BSD due to the way
	the buffer cache works.
Fix:
	Apply the following patch to vm_page.c.

*** vm_page.c.orig	Thu Nov 12 13:16:22 1987
--- vm_page.c	Thu Nov 12 13:16:29 1987
***************
*** 3,9 ****
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)vm_page.c	7.1 (Berkeley) 6/5/86
   */
  
  #include "../machine/reg.h"
--- 3,9 ----
   * All rights reserved.  The Berkeley software License Agreement
   * specifies the terms and conditions for redistribution.
   *
!  *	@(#)vm_page.c	7.2 (Berkeley) 7/27/86
   */
  
  #include "../machine/reg.h"
***************
*** 365,371 ****
  		 * cache, so we explicitly flush them out to disk
  		 * so that the proper data will be paged in.
  		 */
! 		blkflush(dev, bn, (long)CLSIZE*NBPG);
  #ifdef TRACE
  		if (type != CTEXT)
  			trace(TR_XFODMISS, dev, bn);
--- 365,371 ----
  		 * cache, so we explicitly flush them out to disk
  		 * so that the proper data will be paged in.
  		 */
! 		blkflush(dev, bn, (long)klsize*CLSIZE*NBPG);
  #ifdef TRACE
  		if (type != CTEXT)
  			trace(TR_XFODMISS, dev, bn);
***************
*** 1263,1271 ****
  	bn = *pbn;
  	v = v0;
  	for (klsize = 1; klsize < KLMAX; klsize++) {
! 		v -= CLSIZE;
! 		if (v < vmin)
  			break;
  		fpte -= CLSIZE;
  		if (fpte->pg_fod == 0)
  			break;
--- 1263,1271 ----
  	bn = *pbn;
  	v = v0;
  	for (klsize = 1; klsize < KLMAX; klsize++) {
! 		if (v <= vmin)
  			break;
+ 		v -= CLSIZE;
  		fpte -= CLSIZE;
  		if (fpte->pg_fod == 0)
  			break;