The bulk of tmpfs code is in mm/shmem.c. New inodes are created
static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir,
int mode, dev_t dev, unsigned long flags)
but he delegates almost everything to the common file system code.
In particular, the field is i_inofilled in fs/inode.c:
struct inode *new_inode(struct super_block *sb)
{
static unsigned int last_ino;
struct inode *inode;
spin_lock_prefetch(&inode_lock);
inode = alloc_inode(sb);
if (inode) {
spin_lock(&inode_lock);
__inode_add_to_lists(sb, NULL, inode);
inode->i_ino = ++last_ino;
inode->i_state = 0;
spin_unlock(&inode_lock);
}
return inode;
}
And it really only uses a counter (last_ino).
Most other file systems use information from files on disk to redefine the field later i_ino.
Please note that this is entirely possible for this. The kernel also has a “generation” field, which is populated in various ways. mm/shmem.cuses current time.
source
share