1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-03 06:45:37 -08:00
Commit Graph

151 Commits

Author SHA1 Message Date
jsg
d2b6e45e60 move some server only functions from nfs_subs.c to nfs_srvsubs.c
saves space on ramdisks that have option NFSCLIENT

initial diff from and ok miod@
2024-09-09 03:50:14 +00:00
mglocker
9593dc34da Fix some spelling.
Input and ok jmc@, jsg@
2024-09-04 07:54:51 +00:00
jsg
564dba153a remove unneeded includes
ok miod@ mpi@
2024-05-01 13:15:59 +00:00
miod
45db009a9c Constify NFS data whenever possible. Also make a few more const data static.
ok jsg@ semarie@
2024-04-30 17:05:20 +00:00
miod
a43f2b810b Convert all the NFS macros (in nfsm_subs.h) into inline functions with the
appropriate extra arguments.

This (hopefully) completes the unmessyfication work started by thib@ a long,
long time ago (in a galaxy far away).

The conversion logic has been:
- nfsm_dissect has been turned into an rvalue expression, leaving the
  cast operation up to its caller.
- macros which had three different exit paths (return, goto nfsmout or
  fallthrough) have been split so that no macros have more than two exit paths.
- then they have been modified to return a value, which lets the caller
  figure out what exit path is needed.
- local variables abused by the macros are now local variables of the new
  inline functions.

This single commit is the sum of 25 intermediate diffs, which have all been
carefully reviewed by (at least) jsg@ and semarie@.

Tested with v2 and v3 servers and clients.

ok jsg@ semarie@
2024-04-30 17:04:23 +00:00
mbuhl
78a2c979ca fixup previous refactoring
OK stsp@ (without assuming any responsibility for NFS)
2022-01-12 20:17:08 +00:00
jsg
0d297f4756 spelling
ok jmc@
2022-01-11 03:13:58 +00:00
cheloha
3209772dfc kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(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@
2020-06-24 22:03:40 +00:00
claudio
2d6b9e38f3 struct vops is not modified during runtime so use const which moves each
into read-only data segment.
OK deraadt@ tedu@
2020-01-20 23:21:55 +00:00
bluhm
d65b7ceb89 In nfs_clearcommit() the loops over mnt_vnodelist and v_dirtyblkhd
do not delete anything.  So the safe variant of foreach is not
necessary.
OK mpi@ millert@ tedu@
2020-01-14 21:38:02 +00:00
bluhm
a2b5c9223f Convert the vnode list at the mount point into a tailq. During
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@
2020-01-10 10:33:34 +00:00
bluhm
638b8534bb Use FOREACH macro to iterate over mnt_vnodelist.
OK millert@ visa@ benno@
2019-12-25 12:31:12 +00:00
claudio
fc97872292 Switch MH_ALIGN to m_align which is the same.
OK bluhm@
2018-11-30 09:24:57 +00:00
claudio
b5b7f62e3c M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers for
m_leadingspace() and m_trailingspace(). Convert all callers to call
directly the functions and remove the defines.
OK krw@, mpi@
2018-11-09 14:14:31 +00:00
bluhm
3ae16189a6 Use more list macros for v_dirtyblkhd.
OK mpi@
2018-07-02 20:56:22 +00:00
visa
36bb23f12a Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is always
curproc that does the locking or unlocking, so the proc parameter
is pointless and can be dropped.

OK mpi@, deraadt@
2018-04-28 03:13:04 +00:00
deraadt
f46da43846 Remove old deactivated pledge path code. A replacement mechanism is
being brewed.
ok beck
2017-08-29 02:51:27 +00:00
mpi
fe1f2e8dc0 Keep local definitions local.
"good work" deraadt@, ok visa@
2017-02-22 11:42:46 +00:00
dlg
1378bae268 all pools have their ipl set via pool_setipl, so fold it into pool_init.
the ioff argument to pool_init() is unused and has been for many
years, so this replaces it with an ipl argument. because the ipl
will be set on init we no longer need pool_setipl.

most of these changes have been done with coccinelle using the spatch
below. cocci sucks at formatting code though, so i fixed that by hand.

the manpage and subr_pool.c bits i did myself.

ok tedu@ jmatthew@

@ipl@
expression pp;
expression ipl;
expression s, a, o, f, m, p;
@@
-pool_init(pp, s, a, o, f, m, p);
-pool_setipl(pp, ipl);
+pool_init(pp, s, a, ipl, f, m, p);
2016-09-15 02:00:16 +00:00
dlg
e297897fd5 pool_setipl for nfs pools
ok natano@
2016-08-30 07:12:49 +00:00
beck
9b247b225e Fix some gibbering horrors due to uninitialized struct nameidata's
1) turn NDINITAT into a function and make the macros point to it
with the later goal of getting rid of them.

2) Sweep the kernel for places where people make a struct nameidata manually
on the stack and fill in what they hope are the required fields and count
on prayer and clean living to always get them right. Instead use NDINIT
everywhere. NFS was especially bad for this and there have likely
been things lurking there for a while.

3) Add a couple of strategic KASSERT's to catch future offenders.

ok krw@ sthen@ deraadt@
2016-04-29 14:40:36 +00:00
natano
937fcae7c6 Remove the unused flags argument from VOP_UNLOCK().
torture tested on amd64, i386 and macppc
ok beck mpi stefan
"the change looks right" deraadt
2016-03-19 12:04:15 +00:00
stefan
dafa748f1e Convert to uiomove. From Martin Natano. 2016-02-13 15:45:05 +00:00
mpi
fb492c3701 Store a unique ID, an interface index, rather than a pointer to the
receiving interface in the packet header of every mbuf.

The interface pointer should now be retrieved when necessary with
if_get().  If a NULL pointer is returned by if_get(), the interface
has probably been destroy/removed and the mbuf should be freed.

Such mechanism will simplify garbage collection of mbufs and limit
problems with dangling ifp pointers.

Tested by jmatthew@ and krw@, discussed with many.

ok mikeb@, bluhm@, dlg@
2015-06-16 11:09:39 +00:00
guenther
4707cbe35f Tweaks utimensat/futimens handling to always update ctime, even when both
atime and mtime are UTIME_OMIT (at least for ufs, tmpfs, and ext2fs), and
to correctly handle a timestamp of -1.

ok millert@
2015-04-17 04:43:20 +00:00
jsg
21dab745d7 Remove some includes include-what-you-use claims don't
have any direct symbols used.  Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@
2015-03-14 03:38:46 +00:00
miod
081bf72016 First step towards making uiomove() take a size_t size argument:
- rename uiomove() to uiomovei() and update all its users.
- introduce uiomove(), which is similar to uiomovei() but with a size_t.
- rewrite uiomovei() as an uiomove() wrapper.
ok kettenis@
2015-02-10 21:56:08 +00:00
deraadt
646fde30d6 use NGROUPS_MAX 2015-01-17 17:49:26 +00:00
miod
669a8cbb0d Explicitely include <uvm/uvm_extern.h> in order to build on variable page size
architectures.
2014-12-29 05:29:27 +00:00
tedu
53a296e09d change req pool alloc to null. add prwaitok here and nfs_node_pool which
is also sleeping in all callers, but already used null
2014-12-23 01:55:03 +00:00
tedu
8cc886957b convert one hot looking bcopy to memcpy 2014-12-18 21:00:12 +00:00
tedu
0017e6e02d delete a whole mess of unnecessary caddr_t casts 2014-12-18 20:59:21 +00:00
tedu
3811cf1547 move arc4random prototype to systm.h. more appropriate for most code
to include that than rdnvar.h. ok deraadt dlg
2014-11-18 02:37:30 +00:00
tedu
851e11fab0 bzero -> memset 2014-11-14 23:01:44 +00:00
jsg
7f58a11f6c remove uneeded proc.h includes
ok mpi@ kspillner@
2014-09-14 14:17:23 +00:00
deraadt
e6c6495d62 decouple struct uvmexp into a new file, so that uvm_extern.h and sysctl.h
don't need to be married.
ok guenther miod beck jsing kettenis
2014-07-08 17:19:21 +00:00
jsing
0906007ed7 If the v_type is going to change when loading the NFS attribute cache,
purge the vnode from the namecache first. This prevents cache_purge()
from later getting confused and trying to cache_zap() a namecache entry
multiple times over, due to cache_zap() believing that the entry does not
need to be removed from the vnode destinations queue.

ok beck@
2013-11-27 16:02:54 +00:00
guenther
91a535ff42 Switch time_t, ino_t, clock_t, and struct kevent's ident and data
members to 64bit types.  Assign new syscall numbers for (almost
all) the syscalls that involve the affected types, including anything
with time_t, timeval, itimerval, timespec, rusage, dirent, stat,
or kevent arguments.  Add a d_off member to struct dirent and replace
getdirentries() with getdents(), thus immensely simplifying and
accelerating telldir/seekdir.  Build perl with -DBIG_TIME.

Bump the major on every single base library: the compat bits included
here are only good enough to make the transition; the T32 compat
option will be burned as soon as we've reached the new world are
are happy with the snapshots for all architectures.

DANGER: ABI incompatibility.  Updating to this kernel requires extra
work or you won't be able to login: install a snapshot instead.

Much assistance in fixing userland issues from deraadt@ and tedu@
and build assistance from todd@ and otto@
2013-08-13 05:52:02 +00:00
deraadt
8c617d9c05 move the specfs code to a place people can see it; ok guenther thib krw 2011-07-04 20:57:54 +00:00
thib
dc81e71a03 Bring back the "End the VOP experiment." diff, naddy's issues where
unrelated, and his alpha is much happier now.

OK deraadt@
2010-12-21 20:14:43 +00:00
thib
074ac62c2c Backout the VOP diff until the issues naddy was seeing on alpha (gcc3)
have been resolved.
2010-09-10 16:34:08 +00:00
thib
9baecc3add Rename lookup/relookup to vfs_lookup/vfs_relookup.
OK oga@, beck@, matthew@
2010-09-09 10:37:03 +00:00
thib
57593ff041 End the VOP experiment. Instead of the ridicolusly complicated operation
vector setup that has questionable features (that have, as far as I can
tell never been used in practice, atleast not in OpenBSD), remove all
the gunk and favor a simple struct full of function pointers that get
set directly by each of the filesystems.

Removes gobs of ugly code and makes things simpler by a magnitude.

The only downside of this is that we loose the vnoperate feature so
the spec/fifo operations of the filesystems need to be kept in sync
with specfs and fifofs, this is no big deal as the API it self is pretty
static.

Many thanks to armani@ who pulled an earlier version of this diff to
current after c2k10 and Gabriel Kihlman on tech@ for testing.

Liked by many. "come on, find your balls" deraadt@.
2010-09-06 23:44:10 +00:00
thib
3fea4a48de clean up a few things that where left to rot after bob's vfs cache work.
sync a few comments to reality (or remove them), remove the cn_hash member
from struct componentname, spacing.

ok beck@
2010-05-19 08:31:23 +00:00
jsg
906a9d5308 antsy
no binary change apart from nfsm_reqhead() which is clearly correct.

ok thib@
2009-10-19 22:24:18 +00:00
thib
9c9522aef4 Backout the asyncio/aiod change, as it causes buf's to get hung.
problem noticed by deraadt@

ok beck@
2009-09-02 18:20:54 +00:00
thib
004f2c0481 move to having requests on a per nfsmount tailq instead of one global one.
also make the rexmit timeout per nfsmount, and make sure to start/stop the
timer appropriately.

now the nfs_timer() only fires if there is work todo, not always at nfs_ticks
(it did, even if there where no nfsmounts in the system!).

OK blambert@
2009-08-25 13:41:29 +00:00
thib
0324048376 Rework the way we do async I/O in nfs. Introduce separate buf queues for
each mount, and when work is "found", peg an aiod to that mount todo the
I/O. Make nfs_asyncio() a bit smarter when deciding when to do asyncio
and when to force it sync, this is done by keeping the aiod's one two lists,
an "idle" and an "all" list, so asyncio is only done when there are aiods
hanging around todo it for us or are already pegged to the mount.

Idea liked by at least beck@ (and I think art@).
Extensive testing done by myself and jasper and a few others on various
arch's.

Ideas/Code from Net/Free.

OK blambert@.
2009-08-20 15:04:24 +00:00
blambert
7e7d00e2dd Teach nfsm_fhtom about nfsm_info structs
ok thib@
2009-08-13 15:18:16 +00:00
blambert
c2e93c1830 change version 3 post-operation attribute building function to not
use mbufs directly, but the shiny new nfsm_info struct

ok thib@
2009-08-13 15:03:19 +00:00