diff options
author | ed <ed@FreeBSD.org> | 2012-08-28 18:33:12 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-08-28 18:33:12 +0000 |
commit | 6e82ac32c7ef1558432883b4bcd104358ce52334 (patch) | |
tree | 2d8dfa0d2907318ac126216e8689f430836b42ca /sys | |
parent | cfecbd548262f7e923cad1d9fd9e9e2d220dafe2 (diff) | |
download | FreeBSD-src-6e82ac32c7ef1558432883b4bcd104358ce52334.zip FreeBSD-src-6e82ac32c7ef1558432883b4bcd104358ce52334.tar.gz |
Use a proper destructor function.
When calling a revoke(2) on a dtrace device, dtrace_close() could be
called, even if threads are still stuck in the device. Defer the actual
deallocation of datastructures to the cdevpriv destructor.
While there, remove the unneeded D_TRACKCLOSE and D_NEEDMINOR flags. For
the helper device, we never need it. For the regular dtrace devices, we
only need these flags on FreeBSD pre-8.
MFC after: 1 month
Diffstat (limited to 'sys')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 09c4149..86f401f 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -15342,10 +15342,7 @@ dtrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) #if !defined(sun) #if __FreeBSD_version >= 800039 -static void -dtrace_dtr(void *data __unused) -{ -} +static void dtrace_dtr(void *); #endif #endif @@ -15470,11 +15467,15 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) } /*ARGSUSED*/ -static int #if defined(sun) +static int dtrace_close(dev_t dev, int flag, int otyp, cred_t *cred_p) -#else +#elif __FreeBSD_version < 800039 +static int dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) +#else +static void +dtrace_dtr(void *data) #endif { #if defined(sun) @@ -15493,8 +15494,7 @@ dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) if (dev2unit(dev) == 0) return (0); #else - dtrace_state_t *state; - devfs_get_cdevpriv((void **) &state); + dtrace_state_t *state = data; #endif #endif @@ -15537,7 +15537,9 @@ dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) destroy_dev_sched(dev); #endif +#if defined(sun) || __FreeBSD_version < 800039 return (0); +#endif } #if defined(sun) @@ -16584,8 +16586,10 @@ void dtrace_invop_uninit(void); static struct cdevsw dtrace_cdevsw = { .d_version = D_VERSION, +#if __FreeBSD_version < 800039 .d_flags = D_TRACKCLOSE | D_NEEDMINOR, .d_close = dtrace_close, +#endif .d_ioctl = dtrace_ioctl, .d_open = dtrace_open, .d_name = "dtrace", @@ -16593,7 +16597,6 @@ static struct cdevsw dtrace_cdevsw = { static struct cdevsw helper_cdevsw = { .d_version = D_VERSION, - .d_flags = D_TRACKCLOSE | D_NEEDMINOR, .d_ioctl = dtrace_ioctl_helper, .d_name = "helper", }; |