summaryrefslogtreecommitdiffstats
path: root/sys/fs/fifofs
Commit message (Collapse)AuthorAgeFilesLines
* MFC r288044:kib2015-09-271-2/+9
| | | | | Ensure that when a blockable open of fifo returns success, a valid file descriptor opened for complimentary access exists as well.
* MFC r277321:kib2015-01-251-1/+7
| | | | | Make SIGSTOP working for sleeps done while waiting for fifo readers or writers in open(2), when the fifo is located on an NFS mount.
* MFC r265206:mjg2014-07-061-3/+1
| | | | | | | | Ignore the error from pipespace_new when creating a pipe. It can fail if pipe map is exhausted (as a result of too many pipes created), but it is not fatal and could be provoked by unprivileged users. The only consequence is worse performance with given pipe.
* MFC r259521:kib2013-12-241-1/+1
| | | | Do not allow O_EXEC opens for fifo, return EINVAL.
* I am comparing current pipe code with the one in 8.3-STABLE r236165,davidxu2012-07-311-17/+4
| | | | | | | | | | | | | | | | | | | | | | | | I found 8.3 is a history BSD version using socket to implement FIFO pipe, it uses per-file seqcount to compare with writer generation stored in per-pipe object. The concept is after all writers are gone, the pipe enters next generation, all old readers have not closed the pipe should get the indication that the pipe is disconnected, result is they should get EPIPE, SIGPIPE or get POLLHUP in poll(). But newcomer should not know that previous writters were gone, it should treat it as a fresh session. I am trying to bring back FIFO pipe to history behavior. It is still unclear that if single EOF flag can represent SBS_CANTSENDMORE and SBS_CANTRCVMORE which socket-based version is using, but I have run the poll regression test in tool directory, output is same as the one on 8.3-STABLE now. I think the output "not ok 18 FIFO state 6b: poll result 0 expected 1. expected POLLHUP; got 0" might be bogus, because newcomer should not know that old writers were gone. I got the same behavior on Linux. Our implementation always return POLLIN for disconnected pipe even it should return POLLHUP, but I think it is not wise to remove POLLIN for compatible reason, this is our history behavior. Regression test: /usr/src/tools/regression/poll
* When a thread is blocked in direct write state, it only sets PIPE_DIRECTWdavidxu2012-07-311-2/+8
| | | | | | | | | | | | | | | | | | | | | flag but not PIPE_WANTW, but FIFO pipe code does not understand this internal state, when a FIFO peer reader closes the pipe, it wants to notify the writer, it checks PIPE_WANTW, if not set, it skips calling wakeup(), so blocked writer never noticed the case, but in general, the writer should return from the syscall with EPIPE error code and may get SIGPIPE signal. Setting the PIPE_WANTW fixed problem, or you can turn off direct write, it should fix the problem too. This bug is found by PR/170203. Another bug in FIFO pipe code is when peer closes the pipe, another end which is being blocked in select() or poll() is not notified, it missed to call pipeselwakeup(). Third problem is found in poll regression test, the existing code can not pass 6b,6c,6d tests, but FreeBSD-4 works. This commit does not fix the problem, I still need to study more to find the cause. PR: 170203 Tested by: Garrett Copper < yanegomi at gmail dot com >
* Update comment.kib2012-03-111-1/+1
| | | | Submitted by: gianni
* Remove fifo.h. The only used function declaration from the header iskib2012-03-112-39/+0
| | | | | | migrated to sys/vnode.h. Submitted by: gianni
* The pipe_poll() performs lockless access to the vnode to testkib2012-03-072-14/+12
| | | | | | | | | | | | fifo_iseof() condition, allowing the v_fifoinfo to be reset and freed by fifo_cleanup(). Precalculate EOF at the places were fo_wgen is changed, and cache the state in a new pipe state flag PIPE_SAMEWGEN. Reported and tested by: bf Submitted by: gianni MFC after: 1 week (a backport)
* merge pipe and fifo implementationskmacy2012-02-232-403/+76
| | | | | | | | Also reviewed by: jhb, jilles (initial revision) Tested by: pho, jilles Submitted by: gianni Reviewed by: bde
* Initialize fifoinfo fi_wgen field on open. The only important is thekib2011-12-041-1/+1
| | | | | | | | difference between fi_wgen and f_seqcount, so the change is purely cosmetic, but it makes the code easier to understand. Submitted by: gianni MFC after: 2 weeks
* Add the fo_chown and fo_chmod methods to struct fileops and use themkib2011-08-161-0/+2
| | | | | | | | | | to implement fchown(2) and fchmod(2) support for several file types that previously lacked it. Add MAC entries for chown/chmod done on posix shared memory and (old) in-kernel posix semaphores. Based on the submission by: glebius Reviewed by: rwatson Approved by: re (bz)
* - Improve comments about locking of the "struct fifoinfo" which is a bitattilio2009-11-061-8/+9
| | | | | | | | unclear. - Fix a memory leak [0] [0] Diagnosed by: Dorr H. Clark <dclark at engr dot scu dot edu> MFC: 1 week
* Provide default implementation for VOP_ACCESS(9), so that filesystems whichtrasz2009-10-011-1/+0
| | | | | | | want to provide VOP_ACCESSX(9) don't have to implement both. Note that this commit makes implementation of either of these two mandatory. Reviewed by: kib
* Use C99 initialization for struct filterops.rwatson2009-09-121-6/+15
| | | | | | Obtained from: Mac OS X Sponsored by: Apple Inc. MFC after: 3 weeks
* Fix poll() on half-closed sockets, while retaining POLLHUP for fifos.jilles2009-08-251-0/+3
| | | | | | | | | | | | | This reverts part of r196460, so that sockets only return POLLHUP if both directions are closed/error. Fifos get POLLHUP by closing the unused direction immediately after creating the sockets. The tools/regression/poll/*poll.c tests now pass except for two other things: - if POLLHUP is returned, POLLIN is always returned as well instead of only when there is data left in the buffer to be read - fifo old/new reader distinction does not work the way POSIX specs it Reviewed by: kib, bde
* Fix poll(2) and select(2) for named pipes to return "ready for read"kib2009-07-071-20/+14
| | | | | | | | | | | | | | | | | when all writers, observed by reader, exited. Use writer generation counter for fifo, and store the snapshot of the fifo generation in the f_seqcount field of struct file, that is otherwise unused for fifos. Set FreeBSD-undocumented POLLINIGNEOF flag only when file f_seqcount is equal to fifo' fi_wgen, and revert r89376. Fix POLLINIGNEOF for sockets and pipes, and return POLLHUP for them. Note that the patch does not fix not returning POLLHUP for fifos. PR: kern/94772 Submitted by: bde (original version) Reviewed by: rwatson, jilles Approved by: re (kensmith) MFC after: 6 weeks (might be)
* s/a_fdidx/a_fp/ for VOP_OPEN comments that inline struct vop_open_argskib2009-06-101-1/+1
| | | | | | | definition. Discussed with: bde MFC after: 2 weeks
* Remove unused VOP_IOCTL and VOP_KQFILTER implementations for fifofs.kib2009-06-101-40/+2
| | | | MFC after: 2 weeks
* Remove VOP_LEASE and supporting functions. This hasn't been used sincerwatson2009-04-101-1/+0
| | | | | | | | | | | | | | the removal of NQNFS, but was left in in case it was required for NFSv4. Since our new NFSv4 client and server can't use it for their requirements, GC the old mechanism, as well as other unused lease- related code and interfaces. Due to its impact on kernel programming and binary interfaces, this change should not be MFC'd. Proposed by: jeff Reviewed by: jeff Discussed with: rmacklem, zach loafman @ isilon
* Tweak the output of VOP_PRINT/vn_printf() some.jhb2009-02-061-0/+1
| | | | | | | | - Align the fifo output in fifo_print() with other vn_printf() output. - Remove the leading space from lockmgr_printinfo() so its output lines up in vn_printf(). - lockmgr_printinfo() now ends with a newline, so remove an extra newline from vn_printf().
* Assert an exclusive vnode lock for fifo_cleanup() and fifo_close() sincejhb2009-01-281-2/+2
| | | | | | they change v_fifoinfo. Discussed with: ups (a while ago)
* The kernel may do unbalanced calls to fifo_close() for fifo vnode,kib2009-01-261-1/+4
| | | | | | | | | | | | | without corresponding number of fifo_open(). This causes assertion failure in fifo_close() due to vp->v_fifoinfo being NULL for kernel with INVARIANTS, or NULL pointer dereference otherwise. In fact, we may ignore excess calls to fifo_close() without bad consequences. Turn KASSERT() into the return, and print warning for now. Tested by: pho Reviewed by: rwatson MFC after: 2 weeks
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).des2008-10-231-2/+2
| | | | MFC after: 3 months
* Remove kernel support for M:N threading.jeff2008-03-121-1/+1
| | | | | | | | While the KSE project was quite successful in bringing threading to FreeBSD, the M:N approach taken by the kse library was never developed to its full potential. Backwards compatibility will be provided via libmap.conf for dynamically linked binaries and static binaries will be broken.
* Remove Giant acquisition around soreceive() and sosend() in fifofs. Therwatson2008-01-261-10/+4
| | | | | | | | | bug that caused us to reintroduce it is believed to be fixed, and Kris says he no longer sees problems with fifofs in highly parallel builds. If this works out, we'll MFC it for 7.1. MFC after: 3 months Pointed out by: kris
* 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.
OpenPOWER on IntegriCloud