diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2018-09-29 04:29:49 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2018-09-29 04:29:49 +0000 |
commit | 691b70b45c19b10754cea14912bb54a12fd5d359 (patch) | |
tree | 1eef592fd5c723db3f552f3badd2e61409fb62c8 /sys | |
parent | f4a74d27e1515a35cae90566c2493e16e217b453 (diff) |
Use atomic operations to update vfc_refcount. Change the field's type
to unsigned int.
OK deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_subr.c | 9 | ||||
-rw-r--r-- | sys/sys/mount.h | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index de1e14adeb0..b89037e499a 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.281 2018/09/26 14:51:44 visa Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.282 2018/09/29 04:29:48 visa Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -64,6 +64,7 @@ #include <sys/pool.h> #include <sys/tree.h> #include <sys/specdev.h> +#include <sys/atomic.h> #include <netinet/in.h> @@ -179,7 +180,7 @@ vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp) LIST_INIT(&mp->mnt_vnodelist); mp->mnt_vnodecovered = vp; - vfsp->vfc_refcount++; + atomic_inc_int(&vfsp->vfc_refcount); mp->mnt_vfc = vfsp; mp->mnt_op = vfsp->vfc_vfsops; mp->mnt_flag = vfsp->vfc_flags & MNT_VISFLAGMASK; @@ -194,7 +195,7 @@ vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp) void vfs_mount_free(struct mount *mp) { - mp->mnt_vfc->vfc_refcount--; + atomic_dec_int(&mp->mnt_vfc->vfc_refcount); free(mp, M_MOUNT, sizeof(*mp)); } @@ -2227,7 +2228,7 @@ vfs_mount_print(struct mount *mp, int full, mp->mnt_flag, MNT_BITS, mp->mnt_vnodecovered, mp->mnt_syncer, mp->mnt_data); - (*pr)("vfsconf: ops %p name \"%s\" num %d ref %d flags 0x%x\n", + (*pr)("vfsconf: ops %p name \"%s\" num %d ref %u flags 0x%x\n", vfc->vfc_vfsops, vfc->vfc_name, vfc->vfc_typenum, vfc->vfc_refcount, vfc->vfc_flags); diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 98eeda5b98f..9cfeb7ba4b0 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.141 2018/09/26 14:51:44 visa Exp $ */ +/* $OpenBSD: mount.h,v 1.142 2018/09/29 04:29:48 visa Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -454,7 +454,7 @@ struct vfsconf { const struct vfsops *vfc_vfsops; /* filesystem operations vector */ char vfc_name[MFSNAMELEN]; /* filesystem type name */ int vfc_typenum; /* historic filesystem type number */ - int vfc_refcount; /* number mounted of this type */ + u_int vfc_refcount; /* number mounted of this type */ int vfc_flags; /* permanent flags */ size_t vfc_datasize; /* size of data args */ }; |