summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
Commit message (Collapse)AuthorAgeFilesLines
...
* - Don't make vgonel() globally visible, we want to change its prototypejeff2005-06-131-36/+19
| | | | | | | | | | | | anyway and it's not used outside of vfs_subr.c. - Change vgonel() to accept a parameter which determines whether or not we'll put the vnode on the free list when we're done. - Use the new vgonel() parameter rather than VI_DOOMED to signal our intentions in vtryrecycle(). - In vgonel() return if VI_DOOMED is already set, this vnode has already been reclaimed. Sponsored by: Isilon Systems, Inc.
* - Add KTR_VFS events to vdestroy, vtruncbuf, vinvalbuf, vfreehead.jeff2005-06-131-0/+4
| | | | Sponsored by: Isilon Systems, Inc.
* - Assert that we're not in the name cache anymore in vdestroy().jeff2005-06-111-0/+2
| | | | Sponsored by: Isilon Systems, Inc.
* - Add KTR_VFS tracing to track the life of vnodes. Eventually KTR_VFSjeff2005-06-111-1/+20
| | | | | | | | | | events could be added to cover other interesting details. - Add some VNASSERTs to discover places where we access vnodes after they have been uma_zfree'd before we try to free them again. - Add a few more VNASSERTs to vdestroy() to be certain that the vnode is really unused. Sponsored by: Isilon Systems, Inc.
* Allow EVFILT_VNODE events to work on every filesystem type, not justssouhlal2005-06-091-1/+232
| | | | | | | | | | | | | | | UFS by: - Making the pre and post hooks for the VOP functions work even when DEBUG_VFS_LOCKS is not defined. - Moving the KNOTE activations into the corresponding VOP hooks. - Creating a MNTK_NOKNOTE flag for the mnt_kern_flag field of struct mount that permits filesystems to disable the new behavior. - Creating a default VOP_KQFILTER function: vfs_kqfilter() My benchmarks have not revealed any performance degradation. Reviewed by: jeff, bde Approved by: rwatson, jmg (kqueue changes), grehan (mentor)
* - Clear OWEINACT prior to calling VOP_INACTIVE to remove the possibilityjeff2005-06-071-1/+2
| | | | of a vget causing another call to INACTIVE before we're finished.
* If we are going tocperciva2005-05-061-0/+3
| | | | | | | | | | 1. Copy a NULL-terminated string into a fixed-length buffer, and 2. copyout that buffer to userland, we really ought to 0. Zero the entire buffer first. Security: FreeBSD-SA-05:08.kmem
* - A vnode may have made its way onto the free list while it was beingjeff2005-05-031-0/+2
| | | | | | | vgone'd. We must remove it from the freelist before returning in vtryrecycle() or we may get a duplicate free. Reported by: kkenn
* Since it is not possible for curthread to be NULL in this context,csjp2005-05-021-4/+2
| | | | | | | | drop the check+initialization for a straight initialization. Also assert that curthread will never be NULL just to be sure. Discussed with: rwatson, peter MFC after: 1 week
* - All buffers should either be clean or dirty. If neither of these flagsjeff2005-05-011-0/+4
| | | | | | | are set when we attempt to remove a buffer from a queue we should panic. Hopefully this will catch the source of the wrong bufobj panics. Sponsored by: Isilon Systems, Inc.
* - In vnlru_free() remove the vnode from the free list before we calljeff2005-04-301-33/+51
| | | | | | | | | | | | vtryrecycle(). We could sometimes get into situations where two threads could try to recycle the same vnode before this. - vtryrecycle() is now responsible for returning the vnode to the free list if it fails and someone else hasn't done it. - Make a new function vfreehead() which moves a vnode to the head of the free list and use it in vgone() to clean up that code a bit. Sponsored by: Isilon Systems, Inc. Reported by: pho, kkenn
* - Don't vgonel() via vgone() or vrecycle() if the vnode is already doomed.jeff2005-04-271-1/+8
| | | | | | | This fixes forced unmounts via nullfs. Reported by: kkenn Sponsored by: Isilon Systems, Inc.
* - Stop setting vxthread, we've asserted that it was useless for severaljeff2005-04-271-2/+0
| | | | weeks now.
* - Disable code which allows getnewvnode() to fail. Many ffs_vget() callersjeff2005-04-221-0/+2
| | | | | | | | do not correctly deal with failures. This presently risks deadlock problems if dependency processing is held up by failures to allocate a vnode, however, this is better than the situation with the failures. Sponsored by: Isilon Systems, Inc.
* Initialize mountlist_mtx with an MTX_SYSINIT(), we need it to be readyphk2005-04-181-1/+0
| | | | earlier.
* - Change vop_lookup_post assertions to reflect recent vfs_lookup changes.jeff2005-04-131-12/+2
| | | | Sponsored by: Isilon Systems, Inc.
* - Enable ASSERT_VOP_ELOCKED and assert_vop_elocked() now that vnode_if.awkjeff2005-04-111-1/+1
| | | | | | uses it. Sponsored by: Isilon Systems, Inc.
* - Change the VOP_LOCK UPGRADE in vput() to do a LK_NOWAIT to avoid ajeff2005-04-111-39/+43
| | | | | | | | | | | | potential lock order reversal. Also, don't unlock the vnode if this fails, lockmgr has already unlocked it for us. - Restructure vget() now that vn_lock() does all of VI_DOOMED checking for us and also handles the case where there is no real lock type. - If VI_OWEINACT is set, we need to upgrade the lock request to EXCLUSIVE so that we can call inactive. It's not legal to vget a vnode that hasn't had INACTIVE called yet. Sponsored by: Isilon Systems, Inc.
* - Assert that the bufobj matches in flushbuflists. I still haven't gottenjeff2005-04-061-0/+3
| | | | | | | | | | to root cause on exactly how this happens. - If the assert is disabled, we presently try to handle this case, but the BUF_UNLOCK was missing. Thus, if this condition ever hit we would leak a buf lock. Many thanks to Peter Holm for all his help in finding this bug. He really put more effort into it than I did.
* - Move NDFREE() from vfs_subr to vfs_lookup where namei() is.jeff2005-04-051-38/+0
|
* - Add a missing unlock of the vnode_free_list_mtx.jeff2005-04-041-1/+3
| | | | Spotted by: Antoine Brodin
* - Instead of waiting forever to get a vnode in getnewvnode() wait forjeff2005-04-041-1/+3
| | | | | | | | | | one to become available for one second and then return ENFILE. We can run out of vnodes, and there must be a hard limit because without one we can quickly run out of KVA on x86. Presently the system can deadlock if there are maxvnodes directories in the namecache. The original 4.x BSD behavior was to return ENFILE if we reached the max, but 4.x BSD did not have the vnlru proc so it was less profitable to wait.
* - Disable vfs shared locks by default. They must be specifically enabledjeff2005-03-311-1/+5
| | | | | | | on filesystems which safely support them. It appears that many network filesystems specifically are not shared lock safe. Sponsored by: Isilon Systems, Inc.
* - LK_NOPAUSE is a nop now.jeff2005-03-311-2/+2
| | | | Sponsored by: Isilon Systems, Inc.
* Eliminate v_id and v_ddid. The name cache now holds references todas2005-03-301-2/+1
| | | | | | | | | | vnodes whose names it caches, so we no longer need a `generation number' to tell us if a referenced vnode is invalid. Replace the use of the parent's v_id in the hash function with the address of the parent vnode. Tested by: Peter Holm Glanced at by: jeff, phk
* - Dont clear OWEINACT in vbusy(), we still owe an inactive call if someonejeff2005-03-291-11/+16
| | | | | | | | | | vhold()s us. - Avoid an extra mutex acquire and release in the common case of vgonel() by checking for OWEINACT at the start of the function. - Fix the case where we set OWEINACT in vput(). LK_EXCLUPGRADE drops our shared lock if it fails. Sponsored by: Isilon Systems, Inc.
* - Don't initial v_dd here, let cache_purge() do it for us.jeff2005-03-291-1/+0
| | | | Sponsored by: Isilon Systems, Inc.
* - Move code that should probably be an assert above the main body ofjeff2005-03-281-15/+14
| | | | | | | vrele so that we can decrease the indentation of the real work and make things slightly more clear. Sponsored by: Isilon Systems, Inc.
* - Adjust asserts in vop_lookup_post() to match the new post PDIRUNLOCKjeff2005-03-281-11/+8
| | | | | | vfs. Sponsored by: Isilon Systems, Inc.
* Remove another ';' after if().phk2005-03-271-1/+1
| | | | Also spotted by: bz
* Remove extra ; at end of if().phk2005-03-271-1/+1
| | | | Found by: bz
* - Don't recycle vnodes anymore. Free them once they are dead. getnewvnodejeff2005-03-251-121/+116
| | | | | | | | | | | | | | | | now always allocates a new vnode. - Define a new function, vnlru_free, which frees vnodes from the free list. It takes as a parameter the number of vnodes to free, which is wantfreevnodes - freevnodes when called from vnlru_proc or 1 when called from getnewvnode(). For now, getnewvnode() still tries to reclaim a free vnode before creating a new one when we are near the limit. - Define a function, vdestroy, which handles the actual release of memory and teardown of locks, etc. This could become a uma_dtor() routine. - Get rid of minvnodes. Now wantfreevnodes is 1/4th the max vnodes. This keeps more unreferenced vnodes around so that files which have only been stat'd are less likely to be kicked out of the system before we have a chance to read them, etc. These vnodes may still be freed via the normal vnlru_proc() routines which may some day become a real lru.
* - Pass LK_EXCLUSIVE to VFS_ROOT() to satisfy the new flags argument. Forjeff2005-03-241-1/+1
| | | | | | now, all calls to VFS_ROOT() should still acquire exclusive locks. Sponsored by: Isilon Systems, Inc.
* - If vput() is called with a shared lock it must upgrade to an exclusivejeff2005-03-241-3/+12
| | | | | | | | | | | before it can call VOP_INACTIVE(). This must use the EXCLUPGRADE path because we may violate some lock order with another locked vnode if we drop and reacquire the lock. If EXCLUPGRADE fails, we mark the vnode with VI_OWEINACT. This case should be very rare. - Clear VI_OWEINACT in vinactive() and vbusy(). - If VI_OWEINACT is set in vgone() do the VOP_INACTIVE call here as well. Sponsored by: Isilon Systems, Inc.
* - Now that there are no external users of vfree() make it static.jeff2005-03-151-48/+12
| | | | | | | | | | | | | | | | - Move VSHOULDBUSY, VSHOULDFREE, and VTRYRECYCLE into vfs_subr.c so no one else attempts to grow a dependency on them. - Now that objects with pages hold the vnode we don't have to do unlocked checks for the page count in the vm object in VSHOULDFREE. These three macros could simply check for holdcnt state transitions to determine whether the vnode is on the free list already, but the extra safety the flag affords us is probably worth the minimal cost. - The leafonly sysctl and code have been dead for several years now, remove the sysctl and the code that employed it from vtryrecycle(). - vtryrecycle() also no longer has to check the object's page count as the object holds the vnode until it reaches 0. Sponsored by: Isilon Systems, Inc.
* - Expose vholdl() so it may be used outside of vfs_subr.cjeff2005-03-151-2/+1
|
* - Increment the holdcnt once for each usecount reference. This allows usjeff2005-03-141-3/+4
| | | | | | | to use only the holdcnt to determine whether a vnode may be recycled, simplifying the V* macros as well as vtryrecycle(), etc. Sponsored by: Isilon Systems, Inc.
* - We do not have to check the object's ref_count in VSHOULDFREE orjeff2005-03-141-3/+3
| | | | | | | | vtryrecycle(). All obj refs also ref the vnode. - Consistently use v_incr_usecount() to increment the usecount. This will be more important later. Sponsored by: Isilon Systems, Inc.
* - Slightly rearrange vrele() to move the common case in one indentationjeff2005-03-141-20/+17
| | | | | | level. Sponsored by: Isilon Systems, Inc.
* - Rework vget() so we drop the usecount in two failure cases that werejeff2005-03-141-24/+24
| | | | | | missed by my last commit. Sponsored by: Isilon Systems, Inc.
* - Remove vx_lock, vx_unlock, vx_wait, etc.jeff2005-03-131-225/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add a vn_start_write/vn_finished_write around vlrureclaim so we don't do writing ops without suspending. This could suspend the vlruproc which should not be a problem under normal circumstances. - Manually implement VMIGHTFREE in vlrureclaim as this was the only instance where it was used. - Acquire a lock before calling vgone() as it now requires it. - Move the acquisition of the vnode interlock from vtryrecycle() to getnewvnode() so that if it fails we don't drop and reacquire the vnode_free_list_mtx. - Check for a usecount or holdcount at the end of vtryrecycle() in case someone grabbed a ref while we were recycling. Abort the recycle, and on the final ref drop this vnode will be placed on the head of the free list. - Move the redundant VOP_INACTIVE protection code into the local vinactive() routine to avoid code bloat. - Keep the vnode lock held across calls to vgone() in several places. - vgonel() no longer uses XLOCK, instead callers must hold an exclusive vnode lock. The VI_DOOMED flag is set to allow other threads to detect a vnode which is no longer valid. This flag is set until the last reference is gone, and there are no chances for a new ref. vgonel() holds this lock across the entire function, which greatly simplifies logic. _ Only vfree() in one place in vgone() not three. - Adjust vget() to check the VI_DOOMED flag prior to waiting on the lock in the LK_NOWAIT case. In other cases, check after we have slept and acquired an exlusive lock. This will simulate the old vx_wait() behavior. Sponsored by: Isilon Systems, Inc.
* - Enable SMP VFS by default on current. More users are needed to turn upjeff2005-02-231-1/+5
| | | | | | | any remaining bugs. Anyone inconvenienced by this can still disable it in the loader. Sponsored by: Isilon Systems, Inc.
* - Only the xlock holder should be calling VOP_LOCK on a vp once VI_XLOCKjeff2005-02-231-0/+5
| | | | | | | has been set. Assert that this is the case so that we catch filesystems who are using naked VOP_LOCKs in illegal cases. Sponsored by: Isilon Systems, Inc.
* - Add a check for xlock in vop_lock_assert. Presently the xlock isjeff2005-02-221-1/+2
| | | | | | | considered to be as good as an exclusive lock, although there is still a possibility of someone acquiring a VOP LOCK while xlock is held. Sponsored by: Isilon Systems, Inc.
* Zero the v_un container field to make sure everything is gone.phk2005-02-221-1/+1
|
* Reap more benefits from DEVFS:phk2005-02-221-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | List devfs_dirents rather than vnodes off their shared struct cdev, this saves a pointer field in the vnode at the expense of a field in the devfs_dirent. There are often 100 times more vnodes so this is bargain. In addition it makes it harder for people to try to do stypid things like "finding the vnode from cdev". Since DEVFS handles all VCHR nodes now, we can do the vnode related cleanup in devfs_reclaim() instead of in dev_rel() and vgonel(). Similarly, we can do the struct cdev related cleanup in dev_rel() instead of devfs_reclaim(). rename idestroy_dev() to destroy_devl() for consistency. Add LIST_ENTRY de_alias to struct devfs_dirent. Remove v_specnext from struct vnode. Change si_hlist to si_alist in struct cdev. String new devfs vnodes' devfs_dirent on si_alist when we create them and take them off in devfs_reclaim(). Fix devfs_revoke() accordingly. Also don't clear fields devfs_reclaim() will clear when called from vgone(); Let devfs_reclaim() call dev_rel() instead of vgonel(). Move the usecount tracking from dev_rel() to devfs_reclaim(), and let dev_rel() take a struct cdev argument instead of vnode. Destroy SI_CHEAPCLONE devices in dev_rel() (instead of devfs_reclaim()) when they are no longer used. (This should maybe happen in devfs_close() instead.)
* Remove vfinddev(), it is generally bogus when faced with jails andphk2005-02-221-20/+0
| | | | chroot and has no legitimate use(r)s in the tree.
* Try to unbreak the vnode locking around vop_reclaim() (based mostly onphk2005-02-191-36/+30
| | | | | | | | | patch from kan@). Pull bufobj_invalbuf() out of vinvalbuf() and make g_vfs call it on close. This is not yet a generally safe function, but for this very specific use it is safe. This solves the problem with buffers not being flushed by unmount or after failed mount attempts.
* Make sure to drop the VI_LOCK in vgonel();phk2005-02-181-1/+3
| | | | Spotted by: Taku YAMAMOTO <taku@tackymt.homeip.net>
* Introduce vx_wait{l}() and use it instead of home-rolled versions.phk2005-02-171-6/+31
|
OpenPOWER on IntegriCloud