filedesc: move freeing old tables to fdescfree

They cannot be accessed by anyone and hold count only protects the structure
from being freed.
This commit is contained in:
Mateusz Guzik 2014-11-02 14:12:03 +00:00
parent fa360767db
commit 3dca54ab98
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273970

View File

@ -1856,8 +1856,6 @@ fdhold(struct proc *p)
static void
fddrop(struct filedesc *fdp)
{
struct filedesc0 *fdp0;
struct freetable *ft;
int i;
mtx_lock(&fdesc_mtx);
@ -1867,11 +1865,6 @@ fddrop(struct filedesc *fdp)
return;
FILEDESC_LOCK_DESTROY(fdp);
fdp0 = (struct filedesc0 *)fdp;
while ((ft = SLIST_FIRST(&fdp0->fd_free)) != NULL) {
SLIST_REMOVE_HEAD(&fdp0->fd_free, ft_next);
free(ft->ft_table, M_FILEDESC);
}
free(fdp, M_FILEDESC);
}
@ -2032,7 +2025,9 @@ fdclearlocks(struct thread *td)
void
fdescfree(struct thread *td)
{
struct filedesc0 *fdp0;
struct filedesc *fdp;
struct freetable *ft;
struct filedescent *fde;
struct file *fp;
struct vnode *cdir, *jdir, *rdir;
@ -2085,6 +2080,12 @@ fdescfree(struct thread *td)
if (fdp->fd_nfiles > NDFILE)
free(fdp->fd_files, M_FILEDESC);
fdp0 = (struct filedesc0 *)fdp;
while ((ft = SLIST_FIRST(&fdp0->fd_free)) != NULL) {
SLIST_REMOVE_HEAD(&fdp0->fd_free, ft_next);
free(ft->ft_table, M_FILEDESC);
}
if (cdir != NULL)
vrele(cdir);
if (rdir != NULL)