Subject: bin/6249: lfs_cleanerd uses wrong units when computing which segments to clean
To: None <gnats-bugs@gnats.netbsd.org, perseant@hhhh.org, margo@eecs.harvard.edu>
From: None <perseant@hhhh.org>
List: netbsd-bugs
Date: 10/04/1998 16:05:46
>Number:         6249
>Category:       bin
>Synopsis:       lfs_cleanerd miscounts total segs and dirty segs due to wrong units
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  4 16:05:01 1998
>Last-Modified:
>Originator:     Konrad Schroder
>Organization:
-------------------------------------------------------------------------
Konrad Schroder           http://www.hitl.washington.edu/people/perseant/
System Administrator                         perseant@hitl.washington.edu
Human Interface Technology Lab                     Voice: +1.206.616.1478
Box 352142, University of Washington, 98195, USA     FAX: +1.206.543.5380
>Release:        Sep 14, 1998 plus lfs_statfs patch (kern/6246)
>Environment:
System: NetBSD inle 1.3 NetBSD 1.3 (INLE) #1: Sun Apr 19 15:01:29 PDT 1998 perseant@gro:/usr/src/sys/arch/i386/compile/INLE i386

>Description:
        lfs_cleanerd decides when and what to clean based on output from
        statfs(), and its own computation of the available free space
        that is locked up in dirty segments.  However, it does not
        correctly differentiate between block-sized units and
        fragment-sized units when making this computation, and on a
        filesystem with fragments, cleans constantly even though the
        filesystem may be empty.
>How-To-Repeat:
        newlfs -L -b 8192 -f 1024 /dev/rsd0g
        mount -t lfs -o-n /dev/sd0g /mnt
        /usr/libexec/lfs_cleanerd -d /mnt &
        (do some work on the filesystem)
>Fix:
*** lfs_cleanerd.1.3H/cleanerd.c	Sat Sep 26 14:20:51 1998
--- lfs_cleanerd/cleanerd.c	Sun Oct  4 13:58:11 1998
***************
*** 260,267 ****
  	 * Compute the maximum possible number of free segments, given the
  	 * number of free blocks.
  	 */
! 	db_per_seg = fsbtodb(&fsp->fi_lfs, fsp->fi_lfs.lfs_ssize);
! 	max_free_segs = fsp->fi_statfsp->f_bfree / fsp->fi_lfs.lfs_ssize;
  	
  	/* 
  	 * We will clean if there are not enough free blocks or total clean
--- 265,272 ----
  	 * Compute the maximum possible number of free segments, given the
  	 * number of free blocks.
  	 */
! 	db_per_seg = fragstodb(&fsp->fi_lfs, fsp->fi_lfs.lfs_ssize);
! 	max_free_segs = (fsp->fi_statfsp->f_bfree / fsp->fi_lfs.lfs_ssize) >> fsp->fi_lfs.lfs_fbshift;
  	
  	/* 
  	 * We will clean if there are not enough free blocks or total clean
>Audit-Trail:
>Unformatted: