1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

fd: reduce excessive zeroing on fd close

fde_file as NULL is already an indicator of an unused fd. All other
fields are populated when fp is installed.
This commit is contained in:
Mateusz Guzik 2015-06-14 14:10:05 +00:00
parent ea31808c3b
commit cedab3c72c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=284381

View File

@ -309,7 +309,7 @@ fdfree(struct filedesc *fdp, int fd)
seq_write_begin(&fde->fde_seq);
#endif
fdefree_last(fde);
bzero(fde, fde_change_size);
fde->fde_file = NULL;
fdunused(fdp, fd);
#ifdef CAPABILITIES
seq_write_end(&fde->fde_seq);
@ -1651,7 +1651,6 @@ fdalloc(struct thread *td, int minfd, int *result)
("fd_first_free() returned non-free descriptor"));
KASSERT(fdp->fd_ofiles[fd].fde_file == NULL,
("file descriptor isn't free"));
KASSERT(fdp->fd_ofiles[fd].fde_flags == 0, ("file flags are set"));
fdused(fdp, fd);
*result = fd;
return (0);
@ -1766,8 +1765,7 @@ _finstall(struct filedesc *fdp, struct file *fp, int fd, int flags,
seq_write_begin(&fde->fde_seq);
#endif
fde->fde_file = fp;
if ((flags & O_CLOEXEC) != 0)
fde->fde_flags |= UF_EXCLOSE;
fde->fde_flags = (flags & O_CLOEXEC) != 0 ? UF_EXCLOSE : 0;
if (fcaps != NULL)
filecaps_move(fcaps, &fde->fde_caps);
else
@ -2852,7 +2850,7 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
seq_write_begin(&newfde->fde_seq);
#endif
memcpy(newfde, oldfde, fde_change_size);
bzero(oldfde, fde_change_size);
oldfde->fde_file = NULL;
fdunused(fdp, dfd);
#ifdef CAPABILITIES
seq_write_end(&newfde->fde_seq);