Commit Graph

665 Commits

Author SHA1 Message Date
chs 5d3eefe245 use pools for allocating most softdep datastructures. since we want to
allocate memory from kernel_map but some of the objects are freed from
interrupt context, we put objects on a queue instead of freeing them
immediately.  then in softdep_process_worklist() (which is called at
least once per second from the syncer), we process that queue and
free all the objects.  allocating from kernel_map instead of from kmem_map
allows us to have a much larger number of softdeps pending even in
configurations where kmem_map is relatively small.
2001-09-15 16:33:53 +00:00
chs adf5d360a7 add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl.  file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value.  the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.
2001-09-15 16:12:54 +00:00
lukem 5c2ee5861d Incorporate the enhanced ffs_dirpref() by Grigoriy Orlov, as found in
FreeBSD (three commits; the initial work, man page updates, and a fix
to ffs_reload()), with the following differences:
- Be consistent between newfs(8) and tunefs(8) as to the options which
  set and control the tuning parameters for this work (avgfilesize & avgfpdir)
- Use u_int16_t instead of u_int8_t to keep track of the number of
  contiguous directories (suggested by Chuck Silvers)
- Work within our FFS_EI framework
- Ensure that fs->fs_maxclusters and fs->fs_contigdirs don't point to
  the same area of memory

The new algorithm has a marked performance increase, especially when
performing tasks such as untarring pkgsrc.tar.gz, etc.

The original FreeBSD commit messages are attached:

=====
mckusick    2001/04/10 01:39:00 PDT
  Directory layout preference improvements from Grigoriy Orlov <gluk@ptci.ru>.
  His description of the problem and solution follow. My own tests show
  speedups on typical filesystem intensive workloads of 5% to 12% which
  is very impressive considering the small amount of code change involved.

  ------

    One day I noticed that some file operations run much faster on
  small file systems then on big ones. I've looked at the ffs
  algorithms, thought about them, and redesigned the dirpref algorithm.

    First I want to describe the results of my tests. These results are old
  and I have improved the algorithm after these tests were done. Nevertheless
  they show how big the perfomance speedup may be. I have done two file/directory
  intensive tests on a two OpenBSD systems with old and new dirpref algorithm.
  The first test is "tar -xzf ports.tar.gz", the second is "rm -rf ports".
  The ports.tar.gz file is the ports collection from the OpenBSD 2.8 release.
  It contains 6596 directories and 13868 files. The test systems are:

  1. Celeron-450, 128Mb, two IDE drives, the system at wd0, file system for
     test is at wd1. Size of test file system is 8 Gb, number of cg=991,
     size of cg is 8m, block size = 8k, fragment size = 1k OpenBSD-current
     from Dec 2000 with BUFCACHEPERCENT=35

  2. PIII-600, 128Mb, two IBM DTLA-307045 IDE drives at i815e, the system
     at wd0, file system for test is at wd1. Size of test file system is 40 Gb,
     number of cg=5324, size of cg is 8m, block size = 8k, fragment size = 1k
     OpenBSD-current from Dec 2000 with BUFCACHEPERCENT=50

  You can get more info about the test systems and methods at:
  http://www.ptci.ru/gluk/dirpref/old/dirpref.html

                                Test Results

               tar -xzf ports.tar.gz               rm -rf ports
    mode  old dirpref new dirpref speedup old dirprefnew dirpref speedup
                               First system
   normal     667         472      1.41       477        331       1.44
   async      285         144      1.98       130         14       9.29
   sync       768         616      1.25       477        334       1.43
   softdep    413         252      1.64       241         38       6.34
                               Second system
   normal     329         81       4.06       263.5       93.5     2.81
   async      302         25.7    11.75       112          2.26   49.56
   sync       281         57.0     4.93       263         90.5     2.9
   softdep    341         40.6     8.4        284          4.76   59.66

  "old dirpref" and "new dirpref" columns give a test time in seconds.
  speedup - speed increasement in times, ie. old dirpref / new dirpref.

  ------

  Algorithm description

  The old dirpref algorithm is described in comments:

  /*
   * Find a cylinder to place a directory.
   *
   * The policy implemented by this algorithm is to select from
   * among those cylinder groups with above the average number of
   * free inodes, the one with the smallest number of directories.
   */

  A new directory is allocated in a different cylinder groups than its
  parent directory resulting in a directory tree that is spreaded across
  all the cylinder groups. This spreading out results in a non-optimal
  access to the directories and files. When we have a small filesystem
  it is not a problem but when the filesystem is big then perfomance
  degradation becomes very apparent.

  What I mean by a big file system ?

    1. A big filesystem is a filesystem which occupy 20-30 or more percent
       of total drive space, i.e. first and last cylinder are physically
       located relatively far from each other.
    2. It has a relatively large number of cylinder groups, for example
       more cylinder groups than 50% of the buffers in the buffer cache.

  The first results in long access times, while the second results in
  many buffers being used by metadata operations. Such operations use
  cylinder group blocks and on-disk inode blocks. The cylinder group
  block (fs->fs_cblkno) contains struct cg, inode and block bit maps.
  It is 2k in size for the default filesystem parameters. If new and
  parent directories are located in different cylinder groups then the
  system performs more input/output operations and uses more buffers.
  On filesystems with many cylinder groups, lots of cache buffers are
  used for metadata operations.

  My solution for this problem is very simple. I allocate many directories
  in one cylinder group. I also do some things, so that the new allocation
  method does not cause excessive fragmentation and all directory inodes
  will not be located at a location far from its file's inodes and data.
  The algorithm is:
  /*
   * Find a cylinder group to place a directory.
   *
   * The policy implemented by this algorithm is to allocate a
   * directory inode in the same cylinder group as its parent
   * directory, but also to reserve space for its files inodes
   * and data. Restrict the number of directories which may be
   * allocated one after another in the same cylinder group
   * without intervening allocation of files.
   *
   * If we allocate a first level directory then force allocation
   * in another cylinder group.
   */

    My early versions of dirpref give me a good results for a wide range of
  file operations and different filesystem capacities except one case:
  those applications that create their entire directory structure first
  and only later fill this structure with files.

    My solution for such and similar cases is to limit a number of
  directories which may be created one after another in the same cylinder
  group without intervening file creations. For this purpose, I allocate
  an array of counters at mount time. This array is linked to the superblock
  fs->fs_contigdirs[cg]. Each time a directory is created the counter
  increases and each time a file is created the counter decreases. A 60Gb
  filesystem with 8mb/cg requires 10kb of memory for the counters array.

    The maxcontigdirs is a maximum number of directories which may be created
  without an intervening file creation. I found in my tests that the best
  performance occurs when I restrict the number of directories in one cylinder
  group such that all its files may be located in the same cylinder group.
  There may be some deterioration in performance if all the file inodes
  are in the same cylinder group as its containing directory, but their
  data partially resides in a different cylinder group. The maxcontigdirs
  value is calculated to try to prevent this condition. Since there is
  no way to know how many files and directories will be allocated later
  I added two optimization parameters in superblock/tunefs. They are:

          int32_t  fs_avgfilesize;   /* expected average file size */
          int32_t  fs_avgfpdir;      /* expected # of files per directory */

  These parameters have reasonable defaults but may be tweeked for special
  uses of a filesystem. They are only necessary in rare cases like better
  tuning a filesystem being used to store a squid cache.

  I have been using this algorithm for about 3 months. I have done
  a lot of testing on filesystems with different capacities, average
  filesize, average number of files per directory, and so on. I think
  this algorithm has no negative impact on filesystem perfomance. It
  works better than the default one in all cases. The new dirpref
  will greatly improve untarring/removing/coping of big directories,
  decrease load on cvs servers and much more. The new dirpref doesn't
  speedup a compilation process, but also doesn't slow it down.

  Obtained from:	Grigoriy Orlov <gluk@ptci.ru>
=====

=====
iedowse     2001/04/23 17:37:17 PDT
  Pre-dirpref versions of fsck may zero out the new superblock fields
  fs_contigdirs, fs_avgfilesize and fs_avgfpdir. This could cause
  panics if these fields were zeroed while a filesystem was mounted
  read-only, and then remounted read-write.

  Add code to ffs_reload() which copies the fs_contigdirs pointer
  from the previous superblock, and reinitialises fs_avgf* if necessary.

  Reviewed by:	mckusick
=====

=====
nik         2001/04/10 03:36:44 PDT
  Add information about the new options to newfs and tunefs which set the
  expected average file size and number of files per directory.  Could do
  with some fleshing out.
=====
2001-09-06 02:16:00 +00:00
lukem c50eb8cc85 deprecate fs_fscktime; we never used it.
in an effort to maintain compatibility with freebsd/openbsd/whatever,
i'm attempting to get the superblock format in sync, and freebsd uses
the int32_t at this position for `fs_pendinginodes'.

if we ever decide to implement fscktime functionality, we'll:
a) make sure to liaise with the other projects to reserve the same
   spare field
b) actually implement the code this time ...

(this is also preparing us for other changes, like the new dirpref code)
2001-09-03 14:52:17 +00:00
lukem e3ba61f9f3 Incorporate fix by iedowse @ FreeBSD to allow disks with large numbers of
cylinder groups to work correctly, with minor modifications by me to work
with our FFS_EI code.  From the FreeBSD commit message:

	The ffs superblock includes a 128-byte region for use by temporary
	in-core pointers to summary information. An array in this region
	(fs_csp) could overflow on filesystems with a very large number of
	cylinder groups (~16000 on i386 with 8k blocks). When this happens,
	other fields in the superblock get corrupted, and fsck refuses to
	check the filesystem.

	Solve this problem by replacing the fs_csp array in 'struct fs'
	with a single pointer, and add padding to keep the length of the
	128-byte region fixed. Update the kernel and userland utilities
	to use just this single pointer.

	With this change, the kernel no longer makes use of the superblock
	fields 'fs_csshift' and 'fs_csmask'. Add a comment to newfs/mkfs.c
	to indicate that these fields must be calculated for compatibility
	with older kernels.

	Reviewed by:    mckusick
2001-09-02 01:58:30 +00:00
lukem 563fb2d03f no need to cast arg to lblktosize() any more 2001-08-31 03:38:45 +00:00
lukem 2bfd8a2678 More fixes from FreeBSD (with changes):
- Cast blk argument to lblktosize() to (off_t), to prevent 32 bit overflow.
  whilst almost every use in ffs used this for small blknos, there are
  potential issues, and it's safer this way.  (as discussed with chuq)
- Use 64bit (off_t) math to calculate if we have hit our freespace() limit.
  Necessary for coherent results on filesystems bigger than 0.5Tb.
- Use lblktosize() in blksize() and dblksize(), to make it obvious what's
  happening
- Remove sblksize() - nothing uses it
2001-08-31 03:15:45 +00:00
lukem 0cf1d74c5b be consistent when casting arg to lblktosize() in UVM_PAGE_TRKOWN debug code 2001-08-30 15:17:28 +00:00
lukem c56418af73 some improvements from freebsd/openbsd
- replace the unused fs_headswitch and fs_trkseek with fs_id[2], bringing
  our struct fs closer to that in freebsd & openbsd (& solaris FWIW)
- dumpfs: improve warning message when cpc == 0
2001-08-30 14:37:25 +00:00
lukem c535133897 - minor whitespace and comments cleanup
- replace "filesystem" with "file system"
- fix spelo (from freebsd)
2001-08-30 08:31:25 +00:00
chs 1de4b3e2e0 min() -> MIN() (on general principles) 2001-08-30 03:55:42 +00:00
chs eccd469cf7 min() -> MIN() 2001-08-30 03:47:53 +00:00
wiz 251b3464be heirarchy -> hierarchy 2001-08-24 10:24:45 +00:00
chs cb3b720183 disable mmap() for LFS until it is fixed. 2001-08-24 06:42:46 +00:00
wiz 1e378c4c12 precede, not preceed. 2001-08-20 12:00:46 +00:00
chs f0af9f581b add getpages/putpages entries for spec vnodes. 2001-08-17 05:54:36 +00:00
lukem 1b81d6353d remove third argument (`int ns') from ffs_sb_swap(), and let ffs_sb_swap()
determine the endianness of the `struct fs *o' superblock from o->fs_magic
and set needswap as necessary, rather than trusting the caller to get
it right.  invariably, almost every caller of ffs_sb_swap() was calling it
with ns set to the wrong value for ns anyway!
ansi KNF ffs_bswap.c declarations whilst here.

this fixes all sorts of problems when trying to use other-endian file systems,
notably the kernel trying to access memory *way* off, possibly corrupting or
panicing, and userland programs SEGVing and/or corrupting things (e.g,
"fsck_ffs -B"  to swap a file system endianness).

whilst the previous rev of ffs_bswap.c (1.10, 2000/12/23) made this problem
worse, i suspect that the problem was always there and previous versions
just happened not to trash things at the wrong time.

FFS_EI should now be a lot more stable.
2001-08-17 02:18:46 +00:00
lukem ed54fa2d76 correctly cast arguments to scanc() 2001-08-09 08:16:42 +00:00
lukem 1a2d5cf412 be consistent and use "u_char" instead of "unsigned char" 2001-08-09 08:15:26 +00:00
lukem a73aa816f3 get argument name correct in comment describing vop_balloc_args 2001-08-08 08:36:36 +00:00
jdolecek 58ed62e500 Constraint 'blkcnt' of lfs_markv() syscall by 64KB. Reviewed by
Konrad Schroder <perseant@NetBSD.org>.
2001-08-03 06:02:42 +00:00
lukem 3cd4afc9e3 - multiple include protection
- pull in <ufs/ufs/dinode.h> for ufs_daddr_t
- mark a few fields as being "UNUSED" (because they are)
2001-07-27 01:28:06 +00:00
lukem c358141302 multiple include protection 2001-07-27 01:24:54 +00:00
jdolecek bd21ec5d2e lfs_writeseg(): make el_size a size_t (cosmetic only, no functional change) 2001-07-26 20:20:15 +00:00
lukem 714cac851d if printing the value of fs_clean, say 'fs_clean' instead of 'fs_flags' ... 2001-07-26 07:58:55 +00:00
lukem fcf7f6cd06 fix spelo 2001-07-26 07:55:54 +00:00
assar bec71dc090 change vop_symlink and vop_mknod to return vpp (the created node)
refed, so that the caller can actually use it.  update callers and
file systems that implement these vnode operations
2001-07-24 15:39:30 +00:00
perseant 4e3fced95b Merge the short-lived perseant-lfsv2 branch into the trunk.
Kernels and tools understand both v1 and v2 filesystems; newfs_lfs
generates v2 by default.  Changes for the v2 layout include:

- Segments of non-PO2 size and arbitrary block offset, so these can be
  matched to convenient physical characteristics of the partition (e.g.,
  stripe or track size and offset).

- Address by fragment instead of by disk sector, paving the way for
  non-512-byte-sector devices.  In theory fragments can be as large
  as you like, though in reality they must be smaller than MAXBSIZE in size.

- Use serial number and filesystem identifier to ensure that roll-forward
  doesn't get old data and think it's new.  Roll-forward is enabled for
  v2 filesystems, though not for v1 filesystems by default.

- The inode free list is now a tailq, paving the way for undelete (undelete
  is not yet implemented, but can be without further non-backwards-compatible
  changes to disk structures).

- Inode atime information is kept in the Ifile, instead of on the inode;
  that is, the inode is never written *just* because atime was changed.
  Because of this the inodes remain near the file data on the disk, rather
  than wandering all over as the disk is read repeatedly.  This speeds up
  repeated reads by a small but noticeable amount.

Other changes of note include:

- The ifile written by newfs_lfs can now be of arbitrary length, it is no
  longer restricted to a single indirect block.

- Fixed an old bug where ctime was changed every time a vnode was created.
  I need to look more closely to make sure that the times are only updated
  during write(2) and friends, not after-the-fact during a segment write,
  and certainly not by the cleaner.
2001-07-13 20:30:18 +00:00
toshii 4866f1a22b Fix typo. s/extention/extension/ 2001-07-05 08:38:24 +00:00
chs c31ab668df in ext2fs_balloc_range(), clear PG_RDONLY on pages which now have backing store. 2001-07-04 21:16:01 +00:00
chs 2a7b0d97d6 in ufs_balloc_range(), clear PG_RDONLY on pages which now have backing store.
fixes PR 13353.
2001-07-04 21:08:48 +00:00
wiz f3f6c5b675 `accessible' only has one `a'. 2001-06-19 12:52:20 +00:00
mrg 804019f100 only include "fs_lfs.h" if _KERNEL_OPT. 2001-06-05 09:19:33 +00:00
chs d8bbc51566 fix an error case for quotas. 2001-06-03 16:49:07 +00:00
mrg 67afbd6270 use _KERNEL_OPT 2001-05-30 11:57:16 +00:00
chs 45701591c6 add a genfs_mmap() and change all of the disk-based filesystems
to implement VOP_MMAP() with the genfs version, in preparation for
actually using this VOP.
2001-05-28 02:50:51 +00:00
enami c17241f92a Don't flush possibilly relocated file system block if write is done
asynchronously.  They will be flushed later when necessary and flushing
now makes sequential write access very slow.
2001-04-18 03:48:23 +00:00
thorpej 5b35dc8136 When unmounting a file system, acquire the syncer_lock before
vfs_busy'ing just before the dounmount() call.  This is to avoid
sleeping with the mountlist_slock held -- but we must acquire
syncer_lock before vfs_busy because the syncer itself uses
syncer_lock -> vfs_busy locking order.
2001-04-16 22:41:09 +00:00
chs 331bd97cbd work around a problem with sync writes vs. softdeps. 2001-03-26 06:47:34 +00:00
fvdl ad5dcb280f Same change as in the UFS code: unlock vnode before setting v_op
to spec_vnode_ops. From Bill Studenmund.
2001-03-23 21:10:48 +00:00
fvdl 509b0d01a5 Do an explicit VOP_UNLOCK in ufs_vinit before setting v_op to
spec_vnode_ops_p. Workaround for a lock leak. Problem tracked
down by der Mouse.
2001-03-23 12:15:34 +00:00
sommerfeld d02dde9937 Change ffs_dirpref() to pay attention to the amount of available free
space before deciding which cylinder group should contain a new directory
inode.

Fixes kern/11983; works around some, but not all, of the side effects
of kern/11989.

Tested by me for well over a month on my laptop; preliminary versions of
the fix were tested by Frank van der Linden and Herb Peyerl.
2001-03-13 21:16:23 +00:00
chs 060e70db41 min() -> MIN(), max() -> MAX().
fixes more problems with file offsets > 4GB.
2001-02-27 04:37:44 +00:00
chs dfd2654fd2 min() -> MIN(), max() -> MAX().
fixes more problems with file offsets > 4GB.
2001-02-27 02:55:40 +00:00
fvdl 418264a670 Some bugfixes from rev 1.33 and 1.34 of this file in FreeBSD (some
in effect cosmetic). Original FreeBSD commit messages:

==
date: 2000/03/15 07:18:15;  author: mckusick;  state: Exp;  lines: +4 -4
Bug fixes for currently harmless bugs that could rise to bite
the unwary if the code were called in slightly different ways.

[...]

2) In ufs_lookup() there is an off-by-one error in the test that checks
if dp->i_diroff is outside the range of the the current directory size.
This is completely harmless, since the following while-loop condition
'dp->i_offset < endsearch' is never met, so the code immediately
does a second pass starting at dp->i_offset = 0.

3) Again in ufs_lookup(), the condition in a sanity check is wrong
for directories that are longer than one block. This bug means that
the sanity check is only effective for small directories.

Submitted by:   Ian Dowse <iedowse@maths.tcd.ie>

==

date: 2000/03/09 18:54:59;  author: dillon;  state: Exp;  lines: +2 -2
branches:  1.33.2;
    In the 'found' case for ufs_lookup() the underlying bp's data was
    being accessed after the bp had been releaed.  A simple move of the
    brelse() solves the problem.

Approved by: jkh
Submitted by:  Ian Dowse <iedowse@maths.tcd.ie>

==
2001-02-26 20:25:11 +00:00
lukem 5694890732 convert to ANSI KNF 2001-02-26 18:09:20 +00:00
lukem ae86fc2df2 some KNF 2001-02-26 17:12:08 +00:00
cgd 4dddddfe62 fix bug (pointed out as sequence point violation warning with current-ish gcc)
caused by use of makedev(major,minor++).  makedev() now (since 32-bit
dev_t conversion) evaluates its second argument twice.
2001-02-24 00:05:22 +00:00
eeh d0eaafc17f Use int32_t for on-disk time_t values. 2001-02-23 02:25:10 +00:00
chs 5e3caa8b52 skip truncating a file to 0 before freeing it if it's already zero-length. 2001-02-18 20:17:04 +00:00
chs 77b8e1c11d fix the range args to pgo_flush() in the error path of ufs_balloc_range(). 2001-02-18 20:13:29 +00:00
chs 31f045ca75 remove debug code that was left in by accident. 2001-02-07 22:40:06 +00:00
tsutsui ec8b1c000e Fix nested extern declaration of prtactive. 2001-02-07 12:40:43 +00:00
chs a1c22f6d67 add casts to an assertion in ffs_alloc() so it works with offsets past 4GB. 2001-02-05 10:55:02 +00:00
christos bf4fd5e39c don't include lfs_extern.h; ufs/inode.h does too. 2001-02-04 21:51:19 +00:00
augustss 46ee162100 Fix from chuq:
don't update UVM's notion of the file size before the VOP_FSYNC() when
we're partially truncating a file with softdeps enabled.  doing so could
free pages without updating the dependency info, which would result in
"panic: softdep_write_inodeblock: direct pointer #1 mismatch 0 != N".
2001-01-27 04:23:21 +00:00
itohy 7c338ddc48 Call inittodr() from lfs_mountroot() so that the system time is set properly
when booted from LFS.
2001-01-26 07:59:23 +00:00
jdolecek d9466585b7 make filesystem vnodeop, specop, fifoop and vnodeopv_* arrays const 2001-01-22 12:17:35 +00:00
jdolecek 34c8ae80da constify 2001-01-18 20:28:15 +00:00
mycroft fad85a24d8 On a RW->RO transition, explicitly clear fs_fmod after the cgupdate/sbupdate,
to prevent spurious writebacks and whinging about the (correct!) clean flag.
(Why this isn't done in ffs_sbupdate(), I dunno...)
2001-01-10 17:49:18 +00:00
ad d8735dd13a RCS ID 2001-01-10 16:45:56 +00:00
chs bc21905f3c attach the softdep pagecache pseudo-buffers to the inode
so we can find them quickly in the softdep truncate path.
2001-01-10 04:47:10 +00:00
mycroft 7f2aa054f1 ffs_reload(): Copy fs_ronly into the new superblock, too, as it may have been
modified on disk (e.g. by fsck(8)).  This flag should really be elsewhere.
2001-01-09 10:44:19 +00:00
joff a6ef389457 If DIAGNOSTIC and the segment writer gets a badly sized buffer, panic()
instead of silently corrupting the filesystem.
2001-01-09 05:05:35 +00:00
matt ad346bb9eb Convert a MALLOC with a variable size to malloc(). Saves 220 bytes of text
on VAX.
2001-01-01 05:17:26 +00:00
enami 95a1bfa14c - 16 * 8 != 168
- offset should be endian independent.
2000-12-23 14:42:06 +00:00
enami 0e4a3d44c0 Cosmetic changes 2000-12-23 14:09:52 +00:00
cgd 1a1dca038e replace \<space(s)><newline> (wrong!) with \<newline> 2000-12-20 00:24:23 +00:00
mycroft 61a6479ab1 Patch from Kirk McKusick to fix an ordering problem in softdep_setup_freeblks()
that could cause an inode to be reused prematurely (possibly resulting in the
file containing garbage blocks).
2000-12-13 20:07:32 +00:00
chs e6e27e9efc fix bookkeeping for page cache dependency buffers. 2000-12-13 15:32:31 +00:00
chs bb61d9c5e4 in flush_inodedep_deps(), drop the big softdep lock while flushing pages. 2000-12-11 03:53:54 +00:00
chs 4ab33e73c2 call pgo_flush with (start,end) rather than (start,length). 2000-12-10 19:41:35 +00:00
chs 3a5e4f901b in *_sync(), don't skip vnodes which have (potentially dirty) pages. 2000-12-10 19:36:31 +00:00
chs 1c89ab39ad redo ext2fs_balloc_range(), accounting for differences between ext2fs and ffs. 2000-12-10 06:38:31 +00:00
chs 4912461b20 in ffs_sync(), don't skip vnodes which have (potentially dirty) pages. 2000-12-04 09:37:06 +00:00
fvdl 7c2b9d8515 In addition to setting the softdep flag in the superblock when
mounting with softdeps, also explicitly clear it when we don't,
so that a leftover setting after a crash will be cleared.
2000-12-03 19:52:06 +00:00
perseant 32d11b86a5 Call uvm_vmp_setsize() in lfs_{fast,}vget to set initial vnode size. 2000-12-03 07:34:49 +00:00
perseant 72633be8c6 Fix typo in 'malloc' for non-MALLOCLOG case 2000-12-03 06:43:36 +00:00
perseant 2a53ff5ab9 Get rid of some old unnecessary code that cleared B_NEEDCOMMIT from buffers in
lfs_writeseg (possibly after they had been freed).

If MALLOCLOG is defined, make lfs_newbuf and lfs_freebuf pass along the
caller's file and line to _malloc and _free.
2000-12-03 05:56:27 +00:00
chs 65a9d68fda don't forget to set um_lognindir (now required by ufs_bmaparray()). 2000-12-03 05:27:51 +00:00
chs 6944ee458a in ufs_balloc_range(), don't rely on uvm_vnp_setsize() to invalidate
pages we've allocated past the real EOF when we fail to allocate a block.
we used to play games with the VM notion of the file size but we don't do
that anymore, so uvm_vnp_setsize() doesn't do what we want anymore.
call the pager flush op instead.
2000-12-03 03:57:24 +00:00
chs eeabe3f90d make sure that pages are on an paging queue before unlocking them. 2000-12-01 09:54:42 +00:00
chs b3dcb62708 fix merge error: ext2fs uses a custom balloc rather than a VOP-style one. 2000-12-01 07:02:40 +00:00
nathanw aa215181ce Don't set the value of doreallocblks here; it's defined over in vfs_cluster.c
In fact, doreallocblks isn't used here at all. Delete the declaration.
2000-11-30 20:56:10 +00:00
jdolecek 861369604d change vfs.ffs.doreallocblks to 1 by default - this does not have
aby bad symptoms any more, fix for bug causing problems with this
option was in BSD4.4-Lite2 and pulled in together with softdep changes

See also Keith Smith & Margo Seltzer's paper on the topic at
http://www.eecs.harvard.edu/~keith/papers/realloc.ps.gz
2000-11-30 19:46:02 +00:00
jdolecek bf558e3b3e only include opt_ddb.h for !LKM 2000-11-30 15:59:47 +00:00
jdolecek 734f246738 no need to include fs_lfs.h, define LFS directly 2000-11-30 15:57:35 +00:00
chs e9037d16c5 allow building without SOFTDEP by adding the pageiodone hook to bio_ops. 2000-11-27 18:26:38 +00:00
chs aeda8d3b77 Initial integration of the Unified Buffer Cache project. 2000-11-27 08:39:39 +00:00
perseant 0055236dda If LFS_DO_ROLLFORWARD is defined, roll forward from the older checkpoint
on mount, through the newer checkpoint and on through any newer
partial-segments that may have been written but not checkpointed because
of an intervening crash.

LFS_DO_ROLLFORWARD is not defined by default.
2000-11-27 03:33:57 +00:00
perseant 77b518b85d Use u_int32_t instead of u_long to compute LFS checksums, since the
checksum is stored in a u_int32_t.
2000-11-25 02:39:34 +00:00
perseant e4911189f1 Protect lfs_{bmapv,markv} with vfs_{un,}busy. Fix a reference/lock leak
in an error case in lfs_markv.  Change the vfs_getvfs() error to return
ENOENT, for consistency with failure of vfs_busy().

99% of this patch was from Jesse Off <joff@gci-net.com> (PR #11547).
2000-11-22 22:11:34 +00:00
perseant c398987151 More locked_queue_* and lfs_avail accounting fixes from Jesse Off
<joff@gci-net.com>.  Remove a specious btodb() in lfs_fragextend, and
count blocks shrunk or removed by VOP_TRUNCATE in lfs_avail.
2000-11-21 00:00:31 +00:00
toshii 92a17c6ecd Make buildable again.
The previous commit was a backout of rev. 1.45, which must be an accident.
2000-11-18 02:11:23 +00:00
perseant 31fc62d4e9 Correct accounting of lfs_avail, locked_queue_count, and locked_queue_bytes.
(PR #11468).  In the case of fragment allocation, check to see if enough
space is available before extending a fragment already scheduled for writing.

The locked_queue_* variables indicate the number of buffer headers and bytes,
respectively, that are unavailable to getnewbuf() because they are locked up
waiting for LFS to flush them; make sure that that is actually what we're
counting, i.e., never count malloced buffers, and always use b_bufsize instead
of b_bcount.

If DEBUG is defined, the periodic calls to lfs_countlocked will now complain
if either counter is incorrect.  (In the future lfs_countlocked will not need
to be called at all if DEBUG is not defined.)
2000-11-17 19:14:41 +00:00
perseant b880487624 Initialize the cleaner information in the Ifile from the same info from
the superblock at fs mount time, enabling the previous patch to fsck_lfs.
Patch from Jesse Off <joff@gci-net.com> (Closes PR #11470).
2000-11-14 00:42:55 +00:00
perseant a07c936a59 Remove debugging code that accidentally went in with yesterday's commit. 2000-11-13 00:24:30 +00:00
perseant c4c7b2adbb Do not needlessly dirty segment table blocks during lfs_segwrite,
preventing needless disk activity when the filesystem is idle.  (PR #10979.)
2000-11-12 07:58:36 +00:00
toshii af22f56146 Fix obsolete comments in lfs_writeinode since rev. 1.27.
New comments are mostly from perseant, with my additions.
2000-11-12 02:13:51 +00:00
ad 642267bcc7 Update for hashinit() change. 2000-11-08 14:28:12 +00:00
fvdl ef6bdbccd8 Stay at splbio across the VBWAIT loop, as is done elsewhere in the
kernel. Avoids a possible race condition. Pointed out by
enami@netbsd.org, problem reported by deberg@netbsd.org.
2000-10-24 14:43:32 +00:00
toshii 0036e468ef In lfs_fastvget(), initialize i_lfs_effnblks correctly. 2000-10-21 13:53:25 +00:00
perseant 26f26aafcd Do not increment the clean segment counter, if a segment that the cleaner
is trying to clean is already clean (e.g., if two lfs_cleanerds are running
at once.)
2000-10-20 17:48:05 +00:00
pk 5e2d2660fc In ufs_makeinode(), set the new vnode type to VNON before calling vput(). 2000-10-19 10:55:35 +00:00
perseant 7a4d35b365 In lfs_truncate, don't overcount the real blocks removed from the inode,
when deallocating a fragment that has not made it to disk yet.

Also, during dirops, give the directory vnode an extra reference in
SET_DIROP, to ensure its continued existence during SET_ENDOP, preventing
a possible NULL-dereference there.

These two changes should close PR #11064.
2000-10-14 23:22:14 +00:00
simonb ec25ea9f3b Position comment correctly wrt last commit. 2000-10-13 17:59:11 +00:00
simonb 831fce13ac In mfs_start(), move the handling of outstanding I/O requests to before
the check for unmounting the filesystem.

Appears to fix kern/10122 from Hitoshi Matsunawa.
2000-10-13 16:53:53 +00:00
simonb 7bf589b1ae There is no need to explicitly include <uvm/uvm_extern.h> for
<sys/sysctl.h> anymore.
2000-10-13 16:40:26 +00:00
thorpej 053e3ba195 Make sure to set the residual count to 0 after a miniroot access
or after bitbucketing I/O during shutdown.
2000-10-09 18:07:06 +00:00
fvdl 81ba8e7ff7 Adapt for VOP_FSYNC parameter change.
Implement range fsync for FFS. Note: not yet implemented for the
SOFTDEP case.
2000-09-19 22:04:08 +00:00
fvdl db4108490a Adapt for VOP_FSYNC parameter change. 2000-09-19 22:01:59 +00:00
perseant a477e1b98b Cast back to int32_t in LFS_EST_BFREE and LFS_EST_RSVD macros, for
consistency with their arguments.

Change the debugging printf in lfs_reserve to match, and enclose it in
#ifdef DEBUG.

Tested on alpha, arm32, sparc.
2000-09-13 00:07:56 +00:00
perseant 78ae325de3 Make this file compile on the alpha as well (use %ld and cast to long,
instead of %qd with no cast).
2000-09-12 03:22:53 +00:00
augustss 76451577e7 Make this file compile again. 2000-09-10 00:20:45 +00:00
perseant 17cb334f4f oops 2000-09-09 21:03:31 +00:00
perseant 9c7f8050f4 Various bug-fixes to LFS, to wit:
Kernel:

* 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
  btodb()/dbtob().

lfs_cleanerd:

* 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).

fsck_lfs:

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

newfs_lfs:

* 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.

mount_lfs:

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

* 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.]
2000-09-09 04:49:54 +00:00
perseant 988a012d50 Change dlfs_dmeta and dlfs_avail to signed quantities, to prevent
underflow errors, visible in userland as impossibly high values
returned from df(1).
2000-09-09 04:18:28 +00:00
perseant 8cb6723a92 Fix a buffer-cache corrupting bug in lfs_writeseg, where brelse could
be improperly used on an already-queued buffer.
2000-09-09 04:13:43 +00:00
perseant 4446817aca Make sure to unmark B_DELWRI on blocks freed due to truncation to a non-zero
file length.  Should fix PR #s 10551 and 10831.
2000-09-09 03:47:05 +00:00
fvdl ce4bcf47f3 Do not call MALLOC with M_WAITOK while holding the "lock". Thanks to
Ethan Solomita for the reminder.

Mark the parent vnode lock as recursive while flushing pagedeps. XXX.
Should fix kern/10564.
2000-08-15 14:25:08 +00:00
thorpej 7cc27a88c0 Convert namei pathname buffer allocation to use the pool allocator. 2000-08-03 20:41:05 +00:00
thorpej f0dca1ecbe MALLOC()/FREE() are not to be used for variable sized allocations. 2000-08-03 20:29:26 +00:00
mycroft bd58d06c50 Need string.h for memset() prototype. 2000-07-24 00:23:10 +00:00
jdolecek b0fb24279c change the lf_advlock() arguments from
int     lf_advlock __P((struct lockf **,
           off_t, caddr_t, int, struct flock *, int));
to

int     lf_advlock __P((struct vop_advlock_args *, struct lockf **, off_t));

This matches common usage and is also compatible with similar change
in FreeBSD (though they use u_quad_t as last arg).
2000-07-22 15:26:11 +00:00
jdolecek 166a3f16dd ext2fs_reload(), ext2fs_mountfs(): do devvp locking same way as ffs
this has not shown any good or bad effect, but might help narrow
some problems people seen with ext2fs reload (hi Soren!)
2000-07-22 14:49:17 +00:00
thorpej f9ba0345f1 XXX Use of hzto() return value needs to be double-checked here. 2000-07-13 17:35:03 +00:00
perseant 562aaaa063 Fix so non-kernel code will compile (_LKM) 2000-07-06 20:32:06 +00:00
perseant 90b9d9b502 Clean up accounting of lfs_uinodes (dirty but unwritten inodes).
Make lfs_uinodes a signed quantity for debugging purposes, and set it to
zero as fs mount time.

Enclose setting/clearing of the dirty flags (IN_MODIFIED, IN_ACCESSED,
IN_CLEANING) in macros, and use those macros everywhere.  Make
LFS_ITIMES use these macros; updated the ITIMES macro in inode.h to know
about this.  Make ufs_getattr use ITIMES instead of FFS_ITIMES.
2000-07-05 22:25:43 +00:00
jdolecek 84846c5caa kern.maxvnodes (and hence desireddquot) depends more directly on NVNODE than
on NPROC, adjust the hint to tablefull() accordingly
2000-07-05 17:08:14 +00:00
perseant bc303e52cb Fix errors observed while trying to fill the filesystem with yesterday's
fixes:

- Write copies of bfree and avail in the CLEANERINFO block, so the
  cleaner doesn't have to guess which superblock has the current
  information (if indeed any do).

- Tighten up accounting of lfs_avail (more needs to be done).

- When cleansing indirect blocks of UNWRITTEN, make sure not to mark
  them clean, since they'll need to be rewritten later.
2000-07-04 22:30:37 +00:00
mjacob eb17c77233 Add missing second argument to tablefull call. I *think* the added
message makes sense- somebody might want to check it.
2000-07-04 20:31:55 +00:00
perseant eccd5fb47a Fix i_ffs_blocks in fragment extension case where fragment has not yet
been written to disk.
2000-07-03 20:12:42 +00:00
fvdl 7c1d5ec58f Correct typo in previous. 2000-07-03 18:22:10 +00:00
perseant 235a4dd595 i_lfs_effnblks fixes. Put debugging printfs under #ifdef DEBUG_LFS. 2000-07-03 08:20:58 +00:00
perseant ef2da50400 Allow the number of free segments reserved for the cleaner to be
parametrized in the filesystem, defaulting to MIN_FREE_SEGS = 2 but set
to something more reasonable at newfs_lfs time.

Note the number of blocks that have been scheduled for writing but which
are not yet on disk in an inode extension, i_lfs_effnblks.  Move
i_ffs_effnlink out of the ffs extension and onto the main inode, since
it's used all over the shared code and the lfs extension would clobber
it.

At inode write time, indirect blocks and inode-held blocks of inodes
that have i_lfs_effnblks != i_ffs_blocks are cleansed of UNWRITTEN disk
addresses, so that these never make it to disk.
2000-07-03 01:45:46 +00:00
perseant db557257e5 Move SET_ENDOP after vrele to avoid deactivating vnode twice, if
SET_ENDOP triggers a write.
2000-07-01 19:03:57 +00:00
fvdl fa78158b15 Rearrange code around getnewvnode as was already done for ffs, to avoid
locking against oneself because getnewvnode recycles a softdep-using vnode.
2000-06-30 20:45:38 +00:00
mrg 419501093a remove include of <vm/vm.h> and <uvm/uvm_extern.h> 2000-06-28 14:16:37 +00:00
mrg 91cc436b9e <vm/vm.h> -> <uvm/uvm_extern.h> 2000-06-28 14:11:33 +00:00
fvdl d09958adad Due to popular demand, change vinsheadfree to ungetnewvnode to make
the name clearer. No functional change.
2000-06-27 23:51:22 +00:00
fvdl bba2403203 In ffs_vget, do not hold ufs_haslock across the call to getnewvnode.
We may sleep in it, or even recurse, with softdeps. Instead, grab
the lock later, but check if noone else has beaten us to the VFS_VGET
operation, and if so, roll back getnewvnode using vinsheadfree, and
just return.
2000-06-27 23:39:17 +00:00
perseant 39b86955ed Fixes associated with filling an LFS:
Change the space computation to appear to change the size of the *disk*
rather than the *bytes used* when more segment summaries and inode
blocks are written.  Try to estimate the amount of space that these will
take up when more files are written, so the disk size doesn't change too
much.

Regularize error returns from lfs_valloc, lfs_balloc, lfs_truncate: they
now fail entirely, rather than succeeding half-way and leaving the fs in
an inconsistent state.

Rewrite lfs_truncate, mostly stealing from ffs_truncate.  The old
lfs_truncate had difficulty truncating a large file to a non-zero size
(indirect blocks were not handled appropriately).

Unmark VDIROP on fvp after ufs_remove, ufs_rmdir, so these can be
reclaimed immediately: this vnode would not be written to disk again
anyway if the removal succeeded, and if it failed, no directory
operation occurred.

ufs_makeinode and ufs_mkdir now remove IN_ADIROP on error.
2000-06-27 20:57:11 +00:00
perseant d8584d7769 From John Evans <jevans@cray.com>: use datosn() to convert to segment
number, when remarking the current segment ACTIVE.  See PR #10463.
2000-06-27 20:00:03 +00:00
pk 88b0328aca We shouldn't be defining DEBUG and DIAGNOSTIC on our own; these may have
unwanted side-effects in the header files. For now, do the internal
#defines after including the headers.
2000-06-27 16:46:54 +00:00
perseant 9235101232 fix my own typo, grr.... 2000-06-22 18:46:57 +00:00
perseant fd451352d9 Read i_ffs_gen from the version number in the Ifile during lfs_valloc,
instead of keeping it always == 1.  (The ifile version number is
increased on vfree.)  May address PR #7213, but I haven't been able to
test thoroughly enough to say for sure.
2000-06-22 18:31:49 +00:00
perseant 973ddee4e5 Update lfs_vunref for the fact that now a vnode can be locked with no
references (locked for VOP_INACTIVE at the end of vrele) and it's okay.
Check the return value of lfs_vref where appropriate.
Fixes PR #s 10285 and 10352.
2000-06-22 18:11:45 +00:00
fvdl 45b3f2405a Moved here from gnu/sys/ufs/ffs 2000-06-22 16:13:41 +00:00
fvdl 77b2bcbe07 Copyright changed. 2000-06-22 15:23:05 +00:00
perseant da29133e76 make it compile (fix typo) 2000-06-16 05:45:14 +00:00