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
This commit is contained in:
jhb 2011-11-04 03:39:31 +00:00
parent fd2aad9556
commit 1e2d8c9d67
2 changed files with 7 additions and 6 deletions

View File

@ -604,6 +604,13 @@ devfs_close_f(struct file *fp, struct thread *td)
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);
}

View File

@ -2575,12 +2575,6 @@ _fdrop(struct file *fp, struct thread *td)
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);