summaryrefslogtreecommitdiff
path: root/sys/kern/vfs_subr.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove ENABLE_VFS_IOOPT. It is a long unfinished work-in-progress.Alan Cox2003-03-061-6/+0
| | | | | | | Discussed on: arch@ Notes: svn path=/head/; revision=111937
* Finish cleanup of vprint() which was begun with changing v_tag to a string.Nate Lawson2003-03-031-25/+3
| | | | | | | | | Remove extraneous uses of vop_null, instead defering to the default op. Rename vnode type "vfs" to the more descriptive "syncer". Fix formatting for various filesystems that use vop_print. Notes: svn path=/head/; revision=111841
* - Hold the vnode interlock across calls to bgetvp instead of acquiring itJeff Roberson2003-03-021-2/+1
| | | | | | | | internally. This is required to stop multiple bufs from being associated with a single lblkno. Notes: svn path=/head/; revision=111723
* - gc USE_BUFHASH. The smp locking of the buf cache renders this useless.Jeff Roberson2003-03-011-4/+0
| | | | Notes: svn path=/head/; revision=111694
* Prevent large files from monopolizing the system buffers. KeepKirk McKusick2003-02-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | track of the number of dirty buffers held by a vnode. When a bdwrite is done on a buffer, check the existing number of dirty buffers associated with its vnode. If the number rises above vfs.dirtybufthresh (currently 90% of vfs.hidirtybuffers), one of the other (hopefully older) dirty buffers associated with the vnode is written (using bawrite). In the event that this approach fails to curb the growth in it the vnode's number of dirty buffers (due to soft updates rollback dependencies), the more drastic approach of doing a VOP_FSYNC on the vnode is used. This code primarily affects very large and actively written files such as snapshots. This change should eliminate hanging when taking snapshots or doing background fsck on very large filesystems. Hopefully, one day it will be possible to cache filesystem metadata in the VM cache as is done with file data. As it stands, only the buffer cache can be used which limits total metadata storage to about 20Mb no matter how much memory is available on the system. This rather small memory gets badly thrashed causing a lot of extra I/O. For example, taking a snapshot of a 1Tb filesystem minimally requires about 35,000 write operations, but because of the cache thrashing (we only have about 350 buffers at our disposal) ends up doing about 237,540 I/O's thus taking twenty-five minutes instead of four if it could run entirely in the cache. Reported by: Attila Nagy <bra@fsn.hu> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=111466
* - Add an interlock argument to BUF_LOCK and BUF_TIMELOCK.Jeff Roberson2003-02-251-41/+34
| | | | | | | | | | | | | - Remove the buftimelock mutex and acquire the buf's interlock to protect these fields instead. - Hold the vnode interlock while locking bufs on the clean/dirty queues. This reduces some cases from one BUF_LOCK with a LK_NOWAIT and another BUF_LOCK with a LK_TIMEFAIL to a single lock. Reviewed by: arch, mckusick Notes: svn path=/head/; revision=111463
* Bracket the kern.vnode sysctl in #ifdef notyet because it resultsPoul-Henning Kamp2003-02-231-0/+2
| | | | | | | | | | in massive locking issues on diskless systems. It is also not clear that this sysctl is non-dangerous in its requirements for locked down memory on large RAM systems. Notes: svn path=/head/; revision=111333
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-4/+4
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-4/+4
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Add a new vnode flag VI_DOINGINACT to indicate that a VOP_INACTIVEIan Dowse2002-12-291-15/+38
| | | | | | | | | | | | | | | | | | | | | | call is in progress on the vnode. When vput() or vrele() sees a 1->0 reference count transition, it now return without any further action if this flag is set. This flag is necessary to avoid recursion into VOP_INACTIVE if the filesystem inactive routine causes the reference count to increase and then drop back to zero. It is also used to guarantee that an unlocked vnode will not be recycled while blocked in VOP_INACTIVE(). There are at least two cases where the recursion can occur: one is that the softupdates code called by ufs_inactive() via ffs_truncate() can call vput() on the vnode. This has been reported by many people as "lockmgr: draining against myself" panics. The other case is that nfs_inactive() can call vget() and then vrele() on the vnode to clean up a sillyrename file. Reviewed by: mckusick (an older version of the patch) Notes: svn path=/head/; revision=108399
* Use a timeout of one second while we wait for the vnode washer,Poul-Henning Kamp2002-12-291-1/+1
| | | | | | | | this prevents a potential race and makes the system a little bit less jerky under extreme loads. Notes: svn path=/head/; revision=108390
* Vnodes pull in 800-900 bytes these days, all things counted, so we needPoul-Henning Kamp2002-12-291-5/+15
| | | | | | | | | | | | | | | | | | | to treat desiredvnodes much more like a limit than as a vague concept. On a 2GB RAM machine where desired vnodes is 130k, we run out of kmem_map space when we hit about 190k vnodes. If we wake up the vnode washer in getnewvnode(), sleep until it is done, so that it has a chance to offer us a washed vnode. If we don't sleep here we'll just race ahead and allocate yet a vnode which will never get freed. In the vnodewasher, instead of doing 10 vnodes per mountpoint per rotation, do 10% of the vnodes distributed evenly across the mountpoints. Notes: svn path=/head/; revision=108388
* KASSERT that vop_revoke() gets a VCHR.Poul-Henning Kamp2002-12-281-1/+2
| | | | Notes: svn path=/head/; revision=108367
* Perform vm_object_lock() and vm_object_unlock() aroundAlan Cox2002-12-151-0/+2
| | | | | | | vm_object_page_remove(). Notes: svn path=/head/; revision=107891
* To avoid lock order reversals in getnewvnode(), the call to uma_zfree()Alan Cox2002-12-081-3/+11
| | | | | | | | | | must be delayed until the vnode interlock is released. Reported by: kris@ Approved by: re (jhb) Notes: svn path=/head/; revision=107676
* Do not set a variable (vp->p_pollinfo) to NULL if we knowRobert Drehmel2002-11-271-1/+1
| | | | | | | | | it already has that value. Approved by: re Notes: svn path=/head/; revision=107319
* Slightly change the semantics of vnode labels for MAC: rather thanRobert Watson2002-10-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | "refreshing" the label on the vnode before use, just get the label right from inception. For single-label file systems, set the label in the generic VFS getnewvnode() code; for multi-label file systems, leave the labeling up to the file system. With UFS1/2, this means reading the extended attribute during vfs_vget() as the inode is pulled off disk, rather than hitting the extended attributes frequently during operations later, improving performance. This also corrects sematics for shared vnode locks, which were not previously present in the system. This chances the cache coherrency properties WRT out-of-band access to label data, but in an acceptable form. With UFS1, there is a small race condition during automatic extended attribute start -- this is not present with UFS2, and occurs because EAs aren't available at vnode inception. We'll introduce a work around for this shortly. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=105988
* In vrele() we can actually have a VCHR with v_rdev == NULL if wePoul-Henning Kamp2002-10-251-1/+1
| | | | | | | came from the bottom of addaliasu(). Don't panic. Notes: svn path=/head/; revision=105914
* Within ufs, the ffs_sync and ffs_fsync functions did not alwaysKirk McKusick2002-10-251-3/+3
| | | | | | | | | | | | | | | check for and/or report I/O errors. The result is that a VFS_SYNC or VOP_FSYNC called with MNT_WAIT could loop infinitely on ufs in the presence of a hard error writing a disk sector or in a filesystem full condition. This patch ensures that I/O errors will always be checked and returned. This patch also ensures that every call to VFS_SYNC or VOP_FSYNC with MNT_WAIT set checks for and takes appropriate action when an error is returned. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=105902
* Fix the spechash lock order reversal by keeping an updated sumPoul-Henning Kamp2002-10-241-19/+28
| | | | | | | | | | of v_usecount in the dev_t which vcount() can return without locking any vnodes. Seen by: jhb Notes: svn path=/head/; revision=105894
* When scanning the freelist looking for candidate vnodes to recycle,Kirk McKusick2002-10-141-4/+3
| | | | | | | | | | | | be sure to exit the loop with vp == NULL if no candidates are found. Formerly, this bug would cause the last vnode inspected to be used, even if it was not available. The result was a panic "vn_finished_write: neg cnt". Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=105121
* Unconditionally reset vp->v_vnlock back to the default in theKirk McKusick2002-10-141-1/+3
| | | | | | | | | | | | | vclean() function (e.g., vp->v_vnlock = &vp->v_lock) rather than requiring filesystems that use alternate locks to do so in their vop_reclaim functions. This change is a further cleanup of the vop_stdlock interface. Submitted by: Poul-Henning Kamp <phk@critter.freebsd.dk> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=105119
* Regularize the vop_stdlock'ing protocol across all the filesystemsKirk McKusick2002-10-141-9/+8
| | | | | | | | | | | | | | | | | | | | | | | that use it. Specifically, vop_stdlock uses the lock pointed to by vp->v_vnlock. By default, getnewvnode sets up vp->v_vnlock to reference vp->v_lock. Filesystems that wish to use the default do not need to allocate a lock at the front of their node structure (as some still did) or do a lockinit. They can simply start using vn_lock/VOP_UNLOCK. Filesystems that wish to manage their own locks, but still use the vop_stdlock functions (such as nullfs) can simply replace vp->v_vnlock with a pointer to the lock that they wish to have used for the vnode. Such filesystems are responsible for setting the vp->v_vnlock back to the default in their vop_reclaim routine (e.g., vp->v_vnlock = &vp->v_lock). In theory, this set of changes cleans up the existing filesystem lock interface and should have no function change to the existing locking scheme. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=105077
* When considering a vnode for reuse in getnewvnode, we callKirk McKusick2002-10-111-13/+18
| | | | | | | | | | | | | | | | | | | | vcanrecycle to check a free vnode's availability. If it is available, vcanrecycle returns an error code of zero and the vnode in question locked. The getnewvnode routine then used to call vn_start_write with the V_NOWAIT flag. If the filesystem was suspended while taking a snapshot, the vn_start_write would fail but getnewvnode would fail to unlock the vnode, instead leaving it locked on the freelist. The result would be that the vnode would be locked forever and would eventually hang the system with a race to the root when it was attempted to recycle it. This fix moves the vn_start_write check into vcanrecycle where it will properly unlock the vnode if it is unavailable for recycling due to filesystem suspension. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=104829
* Fix problem introduced in rev.1.406, which can cause already unlockedMaxim Sobolev2002-10-051-0/+1
| | | | | | | mutex being unlocked again causing system panic. Notes: svn path=/head/; revision=104509
* Fix some harmless mis-indents.Poul-Henning Kamp2002-10-011-1/+1
| | | | | | | Spotted by: FlexeLint Notes: svn path=/head/; revision=104302
* Move vnode MAC label initialization to after the release of the vnodeRobert Watson2002-09-301-3/+3
| | | | | | | | | | | | | | interlock in getnewvnode() to avoid possible sleeps while holding the mutex. Note that the warning from Witness is a slight false positive since we know there will be no contention on the interlock since we haven't made the vnode available for use yet, but the theory is not a bad one. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories Notes: svn path=/head/; revision=104237
* Be consistent about "static" functions: if the function is markedPoul-Henning Kamp2002-09-281-1/+1
| | | | | | | | | static in its prototype, mark it static at the definition too. Inspired by: FlexeLint warning #512 Notes: svn path=/head/; revision=104094
* - Move ASSERT_VOP_*LOCK* functionality into functions in vfs_subr.cJeff Roberson2002-09-261-29/+92
| | | | | | | | | | - Make the VI asserts more orthogonal to the rest of the asserts by using a new, common vfs_badlock() function and adding a 'str' arg. - Adjust generated ASSERTS to match the new prototype. - Adjust explicit ASSERTS to match the new prototype. Notes: svn path=/head/; revision=103986
* - Lock down the syncer with sync_mtx.Jeff Roberson2002-09-251-74/+188
| | | | | | | | | | | | | | | | | | | | | | - Enable vfs_badlock_mutex by default. - Assert that the vp is locked in VOP_UNLOCK. - Use standard interlock macros in remaining code. - Correct a race in getnewvnode(). - Lock access to v_numoutput with interlock. - Lock access to buf lists and splay tree with interlock. - Add VOP and VI asserts. - Lock b_vnbufs with the vnode interlock. - Add vrefcnt() for callers who want to retreive the vnode ref without holding a lock. Add a comment that describes when this is safe. - Add vholdl() and vdropl() so that callers who already own the interlock can avoid race conditions and unnecessary unlocking. - Move the VOP_GETATTR() in vflush() into the WRITECLOSE conditional case. - Hold the interlock before droping the mntlist_mtx in vflush() to avoid a race. - Fix locking in vfs_msync(). Notes: svn path=/head/; revision=103933
* Remove any VOP_PRINT that redundantly prints the tag.Nate Lawson2002-09-181-8/+8
| | | | | | | | | Move lockmgr_printinfo() into vprint() for everyone's benefit. Suggested by: bde Notes: svn path=/head/; revision=103559
* Remove all use of vnode->v_tag, replacing with appropriate substitutes.Nate Lawson2002-09-141-7/+9
| | | | | | | | | | | | | | | v_tag is now const char * and should only be used for debugging. Additionally: 1. All users of VT_NTS now check vfsconf->vf_type VFCF_NETWORK 2. The user of VT_PROCFS now checks for the new flag VV_PROCDEP, which is propagated by pseudofs to all child vnodes if the fs sets PFS_PROCDEP. Suggested by: phk Reviewed by: bde, rwatson (earlier version) Notes: svn path=/head/; revision=103314
* Indentation does not make a block.. need curly braces too.Julian Elischer2002-09-111-1/+2
| | | | | | | Submitted by: Eagle-eyes evans <bde@freebsd.org> Notes: svn path=/head/; revision=103228
* Completely redo thread states.Julian Elischer2002-09-111-2/+6
| | | | | | | Reviewed by: davidxu@freebsd.org Notes: svn path=/head/; revision=103216
* Fix an inherited style bug: compare with NOCRED instead of NULL.Poul-Henning Kamp2002-09-051-1/+1
| | | | | | | Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=102989
* Introduce new extattr_check_cred() function which implements the canonicalPoul-Henning Kamp2002-09-051-0/+34
| | | | | | | | | crential washing for extended attributes. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=102987
* Replace various spelling with FALLTHROUGH which is lint()ablePhilippe Charnier2002-08-251-1/+1
| | | | Notes: svn path=/head/; revision=102412
* - Fix a mistake in my last few commits. The PDROP flag stops msleep fromJeff Roberson2002-08-231-4/+1
| | | | | | | | | | re-acquiring the mutex. Pointy hat to: me Noticed by: tegge Notes: svn path=/head/; revision=102297
* - Make vn_lock() vget() and VOP_LOCK() all behave the same way WRTJeff Roberson2002-08-221-15/+7
| | | | | | | | | | | LK_INTERLOCK. The interlock will never be held on return from these functions even when there is an error. Errors typically only occur when the XLOCK is held which means this isn't the vnode we want anyway. Almost all users of these interfaces expected this behavior even though it was not provided before. Notes: svn path=/head/; revision=102255
* - Fix interlock handling in vn_lock(). Previously, vn_lock() could returnJeff Roberson2002-08-221-17/+9
| | | | | | | | | | with interlock held in error conditions when the caller did not specify LK_INTERLOCK. - Add several comments to vn_lock() describing the rational behind the code flow since it was not immediately obvious. Notes: svn path=/head/; revision=102251
* - Document two cases, one in vget and the other in vn_lock, where the stateJeff Roberson2002-08-211-0/+1
| | | | | | | | of interlock on exit is not consistent. There are probably several bugs relating to this. Notes: svn path=/head/; revision=102214
* - If vn_lock fails with the LK_INTERLOCK flag set, interlock will not beJeff Roberson2002-08-211-2/+3
| | | | | | | | | | released. vcanrecycle() failed to unlock interlock under this condition. - Remove an extra VOP_UNLOCK from a failure case in vcanrecycle(). Pointed out by: rwatson Notes: svn path=/head/; revision=102211
* - Add two new debugging macros: ASSERT_VI_LOCKED and ASSERT_VI_UNLOCKEDJeff Roberson2002-08-211-6/+59
| | | | | | | | | | | - Use the new VI asserts in place of the old mtx_assert checks. - Add the VI asserts to the automated lock checking in the VOP calls. The interlock should not be held across vops with a few exceptions. - Add the vop_(un)lock_{pre,post} functions to assert that interlock is held when LK_INTERLOCK is set. Notes: svn path=/head/; revision=102210
* - Extend the vnode_free_list_mtx to cover numvnodes and freevnodes. ThisJeff Roberson2002-08-131-3/+15
| | | | | | | was done only some of the time before, and now it is uniformly applied. Notes: svn path=/head/; revision=101769
* - Introduce a new struct xvfsconf, the userland version of struct vfsconf.Maxime Henrion2002-08-101-17/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | - Make getvfsbyname() take a struct xvfsconf *. - Convert several consumers of getvfsbyname() to use struct xvfsconf. - Correct the getvfsbyname.3 manpage. - Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the kernel, and rewrite getvfsbyname() to use this instead of the weird existing API. - Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist sysctl. - Convert a vfsload() call in nfsiod.c to kldload() and remove the useless vfsisloadable() and endvfsent() calls. - Add a warning printf() in vfs_sysctl() to tell people they are using an old userland. After these changes, it's possible to modify struct vfsconf without breaking the binary compatibility. Please note that these changes don't break this compatibility either. When bp will have updated mount_smbfs(8) with the patch I sent him, there will be no more consumers of the {set,get,end}vfsent(), vfsisloadable() and vfsload() API, and I will promptly delete it. Notes: svn path=/head/; revision=101651
* - Move some logic from getnewvnode() to a new function vcanrecycle()Jeff Roberson2002-08-051-69/+95
| | | | | | | | - Unlock the free list mutex around vcanrecycle to prevent a lock order reversal. Notes: svn path=/head/; revision=101367
* - Replace v_flag with v_iflag and v_vflagJeff Roberson2002-08-041-101/+154
| | | | | | | | | | | | | | | | | | - v_vflag is protected by the vnode lock and is used when synchronization with VOP calls is needed. - v_iflag is protected by interlock and is used for dealing with vnode management issues. These flags include X/O LOCK, FREE, DOOMED, etc. - All accesses to v_iflag and v_vflag have either been locked or marked with mp_fixme's. - Many ASSERT_VOP_LOCKED calls have been added where the locking was not clear. - Many functions in vfs_subr.c were restructured to provide for stronger locking. Idea stolen from: BSD/OS Notes: svn path=/head/; revision=101308
* Include file cleanup; mac.h and malloc.h at one point had orderingRobert Watson2002-08-011-1/+1
| | | | | | | | | relationship requirements, and no longer do. Reminded by: bde Notes: svn path=/head/; revision=101173
* Nit in previous commit: the correct sysctl type is "S,xvnode"Dag-Erling Smørgrav2002-07-311-1/+1
| | | | Notes: svn path=/head/; revision=101041
* Initialize v_cachedid to -1 in getnewvnode().Dag-Erling Smørgrav2002-07-311-42/+66
| | | | | | | | | | Reintroduce the kern.vnode sysctl and make it export xvnodes rather than vnodes. Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=101040