Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Nov 2011 03:39:31 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r227069 - in head/sys: fs/devfs kern
Message-ID:  <201111040339.pA43dVt9099483@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Nov  4 03:39:31 2011
New Revision: 227069
URL: http://svn.freebsd.org/changeset/base/227069

Log:
  Move the cleanup of f_cdevpriv when the reference count of a devfs
  file descriptor drops to zero out of _fdrop() and into devfs_close_f()
  as it is only relevant for devfs file descriptors.
  
  Reviewed by:	kib
  MFC after:	1 week

Modified:
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/kern/kern_descrip.c

Modified: head/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- head/sys/fs/devfs/devfs_vnops.c	Fri Nov  4 02:34:52 2011	(r227068)
+++ head/sys/fs/devfs/devfs_vnops.c	Fri Nov  4 03:39:31 2011	(r227069)
@@ -604,6 +604,13 @@ devfs_close_f(struct file *fp, struct th
 	td->td_fpop = fp;
 	error = vnops.fo_close(fp, td);
 	td->td_fpop = fpop;
+
+	/*
+	 * The f_cdevpriv cannot be assigned non-NULL value while we
+	 * are destroying the file.
+	 */
+	if (fp->f_cdevpriv != NULL)
+		devfs_fpdrop(fp);
 	return (error);
 }
 

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Fri Nov  4 02:34:52 2011	(r227068)
+++ head/sys/kern/kern_descrip.c	Fri Nov  4 03:39:31 2011	(r227069)
@@ -2575,12 +2575,6 @@ _fdrop(struct file *fp, struct thread *t
 		panic("fdrop: count %d", fp->f_count);
 	if (fp->f_ops != &badfileops)
 		error = fo_close(fp, td);
-	/*
-	 * The f_cdevpriv cannot be assigned non-NULL value while we
-	 * are destroying the file.
-	 */
-	if (fp->f_cdevpriv != NULL)
-		devfs_fpdrop(fp);
 	atomic_subtract_int(&openfiles, 1);
 	crfree(fp->f_cred);
 	uma_zfree(file_zone, fp);



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