Skip to content

Commit

Permalink
kernel -- tmpfs: Convert tmpfs inode counter to per-mount field
Browse files Browse the repository at this point in the history
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
Venkatesh Srinivas committed May 19, 2012
1 parent 9d2581a commit f7db522
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions sys/vfs/tmpfs/tmpfs.h
Expand Up @@ -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;
Expand Down
16 changes: 6 additions & 10 deletions sys/vfs/tmpfs/tmpfs_subr.c
Expand Up @@ -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 *);

/* --------------------------------------------------------------------- */

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions sys/vfs/tmpfs/tmpfs_vfsops.c
Expand Up @@ -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,
Expand Down

0 comments on commit f7db522

Please sign in to comment.