From nobody Mon Jun 27 19:35:35 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6764F86E075; Mon, 27 Jun 2022 19:35:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LWycm3zG9z3lYb; Mon, 27 Jun 2022 19:35:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656358537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q9M5HunU5+5ClmqSsXZT02/Fn/r0rN3N/vTI67kr05o=; b=ILhmKNFYz85uKmZCqVvn+U6qm+jaAGpgBP0l5wf9VoiimZyuffYKg6IqCuZXxoSIK2fTSt 2GXkNyYZ1uimhmCYzSqg3CKneYf/bzh18beIxrmTFoBn62q5QdxSosoJuqXRHM0HpSadMC vw3Mb0EyJzDoSsgswF3+xTT2IR5SEtqtswtGCwmrTRpz4471E9BLLRqKQiej7Mqig6gdws I4l6+07rVGNH9VwEgbpX1IRZm76RyIKyTsv1WlpaOsHseZo77mbtED9OnThvCgWoxYiyef xrokmGwsWAYsu4HXAd2M2iRtNFyvuNRnidLyt7tEm/4DOx+r6hMxd8xQkn1wIQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D37D06952; Mon, 27 Jun 2022 19:35:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25RJZZp8019816; Mon, 27 Jun 2022 19:35:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25RJZZOs019815; Mon, 27 Jun 2022 19:35:35 GMT (envelope-from git) Date: Mon, 27 Jun 2022 19:35:35 GMT Message-Id: <202206271935.25RJZZOs019815@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 13f544bc8e9f - stable/13 - livedump: add event handler hooks List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 13f544bc8e9f215bfa413b71a258d7c3a6ce4555 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656358537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q9M5HunU5+5ClmqSsXZT02/Fn/r0rN3N/vTI67kr05o=; b=DG3XuepUat4/U9qTOwJf3pfhxtirbcoq4Da39X9gZYo9ZVxW+f7d0oCSztYuooXnbZzqge aAainDvs6mMI1fCM0VYiuFTutHl1lRpE27b01+PtI9vD3Je+jsoj9qiXIwDNB0R3tHaRbW bOXFzuPBx+4kVIkXKM9hoADC0MgJzIUGWvi46+7VrKjRl/Y1+V7uIulorSNMjpGj+VH19K rc/oSRCAzz+F0g9tZjAe5ovXu0VciXyYEiMRA7ytnXuQSRkBvXYy4kJQBROb7O/D6fFHPM vwIs11l9/xjD/C//R77nXP6RdPMBqnBx2t2XJSTXgCyqgXX6Zxt7n4SAukTu8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656358537; a=rsa-sha256; cv=none; b=mFBE0iZice8zIGnMFFgDLLsneqwg96Lfyky8vlDNEWp7DS2+6pR9T0wW8IX3o6vAa5zNCe uYyE2wROZK8QVWpYLtLAlCy4ILlLAwllP5miFowepQaX+BE5T4Axr0OUHXjqOZO4r9kl+j RT3hB/v8dWbKYClyV3iq8c+KYr+yXT77EHRF5xihixteGMqEeL2Odr06YszVQ+iI3fv1lI 9d3HVvJofG7MXIqYHGpsNR+FZsNL0kRcGHlikydT/YHWqUWWCYwU81DoPMdHola4lDXE7E foNNyl2nZ24Ihxbv65Yc/J3wnY1M6tDBij6jFG7iTYtua/KbeVj4ZBJPHcCYfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=13f544bc8e9f215bfa413b71a258d7c3a6ce4555 commit 13f544bc8e9f215bfa413b71a258d7c3a6ce4555 Author: Mitchell Horne AuthorDate: 2022-01-06 19:40:16 +0000 Commit: Mitchell Horne CommitDate: 2022-06-27 19:32:06 +0000 livedump: add event handler hooks Add three hooks to the livedump process: before, after, and for each block of dumped data. This allows, for example, quiescing the system before the dump begins or protecting data of interest to ensure its consistency in the final output. Reviewed by: markj, kib (previous version) Reviewed by: debdrup (manpages) Reviewed by: Pau Amma (manpages) MFC after: 3 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D34067 (cherry picked from commit eb9d205fa6918bad40bdbf66fe3d52931ae3d6ce) --- share/man/man9/EVENTHANDLER.9 | 8 +++++++- sys/kern/kern_vnodedumper.c | 11 +++++++++++ sys/sys/kerneldump.h | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/share/man/man9/EVENTHANDLER.9 b/share/man/man9/EVENTHANDLER.9 index c38bb3d6c93a..b369e2f03258 100644 --- a/share/man/man9/EVENTHANDLER.9 +++ b/share/man/man9/EVENTHANDLER.9 @@ -318,8 +318,14 @@ Callbacks invoked after a linker file has been successfully unloaded. Callbacks invoked before a linker file is about to be unloaded. These callbacks may be used to return an error and prevent the unload from proceeding. +.It Vt livedumper_start +Callback invoked before beginning a kernel dump of the live system. +.It Vt livedumper_dump +Callback invoked for each dumped block of data during a live kernel dump. +.It Vt livedumper_finish +Callback invoked once a live kernel dump has completed. .It Vt lle_event -Callback invoked when an link layer event has happened. +Callback invoked when a link layer event has happened. .It Vt nmbclusters_change Callback invoked when the number of mbuf clusters has changed. .It Vt nmbufs_change diff --git a/sys/kern/kern_vnodedumper.c b/sys/kern/kern_vnodedumper.c index c8fdce5e550a..cd20f4f2fab4 100644 --- a/sys/kern/kern_vnodedumper.c +++ b/sys/kern/kern_vnodedumper.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -111,9 +112,15 @@ livedump_start(int fd, int flags, uint8_t compression) rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + EVENTHANDLER_INVOKE(livedumper_start, &error); + if (error != 0) + goto out; + dump_savectx(); error = minidumpsys(livedi, true); + EVENTHANDLER_INVOKE(livedumper_finish); +out: VOP_UNLOCK(vp); vn_rangelock_unlock(vp, rl_cookie); sx_xunlock(&livedump_sx); @@ -162,6 +169,10 @@ vnode_dump(void *arg, void *virtual, vm_offset_t physical __unused, MPASS(vp != NULL); ASSERT_VOP_LOCKED(vp, __func__); + EVENTHANDLER_INVOKE(livedumper_dump, virtual, offset, length, &error); + if (error != 0) + return (error); + /* Done? */ if (virtual == NULL) return (0); diff --git a/sys/sys/kerneldump.h b/sys/sys/kerneldump.h index 2c73790bc81d..637eab5c39e5 100644 --- a/sys/sys/kerneldump.h +++ b/sys/sys/kerneldump.h @@ -164,6 +164,15 @@ extern int do_minidump; int livedump_start(int, int, uint8_t); +/* Live minidump events */ +typedef void (*livedump_start_fn)(void *arg, int *errorp); +typedef void (*livedump_dump_fn)(void *arg, void *virtual, off_t offset, + size_t len, int *errorp); +typedef void (*livedump_finish_fn)(void *arg); +EVENTHANDLER_DECLARE(livedumper_start, livedump_start_fn); +EVENTHANDLER_DECLARE(livedumper_dump, livedump_dump_fn); +EVENTHANDLER_DECLARE(livedumper_finish, livedump_finish_fn); + #endif #endif /* _SYS_KERNELDUMP_H */