Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Aug 2012 18:33:12 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r239786 - head/sys/cddl/contrib/opensolaris/uts/common/dtrace
Message-ID:  <201208281833.q7SIXClS009589@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Tue Aug 28 18:33:12 2012
New Revision: 239786
URL: http://svn.freebsd.org/changeset/base/239786

Log:
  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

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Tue Aug 28 17:27:46 2012	(r239785)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Tue Aug 28 18:33:12 2012	(r239786)
@@ -15342,10 +15342,7 @@ dtrace_attach(dev_info_t *devi, ddi_atta
 
 #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
 }
 
 /*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
 	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
 	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",
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208281833.q7SIXClS009589>