Commit Graph

577 Commits

Author SHA1 Message Date
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