summaryrefslogtreecommitdiff
path: root/sys/kern/vfs_export.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix some signed/unsigned integer confusion, and add bounds checking ofKris Kennaway2001-09-101-0/+5
| | | | | | | | | | | arguments to some functions. Obtained from: NetBSD Reviewed by: peter MFC after: 2 weeks Notes: svn path=/head/; revision=83291
* Since the netexport struct was centralised to 'struct mount',Ian Dowse2001-05-291-1/+1
| | | | | | | | | | | | | | | | attempting to remove nonexistant exports with MNT_DELEXPORT returns an error; before this change it always succeeded. This caused mountd(8) to log "can't delete exports for /whatever" warnings. Change the error code from EINVAL to a more specific ENOENT, and make mountd ignore this error when deleting the export list. I could have just restored the previous behaviour of returning success, but I think an error return is a useful diagnostic. Reviewed by: phk Notes: svn path=/head/; revision=77405
* vfs_subr.c is getting rather fat. The underlying repocopy and thisPoul-Henning Kamp2001-04-261-2852/+4
| | | | | | | commit moves the filesystem export handling code to vfs_export.c Notes: svn path=/head/; revision=76051
* Move the netexport structure from the fs-specific mountstructurePoul-Henning Kamp2001-04-251-5/+61
| | | | | | | | | | | | | | | | | to struct mount. This makes the "struct netexport *" paramter to the vfs_export and vfs_checkexport interface unneeded. Consequently that all non-stacking filesystems can use vfs_stdcheckexp(). At the same time, make it a pointer to a struct netexport in struct mount, so that we can remove the bogus AF_MAX and #include <net/radix.h> from <sys/mount.h> Notes: svn path=/head/; revision=75934
* Correct #includes to work with fixed sys/mount.h.Greg Lehey2001-04-231-0/+2
| | | | Notes: svn path=/head/; revision=75858
* Reclaim directory vnodes held in namecache if few free vnodes areSeigo Tanimura2001-04-181-0/+26
| | | | | | | | | | | | | | | | | | available. Only directory vnodes holding no child directory vnodes held in v_cache_src are recycled, so that directory vnodes near the root of the filesystem hierarchy remain in namecache and directory vnodes are not reclaimed in cascade. The period of vnode reclaiming attempt and the number of vnodes attempted to reclaim can be tuned via sysctl(2). Suggested by: tegge Approved by: phk Notes: svn path=/head/; revision=75654
* This patch removes the VOP_BWRITE() vector.Poul-Henning Kamp2001-04-171-1/+1
| | | | | | | | | | | | | | | | VOP_BWRITE() was a hack which made it possible for NFS client side to use struct buf with non-bio backing. This patch takes a more general approach and adds a bp->b_op vector where more methods can be added. The success of this patch depends on bp->b_op being initialized all relevant places for some value of "relevant" which is not easy to determine. For now the buffers have grown a b_magic element which will make such issues a tiny bit easier to debug. Notes: svn path=/head/; revision=75580
* Add a NOTE_REVOKE flag for vnodes, which is triggered from within vclean().Jonathan Lemon2001-02-231-0/+5
| | | | | | | | | | Use this to tell a filter attached to a vnode that the underlying vnode is no longer valid, by returning EV_EOF. PR: kern/25309, kern/25206 Notes: svn path=/head/; revision=72956
* Switch to using a struct xucred instead of a struct xucred when notBrian Feldman2001-02-181-2/+10
| | | | | | | | | | | | | | | | | | | | actually in the kernel. This structure is a different size than what is currently in -CURRENT, but should hopefully be the last time any application breakage is caused there. As soon as any major inconveniences are removed, the definition of the in-kernel struct ucred should be conditionalized upon defined(_KERNEL). This also changes struct export_args to remove dependency on the constantly-changing struct ucred, as well as limiting the bounds of the size fields to the correct size. This means: a) mountd and friends won't break all the time, b) mountd and friends won't crash the kernel all the time if they don't know what they're doing wrt actual struct export_args layout. Reviewed by: bde Notes: svn path=/head/; revision=72650
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-87/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* Mechanical change to use <sys/queue.h> macro API instead ofPoul-Henning Kamp2001-02-041-1/+1
| | | | | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1) Notes: svn path=/head/; revision=71999
* Properly lock new vnode.Boris Popov2001-01-311-4/+9
| | | | | | | Reminded by: tegge Notes: svn path=/head/; revision=71860
* Convert all simplelocks to mutexes and remove the simplelock implementations.Jason Evans2001-01-241-55/+55
| | | | Notes: svn path=/head/; revision=71576
* o The move to using VADMIN under vaccess() resulted in some systemRobert Watson2001-01-231-1/+1
| | | | | | | | | | | | | | calls returning EACCES instead of EPERM. This patch modifies vaccess() to return EPERM instead of EACCES if VADMIN is among the requested rights. This affects functions normally limited to the owners of a file, such as chmod(), as EPERM is the error indicating that privilege would allow the operation, rather than a chance in mandatory or discretionary rights. Reported by: bde Notes: svn path=/head/; revision=71411
* Stick the kthread API in a kthread_* namespace, and the specialized kprocJohn Baldwin2000-12-151-2/+2
| | | | | | | | | functions in a kproc_* namespace. Reviewed by: -arch Notes: svn path=/head/; revision=70063
* Use proper mutex locking when calling setrunnable from speedup_syncer().Kirk McKusick2000-12-131-3/+2
| | | | | | | Submitted by: Tor.Egge@fast.no Notes: svn path=/head/; revision=69950
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-4/+2
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781
* Untangle vfsinit() a bit. Use seperate sysinit functions rather thanPeter Wemm2000-12-061-2/+4
| | | | | | | having a super-function calling bits all over the place. Notes: svn path=/head/; revision=69664
* Correct int/long type mismatch in the proper place this time. freevnodesAndrew Gallatin2000-12-021-3/+3
| | | | | | | | | | | | | | and numvnodes are longs in the kernel. They should remain longs in systat, what really needs to change is that they should be using SYSCTL_LONG rather than SYSCTL_INT. I also changed wantfreevnodes to SYSCTL_LONG because I happened to notice it. I wish there was a way to find all of these automatically.. Pointed out by: bde Notes: svn path=/head/; revision=69529
* Use msleep() instead of mtx_exit()/tsleep() so that we release the lock andJohn Baldwin2000-12-011-13/+7
| | | | | | | go to sleep as an "atomic" operation. Notes: svn path=/head/; revision=69436
* Get rid of a bogus mtx_exit (it was attempting to release anKirk McKusick2000-11-301-1/+0
| | | | | | | | | already released mutex). Submitted by: "Chris Knight" <chris@aims.com.au> Notes: svn path=/head/; revision=69400
* Implement a low-memory deadlock solution.Matthew Dillon2000-11-181-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed most of the hacks that were trying to deal with low-memory situations prior to now. The new code is based on the concept that I/O must be able to function in a low memory situation. All major modules related to I/O (except networking) have been adjusted to allow allocation out of the system reserve memory pool. These modules now detect a low memory situation but rather then block they instead continue to operate, then return resources to the memory pool instead of cache them or leave them wired. Code has been added to stall in a low-memory situation prior to a vnode being locked. Thus situations where a process blocks in a low-memory condition while holding a locked vnode have been reduced to near nothing. Not only will I/O continue to operate, but many prior deadlock conditions simply no longer exist. Implement a number of VFS/BIO fixes (found by Ian): in biodone(), bogus-page replacement code, the loop was not properly incrementing loop variables prior to a continue statement. We do not believe this code can be hit anyway but we aren't taking any chances. We'll turn the whole section into a panic (as it already is in brelse()) after the release is rolled. In biodone(), the foff calculation was incorrectly clamped to the iosize, causing the wrong foff to be calculated for pages in the case of an I/O error or biodone() called without initiating I/O. The problem always caused a panic before. Now it doesn't. The problem is mainly an issue with NFS. Fixed casts for ~PAGE_MASK. This code worked properly before only because the calculations use signed arithmatic. Better to properly extend PAGE_MASK first before inverting it for the 64 bit masking op. In brelse(), the bogus_page fixup code was improperly throwing away the original contents of 'm' when it did the j-loop to fix the bogus pages. The result was that it would potentially invalidate parts of the *WRONG* page(!), leading to corruption. There may still be cases where a background bitmap write is being duplicated, causing potential corruption. We have identified a potentially serious bug related to this but the fix is still TBD. So instead this patch contains a KASSERT to detect the problem and panic the machine rather then continue to corrupt the filesystem. The problem does not occur very often.. it is very hard to reproduce, and it may or may not be the cause of the corruption people have reported. Review by: (VFS/BIO: mckusick, Ian Dowse <iedowse@maths.tcd.ie>) Testing by: (VM/Deadlock) Paul Saab <ps@yahoo-inc.com> Notes: svn path=/head/; revision=68885
* Clear the VFREE flag when the vnode is removed from the free list inTor Egge2000-11-021-0/+1
| | | | | | | | | | getnewvnode(). Otherwise routines called from VOP_INACTIVE() might attempt to remove the vnode from a free list the vnode isn't on, causing corruption. PR: 18012 Notes: svn path=/head/; revision=68262
* Take VBLK devices further out of their missery.Poul-Henning Kamp2000-11-021-12/+11
| | | | | | | This should fix the panic I introduced in my previous commit on this topic. Notes: svn path=/head/; revision=68259
* Catch up to moving headers:John Baldwin2000-10-201-1/+1
| | | | | | | | - machine/ipl.h -> sys/ipl.h - machine/mutex.h -> sys/mutex.h Notes: svn path=/head/; revision=67365
* o Introduce new VOP_ACCESS() flag VADMIN, allowing file systems to performRobert Watson2000-10-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | "administrative" authorization checks. In most cases, the VADMIN test checks to make sure the credential effective uid is the same as the file owner. o Modify vaccess() to set VADMIN as an available right if the uid is appropriate. o Modify references to uid-based access control operations such that they now always invoke VOP_ACCESS() instead of using hard-coded policy checks. o This allows alternative UFS policies to be implemented by replacing only ufs_access() (such as mandatory system policies). o VOP_ACCESS() requires the caller to hold an exclusive vnode lock on the vnode: I believe that new invocations of VOP_ACCESS() are always called with the lock held. o Some direct checks of the uid remain, largely associated with the QUOTA and SUIDDIR code. Reviewed by: eivind Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=67309
* Blow away the v_specmountpoint define, replacing it with what it wasEivind Eklund2000-10-091-2/+2
| | | | | | | defined as (rdev->si_mountpoint) Notes: svn path=/head/; revision=66886
* Do not call lockdestroy() for v_vnlock, which may point to a lock in aJason Evans2000-10-061-4/+1
| | | | | | | | | deeper vfs stacking layer. Submitted by: bp Notes: svn path=/head/; revision=66720
* Style fixes based on comments by bdeEivind Eklund2000-10-051-20/+31
| | | | Notes: svn path=/head/; revision=66686
* Convert lockmgr locks from using simple locks to using mutexes.Jason Evans2000-10-041-53/+58
| | | | | | | | | Add lockdestroy() and appropriate invocations, which corresponds to lockinit() and must be called to clean up after a lockmgr lock is no longer needed. Notes: svn path=/head/; revision=66615
* Move KASSERTs which checks value of v_usecount after vnode locking, soBoris Popov2000-10-021-2/+4
| | | | | | | it will not produce wrong alarms. Notes: svn path=/head/; revision=66541
* Do the right thing if bdevvp is called twice for the same device.Kirk McKusick2000-09-271-0/+2
| | | | | | | Obtained from: Poul-Henning Kamp <phk@freebsd.org> Notes: svn path=/head/; revision=66411
* Add a lock structure to vnode structure. Previously it was either allocatedBoris Popov2000-09-251-4/+5
| | | | | | | | | | | | | | | | | | | | | | separately (nfs, cd9660 etc) or keept as a first element of structure referenced by v_data pointer(ffs). Such organization leads to known problems with stacked filesystems. From this point vop_no*lock*() functions maintain only interlock lock. vop_std*lock*() functions maintain built-in v_lock structure using lockmgr(). vop_sharedlock() is compatible with vop_stdunlock(), but maintains a shared lock on vnode. If filesystem wishes to export lockmgr compatible lock, it can put an address of this lock to v_vnlock field. This indicates that the upper filesystem can take advantage of it and use single lock structure for entire (or part) of stack of vnodes. This field shouldn't be examined or modified by VFS code except for initialization purposes. Reviewed in general by: mckusick Notes: svn path=/head/; revision=66355
* Style fixes:Eivind Eklund2000-09-221-52/+107
| | | | | | | | | | | | | * Add lots of comments * Convert a couple of assertions to KASSERT() * Minimal whitespace & misapplied {} fixes * Convert #if 0 to #if COMPILING_LINT for code we presently do not support, but want to keep available. Reviewed by: adrian, markm Notes: svn path=/head/; revision=66244
* Staticize addalias()Eivind Eklund2000-09-221-1/+2
| | | | Notes: svn path=/head/; revision=66242
* comment vfs_export functions, requested by: eivindAlfred Perlstein2000-09-211-1/+12
| | | | Notes: svn path=/head/; revision=66168
* o Add additional comment describing vaccess() behavior.Robert Watson2000-09-201-0/+7
| | | | | | | | Requested by: eivind Reviewed by: eivind, adrian Notes: svn path=/head/; revision=66130
* Rename lminor() to dev2unit(). This function gives a linear unit numberPoul-Henning Kamp2000-09-191-2/+2
| | | | | | | | | | | | | | | which hides the 'hole' in the minor bits. Introduce unit2minor() to do the reverse operation. Fix some some make_dev() calls which didn't use UID_* or GID_* macros. Kill the v_hashchain alias macro, it hides the real relationship. Introduce experimental SI_CHEAPCLONE flag set it on cloned bpfs. Notes: svn path=/head/; revision=66067
* Add three new VOPs: VOP_CREATEVOBJECT, VOP_DESTROYVOBJECT and VOP_GETVOBJECT.Boris Popov2000-09-121-71/+11
| | | | | | | | | | They will be used by nullfs and other stacked filesystems to support full cache coherency. Reviewed in general by: mckusick, dillon Notes: svn path=/head/; revision=65770
* Major update to the way synchronization is done in the kernel. HighlightsJason Evans2000-09-071-0/+4
| | | | | | | | | | | | | | | | | | include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh Notes: svn path=/head/; revision=65557
* o Synchronize vaccess() capability access control checks with TrustedBSDRobert Watson2000-09-061-4/+4
| | | | | | | | | tree. Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=65516
* Move extern declaration of dead_vnodeop_p to a .h file.Poul-Henning Kamp2000-09-051-3/+5
| | | | | | | Remove race condition in vn_isdisk(). Notes: svn path=/head/; revision=65492
* o Restructure vaccess() so as to check for DAC permission to modify theRobert Watson2000-08-291-40/+92
| | | | | | | | | | | | | | | | | | | object before falling back on privilege. Make vaccess() accept an additional optional argument, privused, to determine whether privilege was required for vaccess() to return 0. Add commented out capability checks for reference. Rename some variables to make it more clear which modes/uids/etc are associated with the object, and which with the access mode. o Update file system use of vaccess() to pass NULL as the optional privused argument. Once additional patches are applied, suser() will no longer set ASU, so privused will permit passing of privilege information up the stack to the caller. Reviewed by: bde, green, phk, -security, others Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=65200
* Fix typo in last commit.Poul-Henning Kamp2000-08-201-2/+1
| | | | Notes: svn path=/head/; revision=64875
* Centralize the canonical vop_access user/group/other check in vaccess().Poul-Henning Kamp2000-08-201-0/+54
| | | | | | | Discussed with: bde Notes: svn path=/head/; revision=64865
* This patch corrects the first round of panics and hangs reportedKirk McKusick2000-07-241-3/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with the new snapshot code. Update addaliasu to correctly implement the semantics of the old checkalias function. When a device vnode first comes into existence, check to see if an anonymous vnode for the same device was created at boot time by bdevvp(). If so, adopt the bdevvp vnode rather than creating a new vnode for the device. This corrects a problem which caused the kernel to panic when taking a snapshot of the root filesystem. Change the calling convention of vn_write_suspend_wait() to be the same as vn_start_write(). Split out softdep_flushworklist() from softdep_flushfiles() so that it can be used to clear the work queue when suspending filesystem operations. Access to buffers becomes recursive so that snapshots can recursively traverse their indirect blocks using ffs_copyonwrite() when checking for the need for copy on write when flushing one of their own indirect blocks. This eliminates a deadlock between the syncer daemon and a process taking a snapshot. Ensure that softdep_process_worklist() can never block because of a snapshot being taken. This eliminates a problem with buffer starvation. Cleanup change in ffs_sync() which did not synchronously wait when MNT_WAIT was specified. The result was an unclean filesystem panic when doing forcible unmount with heavy filesystem I/O in progress. Return a zero'ed block when reading a block that was not in use at the time that a snapshot was taken. Normally, these blocks should never be read. However, the readahead code will occationally read them which can cause unexpected behavior. Clean up the debugging code that ensures that no blocks be written on a filesystem while it is suspended. Snapshots must explicitly label the blocks that they are writing during the suspension so that they do not cause a `write on suspended filesystem' panic. Reorganize ffs_copyonwrite() to eliminate a deadlock and also to prevent a race condition that would permit the same block to be copied twice. This change eliminates an unexpected soft updates inconsistency in fsck caused by the double allocation. Use bqrelse rather than brelse for buffers that will be needed soon again by the snapshot code. This improves snapshot performance. Notes: svn path=/head/; revision=63788
* Add snapshots to the fast filesystem. Most of the changes supportKirk McKusick2000-07-111-3/+26
| | | | | | | | | | | | | | | | | | | | | | | the gating of system calls that cause modifications to the underlying filesystem. The gating can be enabled by any filesystem that needs to consistently suspend operations by adding the vop_stdgetwritemount to their set of vnops. Once gating is enabled, the function vfs_write_suspend stops all new write operations to a filesystem, allows any filesystem modifying system calls already in progress to complete, then sync's the filesystem to disk and returns. The function vfs_write_resume allows the suspended write operations to begin again. Gating is not added by default for all filesystems as for SMP systems it adds two extra locks to such critical kernel paths as the write system call. Thus, gating should only be added as needed. Details on the use and current status of snapshots in FFS can be found in /sys/ufs/ffs/README.snapshot so for brevity and timelyness is not included here. Unless and until you create a snapshot file, these changes should have no effect on your system (famous last words). Notes: svn path=/head/; revision=62976
* Fix support for more than 256 simultaneous mounts. Theoretical limitBoris Popov2000-07-071-2/+4
| | | | | | | | | | is 2^16 mounts per fs type. Reported by: Troy Arie Cobb <tcobb@staff.circle.net> via phk Reviewed by: bde Notes: svn path=/head/; revision=62776
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.Poul-Henning Kamp2000-07-041-3/+3
| | | | | | | Pointed out by: bde Notes: svn path=/head/; revision=62573
* Simplify and rationalise the management of the vnode free listKirk McKusick2000-07-041-74/+30
| | | | | | | (preparing the code to add snapshots). Notes: svn path=/head/; revision=62552