Commit 85fe4025 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Al Viro

fs: do not assign default i_ino in new_inode

Instead of always assigning an increasing inode number in new_inode
move the call to assign it into those callers that actually need it.
For now callers that need it is estimated conservatively, that is
the call is added to all filesystems that do not assign an i_ino
by themselves.  For a few more filesystems we can avoid assigning
any inode number given that they aren't user visible, and for others
it could be done lazily when an inode number is actually needed,
but that's left for later patches.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent f991bd2e
...@@ -57,6 +57,7 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -57,6 +57,7 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
goto bail; goto bail;
} }
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_private = data; inode->i_private = data;
......
...@@ -58,6 +58,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -58,6 +58,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry,
goto bail; goto bail;
} }
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = 0; inode->i_uid = 0;
inode->i_gid = 0; inode->i_gid = 0;
......
...@@ -146,6 +146,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) ...@@ -146,6 +146,7 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
struct inode *ret = new_inode(sb); struct inode *ret = new_inode(sb);
if (ret) { if (ret) {
ret->i_ino = get_next_ino();
ret->i_mode = mode; ret->i_mode = mode;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
} }
......
...@@ -28,6 +28,7 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode) ...@@ -28,6 +28,7 @@ static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode)
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
} }
......
...@@ -276,6 +276,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de ...@@ -276,6 +276,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
......
...@@ -980,6 +980,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data, ...@@ -980,6 +980,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
if (likely(inode)) { if (likely(inode)) {
struct timespec current_time = CURRENT_TIME; struct timespec current_time = CURRENT_TIME;
inode->i_ino = usbfs_get_inode();
inode->i_mode = perms->mode; inode->i_mode = perms->mode;
inode->i_uid = perms->uid; inode->i_uid = perms->uid;
inode->i_gid = perms->gid; inode->i_gid = perms->gid;
......
...@@ -1991,6 +1991,7 @@ gadgetfs_make_inode (struct super_block *sb, ...@@ -1991,6 +1991,7 @@ gadgetfs_make_inode (struct super_block *sb,
struct inode *inode = new_inode (sb); struct inode *inode = new_inode (sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = default_uid; inode->i_uid = default_uid;
inode->i_gid = default_gid; inode->i_gid = default_gid;
......
...@@ -193,6 +193,7 @@ static struct inode *anon_inode_mkinode(void) ...@@ -193,6 +193,7 @@ static struct inode *anon_inode_mkinode(void)
if (!inode) if (!inode)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
inode->i_ino = get_next_ino();
inode->i_fop = &anon_inode_fops; inode->i_fop = &anon_inode_fops;
inode->i_mapping->a_ops = &anon_aops; inode->i_mapping->a_ops = &anon_aops;
......
...@@ -398,6 +398,7 @@ struct inode *autofs4_get_inode(struct super_block *sb, ...@@ -398,6 +398,7 @@ struct inode *autofs4_get_inode(struct super_block *sb,
inode->i_gid = sb->s_root->d_inode->i_gid; inode->i_gid = sb->s_root->d_inode->i_gid;
} }
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_ino = get_next_ino();
if (S_ISDIR(inf->mode)) { if (S_ISDIR(inf->mode)) {
inode->i_nlink = 2; inode->i_nlink = 2;
......
...@@ -495,6 +495,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode) ...@@ -495,6 +495,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
struct inode * inode = new_inode(sb); struct inode * inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = inode->i_atime = inode->i_mtime = inode->i_ctime =
current_fs_time(inode->i_sb); current_fs_time(inode->i_sb);
......
...@@ -135,6 +135,7 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd) ...@@ -135,6 +135,7 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd)
{ {
struct inode * inode = new_inode(configfs_sb); struct inode * inode = new_inode(configfs_sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mapping->a_ops = &configfs_aops; inode->i_mapping->a_ops = &configfs_aops;
inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; inode->i_mapping->backing_dev_info = &configfs_backing_dev_info;
inode->i_op = &configfs_inode_operations; inode->i_op = &configfs_inode_operations;
......
...@@ -40,6 +40,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d ...@@ -40,6 +40,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
......
...@@ -2373,6 +2373,7 @@ static int ext4_mb_init_backend(struct super_block *sb) ...@@ -2373,6 +2373,7 @@ static int ext4_mb_init_backend(struct super_block *sb)
printk(KERN_ERR "EXT4-fs: can't get new inode\n"); printk(KERN_ERR "EXT4-fs: can't get new inode\n");
goto err_freesgi; goto err_freesgi;
} }
sbi->s_buddy_cache->i_ino = get_next_ino();
EXT4_I(sbi->s_buddy_cache)->i_disksize = 0; EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
for (i = 0; i < ngroups; i++) { for (i = 0; i < ngroups; i++) {
desc = ext4_get_group_desc(sb, i, NULL); desc = ext4_get_group_desc(sb, i, NULL);
......
...@@ -260,6 +260,7 @@ vxfs_get_fake_inode(struct super_block *sbp, struct vxfs_inode_info *vip) ...@@ -260,6 +260,7 @@ vxfs_get_fake_inode(struct super_block *sbp, struct vxfs_inode_info *vip)
struct inode *ip = NULL; struct inode *ip = NULL;
if ((ip = new_inode(sbp))) { if ((ip = new_inode(sbp))) {
ip->i_ino = get_next_ino();
vxfs_iinit(ip, vip); vxfs_iinit(ip, vip);
ip->i_mapping->a_ops = &vxfs_aops; ip->i_mapping->a_ops = &vxfs_aops;
} }
......
...@@ -222,6 +222,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, ...@@ -222,6 +222,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
if (!inode) if (!inode)
return NULL; return NULL;
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = fc->user_id; inode->i_uid = fc->user_id;
inode->i_gid = fc->group_id; inode->i_gid = fc->group_id;
......
...@@ -455,6 +455,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, ...@@ -455,6 +455,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
inode = new_inode(sb); inode = new_inode(sb);
if (inode) { if (inode) {
struct hugetlbfs_inode_info *info; struct hugetlbfs_inode_info *info;
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = uid; inode->i_uid = uid;
inode->i_gid = gid; inode->i_gid = gid;
......
...@@ -735,7 +735,7 @@ static struct inode *find_inode_fast(struct super_block *sb, ...@@ -735,7 +735,7 @@ static struct inode *find_inode_fast(struct super_block *sb,
#define LAST_INO_BATCH 1024 #define LAST_INO_BATCH 1024
static DEFINE_PER_CPU(unsigned int, last_ino); static DEFINE_PER_CPU(unsigned int, last_ino);
static unsigned int get_next_ino(void) unsigned int get_next_ino(void)
{ {
unsigned int *p = &get_cpu_var(last_ino); unsigned int *p = &get_cpu_var(last_ino);
unsigned int res = *p; unsigned int res = *p;
...@@ -753,6 +753,7 @@ static unsigned int get_next_ino(void) ...@@ -753,6 +753,7 @@ static unsigned int get_next_ino(void)
put_cpu_var(last_ino); put_cpu_var(last_ino);
return res; return res;
} }
EXPORT_SYMBOL(get_next_ino);
/** /**
* new_inode - obtain an inode * new_inode - obtain an inode
...@@ -776,7 +777,6 @@ struct inode *new_inode(struct super_block *sb) ...@@ -776,7 +777,6 @@ struct inode *new_inode(struct super_block *sb)
if (inode) { if (inode) {
spin_lock(&inode_lock); spin_lock(&inode_lock);
__inode_sb_list_add(inode); __inode_sb_list_add(inode);
inode->i_ino = get_next_ino();
inode->i_state = 0; inode->i_state = 0;
spin_unlock(&inode_lock); spin_unlock(&inode_lock);
} }
......
...@@ -400,6 +400,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb) ...@@ -400,6 +400,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
if (inode) { if (inode) {
ip = DLMFS_I(inode); ip = DLMFS_I(inode);
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
...@@ -425,6 +426,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent, ...@@ -425,6 +426,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
if (!inode) if (!inode)
return NULL; return NULL;
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
......
...@@ -954,6 +954,8 @@ static struct inode * get_pipe_inode(void) ...@@ -954,6 +954,8 @@ static struct inode * get_pipe_inode(void)
if (!inode) if (!inode)
goto fail_inode; goto fail_inode;
inode->i_ino = get_next_ino();
pipe = alloc_pipe_info(inode); pipe = alloc_pipe_info(inode);
if (!pipe) if (!pipe)
goto fail_iput; goto fail_iput;
......
...@@ -1603,6 +1603,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st ...@@ -1603,6 +1603,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
/* Common stuff */ /* Common stuff */
ei = PROC_I(inode); ei = PROC_I(inode);
inode->i_ino = get_next_ino();
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_op = &proc_def_inode_operations; inode->i_op = &proc_def_inode_operations;
...@@ -2549,6 +2550,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir, ...@@ -2549,6 +2550,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
/* Initialize the inode */ /* Initialize the inode */
ei = PROC_I(inode); ei = PROC_I(inode);
inode->i_ino = get_next_ino();
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
/* /*
......
...@@ -23,6 +23,8 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, ...@@ -23,6 +23,8 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
if (!inode) if (!inode)
goto out; goto out;
inode->i_ino = get_next_ino();
sysctl_head_get(head); sysctl_head_get(head);
ei = PROC_I(inode); ei = PROC_I(inode);
ei->sysctl = head; ei->sysctl = head;
......
...@@ -58,6 +58,7 @@ struct inode *ramfs_get_inode(struct super_block *sb, ...@@ -58,6 +58,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
struct inode * inode = new_inode(sb); struct inode * inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode_init_owner(inode, dir, mode); inode_init_owner(inode, dir, mode);
inode->i_mapping->a_ops = &ramfs_aops; inode->i_mapping->a_ops = &ramfs_aops;
inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
......
...@@ -1580,6 +1580,7 @@ xfs_mapping_buftarg( ...@@ -1580,6 +1580,7 @@ xfs_mapping_buftarg(
XFS_BUFTARG_NAME(btp)); XFS_BUFTARG_NAME(btp));
return ENOMEM; return ENOMEM;
} }
inode->i_ino = get_next_ino();
inode->i_mode = S_IFBLK; inode->i_mode = S_IFBLK;
inode->i_bdev = bdev; inode->i_bdev = bdev;
inode->i_rdev = bdev->bd_dev; inode->i_rdev = bdev->bd_dev;
......
...@@ -2191,6 +2191,7 @@ extern struct inode * iget_locked(struct super_block *, unsigned long); ...@@ -2191,6 +2191,7 @@ extern struct inode * iget_locked(struct super_block *, unsigned long);
extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *);
extern int insert_inode_locked(struct inode *); extern int insert_inode_locked(struct inode *);
extern void unlock_new_inode(struct inode *); extern void unlock_new_inode(struct inode *);
extern unsigned int get_next_ino(void);
extern void __iget(struct inode * inode); extern void __iget(struct inode * inode);
extern void iget_failed(struct inode *); extern void iget_failed(struct inode *);
......
...@@ -116,6 +116,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb, ...@@ -116,6 +116,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
inode = new_inode(sb); inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
......
...@@ -777,6 +777,7 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb) ...@@ -777,6 +777,7 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb)
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
......
...@@ -1586,6 +1586,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode ...@@ -1586,6 +1586,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
inode = new_inode(sb); inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode_init_owner(inode, dir, mode); inode_init_owner(inode, dir, mode);
inode->i_blocks = 0; inode->i_blocks = 0;
inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
......
...@@ -480,6 +480,7 @@ static struct socket *sock_alloc(void) ...@@ -480,6 +480,7 @@ static struct socket *sock_alloc(void)
sock = SOCKET_I(inode); sock = SOCKET_I(inode);
kmemcheck_annotate_bitfield(sock, type); kmemcheck_annotate_bitfield(sock, type);
inode->i_ino = get_next_ino();
inode->i_mode = S_IFSOCK | S_IRWXUGO; inode->i_mode = S_IFSOCK | S_IRWXUGO;
inode->i_uid = current_fsuid(); inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid(); inode->i_gid = current_fsgid();
......
...@@ -445,6 +445,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode) ...@@ -445,6 +445,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
if (!inode) if (!inode)
return NULL; return NULL;
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch(mode & S_IFMT) { switch(mode & S_IFMT) {
......
...@@ -61,6 +61,7 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) ...@@ -61,6 +61,7 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
struct inode *inode = new_inode(sb); struct inode *inode = new_inode(sb);
if (inode) { if (inode) {
inode->i_ino = get_next_ino();
inode->i_mode = mode; inode->i_mode = mode;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) { switch (mode & S_IFMT) {
......
...@@ -978,6 +978,7 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode) ...@@ -978,6 +978,7 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
struct inode *ret = new_inode(sb); struct inode *ret = new_inode(sb);
if (ret) { if (ret) {
ret->i_ino = get_next_ino();
ret->i_mode = mode; ret->i_mode = mode;
ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment