Commit Graph

1741 Commits

Author SHA1 Message Date
pooka b43847b66c zu, not zd, to print size_t 2008-08-05 13:39:29 +00:00
simonb ba0675032b Only allow WAPBL to operate with UFS2 style superblocks.
Problem reported by Takeshi Nakayama.
2008-08-04 15:55:11 +00:00
simonb 53aeec60eb When checking if there's enough space at the end of a partition,
compare bytes vs bytes, not sectors vs bytes.

Problem discovered and fix tested by Michael Hitch.
2008-08-02 02:23:51 +00:00
oster 9921f79434 Make MSDOS filesystems work again after WAPBL merge. Fixes a quite
repeatable panic in fstrans_getstate() found while searching for a
different USB bug.  Also makes the code somewhat more readable.

Patch from Juergen Hannken-Illjes with a small rearrangement from me.

Approved by: hannken
2008-07-31 23:49:50 +00:00
hannken 85271ee0ad Ffs snapshots don't work (yet) with WAPBL:
- no snapshot creation on logging file systems.
- refuse to mount logging file systems with persistent snapshots.

Ok: Simon Burge <simonb@netbsd.org>
2008-07-31 15:37:56 +00:00
hannken fb6f2c9b30 Resolve a deadlock when fs_nodealloccg() initializes more inodes on
an UFS2 file system.  With the current cylinder group buffer busy it
calls ffs_getblk().  This runs through copy-on-write and may need the
current cylinder group buffer to allocate a new block for the snapshot.

While here write the cylinder group buffer synchronously after
cg_initediblk was changed because fsck_ffs will trust it.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>
2008-07-31 09:35:09 +00:00
simonb 0800f2fb9f Be consistent with #define<tab>. 2008-07-31 08:44:21 +00:00
simonb 36d65f1138 Merge the simonb-wapbl branch. From the original branch commit:
Add Wasabi System's WAPBL (Write Ahead Physical Block Logging)
   journaling code.  Originally written by Darrin B. Jewell while
   at Wasabi and updated to -current by Antti Kantee, Andy Doran,
   Greg Oster and Simon Burge.

OK'd by core@, releng@.
2008-07-31 05:38:04 +00:00
hannken 4685b65ada ffs_snapshot():
Release allocated indir blocks on non-softdep file systems instead
    of writing them twice.
    It is sufficient to clean dirty data pages to avoid UBC inconsistencies.

ffs_snapblkfree() and wrsnapblk():
    If a snapshots effective link count is zero there is no need
    to use synchronous writes.

ffs_copyonwrite():
    Defer locking the snapshots until there is a need to copy the block.

wrsnapblk():
    Use vn_rdwr() instead of bwrite() to write to the snapshots.
2008-07-30 10:09:30 +00:00
hannken f67742b3c8 expunge_ufs*(): Use the buffer cache to update the inodes on the snapshot like
the rest of snapshot creation does.
2008-07-15 08:20:56 +00:00
simonb 27ae933bee Fix potential 32-bit overflow problem in the blockpref code.
mlelstv@ points out FreeBSD fixed the same thing a couple of years
ago - here's the commit message they used on rev 1.127:

   Fixes a bug that caused UFS2 filesystems bigger than 2TB to
   prematurely report that they were full and/or to panic the kernel
   with the message ``ffs_clusteralloc: allocated out of group''.

   Submitted by:   Henry Whincup <henry@jot.to>
2008-07-11 05:31:44 +00:00
ad c4d3520a6e ufsdirhash_build: missing unlock in failure path. 2008-07-03 09:56:15 +00:00
rumble 4c59ea5a60 Fix lkm fallout from previous sysctl changes. This largely duplicates
sysctl creation code, but lkms are going away soon(ish) anyway.

Spotted by Chris Gilbert.
2008-06-28 15:50:20 +00:00
rumble 28f5ebd853 Create sysctl entries during module initialisation and destroy them
appropriately.

Many of these file systems are now ready for modularisation.
2008-06-28 01:34:05 +00:00
gmcgarry 838d34e828 fcntl(4) says the command is type int. lfs_fcntl() comment says u_long. The implementation says int. Synchronise comment with documentation and cast to int before comparison. 2008-06-24 10:47:32 +00:00
reinoud f6a70673ba Mark a buffer `busy` in getnewbuf() when it came from the pool_cache since
its not on a free list.

Also change buf_init() to not automatically mark buffers `busy' since this
only makes sense for bufcache buffers.

Mark all buf_init'd buffers 'busy' on the places where they ought to be
flagged as such to not confuse the buffer cache.

Fixes PR 38923.
2008-06-17 14:53:10 +00:00
skd 66fcc9f90f Add some locking, runs with DIAGNOSTIC. 2008-06-16 02:36:27 +00:00
skd 18ccf49656 Fix two cases where we would panic locking against ourselves. 2008-06-15 21:18:06 +00:00
hannken a618b33b8c ufs_blkatoff: Update comment. 2008-06-05 09:32:29 +00:00
ad e89db9644e When setting DONE on the buffer, assert that there are no waiters in
biowait().
2008-06-04 17:46:21 +00:00
ad 06c343ac94 vm_page: put TAILQ_ENTRY into a union with LIST_ENTRY, so we can use both. 2008-06-04 12:41:40 +00:00
ad 6b01ae766f - Tidy up the locking a bit.
- Use atomics/kmem_alloc/pool_cache.
2008-06-04 11:33:19 +00:00
hannken 15e90e4bbc ufs/ffs: replace calls to getblk() with ffs_getblk(). Now all buffers
have been run through copy-on-write and async mounts work again.

Fixes PR kern/38820

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
2008-06-03 09:47:49 +00:00
ad 3a8db3158e Use atomics to maintain v_usecount. 2008-06-02 16:25:34 +00:00
ad 0d151db6c9 Don't needlessly acquire v_interlock. 2008-06-02 16:00:33 +00:00
christos ee16aae1e5 Revert to using specfs_fsync(); using a do-nothing mfs_fsync() does not work
because the filesystem cannot be unmounted since ffs_fsync() will loop forever
trying to empty the v_dirtyblkhd list.
2008-06-02 00:24:28 +00:00
ad c35a9dfad1 Put a TNF copyright on it. 2008-05-31 21:39:13 +00:00
ad 3592ae4882 XXX softdep:
If the number of deletes in progress is getting too high, newdirrem()
requests the syncer to flush faster, and in some cases will block to
prevent deletes accumulating faster than the disk can service them.

The syncer will try to lock vnodes that the remover holds locked, leading
to the syncer and remover proceeding in lockstep and making very little
overall forward progress.

Put a hook into ufs_rmdir() and ufs_remove() so that the softdep code
can pace itself without holding vnode locks if the number of deletes is
running out of control.
2008-05-31 21:37:08 +00:00
hannken 336f2a69f4 ffs_copyonwrite(): stop abusing ffs_balloc() to get a block address.
Use ufs_getlbns()/bread() instead.
Saves some reads and removes deep recursion with possible deadlock
when ffs_balloc() runs copy-on-write on the buffer returned.
2008-05-29 10:00:50 +00:00
nakayama b70810493a s/log file system/log-structured file system/ 2008-05-24 18:14:24 +00:00
ad 9e6de4df51 Don't moan about LFS unless the mount succeeds. 2008-05-20 16:26:04 +00:00
ad a0fd5bc68d Until these get fixed or replaced:
WARNING: the foo file system is experimental and may be unstable
2008-05-18 13:56:12 +00:00
hannken 5d2bff060a Make sure all cached buffers with valid, not yet written data have been
run through copy-on-write.  Call fscow_run() with valid data where possible.

The LP_UFSCOW hack is no longer needed to protect ffs_copyonwrite() against
endless recursion.

- Add a flag B_MODIFY to bread(), breada() and breadn().  If set the caller
  intends to modify the buffer returned.

- Always run copy-on-write on buffers returned from ffs_balloc().

- Add new function ffs_getblk() that gets a buffer, assigns a new blkno,
  may clear the buffer and runs copy-on-write.  Process possible errors
  from getblk() or fscow_run().  Part of PR kern/38664.

Welcome to 4.99.63

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
2008-05-16 09:21:59 +00:00
rumble a1221b6d4a Convert file systems to dynamically attach with the new module interface.
Make VFS hooks dynamic while we're here and say farewell to VFS_ATTACH and
VFS_HOOKS_ATTACH linksets.

As a consequence, most of the file systems can now be loaded as new style
modules.

Quick sanity check by ad@.
2008-05-10 02:26:09 +00:00
ad 05b982d1c7 mfs doesn't need fsync. 2008-05-07 21:30:42 +00:00
ad 42d0626726 PR kern/38141 lookup/vfs_busy acquire rwlock recursively
Simplify the mount locking. Remove all the crud to deal with recursion on
the mount lock, and crud to deal with unmount as another weirdo lock.

Hopefully this will once and for all fix the deadlocks with this. With this
commit there are two locks on each mount:

- krwlock_t mnt_unmounting. This is used to prevent unmount across critical
  sections like getnewvnode(). It's only ever read locked with rw_tryenter(),
  and is only ever write locked in dounmount(). A write hold can't be taken
  on this lock if the current LWP could hold a vnode lock.

- kmutex_t mnt_updating. This is taken by threads updating the mount, for
  example when going r/o -> r/w, and is only present to serialize updates.
  In order to take this lock, a read hold must first be taken on
  mnt_unmounting, and the two need to be held across the operation.

One effect of this change: previously if an unmount failed, we would make a
half hearted attempt to back out of it gracefully, but that was unlikely to
work in a lot of cases. Now while an unmount that will be aborted is in
progress, new file operations within the mount will fail instead of being
delayed. That is unlikely to be a problem though, because if the admin
requests unmount of a file system then s(he) has made a decision to deny
access to the resource.
2008-05-06 18:43:44 +00:00
ad e071d39c84 - Convert hashinit() to use kmem_alloc(). The hash tables can be large
and it's better to not have them in kmem_map.
- Convert a couple of minor items along the way to kmem_alloc().
- Fix some memory leaks.
2008-05-05 17:11:16 +00:00
ad 928a6b2096 PR kern/38135 vfs_busy/vfs_trybusy confusion
The previous fix worked, but it opened a window where mounts could have
disappeared from mountlist while the caller was traversing it using
vfs_trybusy(). Fix that.
2008-04-30 12:49:16 +00:00
ad e3610f1886 kern/38135 vfs_busy/vfs_trybusy confusion
The symptom was that sometimes file systems would occasionally not appear
in output from 'df' or 'mount' if the system was busy. Resolution:

- Make mount locks work somewhat like vm_map locks.
- vfs_trybusy() now only fails if the mount is gone, or if someone is
  unmounting the file system. Simple contention on mnt_lock doesn't
  cause it to fail.
- vfs_busy() will wait even if the file system is being unmounted.
2008-04-29 23:51:04 +00:00
ad baa3395f8f PR kern/38057 ffs makes assuptions about devvp file system
PR kern/33406 softdeps get stuck in endless loop

Introduce VFS_FSYNC() and call it when syncing a block device, if it
has a mounted file system.
2008-04-29 18:18:08 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 284c2b9aef Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
2008-04-24 18:39:20 +00:00
ad 6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
ad d9bace2a92 Acquire kernel_lock directly in LFS syscalls. 2008-04-21 11:45:34 +00:00
hannken 2fd9e21242 Replace get/setspecific with a void pointer in struct ufsmount. Use explicit
initialization/finalization of snapshot private data on creation/deletion
of struct ufsmount.
Snapshot mounts no longer may fail silently because kmem_alloc() fails.

Welcome to 4.99.60

Ok: Andrew Doran <ad@netbsd.org>
2008-04-17 09:52:47 +00:00
ad 0701eb1ec7 newdirrem: if the number of deletes in progress is getting too high, start
pushing the syncer before considering rate limiting the deletes. We hold
vnodes locked and it's likely that the syncer will try to lock them while
flushing, leading to the syncer and remover proceeding in lockstep and
making very little forward progress. XXX this is not a solution.
2008-04-11 16:25:38 +00:00
ad be04ac4896 Make rusage collection per-LWP and collate in the appropriate places.
cloned threads need a little bit more work but the locking needs to
be fixed first.
2008-03-27 19:06:51 +00:00
ad 021b86dd4b Changes for PR kern/38291 (panic unmounting MFS /tmp):
- Reference count the mfsnode to fix an aincent bug. Only destroy when
  reference count drops to zero. In mfs_start(), busy the mount and get
  a reference to the mfsnode to prevent it disappearing while the server
  is running. If the file system is gone already, vfs_busy() will fail.
- Always destroy the bufq.
- Use a global mfs_lock for simplicity.
- Replace use of malloc/free. Fixes broken MALLOC_TYPE change.
2008-03-26 14:19:43 +00:00
ad a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
ad 110d5cc274 Make MFS MP-safe. Needed because of the funny tricks it plays. 2008-02-21 14:10:57 +00:00
matt e2ca3f7504 Merge all the *different* definitions of bufqueues into one common one. 2008-02-20 17:13:29 +00:00
ad fb00b83874 Give bbusy() an interlock argument. If the we need to wait for the buffer,
the interlock is dropped and reacquired when awoken. This allows for
busying buffers attached to a list that is not locked by bufcache_lock.
2008-02-15 13:46:04 +00:00
ad b2fa822a33 The buffer LOCKED flag need not be under the protection of bufcache_lock,
BUSY is enough.
2008-02-15 13:30:56 +00:00
ad 648f07789f Do genfs_node_init() earlier. PR kern/36162. 2008-02-05 15:18:36 +00:00
hannken a524d758da Make it work after lockmgr -> vlockmgr conversion:
- Initialize si_vnlock in si_mount_init().
  - Also initialize vl_recursecnt to zero.
- Destroy it only in si_mount_dtor().
- Simplify the v_lock <-> si_vnlock exchange.
- Don't abuse the overall error variable for LK_NOWAIT errors.
- ffs_snapremove: release the vnode one instead of three times.
2008-01-30 17:20:04 +00:00
ad 08da6a8594 Replace use of lockmgr. 2008-01-30 14:54:01 +00:00
ad 7356aff6af Replace use of LK_SLEEPFAIL. 2008-01-30 14:50:28 +00:00
ad 25153c3ec9 PR kern/37706 (forced unmount of file systems is unsafe):
- Do reference counting for 'struct mount'. Each vnode associated with a
  mount takes a reference, and in turn the mount takes a reference to the
  vfsops.
- Now that mounts are reference counted, replace the overcomplicated mount
  locking inherited from 4.4BSD with a recursable rwlock.
2008-01-30 11:46:59 +00:00
ad 3490efcc63 Replace struct lock on vnodes with a simpler lock object built on
krwlock_t. This is a step towards removing lockmgr and simplifying
vnode locking. Discussed on tech-kern.
2008-01-30 09:50:19 +00:00
hannken 89cea1c2c4 - Always destroy si_vnlock after use.
- Take care of vnodes without file system data.
2008-01-28 17:49:06 +00:00
dholland 717e1785a5 Fix some race conditions in rename.
Introduce a per-FS rename lock and new vfsops to manipulate it.
Get this lock while renaming. Also add another relookup() in do_sys_rename,
which is a hack to kludge around some of the worst deficiencies of
ufs_rename.
reviewed-by: pooka (and an earlier rev by ad)
posted on tech-kern with no objections.
2008-01-28 14:31:15 +00:00
pooka eb6074e41f Replace vrelel() 010101-mania with a flags parameter. However,
leave flags unimplemented for a while (no change in functionality).
2008-01-27 22:47:31 +00:00
ad 1997a1e1f4 Remove VOP_LEASE. Discussed on tech-kern. 2008-01-25 14:32:11 +00:00
ad 2c1cdef339 Ignore clean vnodes in a couple more places. 2008-01-25 14:16:41 +00:00
ad 51d8643120 - Fix a couple of locking botches.
- Remove calls to VOP_LEASE().
2008-01-25 13:31:22 +00:00
pooka 1bff00ecec Destroy extattr lock when destroying extattrs associated with the
mountpoint.  Make stopping extattrs always succesful to facilitate
always being able to free resources.
2008-01-25 10:49:32 +00:00
pooka 04177824be spec_node_init() mfs device vnode.
fixes PR kern/37867 by Steve Woodford
2008-01-25 10:30:20 +00:00
ad 927229e57b quotaoff: ignore clean vnodes. Fixes PR kern/37818. 2008-01-24 22:55:21 +00:00
ad 703069c0e9 specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
  vnode can describe a block device. Instead, prohibit concurrent opens of
  block devices. As a bonus remove the unreliable code that prevents
  multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
  goes away, instead of abusing vnode::v_usecount to tell if the device is
  open.
2008-01-24 17:32:52 +00:00
hannken 0409981d90 si_mount_dtor(): destroy si_vnlock before free. 2008-01-24 17:29:56 +00:00
hannken ca2bbf9908 Fix a typo from the vmlocking2 merge: vmark() the right vnode. 2008-01-24 16:26:44 +00:00
pooka c40d447080 Sprinkle comments about um_lock status on function entry and exit.
No functional change.
2008-01-21 23:36:26 +00:00
ad 42c90ece4c Fix dodgy tests of v_usecount. 2008-01-17 10:39:14 +00:00
ad abb6491738 mfs_close: remove a broken assertion. 2008-01-17 10:24:05 +00:00
christos 20f21ddc4a fix locking botch; vunmark() needs the mountvnode lock, and the loop invariant
is to exit with the mountvnode lock held.
2008-01-15 21:30:46 +00:00
ad 08c770b434 Initialize caches at IPL_SOFTBIO (not IPL_NONE) so that we are allocating
from kmem_map.
2008-01-12 00:34:10 +00:00
ad dd68496f43 Fix hangs on 'biolock' when creating a directory under / with softdep. 2008-01-09 18:20:54 +00:00
ad 0b52913dee Go back to freeing on disk inodes in the inactive routine. It would be
better not to do this, but it rules out potential side effects with softdep.
2008-01-09 16:15:22 +00:00
ad 52603a7d6d Fix 'panic: softdep_update_inodeblock: update failed'. 2008-01-07 16:56:27 +00:00
tnn 51f964a289 softdep_freefile: don't acquire ufsmount lock twice. 2008-01-07 05:20:25 +00:00
ad e01dd1a1f8 Use pool_cache. 2008-01-03 19:28:48 +00:00
pooka 8e7631e799 make the UFS_EXTATTR case build 2008-01-03 02:23:27 +00:00
pooka d53e261066 valloc -> vnalloc, vfree -> vnfree
Avoids collision with userland valloc(3).

no functional change
ad ok
2008-01-03 01:26:28 +00:00
ad 4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
perry b6a2ef7569 Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
2007-12-25 18:33:32 +00:00
dsl 7e2790cf6f Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
    int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
2007-12-20 23:02:38 +00:00
dyoung c9b4d7e0b1 Call genfs_node_init a little earlier to avoid a vput()ing an
uninitialized node, later, which leads to a kernel panic.  Patch
by Antti Kantee.
2007-12-20 16:18:57 +00:00
he cd15efd05d Fix a use of lfs_truncate() inside an #ifdef notyet (so no resulting change);
lfs_truncate() has lost its lwp argument.
2007-12-12 18:36:10 +00:00
he 8b0afebe4f Make this build again, as part of sys/lkm/dev/vnd/:
- lfs_truncate() has lost its lwp argument.
- Cast from void* to char* before doing pointer arithmetic.
2007-12-12 18:35:21 +00:00
lukem 2b0e4fae39 Move __KERNEL_RCSID() so that it's always available if this file is
compiled, even if DEBUG isn't defined.
(This matches the behaviour of various other source files that
provide functions only if DEBUG is enabled.)
2007-12-12 03:49:03 +00:00
ad e38a5a204c Fix a stray brelse() that got missed. 2007-12-12 03:10:47 +00:00
lukem 85a77245b2 defflag LFS_KERNEL_RFW (in opt_lfs.h).
Note: lfs_rfw.c doesn't compile if you define the option; locking API fallout?
2007-12-12 02:56:03 +00:00
lukem 961afe5035 use __KERNEL_RCSID() instead of __RCSID() 2007-12-11 12:16:34 +00:00
pooka db06a930e6 Remove cn_lwp from struct componentname. curlwp should be used
from on.  The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
2007-12-08 19:29:36 +00:00
ad 5870896633 Grab ump->um_lock in another spot. 2007-12-08 15:23:32 +00:00
ad c27abd2a99 Add some comments. 2007-12-08 15:21:19 +00:00
hannken d556dc98b0 Fscow_run(): add a flag "bool data_valid" to note still valid data.
Buffers run through copy-on-write are marked B_COWDONE.  This condition
is valid until the buffer has run through bwrite() and gets cleared from
biodone().

Welcome to 4.99.39.

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
2007-12-02 13:56:15 +00:00
tsutsui 581d311161 Use e2fs_first_dblock in superblock to read/write group descriptor blocks. 2007-12-01 16:57:26 +00:00
pooka 61e8303e9d Remove the "struct lwp *" argument from all VFS and VOP interfaces.
The general trend is to remove it from all kernel interfaces and
this is a start.  In case the calling lwp is desired, curlwp should
be used.

quick consensus on tech-kern
2007-11-26 19:01:26 +00:00
tsutsui e2199739d6 Misc cosmetics. 2007-11-26 15:46:48 +00:00
tsutsui da1f43d88f Account e2fs_reserved_ngdb blocks accordingly in ext2fs_statvfs(). 2007-11-26 15:41:03 +00:00
dholland 9c31b45f5e Change the fs_clean member of the ffs superblock to be unsigned
(uint8_t instead of int8_t) - this prevents an ugly sign-extension
printing bug as well as formally undefined behavior when you mount an
unclean fs enough times.

From (my own) PR kern/28134; I've been carrying this patch for three
years, long enough to forget about it, and it's had no ill effects in
that time.

reviewed: pooka
2007-11-23 18:00:46 +00:00
pooka 2b2c7bcc21 Update comments: ufs_{rename,mkdir,rmdir} haven't been system calls
since 4.3BSD.
2007-11-23 14:18:01 +00:00
yamt a3dbd70683 lfs_mountroot: use vfs_destroy. 2007-11-22 10:51:44 +00:00
tsutsui d1112c275c Misc cosmetics. 2007-11-17 08:51:51 +00:00
tsutsui b95d1c0be7 Some KNF and cosmetics. 2007-11-17 08:34:38 +00:00
tsutsui bf39da4423 Also bswap recently added e2fs_reserved_ngdb in e2fs_sb_bswap(). 2007-11-17 03:43:18 +00:00
tsutsui 0192f3ddfc Add some definitions for resizefs features. 2007-11-15 12:59:17 +00:00
tsutsui bed6c72507 - add some more constant definitions
- add some comments
- typo and some cosmetics
2007-11-13 13:50:18 +00:00
rmind f499d5e662 Use PRI_BIO for kthreads instead of PINOD. Fixes a missed case of priority
inversion, which caused LFS to fire some assertions.

Reported by Kurt Schreiner on <current-users>.
2007-11-10 18:53:57 +00:00
ad d18c6ca4de Merge from vmlocking:
- pool_cache changes.
- Debugger/procfs locking fixes.
- Other minor changes.
2007-11-07 00:23:13 +00:00
hannken 75bdfc0dac Avoid doing bawrite to initialize inode block while holding cylinder
group block buffer busy.  If filesystem has any active snapshots, bawrite
can come back trying to allocate new snapshot data block from the same
cylinder group and cause deadlock.

From FreeBSD Rev. 1.117
2007-11-01 06:31:59 +00:00
hannken df70316e3f Ffs_blkfree() and ffs_freefile() take a devvp that may be a regular file whencalled from snapshot creation. Be sure to use the right mount.
Ok: Andrew Doran <ad@netbsd.org>
2007-10-18 17:39:04 +00:00
ad fd7e1bf0d1 Sync with ffs: fix ufs_ihashlock / ufs_hash_lock deadlock.
From Sverre Froyen.
2007-10-17 17:34:25 +00:00
ad 4c92a21547 Remove LOCK_ASSERT(!simple_lock_held(&foo)); 2007-10-11 19:53:37 +00:00
ad f103d731ed Fix DEBUG builds. 2007-10-10 22:38:00 +00:00
ad 7dad9f7391 Merge from vmlocking:
- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
2007-10-10 20:42:20 +00:00
ad 5c3b2b3f2d Merge ffs locking & brelse changes from the vmlocking branch. 2007-10-08 18:01:27 +00:00
hannken 3856acafe2 Update the file system copy-on-write handler.
- Instead of hooking the handler on the specdev of a mounted file system
  hook directly on the `struct mount'.

- Rename from `vn_cow_*' to `fscow_*' and move to `kern/vfs_trans.c'.  Use
  `mount_*specific' instead of clobbering `struct mount' or `struct specinfo'.

- Replace the hand-made reader/writer lock with a krwlock.

- Keep `vn_cow_*' functions and mark as obsolete.

- Welcome to NetBSD 4.99.32 - `struct specinfo' changed size.

Reviewed by: Jason Thorpe <thorpej@netbsd.org>
2007-10-07 13:38:53 +00:00
pooka 1b732f2a39 avoid variable size stack allocations 2007-09-25 15:13:14 +00:00
pooka a51616225d BLKSIZE is always the same as blksize these days, so get rid of it. 2007-09-24 16:50:58 +00:00
pooka 094e51ae36 Fix comment inaccurate from prehistoric times: default MINFREE is 5, not 10 2007-09-24 16:20:50 +00:00
rumble 0ae0a486c7 Avoid stack allocation of large dirent structures in foo_readdir(). 2007-09-24 00:42:12 +00:00
pooka b2c6279cb7 include sys/mount.h for export_args30 2007-09-10 23:47:23 +00:00
pooka 3f3cac88a3 Make bioops a pointer and point it to the softdeps struct in softdep
init.  Decouples "options SOFTDEP" from the main kernel and ffs code.
2007-09-01 23:40:21 +00:00
hannken 5657bcacb9 Modify ffs_lock() to take care for changed v_vnlock. Snapshots do not need
transferlockers() anymore.

From FreeBSD ffs_vnops.c Rev. 1.159

Reviewed by: YAMAMOTO Takashi <yamt@netbsd.org>
2007-08-21 09:27:33 +00:00
hannken f43278a84f - Use a mutex to protect snapinfo.
- Move the snapshot lock to snapinfo.
- ffs_snapblkfree(),ffs_copyonwrite(): replace lockmgr() with VOP_LOCK().
2007-08-18 10:11:01 +00:00
hannken 7d3c830b7c Expunge traces of unlinked snapshot files when making a new snapshot.
From FreeBSD Rev. 1.123
2007-08-18 09:48:33 +00:00
hannken d56e8d1456 Move the fstrans-aware lock vnops from ufs to ffs. Other ufs file systems
do not need them.

Ride on 4.99.28
2007-08-09 09:22:34 +00:00
pooka 3de9f5d391 Instead of having lfs muck directly about with vnode free lists,
introduce vrele2(), which allows to release vnodes the way lfs
sometimes wants it:
  + without calling inactive
  + inserting the vnode at the head of the freelist (this is a very
    questionable optimization that isn't even enabled by default,
    but I went along with the same semantics for now)
2007-08-09 08:51:21 +00:00
hannken 70cc392f1e Move snapshot per-mount data from struct ufsmount to mount specific data.
No functional changes.

Welcome to 4.99.28  (struct ufsmount changed size)
2007-08-09 07:34:27 +00:00
pooka 95bedce095 include assumed headers 2007-08-02 12:53:30 +00:00
pooka 8d1f899239 * nuke the nameidata parameter from VFS_MOUNT(). Nobody on tech-kern
knew what it was supposed to be used for and wrstuden gave a go-ahead
* while rototilling, convert file systems which went easily to
  use VFS_PROTOS() instead of manually prototyping the methods
2007-07-31 21:14:15 +00:00
hannken a508ec1750 - Replace the freelist with a pool. Current code never freed its dquot's.
- Always call dqsync() with dq locked.
- Add some assertions to verify the lock held.
- Serialize quotaon()/quotaoff(), dqhashmtx becomes dqlock.  From ad@

Reviewed by: Andrew Doran <ad@netbsd.org>
2007-07-31 09:29:52 +00:00
ad a0d1fd8d0c It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 13:31:07 +00:00
yamt 662e7a9e40 use ubc_uiomove for read as well. 2007-07-27 10:00:42 +00:00
yamt 3822af7031 ubc_uiomove: add an "advice" argument rather than using UVM_ADV_RANDOM blindly. 2007-07-27 09:50:36 +00:00
pooka 1ce406a846 Change unused fflags parameter in VOP_MMAP to prot and pass in
desired vm protection.
2007-07-27 08:26:38 +00:00
pooka d9970c8066 Use eopnotsupp() instead of vfs_stdsuspendctl() and retire the latter. 2007-07-26 22:57:36 +00:00
pooka 2189caca89 comment police: DIRBLKSIZE would be too chatty and therefore the
macro is known as DIRBLKSIZ
2007-07-23 14:58:04 +00:00
ad f92f123709 Workaround the ufs_haslock/ufs_ihash_lock deadlock. From a patch
posted by Blair Sadewitz.
2007-07-23 09:05:02 +00:00
rumble 17b8c7717a Add missing RCSID. 2007-07-22 21:12:27 +00:00
christos 407114c830 make this compile again 2007-07-22 03:40:59 +00:00
ad 744a92f0f8 Don't depend on uvm_extern.h pulling in proc.h. 2007-07-21 19:06:20 +00:00
pooka 9137aeda4b In sync, skip over vnodes based on if they are clean rather than
if they have pages.
2007-07-20 16:46:43 +00:00
hannken 8169dcee9d Update and add locking to ufs_quota:
- Replace DQ_LOCK/DQ_WANT/sleep/wakeup with a mutex `dq_interlock'.  Use this
  mutex to protect all quota values and flags.
- Protect the hashtable with a mutex.
- Never update quotas for the quota files on the same file system.  Prevents
  a deadlock when dqsync() has to change the  quota file's size (PR #13942).

Reviewed by:	Andrew Doran <ad@netbsd.org>
		Bill Stouder-Studenmund <wrstuden@netbsd.org>
2007-07-19 09:33:04 +00:00
christos c9d7b911ee Eliminate MFSNAMELEN 2007-07-17 21:26:41 +00:00
christos 785c01892b eliminate MFSNAMELEN 2007-07-17 21:20:43 +00:00
pooka e24b0872a4 Make set_statvfs_info() take a parameter for the vfs name instead
of always retrieving it from mp->mnt_op->vfs_name

christos ok
2007-07-17 11:19:31 +00:00
pooka 395899ddd0 When allocating blocks, check minfree before asking kauth about
suser.  The latter has unknown cost and rarely needs to be called.
2007-07-16 14:26:08 +00:00
pooka c77565e2a3 include quota.h to score definitions used by this header 2007-07-16 13:55:51 +00:00
rmind 20bbb87e34 Implementation of per-CPU work-queues support for workqueue(9) interface.
WQ_PERCPU flag for workqueue and additional argument for workqueue_enqueue()
to assign a CPU might be used. Notes:
 - For now, the list is used for workqueue_queue, which is non-optimal,
   and will be changed with array, where index would be CPU ID.
 - The data structures should be changed to be cache-friendly.

Reviewed by: <yamt>, <tech-kern>
2007-07-12 20:39:56 +00:00
dsl 2721ab6c7b Change the VFS_MOUNT() interface so that the 'data' buffer passed to the
fs code is a kernel buffer, pass though the length of the buffer as well.
Since the length of the userspace buffer isn'it (yet) passed through the mount
system call, add a field to the vfsops structure containing the default length.
Split sys_mount() for calls from compat code.
Ride one of the recent kernel version changes - old fs LKMs will load, but
sys_mount() will reject any attempt to use them.
2007-07-12 19:35:32 +00:00
hannken a8c44dfbf5 ffs_snapshot_mount: No persistent snapshots on an Apple UFS file system.
From Thor Lancelot Simon <tls@netbsd.org>
2007-07-12 09:30:04 +00:00
perseant 9a05fc1f4a Move the "vp = NULL" assignment after the code that requires vp != NULL.
Reported by Chris Ross on current-users.
2007-07-10 23:06:24 +00:00
hannken af689d2468 Restore the special lkt_held handling for softdep_disk_write_complete().
No more panics 'worklist_remove: lock not held' on DEBUG kernels.

Ok Andrew Doran <ad@netbsd.org>
2007-07-10 10:47:07 +00:00
hannken 149abfc10f Move `struct dquot' and its supporting functions from quota.h to ufs_quota.c.
- Make quota-internal functions static.
- Clean up declarations in quota.h and ufs_extern.h.  quota.h now has the
  description of quota criterions, on-disk structure, user-kernel interface and
  declaration of init/done functions.  All ufs quota related function
  prototypes go to ufs_extern.h.
- New functions ufsquota_init() and ufsquota_free() create or destroy the
  quota fields of `struct inode'.
- chkdq() and chkiq() always update the quota fields of `struct inode' first.
- Only ufs_access() explicitely calls getinoquota().

No objections on tech-kern@
2007-07-10 09:50:07 +00:00
ad e8f24929ec Fix build with DEBUG. 2007-07-09 22:52:14 +00:00
ad 7e7fac7f09 Fix merge botch. 2007-07-09 22:44:07 +00:00
ad c63e04d3bd We got LWPs years ago.. 2007-07-09 22:02:00 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
pooka 835b0326c5 Using POOL_INIT here makes no sense, since file systems always have
an init method.  So get rid of it and #ifdef _LKM and just always
init in the init method.  Give malloc types the same treatment.
Makes file systems nicer to work with in linksetless environments
and fixes a few LKM discrepancies.
2007-06-30 09:37:53 +00:00
pooka e01e324216 remove redundant KASSERTs 2007-06-29 15:34:59 +00:00
hannken bed04c995a If a quota-enabled file system has 65536 active vnodes for one uid
the reference counter of the corresponding struct dquot will overflow.

Change the type of the reference counter from u_int16_t to u_int32_t and
add an assertion to check for overflow.

Observed and tested by Edgar Fuß.

Welcome to 4.99.21 (struct dquot and therefore struct inode changed layout)
2007-06-23 14:56:09 +00:00
yamt 7225d589de remove a duplicated definition of FFS_ITIMES. 2007-06-07 05:34:48 +00:00
yamt da51d139a4 improve post-ubc file overwrite performance in common cases.
ie. when it's safe, actually overwrite blocks rather than doing
read-modify-write.

also fixes PR/33152 and PR/36303.
2007-06-05 12:31:30 +00:00
tsutsui cd07663368 Fix inconsistent changes in rev 1.153 and 1.154:
Adjust fs->fs_maxfilesize instead of ump->um_maxfilesize
in ffs_oldfscompat_read() because the latter is overrided
by the former after ffs_oldfscompat_read() returned.

Fixes EFBIG errors on read(2) and "exec /sbin/init: error 8"
problem on mac68k after mountroot() on old 4.3BSD UFS created
by the Mkfs tool for MacOS (reported and confirmed on port-mac68k).
2007-05-29 11:30:17 +00:00
ad 1ae6657a7b Fix lock order inversion between vnode locks and ufs_hashlock. Addresses
kern/36331 (MP deadlock between ufs_ihashget() and VOP_LOOKUP()) for ffs,
other file systems to follow. Reported by perseant@, debugged by Sverre
Froyen, patch posted/tested by Blair Sadewitz.
2007-05-28 23:42:56 +00:00
hannken 64b7e5637e Fstrans_start() always returns zero, so change its type to void. 2007-05-17 07:26:21 +00:00
perseant 9234ba6fd8 Change references to SEGM_W_DIROPS to SEGM_CKP, and replace the logic that
formerly used SEGM_W_DIROPS in lfs_segwrite() appropriately.  This prevents
a problem in which processes could get stuck in "buffers" sleep forever.
2007-05-16 19:11:37 +00:00
tnn 4407197569 Add missing underscore to wchan name. 2007-05-15 14:35:29 +00:00
yamt d4bb61958b flush_inodedep_deps: fix access after free. PR/29724. 2007-05-07 11:13:01 +00:00
perseant 6a87e08daa Get rid of our own private copy of genfs_putpages, having adapted the real
genfs_putpages to suit our purposes.
2007-04-24 22:47:56 +00:00
yamt 337d052ee1 hold proclist_mutex when calling psignal(). 2007-04-19 11:05:14 +00:00
perseant 0549fd6148 Add/change a couple of comments about locking restrictions. 2007-04-18 00:50:06 +00:00
perseant 0d8a7af5d6 Remember to write dirops when the vnode we are trying to flush is a dirop. 2007-04-18 00:49:33 +00:00
perseant 72507061e4 Fix another locking protocol error in lfs_fsync(). 2007-04-17 20:30:28 +00:00
perseant 43d50ff956 Fix MP locking protocol violations introduced in my previous commit. 2007-04-17 06:49:40 +00:00
perseant 9be0ebd9da Install a new sysctl, vfs.lfs.ignore_lazy_sync, which causes LFS to ignore
the "smooth" syncer, as if vfs.sync.*delay = 0, but only for LFS.  The
default is "on", i.e., ignore lazy sync.

Reduce the amount of polling/busy-waiting done by lfs_putpages().  To
accomplish this, copied genfs_putpages() and modified it to indicate which
page it was that caused it to return with EDEADLK.  fsync()/fdatasync()
should no longer ever fail with EAGAIN, and should not consume huge
quantities of cpu.

Also, try to make dirops less likely to be written as the result of a
VOP_PUTPAGES(), while ensuring that they are written regularly.
2007-04-17 01:16:46 +00:00
pooka bc8224a1b3 fix comment: struct fid is in fstypes.h now 2007-04-09 12:21:24 +00:00
hannken fc6776f366 Remove now obsolete vn_start_write() and vn_finished_write() and
corresponding flags.

Revert softdep_trackbufs() to its state before vn_start_write() was added.

Remove from struct mount now unneeded flags IMNT_SUSPEND* and
members mnt_writeopcountupper, mnt_writeopcountlower and mnt_leaf.

Welcome to 4.99.17
2007-04-08 11:20:42 +00:00
hannken 11601689e7 Remove calls to now obsolete vn_start_write() and vn_finished_write(). 2007-04-07 14:21:52 +00:00
perseant b196644e3b correct comment for lfs_putpages 2007-04-05 17:44:18 +00:00
ad 4b1d78c00e Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-13 02:11:28 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
ad b89010bfa3 Destroy the hash locks on final unmount. 2007-02-27 16:11:51 +00:00
perseant d1d9b558a7 Reverse the order of searching the vnode list in lfs_writevnodes(). This
should speed up e.g. "chown -R" on LFS filesystems; e.g. it shows a 100%
increase in the 'seq_stat' column of bonnie++.
2007-02-23 23:16:03 +00:00
thorpej b3667ada6d TRUE -> true, FALSE -> false 2007-02-22 06:05:00 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
pooka 5b38c61dd4 tyop in comment, fix it 2007-02-20 18:03:03 +00:00
pooka 7016942297 In readdir, in case cookies was already allocated but is later free'd
due to an error, reset value of cookies to NULL to avoid confusing
callers.

should fix kern/35728
2007-02-20 16:45:58 +00:00
ad adbb9ec2fa Call genfs_node_destroy() where appropriate. 2007-02-20 16:21:03 +00:00
ad d266042a07 Release ufs_hashlock before calling ungetnewvnode(). 2007-02-18 14:26:52 +00:00
pavel 934634a18c Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
2007-02-17 22:31:36 +00:00
hannken 198beb0314 Make fstrans(9) the default helper for file system suspension.
Replaces the now obsolete vn_start_write()/vn_finished_write().
2007-02-16 17:23:53 +00:00
ad 93a5fa21eb Destroy the fraglock on unmount. 2007-02-15 17:47:56 +00:00
ad 9abeea588a Replace some uses of lockmgr() / simplelocks. 2007-02-15 15:40:50 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
elad 2ddc81b57b Add missing ')'. Noted by Paul Goyette. 2007-02-07 05:54:42 +00:00
bouyer 0ce1424e8f in ufs_dirremove swap ep->d_reclen before use if needed (affect UFS_DIRHASH
only).
While there remove an unneeded swap before compare against 0 in ufs_direnter().
Both pointed out by Pawel Jakub Dawidek on tech-kern@, thanks !
2007-02-06 20:49:20 +00:00
hannken 4d607243ba Change fstrans enum types to upper case.
No functional change.

From Antti Kantee <pooka@netbsd.org>
2007-01-29 15:42:50 +00:00
hubertf eda05c6413 Remove more duplicate headers.
Patch by Slava Semushin <slava.semushin@gmail.com>

Again, this was tested by comparing obj files from a pristine and a patched
source tree against an i386/ALL kernel, and also for src/sbin/fsck_ffs,
src/sbin/fsdb and src/usr.sbin/makefs. Only changes in assert() line numbers
were detected in 'objdump -d' output.
2007-01-29 01:52:43 +00:00
hannken 1b9c6382e3 New file system suspension API to replace vn_start_write and vn_finished_write.
The suspension helpers are now put into file system specific operations.
This means every file system not supporting these helpers cannot be suspended
and therefore snapshots are no longer possible.

Implemented for file systems of type ffs.

The new API is enabled on a kernel option NEWVNGATE.  This option is
not enabled by default in any kernel config.

Presented and discussed on tech-kern with much input from
Bill Studenmund <wrstuden@netbsd.org> and YAMAMOTO Takashi <yamt@netbsd.org>.

Welcome to 4.99.9 (new vfs op vfs_suspendctl).
2007-01-19 14:49:08 +00:00
isaki be241a0e51 Correct indent. 2007-01-07 09:33:18 +00:00
elad 1e70d64818 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 16:55:29 +00:00
perseant df25fd6968 Change VONWORKLST handling to better match its other uses; in particular,
check memq and clear VWRITEMAPDIRTY at the same time.
2007-01-03 02:42:23 +00:00
elad d4e1860d1a Add KAUTH_SYSTEM_CHSYSFLAGS so we can get rid of the last three
securelevel references (ufs, ext2fs, tmpfs).

Intentionally undocumented.
2007-01-02 11:18:56 +00:00
yamt 90b1120ae3 ufs_readdir: start from offsets known to be valid,
rather than assuming users feed us valid offsets.
2006-12-26 14:50:08 +00:00
yamt 8bf7662829 merge yamt-splraiseipl branch.
- finish implementing splraiseipl (and makeiplcookie).
	  http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
	- complete workqueue(9) and fix its ipl problem, which is reported
	  to cause audio skipping.
	- fix netbt (at least compilation problems) for some ports.
	- fix PR/33218.
2006-12-21 15:55:21 +00:00
chs 975004d9f1 several ext2fs fixes provided by Barry Bouwsma:
- set ip->i_e2fs_dtime to time_second, not time_uptime.
 - don't allow ipref to go negative
 - fs->e2fs.e2fs_icount is a valid inode number, allow it.
2006-12-09 22:07:48 +00:00
chs c398ae9734 a smorgasbord of improvements to vnode locking and path lookup:
- LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP().
   these now always return the parent vnode locked.  namei() works as before.
   lookup() and various other paths no longer acquire vnode locks in the
   wrong order via vrele().  fixes PR 32535.
   as a nice side effect, path lookup is also up to 25% faster.
 - the above allows us to get rid of PDIRUNLOCK.
 - also get rid of WANTPARENT (just use LOCKPARENT and unlock it).
 - remove an assumption in layer_node_find() that all file systems implement
   a recursive VOP_LOCK() (unionfs doesn't).
 - require that all file systems supply vfs_vptofh and vfs_fhtovp routines.
   fill in eopnotsupp() for file systems that don't support being exported
   and remove the checks for NULL.  (layerfs calls these without checking.)
 - in union_lookup1(), don't change refcounts in the ISDOTDOT case, just
   adjust which vnode is locked.  fixes PR 33374.
 - apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename().
2006-12-09 16:11:50 +00:00
hannken 818b049a35 On snapshot creation be sure the snapshot vnode has valid quota information.
Fixes PR kern/35121
2006-12-02 17:21:11 +00:00
joerg f39fcf5763 LFS will never set SF_SNAPSHOT and doesn't support ffs_snapgone anyway.
So conditionally the calls to that function on the inclusion of FFS and
allow a LFS-only kernel to link.
2006-11-16 22:29:03 +00:00
christos 5d48d92007 ifdef out an unused function if !FFS_NO_SNAPSHOT 2006-11-16 21:21:34 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
jmmv b1fe4841a1 Let ext2fs be built even when none of ffs, lfs and mfs are present. 2006-11-13 16:12:54 +00:00
reinoud dc5b5420b9 Revisit mnt_vnodelist TAILQ patch. Remove all suspicious TAILQ_FOREACH()
loops where vnodes can get removed or added during the loops. This could
lead to panic's on unmount since nodes are skipped or otherwise
TAILQ_NEXT(0xdeadbeef, ...) was dereferenced.
2006-10-25 22:01:54 +00:00
drochner bffbce1754 import a fix from FreeBSD (rev.1.185):
After a rmdir()ed directory has been truncated, force an update of
the directory's inode after queuing the dirrem that will decrement
the parent directory's link count.  This will force the update of
the parent directory's actual link to actually be scheduled.  Without
this change the parent directory's actual link count would not be
updated until ufs_inactive() cleared the inode of the newly removed
directory, which might be deferred indefinitely.  ufs_inactive()
will not be called as long as any process holds a reference to the
removed directory, and ufs_inactive() will not clear the inode if
the link count is non-zero, which could be the result of an earlier
system crash.
[plus description about problems woth background fsck solved
by this; irrelevant to NetBSD]

For me, the good effect is at least that I'm getting less filesystem
inconsistencies after a crash.

Approved by christos quite a while ago.
2006-10-24 19:36:26 +00:00
reinoud 0ce809091d Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

An extra benefit is the removal of the ugly hack from the Berkly days on
LFS.

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.
2006-10-20 18:58:12 +00:00
yamt 65a8f1c211 ffs_truncate: don't forget to zero the past eof in the case of
blocksize < pagesize.  PR/33777 from Simon Burge.
XXX check other filesystems, esp. lfs.
2006-10-17 11:39:18 +00:00
yamt 72fc92b729 ffs_alloc: remove an assertion which is no longer true. 2006-10-15 12:23:56 +00:00
yamt 560c0c565c don't use g_glock directly. 2006-10-14 09:17:26 +00:00
yamt b7cedb8e34 handle_workitem_freefrag/handle_workitem_freeblocks:
don't fake up inode/vnode pair.
2006-10-14 07:26:29 +00:00
hannken 3e0dbf3bc5 Add __unused to unused function arguments. 2006-10-13 10:21:21 +00:00
thorpej 25433eb1b5 ufs_quotactl(): consume the arguments even if QUOTAS is not defined. 2006-10-12 04:24:40 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
chs 33c1fd1917 add support for O_DIRECT (I/O directly to application memory,
bypassing any kernel caching for file data).
2006-10-05 14:48:32 +00:00
christos b64edcaded fix empty if 2006-10-04 15:53:24 +00:00
christos 45234b0cee Coverity CID 3690: Add KASSERT to check for reverse INULL. 2006-10-03 19:04:25 +00:00
christos df9ed85b34 redo previous: It is better to add a KASSERT, since this is code is same
with ufs.
2006-10-03 19:01:29 +00:00
christos b6bf786e1c Coverity CID 3690: Reverse INULL: Add KASSERT. 2006-10-03 18:59:22 +00:00
christos e11b3365c9 Coverity CID 3689: dp cannot be NULL at this point, so don't check for it. 2006-10-03 18:54:08 +00:00
christos 2b372f902d Coverity CID 3156: async = TRUE when LFS_READWRITE is defined, leading to
dead code. Ifdef the dead code appropriately (from Arnaud Lacombe)
2006-10-03 18:24:48 +00:00
christos f1a4e9cae0 Coverity CID 2949: comment out dead code (from Arnaud Lacombe) 2006-09-29 19:37:11 +00:00
perseant 2ac2813b6e Use lockstatus instead of a homebrewed locking system to control
LFCNWRAPSTOP and LFCNWRAPGO.

Be less verbose about the various looping checks: use log() rather than
printf(), and only log anything if we are really looping ("count = 2" is
not an error condition).

Allow dirops sleeping on available space to be interruptible.
2006-09-28 23:08:23 +00:00
jld 1b78265f0e Change ffs_mount, in MNT_UPDATE case, to check dev_t's for equality
instead of just vnode pointers.  Fixes erroneous "does not match mounted
device" errors from mount(8) in the presence of MFS /dev, init.root, &c.

No objections on tech-kern.
2006-09-21 00:11:30 +00:00
perseant 8c43e08b21 Don't remark a locked inode with IN_MODIFIED after writing it to disk,
if we ourselves hold the lock.  This prevents e.g. mknod from hanging
indefinitely.

Also, always use the return value from VOP_ISLOCKED to determine whether
we hold the lock or someone else does, rather than looking into the lock
structure ourselves.
2006-09-15 18:50:49 +00:00
yamt 9d3e3eab23 merge yamt-pdpolicy branch.
- separate page replacement policy from the rest of kernel
	- implement an alternative replacement policy
2006-09-15 15:51:12 +00:00
christos 7465b73617 add missing initializers 2006-09-02 07:04:01 +00:00
christos d74781a938 - add missing initializers
- comment out impossible code
2006-09-02 06:48:00 +00:00
christos 0dc26f6dcb remove impossible test 2006-09-02 06:46:04 +00:00
perseant 437e855235 Changes to help the roll-forward agent, to wit:
* Mark being-deleted files in the Ifile so we can finish deleting them
  at fs mount time.
* Flag the Ifile with "cleaner must clean" when writers are waiting for
  the cleaner, rather than relying solely on the cleaner's estimation of
  whether it should clean or not.
* Note partial segments written by a user agent (in particular,
  fsck_lfs) so that repeated rolls forward don't interfere with one
  another.
* Add a new fcntl, LFCNPASS, that allows the log to wrap exactly once,
  for better testing of the validity of checkpoints.
* Keep track of the on-disk nlink count when cleaning, so that we don't
  partially complete directory operations while cleaning.
* Ensure that every single Ifile inode write represents a consistent
  view of the filesystem.  In particular, the accounting for the segment
  we are writing the inode into must be correct, and the accounting for
  the segment that inode used to reside in must be correct.  Rather than
  just rewriting the inode if we wrote it wrong, rewrite the necessary
  ifile blocks before writing the inode so we never write it wrong.
* Don't unmark any VDIROP vnodes if we haven't written them to disk,
  avoiding yet another problem with the "wait for the cleaner" error
  return from lfs_putpages().

Also, move the last callback to an aiodone call, so we no longer do any
memory management from interrupt context.
2006-09-01 19:41:28 +00:00
christos 676e77765a fix missing initializers 2006-08-30 01:28:53 +00:00
christos 57b45699b2 fix incomplete initializer. 2006-08-30 01:26:47 +00:00
martin 12cf319c62 Fix size confusion with lfs_fhandle - and as it now turns out to be the same
as the lfs compat_30_fhandle, g/c the latter.
Add an alias for the LFCNIFILEFH fcntl, so that binaries compiled in the
meantime (with too large lfs_fhandle) continue to work.

This makes vfs_cleanerd work again after the kernel checks filehandle size
more strictly (problem reported by Kurt Schreiner on current-users).
2006-08-06 12:34:12 +00:00
martin b4cb63a646 Make filehandles opaque to userland 2006-07-31 16:34:42 +00:00
ad f474dceb13 Use the LWP cached credentials where sane. 2006-07-23 22:06:03 +00:00
perseant 1e9b73d972 Oops, commit the correct version of lfs_rfw.c. The roll-forward functionality
is known not to work in this version (as it did not previously) but it should
at least compile.
2006-07-20 23:56:27 +00:00
perseant 83771be892 Separate the (non-working) LFS kernel roll-forward code into its own file,
lfs_rfw.c.
2006-07-20 23:49:07 +00:00