From f7db522fa2f1fcbb76a20e92dd738d7ba2b7004b Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Fri, 18 May 2012 20:33:56 -0700 Subject: [PATCH] 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. --- sys/vfs/tmpfs/tmpfs.h | 1 + sys/vfs/tmpfs/tmpfs_subr.c | 16 ++++++---------- sys/vfs/tmpfs/tmpfs_vfsops.c | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sys/vfs/tmpfs/tmpfs.h b/sys/vfs/tmpfs/tmpfs.h index 609b1c18e945..7e8a7e68a929 100644 --- a/sys/vfs/tmpfs/tmpfs.h +++ b/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; diff --git a/sys/vfs/tmpfs/tmpfs_subr.c b/sys/vfs/tmpfs/tmpfs_subr.c index c5ae546e8b73..14e70b90e535 100644 --- a/sys/vfs/tmpfs/tmpfs_subr.c +++ b/sys/vfs/tmpfs/tmpfs_subr.c @@ -54,9 +54,7 @@ #include #include -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); } diff --git a/sys/vfs/tmpfs/tmpfs_vfsops.c b/sys/vfs/tmpfs/tmpfs_vfsops.c index f4ab2f4112fb..4aa5eb1eda1e 100644 --- a/sys/vfs/tmpfs/tmpfs_vfsops.c +++ b/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,