From owner-svn-src-head@FreeBSD.ORG  Fri Nov  4 03:39:31 2011
Return-Path: <owner-svn-src-head@FreeBSD.ORG>
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DAF0B106566B;
	Fri,  4 Nov 2011 03:39:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CAEDC8FC12;
	Fri,  4 Nov 2011 03:39:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA43dV2h099486;
	Fri, 4 Nov 2011 03:39:31 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA43dVt9099483;
	Fri, 4 Nov 2011 03:39:31 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201111040339.pA43dVt9099483@svn.freebsd.org>
From: John Baldwin <jhb@FreeBSD.org>
Date: Fri, 4 Nov 2011 03:39:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r227069 - in head/sys: fs/devfs kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	<svn-src-head.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-head>,
	<mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-head>,
	<mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 04 Nov 2011 03:39:32 -0000

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);