summaryrefslogtreecommitdiffstats
path: root/sys/fs/fifofs
Commit message (Collapse)AuthorAgeFilesLines
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-131-2/+2
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* vn_lock() is currently only used with the 'curthread' passed as argument.attilio2008-01-101-2/+2
| | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com>
* Make ftruncate a 'struct file' operation rather than a vnode operation.jhb2008-01-071-0/+9
| | | | | | | | | | | | | | This makes it possible to support ftruncate() on non-vnode file types in the future. - 'struct fileops' grows a 'fo_truncate' method to handle an ftruncate() on a given file descriptor. - ftruncate() moves to kern/sys_generic.c and now just fetches a file object and invokes fo_truncate(). - The vnode-specific portions of ftruncate() move to vn_truncate() in vfs_vnops.c which implements fo_truncate() for vnode file types. - Non-vnode file types return EINVAL in their fo_truncate() method. Submitted by: rwatson
* Remove explicit locking of struct file.jeff2007-12-301-4/+1
| | | | | | | | | | | | | - Introduce a finit() which is used to initailize the fields of struct file in such a way that the ops vector is only valid after the data, type, and flags are valid. - Protect f_flag and f_count with atomic operations. - Remove the global list of all files and associated accounting. - Rewrite the unp garbage collection such that it no longer requires the global list of all files and instead uses a list of all unp sockets. - Mark sockets in the accept queue so we don't incorrectly gc them. Tested by: kris, pho
* When we do open, we should lock the vnode exclusively. This fixes few races:pjd2007-07-261-1/+1
| | | | | | | | | | - fifo race, where two threads assign v_fifoinfo, - v_writecount modifications, - v_object modifications, - and probably more... Discussed with: kib, ups Approved by: re (rwatson)
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-4/+3
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* Replace custom file descriptor array sleep lock constructed using a mutexrwatson2007-04-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and flags with an sxlock. This leads to a significant and measurable performance improvement as a result of access to shared locking for frequent lookup operations, reduced general overhead, and reduced overhead in the event of contention. All of these are imported for threaded applications where simultaneous access to a shared file descriptor array occurs frequently. Kris has reported 2x-4x transaction rate improvements on 8-core MySQL benchmarks; smaller improvements can be expected for many workloads as a result of reduced overhead. - Generally eliminate the distinction between "fast" and regular acquisisition of the filedesc lock; the plan is that they will now all be fast. Change all locking instances to either shared or exclusive locks. - Correct a bug (pointed out by kib) in fdfree() where previously msleep() was called without the mutex held; sx_sleep() is now always called with the sxlock held exclusively. - Universally hold the struct file lock over changes to struct file, rather than the filedesc lock or no lock. Always update the f_ops field last. A further memory barrier is required here in the future (discussed with jhb). - Improve locking and reference management in linux_at(), which fails to properly acquire vnode references before using vnode pointers. Annotate improper use of vn_fullpath(), which will be replaced at a future date. In fcntl(), we conservatively acquire an exclusive lock, even though in some cases a shared lock may be sufficient, which should be revisited. The dropping of the filedesc lock in fdgrowtable() is no longer required as the sxlock can be held over the sleep operation; we should consider removing that (pointed out by attilio). Tested by: kris Discussed with: jhb, kris, attilio, jeff
* Change fifo_printinfo to check if the vnode v_fifoinfo pointermpp2007-03-021-0/+4
| | | | is NULL and print a message to that effect to prevent a panic.
* Add a_fdidx to comment prototype for fifo_open().rwatson2006-03-151-0/+1
| | | | | MFC after: 3 days Submitted by: Kostik Belousov <kostikbel at gmail dot com>
* If fifo_open() is called with a negative file descriptor, return EINVALrwatson2006-03-141-0/+2
| | | | | | | | | | | rather than panicking later. This can occur if the kernel calls vn_open() on a fifo, as there will be no associated file descriptor, and therefore the file descriptor operations cannot be modified to point to the fifo operation set. MFC after: 3 days Reported by: Martin <nakal at nurfuerspam dot de> PR: 94278
* Second attempt at a work-around for fifo-related socket panics duringrwatson2005-10-011-0/+4
| | | | | | | | make -j with high levels of parallelism: acquire Giant in fifo I/O routines. Discussed with: ups MFC after: 3 days
* Back out fifo_vnops.c:1.127, which introduced an sx lock around I/O onrwatson2005-09-271-16/+3
| | | | | | | | | a fifo. While this did indeed close the race, confirming suspicions about the nature of the problem, it causes difficulties with blocking I/O on fifos. Discussed with: ups Also spotted by: Peter Holm <peter at holm dot cc>
* Assert v_fifoinfo is non-NULL in fifo_close() in order to catchrwatson2005-09-261-0/+1
| | | | | | | non-conforming cases sooner. MFC after: 3 days Reported by: Peter Holm <peter at holm dot cc>
* Lock the read socket receive buffer when frobbing the sb_state flag onrwatson2005-09-251-2/+2
| | | | | | | | | that socket during open, not the write socket receive buffer. This might explain clearing of the sb_state SB_LOCK flag seen occasionally in soreceive() on fifos. MFC after: 3 days Spotted by: ups
* For reasons of consistency (and necessity), assert an exclusive vnoderwatson2005-09-231-0/+1
| | | | | | | lock on the fifo vnode in fifo_open(): we rely on the vnode lock to serialize access to v_fifoinfo. MFC after: 3 days
* Add fi_sx, an sx lock to serialize I/O operations on the socket pairrwatson2005-09-221-3/+16
| | | | | | | | | | | | | | | | | | | | underlying the POSIX fifo implementation. In 6.x/7.x, fifo access is moved from the VFS layer, where it was serialized using the vnode lock, to the file descriptor layer, where access is protected by a reference count but not serialized. This exposed socket buffer locking to high levels of parallelism in specific fifo workloads, such as make -j 32, which expose as yet unresolved socket buffer bugs. fi_sx re-adds serialization about the read and write routines, although not paths that simply test socket buffer mbuf queue state, such as the poll and kqueue methods. This restores the extra locking cost previously present in some cases, but is an effective workaround for the instability that has been experienced. This workaround should be removed once the bug in socket buffer handling has been fixed. Reported by: kris, jhb, Julien Gabel <jpeg at thilelli dot net>, Peter Holm <peter at holm dot cc>, others MFC after: 3 days
* Assert that (vp) is locked in fifo_close(), since we rely on therwatson2005-09-181-0/+1
| | | | | | | exclusive vnode lock to synchronize the reference counts on struct fifoinfo. MFC after: 3 days
* The socket pointers in fifoinfo are not permitted to be NULL, sorwatson2005-09-151-5/+2
| | | | | | don't check if they are, it just confuses the fifo code more. MFC after: 3 days
* Trim down now (believed to be) unused fifo_ioctl() andrwatson2005-09-131-65/+75
| | | | | | | | | | | | | | | | | | | | | | fifo_kqfilter() VOP implementations, since they in theory are used only on open file descriptors, in which case the ioctls are via fifo_ioctl_f() and kqueue requests are via fifo_kqfilter_f(). Generate warnings if they are entered for now. These printf() calls should become panic() calls. Annotate and re-implement fifo_ioctl_f(): don't arbitrarily forward ioctls to the socket layer, only forward the ones we explicitly support for fifos. In the case of FIONREAD, don't forward the request to the write socket on a read-write fifo, or the read result is overwritten. Annotate a nasty case for the undefined POSIX O_RDWR on fifos, in which failure of the second ioctl will result in the socket pair being in an inconsistent state. Assert copyright as I find myself rewriting non-trivial parts of fifofs. MFC after: 3 days
* As a result of kqueue locking work, socket buffer locks will alwaysrwatson2005-09-131-18/+6
| | | | | | | | be held when entering a kqueue filter for fifos via a socket buffer event: as such, assert the lock unconditionally rather than acquiring it conditionall. MFC after: 3 days
* Annotate two issues:rwatson2005-09-131-0/+12
| | | | | | | | | | | | 1) fifo_kqfilter() is not actually ever used, it likely should be GC'd. 2) fifo_kqfilter_f() doesn't implement EVFILT_VNODE, so detecting events on the underlying vnode for a fifo no longer works (it did in 4.x). Likely, fifo_kqfilter_f() should forward the request to the VFS using fp->f_vnode, which would work once fifo_kqfilter() was detached from the vnode operation vector (removing the fifo override). Discussed with: phk
* Introduce no-op nosup fifo kqueue filter and detach routine, which arerwatson2005-09-121-1/+33
| | | | | | | | | | | | | | | | used when a read filter is requested on a write-only fifo descriptor, or a write filter is requested on a read-only fifo descriptor. This permits the filters to be registered, but never raises the event, which causes kqueue behavior for fifos to more closely match similar semantics for poll and select, which permit testing for the condition even though the condition will never be raised, and is consistent with POSIX's notion that a fifo has identical semantics to a one-way IPC channel created using pipe() on most operating systems. The fifo regression test suite can now run to completion on HEAD without errors. MFC after: 3 days
* When a request is made to register a filter on a fifo that doesn'trwatson2005-09-121-2/+2
| | | | | | | apply to the fifo (i.e., not EVFILT_READ or EVFILT_WRITE), reject it as EINVAL, not by returning 1 (EPERM). MFC after: 3 days
* Remove DFLAG_SEEKABLE from fifo file descriptors: fifos are not seekablerwatson2005-09-121-1/+1
| | | | | | according to POSIX, not to mention the fact that it doesn't make sense (and hence isn't really implemented). This causes the fifo_misc regression test to succeed.
* Only poll the fifo for read events if the fifo is attached to a readablerwatson2005-09-121-2/+2
| | | | | | | | | | | | | | file descriptor. Otherwise, the read end of a fifo might return that it is writable (which it isn't). Only poll the fifo for write events if the fifo attached to a writable file descriptor. Otherwise, the write end of a fifo might return that it is readable (which it isn't). In the event that a file is FREAD|FWRITE (which is allowed by POSIX, but has undefined behavior), we poll for both. MFC after: 3 days
* After going to some trouble to identify only the write-related eventsrwatson2005-09-121-2/+2
| | | | | | | | | to poll the write socket for, the fifo polling code proceeded to poll for the complete set of events. Use 'levents' instead of 'events' as the argument to poll, and only poll the write socket if there is interest in write events. MFC after: 3 days
* When a writer opens a fifo, wake up the read socket for read, not therwatson2005-09-121-1/+1
| | | | | | write socket. MFC after: 3 days
* Add an assertion that fifo_open() doesn't race against other threadsrwatson2005-09-121-0/+2
| | | | | | | while sleeping to allocate fifo state: due to using the vnode lock to serialize access to a fifo during open, it shouldn't happen (tm). MFC after: 3 days
* Rather than reaching into the internals of the UNIX domain socket coderwatson2005-09-121-1/+1
| | | | | | | by calling uipc_connect2() to connect two socket endpoints to create a fifo, call soconnect2(). MFC after: 3 days
* - The VI_DOOMED flag now signals the end of a vnode's relationship withjeff2005-03-131-4/+0
| | | | | | | | the filesystem. Check that rather than VI_XLOCK. - VOP_INACTIVE should no longer drop the vnode lock. - The vnode lock is required around calls to vrecycle() and vgone(). Sponsored by: Isilon Systems, Inc.
* Whitespace in vop_vector{} initializations.phk2005-01-131-0/+1
|
* /* -> /*- for copyright notices, minor format tweaks as necessaryimp2005-01-062-2/+2
|
* Don't forget to bypass vnodes in corner cases.phk2004-12-131-8/+6
| | | | | Found by: kkenn and ports/shell/zsh Thanks to: jeffr
* Explicitly panic vop_read/vop_write on fifos.phk2004-12-131-0/+2
|
* Back when VOP_* was introduced, we did not have new-style structphk2004-12-012-43/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initializations but we did have lofty goals and big ideals. Adjust to more contemporary circumstances and gain type checking. Replace the entire vop_t frobbing thing with properly typed structures. The only casualty is that we can not add a new VOP_ method with a loadable module. History has not given us reason to belive this would ever be feasible in the the first place. Eliminate in toto VOCALL(), vop_t, VNODEOP_SET() etc. Give coda correct prototypes and function definitions for all vop_()s. Generate a bit more data from the vnode_if.src file: a struct vop_vector and protype typedefs for all vop methods. Add a new vop_bypass() and make vop_default be a pointer to another struct vop_vector. Remove a lot of vfs_init since vop_vector is ready to use from the compiler. Cast various vop_mumble() to void * with uppercase name, for instance VOP_PANIC, VOP_NULL etc. Implement VCALL() by making vdesc_offset the offsetof() the relevant function pointer in vop_vector. This is disgusting but since the code is generated by a script comparatively safe. The alternative for nullfs etc. would be much worse. Fix up all vnode method vectors to remove casts so they become typesafe. (The bulk of this is generated by scripts)
* Mechanically change prototypes for vnode operations to use the new typedefs.phk2004-12-011-7/+7
|
* Add dropped implementation of ioctl for fifos.phk2004-11-181-1/+20
|
* Make vnode bypass for fifos (read, write, poll) mandatory.phk2004-11-171-133/+6
|
* Add file ops to fifofs so that we can bypass vnodes (and Giant) for thephk2004-11-151-1/+164
| | | | | | heavy-duty operations (read, write, poll/select, kqueue). Disabled for now, enable with "vfs.fifofs.fops=1" in loader.conf.
* fifos doesn't need a vop_lookup, the default will do fine.phk2004-11-131-19/+0
|
* Properly implement a default version of VOP_GETWRITEMOUNT.phk2004-11-061-1/+0
| | | | | Remove improper access to vop_stdgetwritemount() which should and will instead rely on the VOP default path.
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-5/+5
| | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
* Remove unlocked read annotation for sbspace(); the read is locked.rwatson2004-06-231-1/+0
|
* Merge some additional leaf node socket buffer locking fromrwatson2004-06-181-6/+27
| | | | | | | | | | | | | | | | | | | | | rwatson_netperf: Introduce conditional locking of the socket buffer in fifofs kqueue filters; KNOTE() will be called holding the socket buffer locks in fifofs, but sometimes the kqueue() system call will poll using the same entry point without holding the socket buffer lock. Introduce conditional locking of the socket buffer in the socket kqueue filters; KNOTE() will be called holding the socket buffer locks in the socket code, but sometimes the kqueue() system call will poll using the same entry points without holding the socket buffer lock. Simplify the logic in sodisconnect() since we no longer need spls. NOTE: To remove conditional locking in the kqueue filters, it would make sense to use a separate kqueue API entry into the socket/fifo code when calling from the kqueue() system call.
* Merge additional socket buffer locking from rwatson_netperf:rwatson2004-06-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | - Lock down low hanging fruit use of sb_flags with socket buffer lock. - Lock down low hanging fruit use of so_state with socket lock. - Lock down low hanging fruit use of so_options. - Lock down low-hanging fruit use of sb_lowwat and sb_hiwat with socket buffer lock. - Annotate situations in which we unlock the socket lock and then grab the receive socket buffer lock, which are currently actually the same lock. Depending on how we want to play our cards, we may want to coallesce these lock uses to reduce overhead. - Convert a if()->panic() into a KASSERT relating to so_state in soaccept(). - Remove a number of splnet()/splx() references. More complex merging of socket and socket buffer locking to follow.
* Grab the socket buffer send or receive mutex when performing arwatson2004-06-151-0/+6
| | | | | | read-modify-write on the sb_state field. This commit catches only the "easy" ones where it doesn't interact with as yet unmerged locking.
* The socket field so_state is used to hold a variety of socket relatedrwatson2004-06-141-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | flags relating to several aspects of socket functionality. This change breaks out several bits relating to send and receive operation into a new per-socket buffer field, sb_state, in order to facilitate locking. This is required because, in order to provide more granular locking of sockets, different state fields have different locking properties. The following fields are moved to sb_state: SS_CANTRCVMORE (so_state) SS_CANTSENDMORE (so_state) SS_RCVATMARK (so_state) Rename respectively to: SBS_CANTRCVMORE (so_rcv.sb_state) SBS_CANTSENDMORE (so_snd.sb_state) SBS_RCVATMARK (so_rcv.sb_state) This facilitates locking by isolating fields to be located with other identically locked fields, and permits greater granularity in socket locking by avoiding storing fields with different locking semantics in the same short (avoiding locking conflicts). In the future, we may wish to coallesce sb_state and sb_flags; for the time being I leave them separate and there is no additional memory overhead due to the packing/alignment of shorts in the socket buffer structure.
* Add MSG_NBIO flag option to soreceive() and sosend() that causestruckman2004-06-011-12/+6
| | | | | | | | | | | | them to behave the same as if the SS_NBIO socket flag had been set for this call. The SS_NBIO flag for ordinary sockets is set by fcntl(fd, F_SETFL, O_NONBLOCK). Pass the MSG_NBIO flag to the soreceive() and sosend() calls in fifo_read() and fifo_write() instead of frobbing the SS_NBIO flag on the underlying socket for each I/O operation. The O_NONBLOCK flag is a property of the descriptor, and unlike ordinary sockets, fifos may be referenced by multiple descriptors.
* Switch from using the vnode interlock to a private mutex in fifo_open()truckman2004-05-171-24/+23
| | | | | | | | to avoid lock order problems when manipulating the sockets associated with the fifo. Minor optimization of a couple of calls to fifo_cleanup() from fifo_open().
* Remove advertising clause from University of California Regent'simp2004-04-072-8/+0
| | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson
OpenPOWER on IntegriCloud