git: 4103c3cd5b8d - main - fd: drop volatile keyword from refcounts
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 13 Feb 2022 13:07:16 UTC
The branch main has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=4103c3cd5b8d1e04844f24720fe1a5de3f2206c7
commit 4103c3cd5b8d1e04844f24720fe1a5de3f2206c7
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-01-29 22:02:01 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-02-13 13:07:08 +0000
fd: drop volatile keyword from refcounts
While here move a comment where it belongs and do small whitespace clean up.
---
sys/kern/kern_descrip.c | 2 +-
sys/sys/filedesc.h | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 0f640f395ba4..bf4a3a3f20e5 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -2347,7 +2347,7 @@ pdunshare(struct thread *td)
p = td->td_proc;
/* Not shared. */
- if (p->p_pd->pd_refcount == 1)
+ if (refcount_load(&p->p_pd->pd_refcount) == 1)
return;
pdp = pdcopy(p->p_pd);
diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h
index 426f0ef9ab75..7d106adb756f 100644
--- a/sys/sys/filedesc.h
+++ b/sys/sys/filedesc.h
@@ -74,10 +74,6 @@ struct fdescenttbl {
};
#define fd_seqc(fdt, fd) (&(fdt)->fdt_ofiles[(fd)].fde_seqc)
-/*
- * This structure is used for the management of descriptors. It may be
- * shared by multiple processes.
- */
#define NDSLOTTYPE u_long
/*
@@ -87,20 +83,24 @@ struct fdescenttbl {
* Check pwd_* routines for usage.
*/
struct pwd {
- volatile u_int pwd_refcount;
- struct vnode *pwd_cdir; /* current directory */
- struct vnode *pwd_rdir; /* root directory */
- struct vnode *pwd_jdir; /* jail root directory */
+ u_int pwd_refcount;
+ struct vnode *pwd_cdir; /* current directory */
+ struct vnode *pwd_rdir; /* root directory */
+ struct vnode *pwd_jdir; /* jail root directory */
};
typedef SMR_POINTER(struct pwd *) smrpwd_t;
struct pwddesc {
struct mtx pd_lock; /* protects members of this struct */
smrpwd_t pd_pwd; /* directories */
- volatile u_int pd_refcount;
+ u_int pd_refcount;
u_short pd_cmask; /* mask for file creation */
};
+/*
+ * This structure is used for the management of descriptors. It may be
+ * shared by multiple processes.
+ */
struct filedesc {
struct fdescenttbl *fd_files; /* open files table */
NDSLOTTYPE *fd_map; /* bitmap of free fds */