diff options
author | Mark Johnston <markj@FreeBSD.org> | 2020-12-09 14:04:54 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2020-12-09 14:04:54 +0000 |
commit | 4c1c90ea955be45fcbabd9b76d85b8fb18b79f45 (patch) | |
tree | 02cf9856a44c1fec10bc676ce1e5589c32413e1e /sys/kern | |
parent | df546c3b730d4abcace1da24226bd5f01280588e (diff) | |
download | src-test2-4c1c90ea955be45fcbabd9b76d85b8fb18b79f45.tar.gz src-test2-4c1c90ea955be45fcbabd9b76d85b8fb18b79f45.zip |
Use refcount_load(9) to load fd table reference counts
No functional change intended.
Reviewed by: kib, mjg
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27512
Notes
Notes:
svn path=/head/; revision=368485
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_descrip.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 9e64fd742b4c..bf556eddb43f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1830,7 +1830,8 @@ fdgrowtable(struct filedesc *fdp, int nfd) * which must not be freed. */ if (onfiles > NDFILE) { - if (curproc->p_numthreads == 1 && fdp->fd_refcnt == 1) + if (curproc->p_numthreads == 1 && + refcount_load(&fdp->fd_refcnt) == 1) free(otable, M_FILEDESC); else { ft = (struct freetable *)&otable->fdt_ofiles[onfiles]; @@ -2160,7 +2161,7 @@ static void fddrop(struct filedesc *fdp) { - if (fdp->fd_holdcnt > 1) { + if (refcount_load(&fdp->fd_holdcnt) > 1) { if (refcount_release(&fdp->fd_holdcnt) == 0) return; } @@ -2221,7 +2222,7 @@ fdunshare(struct thread *td) struct filedesc *tmp; struct proc *p = td->td_proc; - if (p->p_fd->fd_refcnt == 1) + if (refcount_load(&p->p_fd->fd_refcnt) == 1) return; tmp = fdcopy(p->p_fd); @@ -2570,7 +2571,8 @@ fdsetugidsafety(struct thread *td) int i; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(&fdp->fd_refcnt) == 1, + ("the fdtable should not be shared")); MPASS(fdp->fd_nfiles >= 3); for (i = 0; i <= 2; i++) { fp = fdp->fd_ofiles[i].fde_file; @@ -2621,7 +2623,8 @@ fdcloseexec(struct thread *td) int i, lastfile; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(&fdp->fd_refcnt) == 1, + ("the fdtable should not be shared")); lastfile = fdlastfile_single(fdp); for (i = 0; i <= lastfile; i++) { fde = &fdp->fd_ofiles[i]; @@ -2651,7 +2654,8 @@ fdcheckstd(struct thread *td) int i, error, devnull; fdp = td->td_proc->p_fd; - KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + KASSERT(refcount_load(&fdp->fd_refcnt) == 1, + ("the fdtable should not be shared")); MPASS(fdp->fd_nfiles >= 3); devnull = -1; for (i = 0; i <= 2; i++) { @@ -3974,7 +3978,8 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS) continue; FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (n = 0; fdp->fd_refcnt > 0 && n <= lastfile; ++n) { + for (n = 0; refcount_load(&fdp->fd_refcnt) > 0 && n <= lastfile; + n++) { if ((fp = fdp->fd_ofiles[n].fde_file) == NULL) continue; xf.xf_fd = n; @@ -4245,7 +4250,7 @@ kern_proc_filedesc_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, pwd_drop(pwd); FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { + for (i = 0; refcount_load(&fdp->fd_refcnt) > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; #ifdef CAPABILITIES @@ -4400,7 +4405,7 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS) pwd_drop(pwd); FILEDESC_SLOCK(fdp); lastfile = fdlastfile(fdp); - for (i = 0; fdp->fd_refcnt > 0 && i <= lastfile; i++) { + for (i = 0; refcount_load(&fdp->fd_refcnt) > 0 && i <= lastfile; i++) { if ((fp = fdp->fd_ofiles[i].fde_file) == NULL) continue; export_file_to_kinfo(fp, i, NULL, kif, fdp, |