aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_subr.c
Commit message (Collapse)AuthorAgeFilesLines
* - 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
* Note that the privilege indicating flag to vaccess() originally usedRobert Watson2002-07-311-1/+1
| | | | | | | by the process accounting system is now deprecated. Notes: svn path=/head/; revision=101009
* Introduce support for Mandatory Access Control and extensibleRobert Watson2002-07-311-0/+8
| | | | | | | | | | | | | | | | kernel access control. Invoke the necessary MAC entry points to maintain labels on vnodes. In particular, initialize the label when the vnode is allocated or reused, and destroy the label when the vnode is going to be released, or reused. Wow, an object where there really is exactly one place where it's allocated, and one other where it's freed. Amazing. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=101008
* - Backout the patch made in revision 1.75 of vfs_mount.c. The vputs hereJeff Roberson2002-07-291-0/+1
| | | | | | | | | | were hiding the real problem of the missing unlock in sync_inactive. - Add the missing unlock in sync_inactive. Submitted by: iedowse Notes: svn path=/head/; revision=100863
* Wire the sysctl output buffer before grabbing any locks to preventDon Lewis2002-07-281-0/+1
| | | | | | | | | | SYSCTL_OUT() from blocking while locks are held. This should only be done when it would be inconvenient to make a temporary copy of the data and defer calling SYSCTL_OUT() until after the locks are released. Notes: svn path=/head/; revision=100831
* Teach discretionary access control methods for files about VAPPENDRobert Watson2002-07-221-4/+4
| | | | | | | | | | and VALLPERM. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=100481
* Add support to UFS2 to provide storage for extended attributes.Kirk McKusick2002-07-191-51/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As this code is not actually used by any of the existing interfaces, it seems unlikely to break anything (famous last words). The internal kernel interface to manipulate these attributes is invoked using two new IO_ flags: IO_NORMAL and IO_EXT. These flags may be specified in the ioflags word of VOP_READ, VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that you want to do I/O to the normal data part of the file and IO_EXT means that you want to do I/O to the extended attributes part of the file. IO_NORMAL and IO_EXT are mutually exclusive for VOP_READ and VOP_WRITE, but may be specified individually or together in the case of VOP_TRUNCATE. For example, when removing a file, VOP_TRUNCATE is called with both IO_NORMAL and IO_EXT set. For backward compatibility, if neither IO_NORMAL nor IO_EXT is set, then IO_NORMAL is assumed. Note that the BA_ and IO_ flags have been `merged' so that they may both be used in the same flags word. This merger is possible by assigning the IO_ flags to the low sixteen bits and the BA_ flags the high sixteen bits. This works because the high sixteen bits of the IO_ word is reserved for read-ahead and help with write clustering so will never be used for flags. This merge lets us get away from code of the form: if (ioflags & IO_SYNC) flags |= BA_SYNC; For the future, I have considered adding a new field to the vattr structure, va_extsize. This addition could then be exported through the stat structure to allow applications to find out the size of the extended attribute storage and also would provide a more standard interface for truncating them (via VOP_SETATTR rather than VOP_TRUNCATE). I am also contemplating adding a pathconf parameter (for concreteness, lets call it _PC_MAX_EXTSIZE) which would let an application determine the maximum size of the extended atribute storage. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=100344
* Change utimes to set the file creation time (for filesystems thatKirk McKusick2002-07-171-0/+2
| | | | | | | | | | | support creation times such as UFS2) to the value of the modification time if the value of the modification time is older than the current creation time. See utimes(2) for further details. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=100207
* Replace the global buffer hash table with per-vnode splay trees using aMatthew Dillon2002-07-101-85/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | methodology similar to the vm_map_entry splay and the VM splay that Alan Cox is working on. Extensive testing has appeared to have shown no increase in overhead. Disadvantages Dirties more cache lines during lookups. Not as fast as a hash table lookup (but still N log N and optimal when there is locality of reference). Advantages vnode->v_dirtyblkhd is now perfectly sorted, making fsync/sync/filesystem syncer operate more efficiently. I get to rip out all the old hacks (some of which were mine) that tried to keep the v_dirtyblkhd tailq sorted. The per-vnode splay tree should be easier to lock / SMPng pushdown on vnodes will be easier. This commit along with another that Alan is working on for the VM page global hash table will allow me to implement ranged fsync(), optimize server-side nfs commit rpcs, and implement partial syncs by the filesystem syncer (aka filesystem syncer would detect that someone is trying to get the vnode lock, remembers its place, and skip to the next vnode). Note that the buffer cache splay is somewhat more complex then other splays due to special handling of background bitmap writes (multiple buffers with the same lblkno in the same vnode), and B_INVAL discontinuities between the old hash table and the existence of the buffer on the v_cleanblkhd list. Suggested by: alc Notes: svn path=/head/; revision=99737
* - Use standard locking functions in syncer's opvJeff Roberson2002-07-091-6/+47
| | | | | | | | - vput instead of vrele syncer vnodes in vfs_mount - Add vop_lookup_{pre,post} to verify locking in VOP_LOOKUP Notes: svn path=/head/; revision=99690
* - Don't hold the vn lock while calling VOP_CLOSE in vclean().Jeff Roberson2002-07-071-6/+10
| | | | Notes: svn path=/head/; revision=99515
* - BUF_REFCNT() seems to be the preferred method for verifying a locked buf.Jeff Roberson2002-07-071-3/+9
| | | | | | | | | Tell vop_strategy_pre() to use this instead. - Ignore B_CLUSTER bufs. Their components are locked but they don't really exist so they don't have to be. This isn't ideal but it is safe. Notes: svn path=/head/; revision=99513
* Fix a mistake in my last commit. Don't grab an extra reference to the objectJeff Roberson2002-07-061-3/+1
| | | | | | | in bp->b_object. Notes: svn path=/head/; revision=99508
* Fixup uses of GETVOBJECT.Jeff Roberson2002-07-061-0/+4
| | | | | | | | | | | | | | - Cache a pointer to the vnode's object in the buf. - Hold a reference to that object in addition to the vnode's reference just to be consistent. - Cleanup code that got the object indirectly through the vp and VOP calls. This fixes at least one case where we were calling GETVOBJECT without a lock. It also avoids an expensive layered call at the cost of another pointer in struct buf. Notes: svn path=/head/; revision=99489
* - Add vop_strategy_pre to validate VOP_STRATEGY locking.Jeff Roberson2002-07-061-0/+16
| | | | | | | | | | | | - Disable original vop_strategy lock specification. - Switch to the new vop_strategy_pre for lock validation. VOP_STRATEGY requires only that the buf is locked UNLESS the block numbers need to be translated. There may be other reasons, but as long as the underlying layer uses a VOP to perform the operations they will be caught later. Notes: svn path=/head/; revision=99485
* Add "vop_rename_pre" to do pre rename lock verification. This is enabled onlyJeff Roberson2002-07-061-1/+20
| | | | | | | with DEBUG_VFS_LOCKS. Notes: svn path=/head/; revision=99483
* Move vfs_rootmountalloc() in vfs_mount.c and remove lite2_vfs_mountroot()Maxime Henrion2002-07-031-71/+0
| | | | | | | which was #if 0'd and is not likely to be used now. Notes: svn path=/head/; revision=99338
* Move every code related to mount(2) in a new file, vfs_mount.c.Maxime Henrion2002-07-021-109/+0
| | | | | | | | | | | | | The file vfs_conf.c which was dealing with root mounting has been repo-copied into vfs_mount.c to preserve history. This makes nmount related development easier, and help reducing the size of vfs_syscalls.c, which is still an enormous file. Reviewed by: rwatson Repo-copy by: peter Notes: svn path=/head/; revision=99264
* Use indirect function pointer hooks instead of #ifdef SOFTUPDATESIan Dowse2002-07-011-4/+5
| | | | | | | | | | | | direct calls for the two places where the kernel calls into soft updates code. Set up the hooks in softdep_initialize() and NULL them out in softdep_uninitialize(). This change allows soft updates to function correctly when ufs is loaded as a module. Reviewed by: mckusick Notes: svn path=/head/; revision=99220
* Rename the db command lockedvnodes to lockedvnods so that it fits on theDavid E. O'Brien2002-06-291-1/+1
| | | | | | | help screen and one doens't think we have a lockedvnodesmap command. Notes: svn path=/head/; revision=99021
* nuke caddr_t.Alfred Perlstein2002-06-281-9/+7
| | | | Notes: svn path=/head/; revision=98994
* Improve the VOP locking assertsJeff Roberson2002-06-281-0/+7
| | | | | | | | | | - Add vfs_badlock_print to control whether or not we print lock violations - Add vfs_badlock_panic to control whether we panic on lock violations Both default to on to mimic the original behavior if DEBUG_VFS_LOCKS is on. Notes: svn path=/head/; revision=98985
* Fix a case where a vnode got explicitly unlocked after the pointer to itBrian Feldman2002-06-281-1/+1
| | | | | | | | | got set to NULL. Revision 1.355: in the box Notes: svn path=/head/; revision=98979
* Change the way we internally store the mount options toMaxime Henrion2002-06-201-10/+45
| | | | | | | | | | | | | a linked list. This is to allow the merging of the mount options in the MNT_UPDATE case, as the current data structure is unsuitable for this. There are no functional differences in this commit. Reviewed by: phk Notes: svn path=/head/; revision=98510
* Change vfs_copyopt() so that the length argument passed to itMaxime Henrion2002-06-141-10/+7
| | | | | | | | must be the exact same size as the mount option. This makes vfs_copyopt() much more useful. Notes: svn path=/head/; revision=98233
* Move some sysctls from the debug tree to the vfs tree.Dag-Erling Smørgrav2002-06-061-3/+3
| | | | Notes: svn path=/head/; revision=97935
* Gratuitous whitespace cleanup.Dag-Erling Smørgrav2002-06-061-28/+27
| | | | Notes: svn path=/head/; revision=97934
* More s/file system/filesystem/gTom Rhodes2002-05-161-5/+5
| | | | Notes: svn path=/head/; revision=96755
* o Fix vfs_copyopt(), the first argument to bcopy() is the source,Maxime Henrion2002-05-161-15/+6
| | | | | | | | | not the destination. o Remove some code from vfs_getopt() which was making the interface more complicated to use for a very slight gain. Notes: svn path=/head/; revision=96744
* Switch from just holding the interlock to holding the standard lock throughoutJeff Roberson2002-05-071-12/+17
| | | | | | | | getnewvnode(). This is safer. In the future, we should investigate requiring only the interlock to get the vnode object. Notes: svn path=/head/; revision=96145
* Hold the currently selected vnode's lock across the call to VOP_GETVOBJECT.Jeff Roberson2002-05-061-2/+4
| | | | | | | | | | Don't try to create a vm object before the file system has a chance to finish initializing it. This is incorrect for a number of reasons. Firstly, that VOP requires a lock which the file system may not have initialized yet. Also, open and others will create a vm object if it is necessary later. Notes: svn path=/head/; revision=96094
* Expand the one-line function pbreassignbuf() the only place it is or couldPoul-Henning Kamp2002-05-051-14/+0
| | | | | | | be used. Notes: svn path=/head/; revision=96073
* Remove obsolete code (that was already #if 0'd out).Matthew Dillon2002-05-041-18/+0
| | | | | | | Requested by: Hiten Pandya <hitmaster2k@yahoo.com> Notes: svn path=/head/; revision=96034
* Change callers of mtx_init() to pass in an appropriate lock type name. InJohn Baldwin2002-04-041-7/+7
| | | | | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64 Notes: svn path=/head/; revision=93818
* Change the suser() API to take advantage of td_ucred as well as do aJohn Baldwin2002-04-011-1/+1
| | | | | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@ Notes: svn path=/head/; revision=93593
* As discussed in -arch, add the new nmount(2) system call and theMaxime Henrion2002-03-261-0/+77
| | | | | | | | | | | | | new vfs_getopt()/vfs_copyopt() API. This is intended to be used later, when there will be filesystems implementing the VFS_NMOUNT operation. The mount(2) system call will disappear when all filesystems will be converted to the new API. Documentation will be committed in a while. Reviewed by: phk Notes: svn path=/head/; revision=93228
* Remove references to vm_zone.h and switch over to the new uma API.Jeff Roberson2002-03-201-9/+11
| | | | | | | | Also, remove maxsockets. If you look carefully you'll notice that the old zone allocator never honored this anyway. Notes: svn path=/head/; revision=92751
* Remove __P.Alfred Perlstein2002-03-191-14/+14
| | | | Notes: svn path=/head/; revision=92723
* Three p_ucred -> td_ucred's missed in jhb's earlier pass; all appear toRobert Watson2002-03-051-1/+1
| | | | | | | be safe. Notes: svn path=/head/; revision=91709