aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* pfinet: add payload-aware intrans functionsJustus Winter2014-12-072-0/+16
| | | | | | * pfinet/mig-mutate.h: Add mutators. * pfinet/mig-decls.h (begin_using_socket_payload): New function. (begin_using_sockaddr_payload): Likewise.
* exec: add payload-aware intrans functionsJustus Winter2014-12-072-0/+9
| | | | | * exec/execmutations.h: Add mutators. * exec/mig-decls.h (begin_using_bootinfo_payload): New function.
* console-client: make the demuxer payload-awareJustus Winter2014-12-071-2/+10
| | | | * console-client/trans.c (console_demuxer): make the demuxer payload-aware.
* console: add a payload-aware intrans functionJustus Winter2014-12-072-0/+9
| | | | | * console/priv.h (begin_using_protid_payload): New function. * console/mutations.h: Add mutators.
* auth: add a payload-aware intrans functionJustus Winter2014-12-072-0/+7
| | | | | * auth/mig-mutate.h: Add mutator. * auth/mig-decls.h (auth_payload_to_handle): New function.
* libcons: add a payload-aware intrans functionJustus Winter2014-12-072-0/+7
| | | | | * libcons/mutations.h: Add mutator. * libcons/priv.h (begin_using_notify_payload): New function.
* libpager: add a payload-aware intrans functionJustus Winter2014-12-072-0/+9
| | | | | * libpager/mig-decls.h (begin_using_pager_payload): New function. * libpager/mig-mutate.h: Add mutators.
* libtrivfs: add payload-aware intrans functionsJustus Winter2014-12-072-0/+61
| | | | | | * libtrivfs/mig-decls.h (trivfs_begin_using_protid_payload): New function. (trivfs_begin_using_control_payload): Likewise. * libtrivfs/mig-mutate.h: Add mutators.
* libnetfs: add a payload-aware intrans functionJustus Winter2014-12-072-0/+9
| | | | | * libnetfs/priv.h (begin_using_protid_payload): New function. * libnetfs/mutations.h: Add mutator.
* libdiskfs: add payload-aware intrans functionsJustus Winter2014-12-072-0/+34
| | | | | | | * libdiskfs/diskfs.h (diskfs_begin_using_protid_payload): New function. (diskfs_begin_using_control_payload): Likewise. (diskfs_begin_using_bootinfo_payload): Likewise. * libdiskfs/fsmutations.h: Add mutators.
* libports: add a payload-aware intrans functionJustus Winter2014-12-072-0/+10
| | | | | * libports/mig-decls.h (begin_using_port_info_payload): New function. * libports/mig-mutate.h: Add mutator.
* libports: add `ports_lookup_payload' and `ports_payload_get_name'Justus Winter2014-12-073-1/+76
| | | | | | | | | | | | These two functions map payloads to objects and port names. The former can be used like `ports_lookup_port' to look up objects, the latter to map payloads to port names if the server function expects a `mach_port_t'. * libports/ports.h: Add function ports_payload_get_name. * libports/lookup-payload.c: New file. * libports/ports.h (ports_lookup_payload): Add declaration. * libports/Makefile (SRCS): Add lookup-payload.c.
* Fix coding styleSamuel Thibault2014-12-061-1/+1
|
* libshouldbeinlibc: move the reference counting primitives hereJustus Winter2014-12-013-19/+52
| | | | | | | | | | Declare all functions `extern inline' instead of `static inline'. This allows us to use them in functions declared as `extern inline'. * libshouldbeinlibc/refcount.h: Move here, and declare all functions `extern inline'. * libshouldbeinlibc/refcount.c: And define the functions here. * libshouldbeinlibc/Makefile: Add `refcount.{c,h}'.
* Revert "random: fix a receiver lookup"Justus Winter2014-11-284-74/+4
| | | | | | | This reverts "8927fbd63e29005ddb9b2c2264046089bf669857". The change mistakenly adds mutators for the `startup' protocol, but the server routine is for the `startup_notify' protocol.
* Add atomicity support to fshelp_acquire_lockSamuel Thibault2014-11-271-18/+77
| | | | | | | | | | This adds support for the __LOCK_ATOMIC flag which requests atomicity of SH->EX upgrades and EX->SH downgrades. * libfshelp/lock-acquire.c (__LOCK_ATOMIC): New macro (fshelp_acquire_lock): When __LOCK_ATOMIC is set, do not release the lock early, change the lock hold atomically instead. On upgrade to LOCK_EX, prevent new shared locks from being acquired to avoid starvation.
* Fix proc crashesSamuel Thibault2014-11-271-2/+4
| | | | | * proc/notify.c (do_mach_notify_dead_name): When `pi' is NULL, immediately return EOPNOTSUPP.
* libdiskfs: fix fabrication of protidJustus Winter2014-11-231-1/+2
| | | | * libdiskfs/dir-init.c (diskfs_init_dir): Fix fabrication of protid.
* libpager: make the request queue more memory-efficientJustus Winter2014-11-231-17/+49
| | | | | | | | | | | | | | | | | | Previously, `pager_demuxer' allocated a chunk of memory for the response message. But if memory gets scarce, the kernel will issue a large number of paging requests to free up memory. In such a situation, allocating memory is dangerous. Fix this by not allocating space for the response message, rather, use a chunk of the workers stack space. Also, we only handle the `notify' and `memory_object' protocol, which both only contain simple routines, we only need a `mig_response_header_t'. * libpager/demuxer.c (struct request): Remove `inp' and `outp'. (request_inp): New function. (pager_demuxer): Do not allocate memory for the response. (mig_reply_setup): New function. (worker_func): Adjust accordingly.
* boot: improve the demuxerJustus Winter2014-11-211-18/+49
| | | | | | | | | | Handle multiple request types as recommended by the Mach Server Writer's Guide section 4, subsection "Handling Multiple Request Types". This avoids initializing the reply message in every X_server function. * boot/boot.c (mig_reply_setup): Provide local version. (request_server): Rename to `boot_demuxer', and improve the dispatch.
* boot: implement pseudo-time deviceJustus Winter2014-11-211-3/+35
| | | | | | | * boot/boot.c (pseudo_time): New variable. (main): Allocate port `pseudo_time'. (ds_device_open): Give out `pseudo_time'. (ds_device_map): Emulate Mach-style `Mapped Time'.
* boot: support ds_device_get_status with flavor DEV_GET_RECORDSJustus Winter2014-11-211-12/+21
| | | | * boot/boot.c (ds_device_get_status): Support flavor DEV_GET_RECORDS.
* boot: drop obsolete device proceduresJustus Winter2014-11-211-34/+0
| | | | | | * boot/boot.c (ds_xxx_device_set_status): Remove function. (ds_xxx_device_get_status): Likewise. (ds_xxx_device_set_filter): Likewise.
* boot: remove unused function `boot_script_read_file'Justus Winter2014-11-212-49/+1
| | | | | | | | | | The unused function `boot_script_read_file' requires access to the default pager, which is privileged. * boot/boot.c (defpager): Remove now unused variable. (boot_script_read_file): Remove unused function. (main): Do not acquire port to the default pager. * boot/boot_script.h (boot_script_read_file): Remove declaration.
* boot: drop bootstrap compat codeJustus Winter2014-11-211-78/+0
| | | | | | | | GNU Mach never sent old-style bootstrap messages. Drop the unused compatibility code. * boot/boot.c (request_server): Drop unused code. (bootstrap_compat): Drop unused function.
* startup: also open `console' for readingJustus Winter2014-11-211-1/+1
| | | | * startup/startup.c (main): Also open `console' for reading.
* proc: gracefully handle failure to increase priorityJustus Winter2014-11-211-12/+32
| | | | | | * proc/main.c (increase_priority): New function. (main): Move code increasing the proc servers priority to a new function and handle errors gracefully.
* Makeconf: handle the gnumach protocolJustus Winter2014-11-211-1/+3
| | | | * Makeconf (mach_defs_names): Add `gnumach'.
* startup: bind the startup server to /servers/startupJustus Winter2014-11-217-21/+146
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, the Hurd (ab)used the fact that the startup server speaks all protocols on its message port. Any server that wished to register for shutdown notifications would use proc_getmsgport to get a port to the startup server. This hardcodes the PID of /hurd/startup, and does not allow one to point a server to ones own startup server (e.g. using remap). Bind the startup server to /servers/startup instead. Use this to contact the startup server. * exec/main.c (S_exec_init): Use /servers/startup. Fall back to the old method so that the system still boots when the node /servers/startup is missing. * hurd/paths.h (_SERVERS_STARTUP): New macro. * libdiskfs/boot-start.c (diskfs_S_fsys_init): Use /servers/startup. * libdiskfs/init-startup.c (_diskfs_init_completed): Likewise. * pfinet/main.c (arrange_shutdown_notification): Likewise. * startup/Makefile (OBJS): Add fsysServer.o. * startup/startup.c (demuxer): Handle the fsys protocol. (main): Bind to /servers/startup. (S_fsys_getroot): Implement fsys_getroot. Stub out the rest.
* startup: fix the declaration of the *_server functionsJustus Winter2014-11-211-1/+3
| | | | * startup/startup.c (demuxer): Fix the declaration of the server functions.
* startup: be more specific in the shutdown messageJustus Winter2014-11-211-1/+1
| | | | | | | Use the BOOT macro to print either halt or reboot instead of the generic shutdown in the event of an system shutdown. * startup/startup.c (reboot_system): Use more specific message.
* startup: do not pass signals on to the childJustus Winter2014-11-213-189/+1
| | | | | | | | | | | | | | Formerly /hurd/startup would forward all signals to the child it started (e.g. /libexec/runsystem). The motivation for doing so is not revealed in the comments, nor it is mentioned in the history of the version control system. This patch removes the forwarding of signals to the child. * startup/startup.c (process_signal): Do not pass signals on to the child. * startup/stubs.c: Remove file. * startup/Makefile: Remove stubs.c.
* init: add a minimalist init programJustus Winter2014-11-217-58/+364
| | | | | | | | | | | | | | | | | | | | | | This patch adds a minimalist init program. It is somewhat lacking in features, but is able to bring up a Hurd system with the runsystem and rc scripts. In fact, it roughly does what the former /hurd/init did, modulo all the very early bootstrapping stuff and the startup protocol. It is started when all the essential servers are up and running, so it can make use of most of the POSIX goodies, making its implementation much simpler. * Makefile (prog-subdirs): Add init. * daemons/runsystem.sh: Generalize runsystem so that it can start any init as specified on the kernel command line. By default, it starts /hurd/init. * daemons/runsystem.hurd: This is a verbatim copy of runsystem.sh. It is started by /hurd/init. * daemons/rc.sh: Do not start /hurd/mach-defpager as it is already started in runsystem.sh. * daemons/Makefile (SRCS): Add runsystem.hurd. * init/Makefile: New file. * init/init.c: Likewise.
* startup: rename /hurd/init to /hurd/startupJustus Winter2014-11-218-11/+12
| | | | | | | | | | | | | This patch series splits /hurd/init into two programs. As a first step, this patch renames /hurd/init to /hurd/startup. It is called startup because it speaks the startup protocol. * startup: Rename init to startup. Adjust accordingly. * Makefile (prog-subdirs): Likewise. * doc/hurd.texi (Server Bootstrap): Likewise. * hurd/paths.h (_HURD_STARTUP): Likewise. * libdiskfs/boot-start.c (diskfs_boot_init_program): Likewise. * libdiskfs/opts-std-startup.c (startup_options): Likewise.
* procfs: do not hard-code the default argument valuesJustus Winter2014-11-211-3/+3
| | | | | * procfs/main.c (common_options): If possible, do not hard-code the default values.
* Add proc_set_init_task, make runsystem pid 1Justus Winter2014-11-2110-35/+93
| | | | | | | | | | | | | | | | | * hurd/process.defs (proc_set_init_task): New procedure. * hurd/process_reply.defs (proc_set_init_task): Likewise. * hurd/process_request.defs (proc_set_init_task): Likewise. * include/pids.h: Add HURD_PID_INIT as 1, adjust others accordingly. * init/init.c (start_child): Register the child task. * proc/proc.h (init_proc): New variable. (create_startup_proc): Rename to create_init_proc. * proc/main.c (main): Create placeholder proc object for pid 1. * proc/mgt.c: Use init_proc instead of startup_proc, as the former is the new root of the process tree. (create_startup_proc): Rename to create_init_proc. (S_proc_set_init_task): New function. * doc/hurd.texi (Server Bootstrap): Update accordingly. * procfs/main.c: Do not hard-code kernel pid, use pids.h instead.
* trans/mtab: avoid firmlink loopsJustus Winter2014-11-211-1/+45
| | | | | | | | | | | * trans/mtab.c (struct mtab): Add a hash table to keep track of seen ports. (mtab_mark_as_seen): New function that records the identity port of a given node in the hash table and reports whether it has been there before. (mtab_populate): Use the new function to avoid running in circles. (main, open_hook): Initialize hash table. (close_hook): Free ports and destroy hash table.
* Always canonicalize fstab entries with realpathSamuel Thibault2014-11-212-44/+63
| | | | | | | | | | | | To avoid spurious ./, /, symlinks, etc. * sutils/fstab.c (fs_set_mntent): Try to call realpath on mnt_fsname and mnt_dir field of `mntent'. (fstab_find_mount): Try to call realpath on `name' parameter. (fstab_find): Do not try to call realpath. (fstab_read): Reset errno to zero before calling getmntent. * utils/umount.c (main): Do not warn about missing fstab entries for active translators.
* Fix compiler warningSamuel Thibault2014-11-211-1/+1
| | | | | | * libnetfs/dir-lookup.c (netfs_S_dir_lookup): Initialize register_translator to 0, otherwise it may be used uninitialized in case of non-ENOENT errors.
* Fix recording complete path of passive relative translatorsSamuel Thibault2014-11-211-1/+10
| | | | | * libnetfs/dir-lookup.c (netfs_S_dir_lookup): Prepend current path to the relative path before recording the active translator.
* Fix recording complete path of passive relative translatorsSamuel Thibault2014-11-211-1/+10
| | | | | * libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Prepend current path to the relative path before recording the active translator.
* Let pty readers always read end of writer outputSamuel Thibault2014-11-211-1/+1
| | | | | * term/ptyio.c (pty_io_read): Do not return EIO when there is no writer any more but some output remains in the pipe.
* utils/rpctrace: fix crash while printing messagesJustus Winter2014-11-121-1/+1
| | | | | | | | | | | | % fakeroot rpctrace install [...] 63<--66(pid5363)->io_read (-1 8192) = 0 [... rpctrace crashes] /bin/fakeauth: Segmentation fault for child 5362 /bin/settrans: Error 139 for child 5361 * utils/rpctrace.c (print_data): Fix this by guarding the code escaping non-printable characters introduced in 84932431 against `data' being NULL.
* Make procfs appear in /proc/mountsSamuel Thibault2014-11-111-0/+12
| | | | | | d-i needs to be able to check whether /proc is mounted or not. * procfs/main.c (netfs_get_source): New function.
* Fix mach-defpager's kalloc valuesSamuel Thibault2014-11-101-7/+7
| | | | | | | | * mach-defpager/kalloc.c (MINSIZE): Set to sizeof(vm_offset_t) instead of hardcoded 4. (kalloc_init): Set kalloc_max to MINSIZE << (KLIST_MAX-1) instead of hardcoded 16384. (kalloc, kfree): Use the cache for the maximum size too.
* Avoid hitting VM_MAX_ADDRESSSamuel Thibault2014-11-101-1/+3
| | | | | | * libpager/pager-memcpy.c (pager_memcpy): Reset address passed to vm_map on each loop, to avoid potentially monotonically increasing up to VM_MAX_ADDRESS.
* Deal with odd kernel behaviorSamuel Thibault2014-11-091-0/+1
| | | | | | | | Some versions of gnumach actually take address as a mapping hint, and would fail if the hint is bogus. Make sure to pass 0 for those versions. * libstore/memobj.c (memobj_read): Make sure to set *buf to 0 before calling vm_map.
* Deal with odd kernel behaviorSamuel Thibault2014-11-094-1/+4
| | | | | | | | | | | | | | Some versions of gnumach actually take address as a mapping hint, and would fail if the hint is bogus. Make sure to pass 0 for those versions. * console/pager.c (user_pager_create): Make sure to set *user to 0 before calling vm_map. * libdiskfs/disk-pager.c (diskfs_start_disk_pager): Make sure to set *image to 0 before calling vm_map. * libpager/pager-memcpy.c (pager_memcpy): Set window to 0 before calling vm_map. * tmpfs/node.c (diskfs_get_filemap): Make sure to set np->dn->u.reg.memref to 0 before calling vm_map.
* libpager: use a fixed number of threadsJustus Winter2014-11-0321-262/+361
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, libpager used an unbounded number of threads to receive messages from the pager bucket. It used sequence barriers to execute the requests to order requests to each object. The sequence barriers are implemented in seqnos.c. A server function uses _pager_wait_for_seqno to wait for its sequence number and _pager_release_seqno to release it, or it uses _pager_update_seqno to do both operations in one step. These sequence barriers divide each server function in three parts: A, B, and C. A_i happens "before" the sequence barrier i, B_i happens "in order", C_i happens "after" the sequence barrier. This partial order < has the following properties: * This order is *per object*. Requests to different objects are not ordered. * A_i < B_i, B_i < C_i (due to the structure of the code) * B_i < B_{i+1} (this is due to the sequence barriers) * Note that only the B parts are ordered by the sequence numbers, we are free to execute C_i and C_{i+1} in any possible order. The same argument applies to the A parts. The sequence barriers are implemented using a very simple ticket algorithm. Every request, even the invalid ones, is processed by a thread, and waits until the ticket count reaches its seqno, does some work in-order, then increments the ticket and awakes all threads that have piled up up to this moment. All of them except one will then discover that it's not their turn yet and go to sleep again. Creating one thread per request has proven to be problematic as memory_object requests often arrive in large batches. This patch does two things: * Use a single thread to receive messages from the port bucket. All incoming request are put into a queue. * Use a fixed-number of threads (though even one is actually enough) to execute the the server functions. If multiple threads are used, a work-delegation mechanism ensures that the per object order < is preserved. For reference, I used the following command to create workloads that highlight the problem this patch is addressing: % settrans t .../ext2fs --sync=30 /dev/sd2s1 ... % /usr/bin/time zsh -c 'for ((i=0; i < 1500; i++)); do dd if=/dev/zero of=t/src/$i bs=4k count=290 2>/dev/null echo -n . if ((i % 100 == 0)) ; then echo -n $i; fi done' * libpager/queue.h: New file. * libpager/demuxer.c: Manage a queue of requests received from the port bucket. (pager_demuxer): Just decode the server function and enqueue the request. (worker_func): New function that consumes and executes the requests from the queue. (service_paging_requests): New function. (pager_start_workers): Likewise. * libpager/data-request.c: Remove the seqno barriers. * libpager/data-return.c: Likewise. * libpager/data-unlock.c: Likewise. * libpager/chg-compl.c: Likewise. * libpager/lock-completed.c: Likewise. * libpager/no-senders.c: Likewise. * libpager/notify-stubs.c: Likewise. * libpager/object-init.c: Likewise. * libpager/object-terminate.c: Likewise. * libpager/seqnos.c: Remove file. * libpager/stubs.c: Likewise. * libpager/pager.h (pager_demuxer): Drop declaration. (pager_start_workers): New declaration. * libpager/priv.h: Remove the _pager_seqno declarations. * libpager/Makefile (SRCS): Drop seqnos.c. * console/pager.c (user_pager_init): Call pager_start_workers. * libdiskfs/disk-pager.c: Likewise. * storeio/pager.c: Likewise. * ext2fs/pager.c (service_paging_requests): Remove function. (create_disk_pager): Start separate file pager using `pager_start_workers'. * fatfs/pager.c (service_paging_requests): Remove function. (create_fat_pager): Start separate file pager using `pager_start_workers'.
* mach-defpager: use protected payloads for object lookupsJustus Winter2014-11-033-0/+18
| | | | | | | | | * mach-defpager/default_pager.c (pager_port_list_insert): Set protected payload. (pager_port_list_delete): Clear protected payload. * mach-defpager/mig-decls.h (begin_using_default_pager_payload): New function. * mach-defpager/mig-mutate.h: Add mutator.