Module Name: src
Committed By: rmind
Date: Mon Nov 18 01:39:34 UTC 2013
Modified Files:
src/sys/fs/tmpfs: tmpfs.h tmpfs_subr.c
Log Message:
Make tmpfs_node_t::tn_gen a 32-bit number, keep it in sync with tmpfs_fid_t.
Also, change tn_status to unsigned while here.
To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/fs/tmpfs/tmpfs.h
cvs rdiff -u -r1.87 -r1.88 src/sys/fs/tmpfs/tmpfs_subr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/tmpfs/tmpfs.h
diff -u src/sys/fs/tmpfs/tmpfs.h:1.46 src/sys/fs/tmpfs/tmpfs.h:1.47
--- src/sys/fs/tmpfs/tmpfs.h:1.46 Fri Nov 8 15:44:23 2013
+++ src/sys/fs/tmpfs/tmpfs.h Mon Nov 18 01:39:34 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs.h,v 1.46 2013/11/08 15:44:23 rmind Exp $ */
+/* $NetBSD: tmpfs.h,v 1.47 2013/11/18 01:39:34 rmind Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -99,10 +99,10 @@ typedef struct tmpfs_node {
/* Inode identifier and generation number. */
ino_t tn_id;
- unsigned long tn_gen;
+ uint32_t tn_gen;
/* Inode status flags (for operations in delayed manner). */
- int tn_status;
+ unsigned tn_status;
/* The inode size. */
off_t tn_size;
@@ -195,8 +195,8 @@ CTASSERT(TMPFS_MAXNAMLEN < UINT16_MAX);
* Bit indicating vnode reclamation.
* We abuse tmpfs_node_t::tn_gen for that.
*/
-#define TMPFS_NODE_GEN_MASK (~0UL >> 1)
-#define TMPFS_RECLAIMING_BIT (~TMPFS_NODE_GEN_MASK)
+#define TMPFS_RECLAIMING_BIT (1U << 31)
+#define TMPFS_NODE_GEN_MASK (TMPFS_RECLAIMING_BIT - 1)
#define TMPFS_NODE_RECLAIMING(node) \
(((node)->tn_gen & TMPFS_RECLAIMING_BIT) != 0)
Index: src/sys/fs/tmpfs/tmpfs_subr.c
diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.87 src/sys/fs/tmpfs/tmpfs_subr.c:1.88
--- src/sys/fs/tmpfs/tmpfs_subr.c:1.87 Sat Nov 16 17:58:27 2013
+++ src/sys/fs/tmpfs/tmpfs_subr.c Mon Nov 18 01:39:34 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_subr.c,v 1.87 2013/11/16 17:58:27 rmind Exp $ */
+/* $NetBSD: tmpfs_subr.c,v 1.88 2013/11/18 01:39:34 rmind Exp $ */
/*
* Copyright (c) 2005-2013 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.87 2013/11/16 17:58:27 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.88 2013/11/18 01:39:34 rmind Exp $");
#include <sys/param.h>
#include <sys/cprng.h>
@@ -127,7 +127,7 @@ tmpfs_alloc_node(tmpfs_mount_t *tmp, enu
* for applications that do not understand 64-bit ino_t.
*/
nnode->tn_id = (ino_t)((uintptr_t)nnode / sizeof(*nnode));
- nnode->tn_gen = TMPFS_NODE_GEN_MASK & (unsigned long)cprng_fast64();
+ nnode->tn_gen = TMPFS_NODE_GEN_MASK & cprng_fast32();
/* Generic initialization. */
nnode->tn_type = type;
@@ -272,7 +272,7 @@ tmpfs_vnode_get(struct mount *mp, tmpfs_
again:
/* If there is already a vnode, try to reclaim it. */
if ((vp = node->tn_vnode) != NULL) {
- atomic_or_ulong(&node->tn_gen, TMPFS_RECLAIMING_BIT);
+ atomic_or_32(&node->tn_gen, TMPFS_RECLAIMING_BIT);
mutex_enter(vp->v_interlock);
mutex_exit(&node->tn_vlock);
error = vget(vp, LK_EXCLUSIVE);
@@ -280,12 +280,12 @@ again:
mutex_enter(&node->tn_vlock);
goto again;
}
- atomic_and_ulong(&node->tn_gen, ~TMPFS_RECLAIMING_BIT);
+ atomic_and_32(&node->tn_gen, ~TMPFS_RECLAIMING_BIT);
*vpp = vp;
return error;
}
if (TMPFS_NODE_RECLAIMING(node)) {
- atomic_and_ulong(&node->tn_gen, ~TMPFS_RECLAIMING_BIT);
+ atomic_and_32(&node->tn_gen, ~TMPFS_RECLAIMING_BIT);
}
/*