summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_aio.c
Commit message (Collapse)AuthorAgeFilesLines
* Check validity of signal callback requested via aio routines.alfred2001-04-181-2/+13
| | | | | | | | | | | | | Also move the insertion of the request to after the request is validated, there's still looks like there may be some problems if an invalid address is passed to the aio routines, basically a possible leak or having a not completely initialized structure on the queue may still be possible. A new sig macro was made _SIG_VALID to check the validity of a signal, it would be advisable to use it from now on (in kern/kern_sig.c) rather than rolling your own. PR: kern/17152
* When aio_read/write() is used on a raw device, physical buffers arealc2001-03-101-7/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | used for up to "vfs.aio.max_buf_aio" of the requests. If a request size is MAXPHYS, but the request base isn't page aligned, vmapbuf() will map the end of the user space buffer into the start of the kva allocated for the next physical buffer. Don't use a physical buffer in this case. (This change addresses problem report 25617.) When an aio_read/write() on a raw device has completed, timeout() is used to schedule a signal to the process. Thus, the reporting is delayed up to 10 ms (assuming hz is 100). The process might have terminated in the meantime, causing a trap 12 when attempting to deliver the signal. Thus, the timeout must be cancelled when removing the job. aio jobs in state JOBST_JOBQGLOBAL should be removed from the kaio_jobqueue list during process rundown. During process rundown, some aio jobs might move from one list to a different list that has already been "emptied", causing the rundown to be incomplete. Retry the rundown. A call to BUF_KERNPROC() is needed after obtaining a physical buffer to disassociate the lock from the running process since it can return to userland without releasing that lock. PR: 25617 Submitted by: tegge
* Use the kthread API to create and destroy AIO daemons.alc2001-03-091-9/+7
| | | | Submitted by: jhb
* Grab the process lock while calling psignal and before calling psignal.jhb2001-03-071-9/+26
|
* Add a missing splx() to aio_fphysio(). (This change is a no-op in -5.0,alc2001-03-061-12/+6
| | | | | | | | but potentially significant in -4.x.) Eliminate a pointless parameter to aio_fphysio(). Remove unnecessary casts from aio_fphysio() and aio_physwakeup().
* Eliminate the aio_freejobs list. Its purpose was to store freealc2001-03-051-40/+30
| | | | | | | | | | | | | | | | | | | | | aiocb's allocated by zalloc(). In other words, zfree() was never called. Now, we call zfree(). Why eliminate this micro- optimization? At some later point, when we multithread the AIO system, we would need a mutex to synchronize access to aio_freejobs, making its use nearly indistinguishable in cost from zalloc() and zfree(). Remove unnecessary fhold() and fdrop() calls from aio_qphysio(), undo'ing a part of revision 1.86. The reference count on the file structure is already incremented by _aio_aqueue() before it calls aio_qphysio(). (Update the comments to document this fact.) Remove unnecessary casts from _aio_aqueue(), aio_read(), aio_write() and aio_waitcomplete(). Remove an unnecessary "return;" from aio_process(). Add "static" in various places.
* Remove the field privatemodes from struct __aiocb_private and thealc2001-03-041-137/+2
| | | | | | | related code from aio_read() and aio_write(). This field was intended, but never used, to allow a mythical user-level library to make an aio_read() or aio_write() behave like an ordinary read() or write(), i.e., a blocking I/O operation.
* Change and clean the mutex lock interface.bmilekic2001-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Fix typo: wierd -> weird.asmodai2001-02-061-1/+1
| | | | There is no such thing as wierd in the english language.
* Another round of the <sys/queue.h> FOREACH transmogriffer.phk2001-02-041-4/+2
| | | | | Created with: sed(1) Reviewed by: md5(1)
* Remove thr_sleep and thr_wakeup. Remove fields p_nthread and p_wakeupjake2000-12-021-1/+1
| | | | | | | | | | from struct proc, which are now unused (p_nthread already was). Remove process flag P_KTHREADP which was untested and only set in vfs_aio.c (it should use kthread_create). Move the yield system call to kern_synch.c as kern_threads.c has been removed completely. moral support from: alfred, jhb
* Provide a new interface for the user of aio_read() and aio_write() to requestalc2000-11-211-29/+33
| | | | | | | | | | | | | | | a kevent upon completion of the I/O. Specifically, introduce a new type of sigevent notification, SIGEV_EVENT. If sigev_notify is SIGEV_EVENT, then sigev_notify_kqueue names the kqueue that should receive the event and sigev_value contains the "void *" is copied into the kevent's udata field. In contrast to the existing interface, this one: 1) works on the Alpha 2) avoids the extra copyin() call for the kevent because all of the information needed is in the sigevent and 3) could be applied to request a single kevent upon completion of an entire lio_listio(). Reviewed by: jlemon
* This patchset fixes a large number of file descriptor race conditions.dillon2000-11-181-5/+32
| | | | | | | | | | | | Pre-rfork code assumed inherent locking of a process's file descriptor array. However, with the advent of rfork() the file descriptor table could be shared between processes. This patch closes over a dozen serious race conditions related to one thread manipulating the table (e.g. closing or dup()ing a descriptor) while another is blocked in an open(), close(), fcntl(), read(), write(), etc... PR: kern/11629 Discussed with: Alexander Viro <viro@math.psu.edu>
* _aio_aqueue(): Change kevent registration to use its own struct file pointer.alc2000-10-291-3/+4
| | | | | | Otherwise, aio_read() and aio_write() on sockets are broken if a kevent is registered. (The code after kevent registration for handling sockets assumes that the struct file pointer "fp" still refers to the socket, not the kqueue.)
* Catch up to moving headers:jhb2000-10-201-1/+1
| | | | | - machine/ipl.h -> sys/ipl.h - machine/mutex.h -> sys/mutex.h
* aio_qphysio: Eliminate one instance of an out-of-range check that isalc2000-09-261-18/+3
| | | | | | | | performed twice. Eliminate initialization that is already performed by _aio_aqueue. aio_physwakeup: Eliminate redundant synchronization that is already performed by bufdone.
* Added used include of <sys/mutex.h> (don't depend on pollution inbde2000-09-171-0/+2
| | | | <sys/signalvar.h>).
* aio processes need to have the Giant mutex before doing work.jhb2000-09-111-0/+1
| | | | Submitted by: tegge
* Remove uidinfo hash table lookup and maintenance out of chgproccnt() andtruckman2000-09-051-0/+2
| | | | | | | | | | | | | | chgsbsize(), which are called rather frequently and may be called from an interrupt context in the case of chgsbsize(). Instead, do the hash table lookup and maintenance when credentials are changed, which is a lot less frequent. Add pointers to the uidinfo structures to the ucred and pcred structures for fast access. Pass a pointer to the credential to chgproccnt() and chgsbsize() instead of passing the uid. Add a reference count to the uidinfo structure and use it to decide when to free the structure rather than freeing the structure when the resource consumption drops to zero. Move the resource tracking code from kern_proc.c to kern_resource.c. Move some duplicate code sequences in kern_prot.c to separate helper functions. Change KASSERTs in this code to unconditional tests and calls to panic().
* Make filt_aio() check the jobstate for JOBST_JOBBFINISHED (in additionalc2000-09-041-1/+2
| | | | | to JOBST_JOBFINISHED) in case the aio_read() or aio_write() was performed via the high-performance physio method, i.e., aio_qphysio().
* Fix the #ifdef VFS_AIO to not compile a whole bunch of unused stuff in thepeter2000-07-281-7/+34
| | | | | | !VFS_AIO case. Lots of things have hooks into here (kqueue, exit(), sockets, etc), I elected to keep the external interfaces the same rather than spread more #ifdefs around the kernel.
* Back out the previous change to the queue(3) interface.jake2000-05-261-14/+14
| | | | | | It was not discussed and should probably not happen. Requested by: msmith and others
* Change the way that the queue(3) structures are declared; don't assume thatjake2000-05-231-14/+14
| | | | | | | | the type argument to *_HEAD and *_ENTRY is a struct. Suggested by: phk Reviewed by: phk Approved by: mdodd
* Separate the struct bio related stuff out of <sys/buf.h> intophk2000-05-051-0/+1
| | | | | | | | | | | | | | | <sys/bio.h>. <sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall not be made a nested include according to bdes teachings on the subject of nested includes. Diskdrivers and similar stuff below specfs::strategy() should no longer need to include <sys/buf.> unless they need caching of data. Still a few bogus uses of struct buf to track down. Repocopy by: peter
* Introduce kqueue() and kevent(), a kernel event notification facility.jlemon2000-04-161-3/+104
|
* Move B_ERROR flag to b_ioflags and call it BIO_ERROR.phk2000-04-021-3/+3
| | | | | | | | | | | | | (Much of this done by script) Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED. Move b_pblkno and b_iodone_chain to struct bio while we transition, they will be obsoleted once bio structs chain/stack. Add bio_queue field for struct bio aware disksort. Address a lot of stylistic issues brought up by bde.
* Rename the existing BUF_STRATEGY() to DEV_STRATEGY()phk2000-03-201-1/+1
| | | | | | | | substitute BUF_WRITE(foo) for VOP_BWRITE(foo->b_vp, foo) substitute BUF_STRATEGY(foo) for VOP_STRATEGY(foo->b_vp, foo) This patch is machine generated except for the ccd.c and buf.h parts.
* Remove B_READ, B_WRITE and B_FREEBUF and replace them with a newphk2000-03-201-4/+3
| | | | | | | | | | | | | | | | | | | | | field in struct buf: b_iocmd. The b_iocmd is enforced to have exactly one bit set. B_WRITE was bogusly defined as zero giving rise to obvious coding mistakes. Also eliminate the redundant struct buf flag B_CALL, it can just as efficiently be done by comparing b_iodone to NULL. Should you get a panic or drop into the debugger, complaining about "b_iocmd", don't continue. It is likely to write on your disk where it should have been reading. This change is a step in the direction towards a stackable BIO capability. A lot of this patch were machine generated (Thanks to style(9) compliance!) Vinum users: Greg has not had time to test this yet, be careful.
* Add the VFS_AIO config option and leave it off by default. Unless thejasone2000-02-231-7/+153
| | | | | | | | | VFS_AIO option is specified, all aio-related syscalls return ENOSYS. The aio code is very fragile right now, and is unsuitable for default inclusion in a production shell box. Approved by: jkh
* Back out the previous spl change, since it opens a race window.jasone2000-01-201-1/+1
| | | | Reviewed by: alfred, dillon, peter
* Don't tsleep() while at splbio().jasone2000-01-201-2/+12
| | | | | | | Correctly return EINPROGRESS from aio_error() even when an aio request is still in the socket queue. Submitted by: Adrian Chadd <adrian@bofh.co.uk>
* Fix vn_isdisk() usage to make AIO work on non-disk-files again, rathergreen2000-01-171-2/+11
| | | | | | | than just return ENOTBLK. PR: 16163 Submitted by: Adrian Chadd <adrian@FreeBSD.org>
* Add aio_waitcomplete(). Make aio work correctly for socket descriptors.jasone2000-01-141-502/+633
| | | | | | | | Make gratuitous style(9) fixes (me, not the submitter) to make the aio code more readable. PR: kern/12053 Submitted by: Chris Sedore <cmsedore@maxwell.syr.edu>
* Give vn_isdisk() a second argument where it can return a suitable errno.phk2000-01-101-2/+2
| | | | Suggested by: bde
* Convert various pieces of code to use vn_isdisk() rather than checkingphk1999-11-221-4/+1
| | | | | | | | for vp->v_type == VBLK. In ccd: we don't need to call VOP_GETATTR to find the type of a vnode. Reviewed by: sos
* Simplify and de-bogotify check for raw disk.phk1999-11-071-31/+15
|
* Change useracc() and kernacc() to use VM_PROT_{READ|WRITE|EXECUTE} for thephk1999-10-301-18/+13
| | | | | | | | | "rw" argument, rather than hijacking B_{READ|WRITE}. Fix two bugs (physio & cam) resulting by the confusion caused by this. Submitted by: Tor.Egge@fast.no Reviewed by: alc, ken (partly)
* Trim unused options (or #ifdef for undoc options).peter1999-10-111-3/+0
| | | | Submitted by: phk
* This is what was "fdfix2.patch," a fix for fd sharing. It's prettygreen1999-09-191-4/+4
| | | | | | | | | | | | | | | | | far-reaching in fd-land, so you'll want to consult the code for changes. The biggest change is that now, you don't use fp->f_ops->fo_foo(fp, bar) but instead fo_foo(fp, bar), which increments and decrements the fp refcount upon entry and exit. Two new calls, fhold() and fdrop(), are provided. Each does what it seems like it should, and if fdrop() brings the refcount to zero, the fd is freed as well. Thanks to peter ("to hell with it, it looks ok to me.") for his review. Thanks to msmith for keeping me from putting locks everywhere :) Reviewed by: peter
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Spring cleaning around strategy and disklabels/slices:phk1999-08-141-10/+3
| | | | | | | | | | | | | | Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout. please see comment in sys/conf.h about the flag argument. Remove strategy argument from all the diskslice/label/bad144 implementations, it should be found from the dev_t. Remove bogus and unused strategy1 routines. Remove open/close arguments from dssize(). Pick them up from dev_t. Remove unused and unfinished setgeom support from diskslice/label/bad144 code.
* s/v_specinfo/v_rdev/phk1999-08-131-2/+2
|
* Decommision miscfs/specfs/specdev.h. Most of it goes into <sys/conf.h>,phk1999-08-081-2/+1
| | | | | | a few lines into <sys/vnode.h>. Add a few fields to struct specinfo, paving the way for the fun part.
* Slight reorganization of kernel thread/process creation. Instead of usingpeter1999-07-011-3/+3
| | | | | | | | | | | | | | | SYSINIT_KT() etc (which is a static, compile-time procedure), use a NetBSD-style kthread_create() interface. kproc_start is still available as a SYSINIT() hook. This allowed simplification of chunks of the sysinit code in the process. This kthread_create() is our old kproc_start internals, with the SYSINIT_KT fork hooks grafted in and tweaked to work the same as the NetBSD one. One thing I'd like to do shortly is get rid of nfsiod as a user initiated process. It makes sense for the nfs client code to create them on the fly as needed up to a user settable limit. This means that nfsiod doesn't need to be in /sbin and is always "available". This is a fair bit easier to do outside of the SYSINIT_KT() framework.
* Slight tweak to fork1() calling conventions. Add a third argument sopeter1999-06-301-3/+2
| | | | | | | | the caller can easily find the child proc struct. fork(), rfork() etc syscalls set p->p_retval[] themselves. Simplify the SYSINIT_KT() code and other kernel thread creators to not need to use pfind() to find the child based on the pid. While here, partly tidy up some of the fork1() code for RF_SIGSHARE etc.
* Convert buffer locking from using the B_BUSY and B_WANTED flags to usingmckusick1999-06-261-2/+2
| | | | | | | lockmgr locks. This commit should be functionally equivalent to the old semantics. That is, all buffer locking is done with LK_EXCLUSIVE requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will be done in future commits.
* Introduce the makebdev() function, it does the same as the makedev()phk1999-06-011-2/+2
| | | | function for now, but that will change.
* major(something) can never become NODEV.phk1999-05-091-4/+2
|
* I got tired of seeing all the cdevsw[major(foo)] all over the place.phk1999-05-081-2/+2
| | | | | | | | Made a new (inline) function devsw(dev_t dev) and substituted it. Changed to the BDEV variant to this format as well: bdevsw(dev_t dev) DEVFS will eventually benefit from this change too.
* remove b_proc from struct buf, it's (now) unused.phk1999-05-061-3/+3
| | | | Reviewed by: dillon, bde
OpenPOWER on IntegriCloud