From nobody Tue Apr 05 18:35:14 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 8D6881A81E11; Tue, 5 Apr 2022 18:35:15 +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 4KXxCR13WKz3pNW; Tue, 5 Apr 2022 18:35:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649183715; 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=INFsn8Q5Sr7iBFaY3Iovnt9FYf4d//fZWtJGWP2v0ng=; b=j+LBU/0AgldAGn9prL6xtZDkz7+wVSdT/APpJpJjUqPVatGMoPZ9WUGwYXyrWhAu759bte 2W85oiPHwCQ1mlLvumL44SeLLnIEvi7dqfGcIW9NHS9mfiXKd2FN4dLaPO+syJ/yJDCxbo oPy4L3i7QS89Q/5/aCCL/37SHW0+NOTXZmoKZyzALDmuMlU40SzBKbx3YKKLXTsP9ThN+x ocB6g7VDVEDP3VMPqh1nvkSDxt6lUebFSZj+aimPW4m+tlU1cLlMTPXC4HKfgmoc2Djfai KzXZzH1nsXAfpUzWzCluCJit/lj7urd+nHZTTK+oR3cpJBdRZygFSzzfxoiAcg== 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 4FFC33948; Tue, 5 Apr 2022 18:35:14 +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 235IZEMV044194; Tue, 5 Apr 2022 18:35:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 235IZExT044193; Tue, 5 Apr 2022 18:35:14 GMT (envelope-from git) Date: Tue, 5 Apr 2022 18:35:14 GMT Message-Id: <202204051835.235IZExT044193@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: eb9d205fa691 - main - 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/main X-Git-Reftype: branch X-Git-Commit: eb9d205fa6918bad40bdbf66fe3d52931ae3d6ce Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649183715; 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=INFsn8Q5Sr7iBFaY3Iovnt9FYf4d//fZWtJGWP2v0ng=; b=Vkud6JRATJJfvtywjBNSPDuHp8MuOpRkfQv2I5AFvzOE5q0qRhC/5IMqsZtBrOe6cA/24D WhZzHf2lDHo6GVaKV1X3JrXxtQa2xJqtFEem+d36Hu62Nr7xMyMD4S4s4o5GNqGFU3NXgW vUxYo/u+qBX1G/az17VQEufZEukxcs0fQISiTdnvCHGfBkICgepuZON08lLlNZib56PCL4 saP7pYLA8jjjbWVz5sJuwkDozktp92d7B/Q+P/y5WdVlasGWErUPOxriTwBnYLnIaFb6Hv A1zAtcRDpdVcDrexWZbw+cXvfUVorBKRpWOzQeRSyTSKk39ws/GAEUy5dmEJyQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649183715; a=rsa-sha256; cv=none; b=WmjT9xZwcy58aFhAZJFI7lWcotQ1elyiPDqcOZLnYC8NJGxDDXWPyHAYhjHo6GnWTPVE+D 7UKV5IEVJG17lCQz9kgfGssuOJ097LCNctDWqgbDL2nxPVYwqOWX7cNxaHl5AFrPZsbb1i iMXWkzDTQbsJus4s0XtEuNTyz+s3VePgUAcbdGMxpdwJe1EDfk31MqiyfOZ6HUi8dwI+me hMFGdT63Mg6mcwEO5nZnxvyUCLE62lZkE5WWZuheDc3KpG/1ivo223vmSII5IWl6vLNcwh 5Wt9SvhKO9o3HaBXy9dwDxqBtqgdz0WliQKMEX8YhOoOqpuMYGlVEs3SdDCkmQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=eb9d205fa6918bad40bdbf66fe3d52931ae3d6ce commit eb9d205fa6918bad40bdbf66fe3d52931ae3d6ce Author: Mitchell Horne AuthorDate: 2022-01-06 19:40:16 +0000 Commit: Mitchell Horne CommitDate: 2022-04-05 18:35:05 +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 --- 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 */