Commit Graph

221 Commits

Author SHA1 Message Date
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
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 714cac851d if printing the value of fs_clean, say 'fs_clean' instead of 'fs_flags' ... 2001-07-26 07:58:55 +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
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
eeh d0eaafc17f Use int32_t for on-disk time_t values. 2001-02-23 02:25:10 +00:00
chs 31f045ca75 remove debug code that was left in by accident. 2001-02-07 22:40:06 +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
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
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
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
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 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
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
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
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
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
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 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
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
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
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
matt 1b5bc7ce61 ignore the softdep flags when mounting and there's no softdep in the kernel. 2000-06-16 00:30:15 +00:00
fvdl 4f11634756 Allow MNT_SOFTDEP to be passed in via the mount(2) system call, do not
require it to be set via tunefs(8). Silently ignore it when doing
an update mount of a writeable filesystem, the FFS/softdep code isn't ready
for this yet.
2000-06-15 22:35:37 +00:00
mycroft 64f5a574a7 In ffs_update():
* Move the clearing of IN_MODIFIED and IN_ACCESSED later, so they are not
  cleared if the bread() failed.
* Explicitly set waitfor to 0 in the softdep case, if IN_MODIFIED is not
  set (mirroring the bwrite()/bdwrite() decision).
2000-05-30 17:23:52 +00:00
mycroft 4db674fa50 According to Frank, buffers with dependencies *are* left on v_dirtyblks, so
remove the FSYNC_RECLAIM check and force them to be flushed.
2000-05-29 18:53:35 +00:00
mycroft edfd1e6f32 Use LIST_{FIRST,NEXT,EMPTY}(). 2000-05-29 18:28:48 +00:00
mycroft d747ada9c2 Add a new inode flags called IN_ACCESSED. This used in place of IN_MODIFIED
to record that the atime was updated.  In ffs_update(), we only do synchronous
writes if something *other* than the atime was changed.
2000-05-29 18:04:30 +00:00
mycroft 941524439a Never call softdep_sync_metadata() in the FSYNC_RECLAIM case. Any pending
blocks are detached from the vnode at this point.  When the dependencies are
broken to enable writing the blocks, the vnode will be regenerated.  (The only
reason we sync buffers in this case is that they have to be detached from the
vnode.)
2000-05-29 17:19:20 +00:00
mycroft c47adf55e0 In ffs_fsync(), remove the FSYNC_RECLAIM special case, so that it properly
waits for pending buffers, and doesn't throw away time stamp updates.
2000-05-29 17:12:06 +00:00
mycroft ccf1cf4b69 MNT_WAIT -> FSYNC_WAIT 2000-05-29 16:28:27 +00:00
mycroft 1ea529f6df DTRT when unwinding multiple levels. 2000-05-28 08:31:41 +00:00
mycroft 4fc7b946c2 When unwinding a failed allocation, make sure to nuke the unwound block from
the vnode's block list.  This fixes `itrunc3' panics (at least in some cases;
further testing is needed) and prevents further lossage later on.
2000-05-28 08:15:40 +00:00
mycroft 4656dfd24f Add a new function to remove extra buffers when truncating a file. This is
more generic than the vinvalbuf(V_SAVEMETA) case, avoiding synchronous
operations when truncating to a non-zero length.
2000-05-28 04:13:56 +00:00
thorpej 21fc65e1a8 sleep() -> tsleep() 2000-05-27 04:52:27 +00:00
thorpej f636538446 NULL != 0 2000-05-19 04:34:39 +00:00
bouyer 1900598507 Sync copyrigth notice. 2000-05-15 08:51:55 +00:00
perseant f0728fdce1 Change the sementics of the last parameter from a boolean ("waitfor") to
a set of flags ("flags").  Two flags are defined, UPDATE_WAIT and
UPDATE_DIROP.

Under the old semantics, VOP_UPDATE would block if waitfor were set,
under the assumption that directory operations should be done
synchronously.  At least LFS and FFS+softdep do not make this
assumption; FFS+softdep got around the problem by enclosing all relevant
calls to VOP_UPDATE in a "if(!DOINGSOFTDEP(vp))", while LFS simply
ignored waitfor, one of the reasons why NFS-serving an LFS filesystem
did not work properly.

Under the new semantics, the UPDATE_DIROP flag is a hint to the
fs-specific update routine that the call comes from a dirop routine, and
should be wait for, or not, accordingly.

Closes PR#8996.
2000-05-13 23:43:06 +00:00
jdolecek c78399fc88 Add a new sysctl variable vfs.ffs.log_changeopt - if this is true,
an optimalization strategy change is logged into syslog. Default
is 0 (to not log). This replaces the recent not quite "right"
change to only log the change if kernel is compiled with DEBUG.
2000-04-04 09:23:20 +00:00
augustss 169ac5b3c1 Remove register declarations. 2000-03-30 12:41:09 +00:00
simonb c2e5560a03 Delete redundant decls of rootvp - it's in <sys/systm.h>.
Delete redundant decl of ffs_sbupdate() - it's in <ufs/ffs/ffs_extern.h>.
2000-03-30 02:48:22 +00:00
jdolecek a6cb6fe4ee Log the optimization changes only if DEBUG. Fixes kern/9697 2000-03-29 08:46:57 +00:00
simonb 0fd09c8496 Don't need to include <sys/conf.h> here. 2000-03-29 03:43:33 +00:00
fvdl 512503c606 If we're reclaiming, and there are no dirty blocks, just return. 2000-03-17 01:26:52 +00:00
jdolecek 03efc0b2b7 Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading.

For each leaf filesystem, add appropriate vfs_done routine.

Also remember how many times ffs_init() was called and do
the appropriate initialization on first call only. In ffs_done(),
destroy the resources when called by the last user of ffs code.
Change mfs to call ffs_init()/ffs_done() appropriately.
2000-03-16 18:20:06 +00:00
fvdl 1c78f3708b Inititalize the fs variable struct a little earlier to avoid referencing
a bad pointer in a printf. Problem reported by Krister Walfridsson.
2000-03-16 10:37:00 +00:00
fvdl e3dbad5a3c Revert this back to 2 revisions ago, these checks are done higher up now. 2000-03-15 16:31:52 +00:00
fvdl 563d336e44 Don't immediately return in ffs_fsync if there appears to be no data
to flush if it's a vnode on a softdep filesystem. softdep_sync_metadata
may still need to do some work.
2000-03-14 13:06:29 +00:00
perseant 61fa9e1409 Move vinvalbuf's check for dirty blocks into ffs_fsync, to ensure that
mode and ownership bits are flushed to disk before the vnode is
reclaimed.

The check, introduced in the softdep merge, assumes that if no blocks
are dirty, no file data *or metadata* needs to be flushed to disk.  This
is true of ffs, but is not true of lfs, and may not be true of other
filesystems.

Tested by myself and Bill Squier <groo@cs.stevens-tech.edu>.
2000-03-11 05:00:18 +00:00
fvdl 89670eb646 Fix a bug introduced in Lite2 with block allocation and full disk
conditions. Reported by Ian Dowse <iedowse@maths.tcd.ie>, based
on patch in FreeBSD reviewed by Kirk McKusick.
2000-02-25 19:58:25 +00:00
fvdl fe39281ea4 Fixes to the softdep code from Ethan Solomita <ethan@geocast.com>.
* Fix buffer ordering when it has dependencies.
* Alleviate memory problems.
* Deal with some recursive vnode locks (sigh).
* Fix other bugs.
2000-02-14 22:00:21 +00:00
bouyer 3c680c00ab Handle pre-FS_42POSTBLFMT. I now can mount an Ultrix file system on my
sparc without panic.
2000-01-18 18:41:29 +00:00
drochner 800b976584 Call ffs_oldfscompat() before all the consistency checks, to avoid the
use of uninitialized data in the checks if the filesystem is an old one.
1999-12-10 14:36:04 +00:00
fvdl 0b1963121a Add Kirk McKusick's soft updates code to the trunk. Not enabled by
default, as the copyright on the main file (ffs_softdep.c) is such
that is has been put into gnusrc. options SOFTDEP will pull this
in. This code also contains the trickle syncer.

Bump version number to 1.4O
1999-11-15 18:49:07 +00:00
enami fee96e1746 Check if the type of device node isn't VBAD before touching v_specinfo. If
the device vnode is revoked, the field is NULL and touching it causes null
pointer derefercence.
1999-10-20 14:32:09 +00:00
wrstuden e682a080e9 In spec_close(), if we're not doing a non-blocking close and VXLOCK is
not set, unlock the vnode before calling the device's close routine and
relock it after it returns. tty close routines will sleep waiting for
buffers to drain, which won't happen often times as the other side needs
to grab the vnode lock first.

Make all unmount routines lock the device vnode before calling VOP_CLOSE().
1999-10-16 23:53:26 +00:00
thorpej 29df848753 Need <string.h> for memcpy(3) prototype if building from userland. 1999-09-14 04:50:54 +00:00
wrstuden 3bf14d81e9 Add support for fcntl(2) to generate VOP_FCNTL calls. Any fcntl
call with F_FSCTL set and F_SETFL calls generate calls to a new
fileop fo_fcntl. Add genfs_fcntl() and soo_fcntl() which return 0
for F_SETFL and EOPNOTSUPP otherwise. Have all leaf filesystems
use genfs_fcntl().

Reviewed by: thorpej
Tested by: wrstuden
1999-08-03 20:19:16 +00:00
drochner 12a6593f79 clean up inclusion of "opt_ffs.h" and use of "FFS_EI" a bit 1999-08-03 19:22:43 +00:00
wrstuden 976aedb7ac Adjust mountroot routines to vrele rootvp in case of mount error. Closes
PR 7977 by Neil Carson, <neil@brini.com>.
1999-07-17 01:08:28 +00:00
wrstuden 379a26972f Modify file systems to deal with struct lock in struct vnode. All leaf
fs's other than nfs use genfs_lock() for locking.

Modify lookup routines to set PDIRUNLOCK when they unlock the parrent.
1999-07-08 01:05:58 +00:00
mrg d2397ac5f7 completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
1999-03-24 05:50:49 +00:00
mycroft b174019ccc Pass null pointers to VOP_UPDATE rather than having all the callers fetch the
current time themselves.
1999-03-05 21:09:48 +00:00
mycroft 86ed73efb4 Permit the access and modify time pointers passed to VOP_UPDATE to be null,
meaning the current time.
1999-03-05 20:47:06 +00:00
bouyer 00d7241e81 Don't check fs_bsize before the superblock has been swapped if needed.
Check value of sbsize before allocating memory with this value.
1999-03-05 12:02:18 +00:00
wrstuden 862a56e88b Modify vfsops to seperate vfs_fhtovp() into two routines. vfs_fhtovp() now
only handles the file handle to vnode conversion, and a new call,
vfs_checkexp(), performs the export verification.
1999-02-26 23:44:43 +00:00
bouyer 22d556f6cf Make sure a buffer optained from bread() is always bresle()'d in case of
error. Closes PR kern/1448 from Wolfgang Solfrank.
1999-02-10 13:14:08 +00:00
bouyer cdbe530495 No need to #include malloc.h here. 1998-12-04 11:02:30 +00:00
bouyer 3efc699962 Sanity check a few values in the superblock, to avoid mallocing huge
memory area if we try to mount a corrupted filesystem. Fixes kern/3933.
1998-12-04 11:00:40 +00:00
thorpej 1fcae7f1be defopt FFS_EI 1998-11-12 19:51:10 +00:00
mycroft 1a5b9c6c30 Do not corrupt file flags when file system is full! 1998-10-27 21:32:58 +00:00
thorpej f7948d05a1 Use DINODE_SIZE rather than pointer arithmetic. 1998-10-23 00:31:28 +00:00
christos e62c8fd824 Missed a conditional for FFS_EI; appears when we compile without -Ox 1998-10-04 18:07:57 +00:00
thorpej 60cfe320cc Use the pool allocator and the "nointr" pool page allocator for FFS inodes.
XXX MFS also comes in here for inodes, and used a different malloc type,
but the structure is the same, so we just use the FFS inode pool.
1998-09-01 03:11:08 +00:00
thorpej 39f683419f Back out part of last change (uninitialized work-around). 1998-08-18 18:15:41 +00:00
thorpej 6fc90a1a4d Add some braces to make egcs happy (ambiguous else warning). Also,
deal with bogus uninitialized warning (__noreturn__ related)
1998-08-18 06:47:53 +00:00
perry 27ca6798df bzero->memset, bcopy->memcpy, bcmp->memcmp 1998-08-09 20:15:38 +00:00