summaryrefslogtreecommitdiffstats
path: root/sys/nfs (follow)
Commit message (Collapse)AuthorAgeFilesLines
* spellingjsg2021-03-114-9/+9
|
* nfs/nfs_boot.c: convert ifunit() to if_unit(9)mvs2021-01-191-2/+3
| | | | ok dlg@
* nfs: don't sleep on lboltcheloha2021-01-022-6/+7
| | | | | | | We can simulate the current behavior without lbolt by sleeping for 1 second on the &nowake channel. ok mpi@
* Refactor klist insertion and removalvisa2020-12-251-3/+3
| | | | | | | | | | | | Rename klist_{insert,remove}() to klist_{insert,remove}_locked(). These functions assume that the caller has locked the klist. The current state of locking remains intact because the kernel lock is still used with all klists. Add new functions klist_insert() and klist_remove() that lock the klist internally. This allows some code simplification. OK mpi@
* In the previous commit, check tv_nsec, not tv_sec as VNOVAL is amatthieu2020-09-271-3/+3
| | | | | valid valuse of tv_sec but an invalid value for tv_nsec. Noticed by guenther@. ok beck@ deraadt@
* nfs_create: after an exclusive create rpc, make sure to updatematthieu2020-09-271-2/+9
| | | | | | | | | timestamps. This issue was iscovered after rsync 3.2 changed behaviour on an NFS mounted partition.. Change lifted from NetBSD (r 1.204). ok beck@, kn@, deraadt@
* According the code `nfsbootdevname' is always set to network device namemvs2020-08-241-11/+3
| | | | | | | | | we expected. Remove the `else' path from nfs_boot_init(). If `nfsbootdevname' is not set something goes wrong and this is the panic condition. Also we exclude the case where we can get `ifp' which we don't expect. OK mpi@
* kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha2020-06-242-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
* Rename poll-compatibility flag to better reflect what it is.mpi2020-06-111-4/+4
| | | | | | While here prefix kernel-only EV flags with two underbars. Suggested by kettenis@, ok visa@
* Use a new EV_OLDAPI flag to match the behavior of poll(2) and select(2).mpi2020-06-081-9/+64
| | | | | | | | | Adapt FS kqfilters to always return true when the flag is set and bypass the polling mechanism of the NFS thread. While here implement a write filter for NFS. ok visa@
* Abstract the head of knote lists. This allows extending the lists,visa2020-04-071-3/+3
| | | | | | for example, with locking assertions. OK mpi@, anton@
* Replace field f_isfd with field f_flags in struct filterops to allowvisa2020-02-201-3/+3
| | | | | | adding more filter properties without cluttering the struct. OK mpi@, anton@
* sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@cheloha2020-01-212-17/+15
|
* struct vops is not modified during runtime so use const which moves eachclaudio2020-01-203-9/+9
| | | | | into read-only data segment. OK deraadt@ tedu@
* Keep socket timeout intervals in nsecs and use them with tsleep_nsec(9).mpi2020-01-152-8/+9
| | | | | | | | | | | | | | Introduce and use TIMEVAL_TO_NSEC() to convert SO_RCVTIMEO/SO_SNDTIMEO specified values into nanoseconds. As a side effect it is now possible to specify a timeout larger that (USHRT_MAX / 100) seconds. To keep code simple `so_linger' now represents a number of seconds with 0 meaning no timeout or 'infinity'. Yes, the 0 -> INFSLP API change makes conversions complicated as many timeout holders are still memset()'d. Inputs from cheloha@ and bluhm@, ok bluhm@
* In nfs_clearcommit() the loops over mnt_vnodelist and v_dirtyblkhdbluhm2020-01-141-5/+5
| | | | | | do not delete anything. So the safe variant of foreach is not necessary. OK mpi@ millert@ tedu@
* Convert the vnode list at the mount point into a tailq. Duringbluhm2020-01-102-4/+4
| | | | | | | | | | | | unmount this list is traversed and the dirty vnodes are flushed to disk. Forced unmount expects that the list is empty after flushing, otherwise the kernel panics with "dangling vnode". As the write to disk can sleep, new vnodes may be inserted. If softdep is enabled, resolving the dependencies creates new dirty vnodes and inserts them to the list. To fix the panic, let insmntque() insert new vnodes at the tail of the list. Then vflush() will still catch them while traversing the list in forward direction. OK tedu@ millert@ visa@
* Convert infinite sleeps to tsleep_nsec(9).mpi2020-01-081-3/+2
| | | | ok bluhm@
* Use C99 designated initializers with struct filterops. In addition,visa2019-12-311-5/+14
| | | | | | make the structs const so that the data are put in .rodata. OK mpi@, deraadt@, anton@, bluhm@
* Convert struct vfsops initializer to C99 style.bluhm2019-12-261-14/+14
| | | | OK visa@
* Use FOREACH macro to iterate over mnt_vnodelist.bluhm2019-12-251-3/+2
| | | | OK millert@ visa@ benno@
* Convert infinite sleeps to tsleep_nsec(9).mpi2019-12-055-14/+14
| | | | ok jca@
* Allow concurrent reads of the f_offset field of struct file byanton2019-08-051-2/+2
| | | | | | | | | serializing both read/write operations using the existing file mutex. The vnode lock still grants exclusive write access to the offset; the mutex is only used to make the actual write atomic and prevent any concurrent reader from observing intermediate values. ok mpi@ visa@
* vinvalbuf(9): tlseep -> tsleep_nsec(9); ok millert@cheloha2019-07-251-7/+10
|
* vwaitforio(9): tsleep(9) -> tsleep_nsec(9); ok visa@cheloha2019-07-191-6/+7
|
* getblk(9): tsleep(9) -> tsleep_nsec(9); ok visa@cheloha2019-07-191-4/+4
|
* Revert anton@ changes about read/write unlockingsolene2019-07-121-2/+2
| | | | | | https://marc.info/?l=openbsd-cvs&m=156277704122293&w=2 ok anton@
* Make read/write of the f_offset field belonging to struct file MP-safe;anton2019-07-101-2/+2
| | | | | | | | | | | | | | | | as part of the effort to unlock the kernel. Instead of relying on the vnode lock, introduce a dedicated lock per file. Exclusive write access is granted using the new foffset_enter and foffset_leave API. A convenience function foffset_get is also available for threads that only need to read the current offset. The lock acquisition order in vn_write has been changed to match the one in vn_read in order to avoid a potential deadlock. This change also gets rid of a documented race in vn_read(). Inspired by the FreeBSD implementation. With help and ok mpi@ visa@
* When killing a process, the signal is handled by any thread thatbluhm2019-05-131-4/+3
| | | | | | | | | | does not block the signal. If all threads block the signal, we delivered it to the main thread. This does not conform to POSIX. If any thread unblocks the signal, it should be delivered immediately to this thread. Mark such signals pending at the process instead of a single thread. Then any thread can handle it later. OK kettenis@ guenther@
* The kernel interpreted bogus lengths in RPC calls during NFS boot.bluhm2019-01-221-8/+31
| | | | | | | | A malicious rpc.bootparamd could corrupt memory, but the kernel has to trust the local network anyway in a diskless environment. Now in case of an RPC error, the kernel will stop booting with a specific panic. OK claudio@ beck@
* Introduce a dedicated entry point data structure for file locks. This new dataanton2019-01-211-2/+2
| | | | | | | | | | | | structure allows for better tracking of pending lock operations which is essential in order to prevent a use-after-free once the underlying vnode is gone. Inspired by the lockf implementation in FreeBSD. ok visa@ Reported-by: syzbot+d5540a236382f50f1dac@syzkaller.appspotmail.com
* Move boottime into the timehands.cheloha2019-01-191-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To protect the timehands we first need to protect the basis for all UTC time in the kernel: the boottime. Because the boottime can be changed at any time it needs to be versioned along with the other members of the timehands to enable safe lockless reads when using it for anything. So the global boottime timespec goes away and the static boottimebin becomes a member of the timehands. Instead of reading the global boottime you use one of two interfaces: binboottime(9) or microboottime(9). nanoboottime(9) can trivially be added later, though there are no consumers for it at the moment. This introduces one small change in behavior. We used to advance the reported boottime just before launching kernel threads from main(). This makes it look to userland like we "booted" moments before those threads were launched. Because there is no longer a boottime global we can no longer trivially do this from main(), so the boottime we report to userspace via e.g. kern.boottime will now reflect whatever the time was when we bootstrapped the timehands via inittodr(9). This is usually no more than a minute before the kernel threads are launched from main(). The prior behavior can be restored by adding a new interface to the timecounter layer in a future commit. Based on FreeBSD r303387. Discussed with mpi@ and visa@. ok visa@
* Check for negative length in NFS strings. This affects both, thebluhm2019-01-181-2/+2
| | | | | client and server. OK beck@
* Check for negative length integers in NFS server. A maliciousbluhm2019-01-181-10/+11
| | | | | client could crash the server. OK tedu@
* Check for negative length integers in NFS client. A maliciousbluhm2019-01-181-3/+4
| | | | | server could confuse the client file system code. OK beck@
* Switch MH_ALIGN to m_align which is the same.claudio2018-11-301-2/+2
| | | | OK bluhm@
* M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers forclaudio2018-11-093-9/+9
| | | | | | m_leadingspace() and m_trailingspace(). Convert all callers to call directly the functions and remove the defines. OK krw@, mpi@
* Instead of calculating the mbuf packet header length here and there,bluhm2018-09-102-18/+5
| | | | | | put the algorithm into a new function m_calchdrlen(). Also set an uninitialized m_len to 0 in NFS code. OK claudio@
* Use FNONBLOCK instead of SS_NBIO to check/indicate that the I/O modempi2018-07-303-6/+6
| | | | | | | | | | | | | for sockets is non-blocking. This allows us to G/C SS_NBIO. Having to keep the two flags in sync in a mp-safe way is complicated. This change introduce a behavior change in sosplice(), it can now always block. However this should not matter much due to the socket lock being taken beforhand. ok bluhm@, benno@, visa@
* Nuke unused define 'nfsm_writereply()'.krw2018-07-091-11/+1
| | | | ok beck@ deraadt@ guenther@ mpi@
* Use more list macros for v_dirtyblkhd.bluhm2018-07-023-15/+10
| | | | OK mpi@
* Drop redundant "node == parent node" checks from VOP_RMDIR()visa2018-06-211-8/+1
| | | | | | implementations. Rely on the VFS layer to do the checking. OK mpi@, helg@
* Make the VFS layer responsible for preventing the deletionvisa2018-06-131-1/+8
| | | | | | of mounted on directories. OK guenther@, mpi@
* Make callers of VOP_CREATE(9) and VOP_MKNOD(9) responsible forvisa2018-06-072-10/+10
| | | | | | unlocking the directory vnode. OK mpi@, helg@
* Pass the socket to sounlock(), this prepare the terrain for per-socketmpi2018-06-063-12/+12
| | | | | | locking. ok visa@, bluhm@
* Drop unnecessary `p' parameter from vget(9).visa2018-05-272-5/+4
| | | | OK mpi@
* Implement proper locking for NFS nodes.mpi2018-05-053-15/+69
| | | | Tested in bulks by many. ok visa@, beck@
* After unmount nfs_timer() could access the freed memory of structbluhm2018-05-041-2/+15
| | | | | | | nfsmount. Delay the free(9) of the nfs mount point data until pending or sleeping timeouts have finished by running it on the softclock thread. OK visa@
* Remove proc from the parameters of vn_lock(). The parameter isvisa2018-05-023-10/+9
| | | | | | unnecessary because curproc always does the locking. OK mpi@
* Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysvisa2018-04-285-17/+16
| | | | | | | curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@