Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

kernel -- tmpfs: Convert tmpfs inode counter to per-mount field

tmpfs used a global counter under a spinlock to set inode numbers. This
should be a per-mount field, protected by the mount lock.
  • Loading branch information...
commit f7db522fa2f1fcbb76a20e92dd738d7ba2b7004b 1 parent 9d2581a
@vsrinivas vsrinivas authored
View
1  sys/vfs/tmpfs/tmpfs.h
@@ -398,6 +398,7 @@ struct tmpfs_mount {
struct objcache *tm_dirent_pool;
struct objcache *tm_node_pool;
+ int tm_ino;
int tm_flags;
struct netexport tm_export;
View
16 sys/vfs/tmpfs/tmpfs_subr.c
@@ -54,9 +54,7 @@
#include <vfs/tmpfs/tmpfs.h>
#include <vfs/tmpfs/tmpfs_vnops.h>
-static ino_t t_ino = 2;
-static struct spinlock ino_lock;
-static ino_t tmpfs_fetch_ino(void);
+static ino_t tmpfs_fetch_ino(struct tmpfs_mount *);
/* --------------------------------------------------------------------- */
@@ -115,7 +113,7 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type,
nnode->tn_uid = uid;
nnode->tn_gid = gid;
nnode->tn_mode = mode;
- nnode->tn_id = tmpfs_fetch_ino();
+ nnode->tn_id = tmpfs_fetch_ino(tmp);
nnode->tn_advlock.init_done = 0;
/* Type-specific initialization. */
@@ -1340,13 +1338,11 @@ tmpfs_truncate(struct vnode *vp, off_t length)
/* --------------------------------------------------------------------- */
static ino_t
-tmpfs_fetch_ino(void)
+tmpfs_fetch_ino(struct tmpfs_mount *tmp)
{
- ino_t ret;
+ ino_t ret;
- spin_lock(&ino_lock);
- ret = t_ino++;
- spin_unlock(&ino_lock);
+ ret = tmp->tm_ino++;
- return ret;
+ return (ret);
}
View
2  sys/vfs/tmpfs/tmpfs_vfsops.c
@@ -251,6 +251,8 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
tmpfs_node_init, tmpfs_node_fini,
&tmp->tm_node_zone_malloc_args);
+ tmp->tm_ino = 2;
+
/* Allocate the root node. */
error = tmpfs_alloc_node(tmp, VDIR, root_uid, root_gid,
root_mode & ALLPERMS, NULL, NULL,
Please sign in to comment.
Something went wrong with that request. Please try again.