kerneldump: add livedump_start_vnode(9)

livedump_start_vnode(9) is introduced such that the live minidump on the
system could take a vnode. This interface could be used to extend support
for the existing framework in downstream.

Bump __FreeBSD_version for introducing livedump_start_vnode(9).

Sponsored by:	Juniper Networks, Inc.
Reviewed by:	khng
Differential Revision:	https://reviews.freebsd.org/D43471
This commit is contained in:
Vijeyalakshumi Koteeswaran
2024-03-18 15:26:29 -04:00
committed by Ka Ho Ng
parent e34ea0196f
commit 60bc9617e7
3 changed files with 25 additions and 10 deletions
+23 -9
View File
@@ -61,11 +61,8 @@ int
livedump_start(int fd, int flags, uint8_t compression)
{
#if MINIDUMP_PAGE_TRACKING == 1
struct dumperinfo di, *livedi;
struct diocskerneldump_arg kda;
struct vnode *vp;
struct file *fp;
void *rl_cookie;
struct vnode *vp;
int error;
error = priv_check(curthread, PRIV_KMEM_READ);
@@ -84,8 +81,27 @@ livedump_start(int fd, int flags, uint8_t compression)
error = EBADF;
goto drop;
}
error = livedump_start_vnode(vp, flags, compression);
if (error != 0)
goto drop;
drop:
fdrop(fp, curthread);
return (error);
#else
return (EOPNOTSUPP);
#endif /* MINIDUMP_PAGE_TRACKING == 1 */
}
/* Set up a new dumper. */
int
livedump_start_vnode(struct vnode *vp, int flags, uint8_t compression)
{
#if MINIDUMP_PAGE_TRACKING == 1
struct dumperinfo di, *livedi;
struct diocskerneldump_arg kda;
void *rl_cookie;
int error;
/* Set up a new dumper. */
bzero(&di, sizeof(di));
di.dumper_start = vnode_dumper_start;
di.dumper = vnode_dump;
@@ -97,13 +113,13 @@ livedump_start(int fd, int flags, uint8_t compression)
kda.kda_compression = compression;
error = dumper_create(&di, "livedump", &kda, &livedi);
if (error != 0)
goto drop;
return (error);
/* Only allow one livedump to proceed at a time. */
if (sx_try_xlock(&livedump_sx) == 0) {
dumper_destroy(livedi);
error = EBUSY;
goto drop;
return (error);
}
/* To be used by the callback functions. */
@@ -126,8 +142,6 @@ livedump_start(int fd, int flags, uint8_t compression)
vn_rangelock_unlock(vp, rl_cookie);
sx_xunlock(&livedump_sx);
dumper_destroy(livedi);
drop:
fdrop(fp, curthread);
return (error);
#else
return (EOPNOTSUPP);
+1
View File
@@ -161,6 +161,7 @@ void dumpsys_pb_progress(size_t);
extern int do_minidump;
int livedump_start(int, int, uint8_t);
int livedump_start_vnode(struct vnode *, int, uint8_t);
/* Live minidump events */
typedef void (*livedump_start_fn)(void *arg, int *errorp);
+1 -1
View File
@@ -73,7 +73,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1500015
#define __FreeBSD_version 1500016
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,