git: 9eff58c6d52b - main - sound: Implement asynchronous device detach
The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=9eff58c6d52b66eb8abe7f724dabcd804a566df4 commit 9eff58c6d52b66eb8abe7f724dabcd804a566df4 Author: Christos Margiolis AuthorDate: 2024-03-31 14:13:43 + Commit: Christos Margiolis CommitDate: 2024-03-31 14:13:43 + sound: Implement asynchronous device detach Hot-unplugging a sound device, such as a USB sound card, whilst being consumed by an application, results in an infinite loop until either the application closes the device's file descriptor, or the channel automatically times out after hw.snd.timeout seconds. In the case of a detach however, the timeout approach is still not ideal, since we want all resources to be released immediatelly, without waiting for N seconds until we can use the bus again. The timeout mechanism works by calling chn_sleep() in chn_read() and chn_write() (see pcm/channel.c) in order to send the thread to sleep, using cv_timedwait_sig(). Since chn_sleep() sets the CHN_F_SLEEPING flag while waiting for cv_timedwait_sig() to return, we can test this flag in pcm_unregister() (called during detach) and wakeup the sleeping thread(s) to immediately kill the channel(s) being consumed. Sponsored by: The FreeBSD Foundation MFC after: 2 months PR: 194727, 278055, 202275, 220949, 272286 Reviewed by:dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D43545 --- share/man/man4/snd_uaudio.4 | 11 +-- sys/dev/sound/pcm/dsp.c | 2 +- sys/dev/sound/pcm/mixer.c | 11 --- sys/dev/sound/pcm/sound.c | 24 ++-- sys/dev/sound/usb/uaudio.c | 13 +++-- 5 files changed, 15 insertions(+), 46 deletions(-) diff --git a/share/man/man4/snd_uaudio.4 b/share/man/man4/snd_uaudio.4 index b6a6c06a2312..6e2509b8f2ac 100644 --- a/share/man/man4/snd_uaudio.4 +++ b/share/man/man4/snd_uaudio.4 @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 29, 2024 +.Dd March 26, 2024 .Dt SND_UAUDIO 4 .Os .Sh NAME @@ -156,15 +156,6 @@ and modified for by .An Hiten Pandya Aq Mt h...@freebsd.org . .Sh BUGS -The PCM framework in -.Fx -only supports synchronous device detach. -That means all mixer and DSP character devices belonging to a given -USB audio device must be closed when receiving an error on a DSP read, -a DSP write or a DSP IOCTL request. -Else the USB audio driver will wait for this to happen, preventing -enumeration of new devices on the parenting USB controller. -.Pp Some USB audio devices might refuse to work properly unless the sample rate is configured the same for both recording and playback, even if only simplex is used. diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index b9693908da43..754f09c7199e 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -295,7 +295,7 @@ dsp_close(void *data) d = priv->sc; /* At this point pcm_unregister() will destroy all channels anyway. */ - if (!PCM_REGISTERED(d)) + if (PCM_DETACHING(d)) goto skip; PCM_GIANT_ENTER(d); diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index ee1ed11a8ed0..cc8cf5b1ceea 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -817,17 +817,6 @@ mixer_uninit(device_t dev) KASSERT(m->type == MIXER_TYPE_PRIMARY, ("%s(): illegal mixer type=%d", __func__, m->type)); - snd_mtxlock(m->lock); - - if (m->busy) { - snd_mtxunlock(m->lock); - return EBUSY; - } - - /* destroy dev can sleep --hps */ - - snd_mtxunlock(m->lock); - pdev->si_drv1 = NULL; destroy_dev(pdev); diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 36a6f778e024..b45ca30dc984 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -1137,26 +1137,22 @@ pcm_unregister(device_t dev) CHN_FOREACH(ch, d, channels.pcm) { CHN_LOCK(ch); - if (ch->refcount > 0) { - device_printf(dev, - "unregister: channel %s busy (pid %d)\n", - ch->name, ch->pid); - CHN_UNLOCK(ch); - PCM_RELEASE_QUICK(d); - return (EBUSY); + if (ch->flags & CHN_F_SLEEPING) { + /* +* We are detaching, so do not wait for the timeout in +* chn_read()/chn_write(). Wake up the thread and kill +* the channel immediately. +*/ + CHN_BROADCAST(&ch->intr_cv); + ch->flags |= CHN_F_DEAD; } + chn_abort(ch);
git: d68c68693e11 - main - tar: make error reporting more robust and use correct errno
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d68c68693e110353f70b5c04f8de416cf5766eca commit d68c68693e110353f70b5c04f8de416cf5766eca Author: Ed Maste AuthorDate: 2024-03-31 14:37:38 + Commit: Ed Maste CommitDate: 2024-03-31 14:39:53 + tar: make error reporting more robust and use correct errno Apply upstream pull request 2101. --- contrib/libarchive/tar/read.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/libarchive/tar/read.c b/contrib/libarchive/tar/read.c index 2a907518d7cb..94616f279e65 100644 --- a/contrib/libarchive/tar/read.c +++ b/contrib/libarchive/tar/read.c @@ -372,8 +372,9 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer) if (r != ARCHIVE_OK) { if (!bsdtar->verbose) safe_fprintf(stderr, "%s", archive_entry_pathname(entry)); - fprintf(stderr, ": %s: ", archive_error_string(a)); - fprintf(stderr, "%s", strerror(errno)); + safe_fprintf(stderr, ": %s: %s", + archive_error_string(a), + strerror(archive_errno(a))); if (!bsdtar->verbose) fprintf(stderr, "\n"); bsdtar->return_value = 1;
git: ddd779a062c1 - stable/14 - acpi_hpet: Make use of enum for vm_guest to improve readability
The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=ddd779a062c1de28a3f632ece9fe4d1abf07dbdb commit ddd779a062c1de28a3f632ece9fe4d1abf07dbdb Author: Zhenlei Huang AuthorDate: 2024-03-24 15:31:22 + Commit: Zhenlei Huang CommitDate: 2024-03-31 15:54:48 + acpi_hpet: Make use of enum for vm_guest to improve readability No functional change intended. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44402 (cherry picked from commit 579cb41b132f532bf4915121c0d0b2f43688242e) --- sys/dev/acpica/acpi_hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index de75e70a2d49..9a1abe6ca72d 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -643,7 +643,7 @@ hpet_attach(device_t dev) * The only way to use HPET there is to specify IRQs manually * and/or use legacy_route. Legacy_route mode works on both. */ - if (vm_guest) + if (vm_guest != VM_GUEST_NO) sc->allowed_irqs = 0x; /* Let user override. */ resource_int_value(device_get_name(dev), device_get_unit(dev),
git: f3b21c553681 - stable/13 - acpi_hpet: Make use of enum for vm_guest to improve readability
The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=f3b21c5536816eae4d8ecbbddd790419753d403a commit f3b21c5536816eae4d8ecbbddd790419753d403a Author: Zhenlei Huang AuthorDate: 2024-03-24 15:31:22 + Commit: Zhenlei Huang CommitDate: 2024-03-31 15:55:49 + acpi_hpet: Make use of enum for vm_guest to improve readability No functional change intended. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44402 (cherry picked from commit 579cb41b132f532bf4915121c0d0b2f43688242e) (cherry picked from commit ddd779a062c1de28a3f632ece9fe4d1abf07dbdb) --- sys/dev/acpica/acpi_hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index a32edb9c7e7a..d30bc99047a9 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -645,7 +645,7 @@ hpet_attach(device_t dev) * The only way to use HPET there is to specify IRQs manually * and/or use legacy_route. Legacy_route mode works on both. */ - if (vm_guest) + if (vm_guest != VM_GUEST_NO) sc->allowed_irqs = 0x; /* Let user override. */ resource_int_value(device_get_name(dev), device_get_unit(dev),
git: a1f89082dcb5 - stable/14 - hyperv/hn: Don't return error when setting media to autoselect
The branch stable/14 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=a1f89082dcb591886acc22c5503a2d5a82b267d9 commit a1f89082dcb591886acc22c5503a2d5a82b267d9 Author: Mark Peek AuthorDate: 2024-03-13 23:53:07 + Commit: Mark Peek CommitDate: 2024-03-31 16:51:02 + hyperv/hn: Don't return error when setting media to autoselect Setting media to autoselect would always return EOPNOTSUPP. As autoselect is the only valid media, this change now returns success instead. PR: 264253 Reported by:Prakash Shiva Reviewed by:Dexuan Cui , whu Approved by:whu MFC after: 2 weeks (cherry picked from commit 63a7c4be4ad524629292eee659d6542f1c5e9c21) --- sys/dev/hyperv/netvsc/if_hn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index 6e1c9771a02d..41be4226e592 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -1103,7 +1103,8 @@ static int hn_ifmedia_upd(if_t ifp __unused) { - return EOPNOTSUPP; + /* Ignore since autoselect is the only defined and valid media */ + return (0); } static void
git: a26e93052a38 - stable/13 - hyperv/hn: Don't return error when setting media to autoselect
The branch stable/13 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=a26e93052a3897bb55301954dff7e40547d7f291 commit a26e93052a3897bb55301954dff7e40547d7f291 Author: Mark Peek AuthorDate: 2024-03-13 23:53:07 + Commit: Mark Peek CommitDate: 2024-03-31 16:49:01 + hyperv/hn: Don't return error when setting media to autoselect Setting media to autoselect would always return EOPNOTSUPP. As autoselect is the only valid media, this change now returns success instead. PR: 264253 Reported by:Prakash Shiva Reviewed by:Dexuan Cui , whu Approved by:whu MFC after: 2 weeks (cherry picked from commit 63a7c4be4ad524629292eee659d6542f1c5e9c21) --- sys/dev/hyperv/netvsc/if_hn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c index a18f608e1aab..dc90f7b0dd22 100644 --- a/sys/dev/hyperv/netvsc/if_hn.c +++ b/sys/dev/hyperv/netvsc/if_hn.c @@ -,7 +,8 @@ static int hn_ifmedia_upd(struct ifnet *ifp __unused) { - return EOPNOTSUPP; + /* Ignore since autoselect is the only defined and valid media */ + return (0); } static void
git: 811bd332abdd - stable/14 - efibootmgr: allow -u as a valid option
The branch stable/14 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=811bd332abddf44a2f410fd04a6a61849d1b736a commit 811bd332abddf44a2f410fd04a6a61849d1b736a Author: Mark Peek AuthorDate: 2024-03-24 19:37:12 + Commit: Mark Peek CommitDate: 2024-03-31 16:58:45 + efibootmgr: allow -u as a valid option PR: 277907 Reported by:vsasja...@gmail.com MFC after: 1 week (cherry picked from commit 65904399db9167b0970e42e14642e1d6bdbf6d3a) --- usr.sbin/efibootmgr/efibootmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c index be1157b4aa84..dfe8bfb1c145 100644 --- a/usr.sbin/efibootmgr/efibootmgr.c +++ b/usr.sbin/efibootmgr/efibootmgr.c @@ -203,8 +203,8 @@ parse_args(int argc, char *argv[]) { int ch; - while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:v", - lopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, + "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:u:v", lopts, NULL)) != -1) { switch (ch) { case 'A': opts.set_inactive = true;
git: 14b2221ae7ce - stable/13 - efibootmgr: allow -u as a valid option
The branch stable/13 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=14b2221ae7cee33b5b75d662da6a396ca5c46f95 commit 14b2221ae7cee33b5b75d662da6a396ca5c46f95 Author: Mark Peek AuthorDate: 2024-03-24 19:37:12 + Commit: Mark Peek CommitDate: 2024-03-31 16:57:17 + efibootmgr: allow -u as a valid option PR: 277907 Reported by:vsasja...@gmail.com MFC after: 1 week (cherry picked from commit 65904399db9167b0970e42e14642e1d6bdbf6d3a) --- usr.sbin/efibootmgr/efibootmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c index be1157b4aa84..dfe8bfb1c145 100644 --- a/usr.sbin/efibootmgr/efibootmgr.c +++ b/usr.sbin/efibootmgr/efibootmgr.c @@ -203,8 +203,8 @@ parse_args(int argc, char *argv[]) { int ch; - while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:v", - lopts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, + "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:u:v", lopts, NULL)) != -1) { switch (ch) { case 'A': opts.set_inactive = true;
git: 43b4da44118e - main - ptrace tests: Add a test using PROC_REAP_KILL to kill a traced debuggee
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=43b4da44118e4fe29e9d7456db4390c9cbb53636 commit 43b4da44118e4fe29e9d7456db4390c9cbb53636 Author: Mark Johnston AuthorDate: 2024-03-31 18:11:47 + Commit: Mark Johnston CommitDate: 2024-03-31 18:11:47 + ptrace tests: Add a test using PROC_REAP_KILL to kill a traced debuggee This exercises the bug fix in commit 9241ebc796c1 ("thread_single(9): decline external requests for traced or debugger-stopped procs"). Reviewed by:kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44564 --- tests/sys/kern/ptrace_test.c | 47 1 file changed, 47 insertions(+) diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c index bd176e2963f0..b65c84144ad0 100644 --- a/tests/sys/kern/ptrace_test.c +++ b/tests/sys/kern/ptrace_test.c @@ -4368,6 +4368,52 @@ ATF_TC_BODY(ptrace__PT_SC_REMOTE_getpid, tc) ATF_REQUIRE(ptrace(PT_DETACH, fpid, (caddr_t)1, 0) != -1); } +/* + * Ensure that procctl(PROC_REAP_KILL) won't block forever waiting for a target + * process that stopped to report its status to a debugger. + */ +ATF_TC_WITHOUT_HEAD(ptrace__reap_kill_stopped); +ATF_TC_BODY(ptrace__reap_kill_stopped, tc) +{ + struct procctl_reaper_kill prk; + pid_t debuggee, wpid; + int error, status; + + REQUIRE_EQ(procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL), 0); + + debuggee = fork(); + ATF_REQUIRE(debuggee >= 0); + if (debuggee == 0) { + trace_me(); + for (;;) + sleep(10); + _exit(0); + } + wpid = waitpid(debuggee, &status, 0); + REQUIRE_EQ(wpid, debuggee); + ATF_REQUIRE(WIFSTOPPED(status)); + REQUIRE_EQ(WSTOPSIG(status), SIGSTOP); + + /* Resume the child and ask it to stop during syscall exits. */ + ATF_REQUIRE(ptrace(PT_TO_SCX, debuggee, (caddr_t)1, 0) != -1); + + /* Give the debuggee some time to go to sleep. */ + usleep(10); + + /* +* Kill the child process. procctl() may attempt to stop the target +* process to prevent it from adding new children to the reaper subtree, +* and this should not conflict with the child stopping itself for the +* debugger. +*/ + memset(&prk, 0, sizeof(prk)); + prk.rk_sig = SIGTERM; + error = procctl(P_PID, getpid(), PROC_REAP_KILL, &prk); + REQUIRE_EQ(error, 0); + REQUIRE_EQ(1, prk.rk_killed); + REQUIRE_EQ(-1, prk.rk_fpid); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, ptrace__parent_wait_after_trace_me); @@ -4434,6 +4480,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__procdesc_wait_child); ATF_TP_ADD_TC(tp, ptrace__procdesc_reparent_wait_child); ATF_TP_ADD_TC(tp, ptrace__PT_SC_REMOTE_getpid); + ATF_TP_ADD_TC(tp, ptrace__reap_kill_stopped); return (atf_no_error()); }
git: 7ef5c19b219e - main - kern linker: Don't invoke dtors without having invoked ctors
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7ef5c19b219e47684afd9d8d9126df39edc8d885 commit 7ef5c19b219e47684afd9d8d9126df39edc8d885 Author: Mark Johnston AuthorDate: 2024-03-31 18:14:02 + Commit: Mark Johnston CommitDate: 2024-03-31 18:15:11 + kern linker: Don't invoke dtors without having invoked ctors I have a kernel module which fails to load because of an unrecognized relocation type. link_elf_load_file() fails before the module's ctors are invoked and it calls linker_file_unload(), which causes the module's dtors to be executed, resulting in a kernel panic. Add a flag to the linker file to ensure that dtors are not invoked if unloading due to an error prior to ctors being invoked. At the moment I only implemented this for link_elf_obj.c since link_elf.c doesn't invoke dtors, but I refactored link_elf.c to make them more similar. Fixes: 9e575fadf491 ("link_elf_obj: Invoke fini callbacks") Reviewed by:zlei, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44559 --- sys/kern/kern_linker.c | 1 + sys/kern/link_elf.c | 15 +-- sys/kern/link_elf_obj.c | 30 +++--- sys/sys/linker.h| 5 + 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 54b7466124db..08b85867d781 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -657,6 +657,7 @@ linker_make_file(const char *pathname, linker_class_t lc) return (NULL); lf->ctors_addr = 0; lf->ctors_size = 0; + lf->ctors_invoked = LF_NONE; lf->dtors_addr = 0; lf->dtors_size = 0; lf->refs = 1; diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index b08c19f3c018..9f9c10456b60 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -358,7 +358,7 @@ link_elf_error(const char *filename, const char *s) } static void -link_elf_invoke_ctors(caddr_t addr, size_t size) +link_elf_invoke_cbs(caddr_t addr, size_t size) { void (**ctor)(void); size_t i, cnt; @@ -373,6 +373,17 @@ link_elf_invoke_ctors(caddr_t addr, size_t size) } } +static void +link_elf_invoke_ctors(linker_file_t lf) +{ + KASSERT(lf->ctors_invoked == LF_NONE, + ("%s: file %s ctor state %d", + __func__, lf->filename, lf->ctors_invoked)); + + link_elf_invoke_cbs(lf->ctors_addr, lf->ctors_size); + lf->ctors_invoked = LF_CTORS; +} + /* * Actions performed after linking/loading both the preloaded kernel and any * modules; whether preloaded or dynamicly loaded. @@ -403,7 +414,7 @@ link_elf_link_common_finish(linker_file_t lf) #endif /* Invoke .ctors */ - link_elf_invoke_ctors(lf->ctors_addr, lf->ctors_size); + link_elf_invoke_ctors(lf); return (0); } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index c8ccebea0832..a7c7d4826322 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -658,6 +658,30 @@ link_elf_invoke_cbs(caddr_t addr, size_t size) } } +static void +link_elf_invoke_ctors(linker_file_t lf) +{ + KASSERT(lf->ctors_invoked == LF_NONE, + ("%s: file %s ctor state %d", + __func__, lf->filename, lf->ctors_invoked)); + + link_elf_invoke_cbs(lf->ctors_addr, lf->ctors_size); + lf->ctors_invoked = LF_CTORS; +} + +static void +link_elf_invoke_dtors(linker_file_t lf) +{ + KASSERT(lf->ctors_invoked != LF_DTORS, + ("%s: file %s ctor state %d", + __func__, lf->filename, lf->ctors_invoked)); + + if (lf->ctors_invoked == LF_CTORS) { + link_elf_invoke_cbs(lf->dtors_addr, lf->dtors_size); + lf->ctors_invoked = LF_DTORS; + } +} + static int link_elf_link_preload_finish(linker_file_t lf) { @@ -684,7 +708,7 @@ link_elf_link_preload_finish(linker_file_t lf) /* Apply protections now that relocation processing is complete. */ link_elf_protect(ef); - link_elf_invoke_cbs(lf->ctors_addr, lf->ctors_size); + link_elf_invoke_ctors(lf); return (0); } @@ -1239,7 +1263,7 @@ link_elf_load_file(linker_class_t cls, const char *filename, #endif link_elf_protect(ef); - link_elf_invoke_cbs(lf->ctors_addr, lf->ctors_size); + link_elf_invoke_ctors(lf); *result = lf; out: @@ -1259,7 +1283,7 @@ link_elf_unload_file(linker_file_t file) elf_file_t ef = (elf_file_t) file; u_int i; - link_elf_invoke_cbs(file->dtors_addr, file->dtors_size); + link_elf_invoke_dtors(file); /* Notify MD code that a module is being unloaded. */ elf_cpu_unload_file(file); diff --git a/sys/sys/linker.h b/sys/sys/linker.h index b6184f4fc876..52fbeb5584ff 100644 --- a/sys/sys/linker.h +++ b/sys/sys/linker.h @@ -82,6 +82,
git: 07b17a1692a3 - main - bsd-family-tree: add NetBSD 10.0
The branch main has been updated by maxim: URL: https://cgit.FreeBSD.org/src/commit/?id=07b17a1692a3c067e8f3e2dad31441ae441c5387 commit 07b17a1692a3c067e8f3e2dad31441ae441c5387 Author: Maxim Konovalov AuthorDate: 2024-03-31 18:35:02 + Commit: Maxim Konovalov CommitDate: 2024-03-31 18:35:02 + bsd-family-tree: add NetBSD 10.0 --- share/misc/bsd-family-tree | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index 06cb803f709c..6bcde1ed052e 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -456,6 +456,8 @@ FreeBSD 5.2 | | | | || | ||| | FreeBSD| ||| | 13.3 | ||| + || *--NetBSD|| + || | 10.0 || || ||| FreeBSD 15 -current | NetBSD -current OpenBSD -currentDragonFly -current || ||| @@ -886,6 +888,7 @@ macOS 142023-09-26 [APL] OpenBSD 7.42023-10-16 [OBD] FreeBSD 14.0 2023-11-20 [FBD] FreeBSD 13.3 2024-03-05 [FBD] +NetBSD 10.02024-03-28 [NBD] Bibliography
git: ad5ec5136ba3 - main - bsd-family-tree: remove EoL whitespace
The branch main has been updated by maxim: URL: https://cgit.FreeBSD.org/src/commit/?id=ad5ec5136ba3aa7d2863db23dc97fd875213f7ad commit ad5ec5136ba3aa7d2863db23dc97fd875213f7ad Author: Maxim Konovalov AuthorDate: 2024-03-31 18:36:03 + Commit: Maxim Konovalov CommitDate: 2024-03-31 18:36:03 + bsd-family-tree: remove EoL whitespace --- share/misc/bsd-family-tree | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index 6bcde1ed052e..e2aa0ceecc20 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -924,7 +924,7 @@ URL: https://web.archive.org/web/20081230094857/http://www.byte.com/art/9410/sec Andreas Klemm, Lars Köller. If you're going to San Francisco ... Die freien BSD-Varianten von Unix. c't April 1997, page 368ff. -FreeBSD Release Information +FreeBSD Release Information URL: https://www.FreeBSD.org/releases/ Manual pages for FreeBSD and ports
git: fefb7c399b39 - main - mountd.c: Add warning messages for administrative controls
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=fefb7c399b39403e1a31157e925a541f1cc24f0b commit fefb7c399b39403e1a31157e925a541f1cc24f0b Author: Rick Macklem AuthorDate: 2024-03-31 19:00:08 + Commit: Rick Macklem CommitDate: 2024-03-31 19:00:08 + mountd.c: Add warning messages for administrative controls When "administrative controls" (which are exports of subdirectories within a NFS server's local file system) are used, they export the entire local server file system. (The subdirectory only applies to the Mount protocol used for NFSv3 mounts.) To minimize the risk that this causes confusion w.r.t. what is exported to NFS client(s), this patch generates warning messages for these. Only one message is generated for each server local file system. The messages can be silenced via a new "-A" command line option. The mountd.8 man page will be patched via a separate commit. Reviewed by:emaste, markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44502 --- usr.sbin/mountd/mountd.c | 29 - 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 73a4dbfe39b3..14693a922186 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -130,10 +130,11 @@ struct exportlist { SLIST_ENTRY(exportlist) entries; }; /* ex_flag bits */ -#defineEX_LINKED 0x1 -#defineEX_DONE 0x2 -#defineEX_DEFSET 0x4 -#defineEX_PUBLICFH 0x8 +#defineEX_LINKED 0x01 +#defineEX_DONE 0x02 +#defineEX_DEFSET 0x04 +#defineEX_PUBLICFH 0x08 +#defineEX_ADMINWARN0x10 SLIST_HEAD(exportlisthead, exportlist); @@ -272,6 +273,7 @@ static char *exnames_default[2] = { _PATH_EXPORTS, NULL }; static char **exnames; static char **hosts = NULL; static int force_v2 = 0; +static int warn_admin = 1; static int resvport_only = 1; static int nhosts = 0; static int dir_only = 1; @@ -434,11 +436,14 @@ main(int argc, char **argv) else close(s); - while ((c = getopt(argc, argv, "2deh:lnp:RrS")) != -1) + while ((c = getopt(argc, argv, "2Adeh:lnp:RrS")) != -1) switch (c) { case '2': force_v2 = 1; break; + case 'A': + warn_admin = 0; + break; case 'e': /* now a no-op, since this is the default */ break; @@ -1696,6 +1701,20 @@ get_exportlist_one(int passno) fsb.f_fsid.val[1]); } + if (warn_admin != 0 && + (ep->ex_flag & EX_ADMINWARN) == 0 && + strcmp(unvis_dir, fsb.f_mntonname) != + 0) { + if (debug) + warnx("exporting %s exports entire " + "%s file system", unvis_dir, + fsb.f_mntonname); + syslog(LOG_ERR, "Warning: exporting %s " + "exports entire %s file system", + unvis_dir, fsb.f_mntonname); + ep->ex_flag |= EX_ADMINWARN; + } + /* * Add dirpath to export mount point. */
git: ee36e7faceaf - main - snd_hdspe(4): Only buffer_copy() audio data once.
The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=ee36e7faceafeef05c5e81654a1d8ec11d314894 commit ee36e7faceafeef05c5e81654a1d8ec11d314894 Author: Florian Walpen AuthorDate: 2024-03-31 19:14:16 + Commit: Ruslan Bukin CommitDate: 2024-03-31 19:14:16 + snd_hdspe(4): Only buffer_copy() audio data once. Instead of blindly copying two periods of audio data to and from DMA buffers, keep track of the writing position and derive the actual part of audio data that needs to be copied. This approximately halves the number of samples copied in total. Differential Revision: https://reviews.freebsd.org/D44084 --- sys/dev/sound/pci/hdspe-pcm.c | 46 ++- sys/dev/sound/pci/hdspe.h | 1 + 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/sys/dev/sound/pci/hdspe-pcm.c b/sys/dev/sound/pci/hdspe-pcm.c index 594a4f704028..0e78be113a66 100644 --- a/sys/dev/sound/pci/hdspe-pcm.c +++ b/sys/dev/sound/pci/hdspe-pcm.c @@ -540,7 +540,8 @@ buffer_copy(struct sc_chinfo *ch) struct sc_pcminfo *scp; struct sc_info *sc; uint32_t row, ports; - unsigned int pos; + uint32_t dma_pos; + unsigned int pos, length, offset; unsigned int n; unsigned int adat_width, pcm_width; @@ -558,13 +559,35 @@ buffer_copy(struct sc_chinfo *ch) else pcm_width = 8; - if (ch->dir == PCMDIR_PLAY) - pos = sndbuf_getreadyptr(ch->buffer); - else - pos = sndbuf_getfreeptr(ch->buffer); + /* Derive buffer position and length to be copied. */ + if (ch->dir == PCMDIR_PLAY) { + /* Position per channel is n times smaller than PCM. */ + pos = sndbuf_getreadyptr(ch->buffer) / n; + length = sndbuf_getready(ch->buffer) / n; + /* Copy no more than 2 periods in advance. */ + if (length > (sc->period * 4 * 2)) + length = (sc->period * 4 * 2); + /* Skip what was already copied last time. */ + offset = (ch->position + HDSPE_CHANBUF_SIZE) - pos; + offset %= HDSPE_CHANBUF_SIZE; + if (offset <= length) { + pos = (pos + offset) % HDSPE_CHANBUF_SIZE; + length -= offset; + } + } else { + /* Position per channel is n times smaller than PCM. */ + pos = sndbuf_getfreeptr(ch->buffer) / n; + /* Get DMA buffer write position. */ + dma_pos = hdspe_read_2(sc, HDSPE_STATUS_REG); + dma_pos &= HDSPE_BUF_POSITION_MASK; + /* Copy what is newly available. */ + length = (dma_pos + HDSPE_CHANBUF_SIZE) - pos; + length %= HDSPE_CHANBUF_SIZE; + } - pos /= 4; /* Bytes per sample. */ - pos /= n; /* Destination buffer n-times smaller. */ + /* Position and length in samples (4 bytes). */ + pos /= 4; + length /= 4; /* Iterate through rows of ports with contiguous slots. */ ports = ch->ports; @@ -576,10 +599,10 @@ buffer_copy(struct sc_chinfo *ch) while (row != 0) { if (ch->dir == PCMDIR_PLAY) buffer_mux_port(sc->pbuf, ch->data, row, ch->ports, pos, - sc->period * 2, adat_width, pcm_width); + length, adat_width, pcm_width); else buffer_demux_port(sc->rbuf, ch->data, row, ch->ports, - pos, sc->period * 2, adat_width, pcm_width); + pos, length, adat_width, pcm_width); ports &= ~row; if (pcm_width == adat_width) @@ -587,6 +610,8 @@ buffer_copy(struct sc_chinfo *ch) else row = hdspe_port_first(ports); } + + ch->position = ((pos + length) * 4) % HDSPE_CHANBUF_SIZE; } static int @@ -620,6 +645,8 @@ clean(struct sc_chinfo *ch) row = hdspe_port_first_row(ports); } + ch->position = 0; + return (0); } @@ -664,6 +691,7 @@ hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, /* Allocate maximum buffer size. */ ch->size = HDSPE_CHANBUF_SIZE * hdspe_channel_count(ch->ports, 8); ch->data = malloc(ch->size, M_HDSPE, M_NOWAIT); + ch->position = 0; ch->buffer = b; ch->channel = c; diff --git a/sys/dev/sound/pci/hdspe.h b/sys/dev/sound/pci/hdspe.h index 26694f60ce58..de20462170e7 100644 --- a/sys/dev/sound/pci/hdspe.h +++ b/sys/dev/sound/pci/hdspe.h @@ -184,6 +184,7 @@ struct sc_chinfo { /* Buffer */ uint32_t*data; uint32_tsize; + uint32_tposition; /* Flags */ uint32_trun;
git: 71f16d2efe7e - stable/14 - nfsd.8: Document ways to minimize Copy operation times
The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=71f16d2efe7e9e6ba15620d5ecf6c22051feebfd commit 71f16d2efe7e9e6ba15620d5ecf6c22051feebfd Author: Rick Macklem AuthorDate: 2024-03-18 22:40:41 + Commit: Rick Macklem CommitDate: 2024-04-01 02:10:40 + nfsd.8: Document ways to minimize Copy operation times For NFSv4.2, a Copy operation can take a long time to complete. If there is a concurrent ExchangeID or DelegReturn operation which requires the exclusive lock on all NFSv4 state, this can result in a stall of the nfsd server. This patch documents ways to avoid this problem. This is a content change. (cherry picked from commit 8f13abb4fd2f3c5d25bde830607a4aec6cec42d9) --- usr.sbin/nfsd/nfsd.8 | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/usr.sbin/nfsd/nfsd.8 b/usr.sbin/nfsd/nfsd.8 index 0a9f6f82c85f..1c04bad3a042 100644 --- a/usr.sbin/nfsd/nfsd.8 +++ b/usr.sbin/nfsd/nfsd.8 @@ -27,7 +27,7 @@ .\" .\"@(#)nfsd.8 8.4 (Berkeley) 3/29/95 .\" -.Dd March 22, 2023 +.Dd March 16, 2024 .Dt NFSD 8 .Os .Sh NAME @@ -355,3 +355,25 @@ to be set to one on the MDS as a workaround. Linux 5.n kernels appear to have been patched such that this .Xr sysctl 8 does not need to be set. +.Pp +For NFSv4.2, a Copy operation can take a long time to complete. +If there is a concurrent ExchangeID or DelegReturn operation +which requires the exclusive lock on all NFSv4 state, this can +result in a +.Dq stall +of the +.Nm +server. +If your storage is on ZFS without block cloning enabled, +setting the +.Xr sysctl 8 +.Va vfs.zfs.dmu_offset_next_sync +to 0 can often avoid this problem. +It is also possible to set the +.Xr sysctl 8 +.Va vfs.nfsd.maxcopyrange +to 10-100 megabytes to try and reduce Copy operation times. +As a last resort, setting +.Xr sysctl 8 +.Va vfs.nfsd.maxcopyrange +to 0 disables the Copy operation.
git: 23a48a469a4e - stable/13 - nfsd.8: Document ways to minimize Copy operation times
The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=23a48a469a4e6ce7b69620084513a7bf9b0fb939 commit 23a48a469a4e6ce7b69620084513a7bf9b0fb939 Author: Rick Macklem AuthorDate: 2024-03-18 22:40:41 + Commit: Rick Macklem CommitDate: 2024-04-01 02:16:36 + nfsd.8: Document ways to minimize Copy operation times For NFSv4.2, a Copy operation can take a long time to complete. If there is a concurrent ExchangeID or DelegReturn operation which requires the exclusive lock on all NFSv4 state, this can result in a stall of the nfsd server. This patch documents ways to avoid this problem. This is a content change. (cherry picked from commit 8f13abb4fd2f3c5d25bde830607a4aec6cec42d9) --- usr.sbin/nfsd/nfsd.8 | 24 +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/usr.sbin/nfsd/nfsd.8 b/usr.sbin/nfsd/nfsd.8 index 0a9f6f82c85f..1c04bad3a042 100644 --- a/usr.sbin/nfsd/nfsd.8 +++ b/usr.sbin/nfsd/nfsd.8 @@ -27,7 +27,7 @@ .\" .\"@(#)nfsd.8 8.4 (Berkeley) 3/29/95 .\" -.Dd March 22, 2023 +.Dd March 16, 2024 .Dt NFSD 8 .Os .Sh NAME @@ -355,3 +355,25 @@ to be set to one on the MDS as a workaround. Linux 5.n kernels appear to have been patched such that this .Xr sysctl 8 does not need to be set. +.Pp +For NFSv4.2, a Copy operation can take a long time to complete. +If there is a concurrent ExchangeID or DelegReturn operation +which requires the exclusive lock on all NFSv4 state, this can +result in a +.Dq stall +of the +.Nm +server. +If your storage is on ZFS without block cloning enabled, +setting the +.Xr sysctl 8 +.Va vfs.zfs.dmu_offset_next_sync +to 0 can often avoid this problem. +It is also possible to set the +.Xr sysctl 8 +.Va vfs.nfsd.maxcopyrange +to 10-100 megabytes to try and reduce Copy operation times. +As a last resort, setting +.Xr sysctl 8 +.Va vfs.nfsd.maxcopyrange +to 0 disables the Copy operation.
git: 319a5d086b50 - main - if_bridge: use IF_MINMTU
The branch main has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=319a5d086b50f38618b62c78e83b12931f00b508 commit 319a5d086b50f38618b62c78e83b12931f00b508 Author: Eugene Grosbein AuthorDate: 2024-04-01 03:31:51 + Commit: Eugene Grosbein CommitDate: 2024-04-01 03:35:59 + if_bridge: use IF_MINMTU Replace incorrect constant 576 with IF_MINMTU to check for minumum MTU. This unbreaks bridging tap interfaces with small mtu. MFC after: 1 week --- sys/net/if_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index fe5de468bf28..31758733adb1 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -960,7 +960,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFMTU: oldmtu = sc->sc_ifp->if_mtu; - if (ifr->ifr_mtu < 576) { + if (ifr->ifr_mtu < IF_MINMTU) { error = EINVAL; break; }