Subject: CVS commit: basesrc
To: None <>
From: Konrad Schroder <>
List: source-changes
Date: 09/09/2000 07:49:57
Module Name:	basesrc
Committed By:	perseant
Date:		Sat Sep  9 04:49:56 UTC 2000

Modified Files:
	basesrc/libexec/lfs_cleanerd: cleanerd.c lfs_cleanerd.8 library.c
	basesrc/sbin/fsck_lfs: pass5.c
	basesrc/sbin/mount_lfs: mount_lfs.8 mount_lfs.c
	basesrc/sbin/newfs_lfs: config.h lfs.c
	syssrc/sys/ufs/lfs: lfs.h lfs_alloc.c lfs_balloc.c lfs_bio.c
	    lfs_cksum.c lfs_debug.c lfs_extern.h lfs_inode.c lfs_segment.c
	    lfs_subr.c lfs_syscalls.c lfs_vfsops.c lfs_vnops.c
	syssrc/sys/ufs/ufs: ufs_readwrite.c

Log Message:
Various bug-fixes to LFS, to wit:


* Add runtime quantity lfs_ravail, the number of disk-blocks reserved
  for writing.  Writes to the filesystem first reserve a maximum amount
  of blocks before their write is allowed to proceed; after the blocks
  are allocated the reserved total is reduced by a corresponding amount.

  If the lfs_reserve function cannot immediately reserve the requested
  number of blocks, the inode is unlocked, and the thread sleeps until
  the cleaner has made enough space available for the blocks to be
  reserved.  In this way large files can be written to the filesystem
  (or, smaller files can be written to a nearly-full but thoroughly
  clean filesystem) and the cleaner can still function properly.

* Remove explicit switching on dlfs_minfreeseg from the kernel code; it
  is now merely a fs-creation parameter used to compute dlfs_avail and
  dlfs_bfree (and used by fsck_lfs(8) to check their accuracy).  Its
  former role is better assumed by a properly computed dlfs_avail.

* Bounds-check inode numbers submitted through lfs_bmapv and lfs_markv.
  This prevents a panic, but, if the cleaner is feeding the filesystem
  the wrong data, you are still in a world of hurt.

* Cleanup: remove explicit references of DEV_BSIZE in favor of


* Make -n mean "send N segments' blocks through a single call to
  lfs_markv".  Previously it had meant "clean N segments though N calls
  to lfs_markv, before looking again to see if more need to be cleaned".
  The new behavior gives better packing of direct data on disk with as
  little metadata as possible, largely alleviating the problem that the
  cleaner can consume more disk through inefficient use of metadata than
  it frees by moving dirty data away from clean "holes" to produce
  entirely clean segments.

* Make -b mean "read as many segments as necessary to write N segments
  of dirty data back to disk", rather than its former meaning of "read
  as many segments as necessary to free N segments worth of space".  The
  new meaning, combined with the new -n behavior described above,
  further aids in cleaning storage efficiency as entire segments can be
  written at once, using as few blocks as possible for segment summaries
  and inode blocks.

* Make the cleaner take note of segments which could not be cleaned due
  to error, and not attempt to clean them until they are entirely free
  of dirty blocks.  This prevents the case in which a cleanerd running
  with -n 1 and without -b (formerly the default) would spin trying
  repeatedly to clean a corrupt segment, while the remaining space
  filled and deadlocked the filesystem.

* Update the lfs_cleanerd manual page to describe all the options,
  including the changes mentioned here (in particular, the -b and -n
  flags were previously undocumented).


* Check, and optionally fix, lfs_avail (to an exact figure) and
  lfs_bfree (within a margin of error) in pass 5.


* Reduce the default dlfs_minfreeseg to 1/20 of the total segments.

* Add a warning if the sgs disklabel field is 16 (the default for FFS'
  cpg, but not usually desirable for LFS' sgs: 5--8 is a better range).

* Change the calculation of lfs_avail and lfs_bfree, corresponding to
  the kernel changes mentioned above.


* Add -N and -b options to pass corresponding -n and -b options to

* Default to calling lfs_cleanerd with "-b -n 4".

[All of these changes were largely tested in the 1.5 branch, with the
idea that they (along with previous un-pulled-up work) could be applied
to the branch while it was still in ALPHA2; however my test system has
experienced corruption on another filesystem (/dev/console has gone
missing :^), and, while I believe this unrelated to the LFS changes, I
cannot with good conscience request that the changes be pulled up.]

To generate a diff of this commit:
cvs rdiff -r1.21 -r1.22 basesrc/libexec/lfs_cleanerd/cleanerd.c
cvs rdiff -r1.6 -r1.7 basesrc/libexec/lfs_cleanerd/lfs_cleanerd.8
cvs rdiff -r1.15 -r1.16 basesrc/libexec/lfs_cleanerd/library.c
cvs rdiff -r1.5 -r1.6 basesrc/sbin/fsck_lfs/pass5.c
cvs rdiff -r1.6 -r1.7 basesrc/sbin/mount_lfs/mount_lfs.8
cvs rdiff -r1.9 -r1.10 basesrc/sbin/mount_lfs/mount_lfs.c
cvs rdiff -r1.4 -r1.5 basesrc/sbin/newfs_lfs/config.h
cvs rdiff -r1.16 -r1.17 basesrc/sbin/newfs_lfs/lfs.c
cvs rdiff -r1.30 -r1.31 syssrc/sys/ufs/lfs/lfs.h
cvs rdiff -r1.42 -r1.43 syssrc/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -r1.24 -r1.25 syssrc/sys/ufs/lfs/lfs_balloc.c
cvs rdiff -r1.26 -r1.27 syssrc/sys/ufs/lfs/lfs_bio.c
cvs rdiff -r1.12 -r1.13 syssrc/sys/ufs/lfs/lfs_cksum.c
cvs rdiff -r1.10 -r1.11 syssrc/sys/ufs/lfs/lfs_debug.c
cvs rdiff -r1.20 -r1.21 syssrc/sys/ufs/lfs/lfs_extern.h
cvs rdiff -r1.43 -r1.44 syssrc/sys/ufs/lfs/lfs_inode.c \
cvs rdiff -r1.57 -r1.58 syssrc/sys/ufs/lfs/lfs_segment.c \
cvs rdiff -r1.16 -r1.17 syssrc/sys/ufs/lfs/lfs_subr.c
cvs rdiff -r1.48 -r1.49 syssrc/sys/ufs/lfs/lfs_syscalls.c
cvs rdiff -r1.26 -r1.27 syssrc/sys/ufs/ufs/ufs_readwrite.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.