aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-10-23 11:19:54 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-10-25 21:26:11 -0400
commit85fe4025c616a7c0ed07bc2fc8c5371b07f3888c (patch)
tree7a5db7accb6192f2911f2473b4e3191227b914cc /fs
parentf991bd2e14210fb93d722cb23e54991de20e8a3d (diff)
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: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/anon_inodes.c1
-rw-r--r--fs/autofs4/inode.c1
-rw-r--r--fs/binfmt_misc.c1
-rw-r--r--fs/configfs/inode.c1
-rw-r--r--fs/debugfs/inode.c1
-rw-r--r--fs/ext4/mballoc.c1
-rw-r--r--fs/freevxfs/vxfs_inode.c1
-rw-r--r--fs/fuse/control.c1
-rw-r--r--fs/hugetlbfs/inode.c1
-rw-r--r--fs/inode.c4
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c2
-rw-r--r--fs/pipe.c2
-rw-r--r--fs/proc/base.c2
-rw-r--r--fs/proc/proc_sysctl.c2
-rw-r--r--fs/ramfs/inode.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c1
16 files changed, 21 insertions, 2 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 9c8e87b0361f..5365527ca43f 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -193,6 +193,7 @@ static struct inode *anon_inode_mkinode(void)
193 if (!inode) 193 if (!inode)
194 return ERR_PTR(-ENOMEM); 194 return ERR_PTR(-ENOMEM);
195 195
196 inode->i_ino = get_next_ino();
196 inode->i_fop = &anon_inode_fops; 197 inode->i_fop = &anon_inode_fops;
197 198
198 inode->i_mapping->a_ops = &anon_aops; 199 inode->i_mapping->a_ops = &anon_aops;
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 821b2b955dac..ac87e49fa706 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -398,6 +398,7 @@ struct inode *autofs4_get_inode(struct super_block *sb,
398 inode->i_gid = sb->s_root->d_inode->i_gid; 398 inode->i_gid = sb->s_root->d_inode->i_gid;
399 } 399 }
400 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 400 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
401 inode->i_ino = get_next_ino();
401 402
402 if (S_ISDIR(inf->mode)) { 403 if (S_ISDIR(inf->mode)) {
403 inode->i_nlink = 2; 404 inode->i_nlink = 2;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 139fc8083f53..29990f0eee0c 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -495,6 +495,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
495 struct inode * inode = new_inode(sb); 495 struct inode * inode = new_inode(sb);
496 496
497 if (inode) { 497 if (inode) {
498 inode->i_ino = get_next_ino();
498 inode->i_mode = mode; 499 inode->i_mode = mode;
499 inode->i_atime = inode->i_mtime = inode->i_ctime = 500 inode->i_atime = inode->i_mtime = inode->i_ctime =
500 current_fs_time(inode->i_sb); 501 current_fs_time(inode->i_sb);
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index cf78d44a8d6a..253476d78ed8 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -135,6 +135,7 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd)
135{ 135{
136 struct inode * inode = new_inode(configfs_sb); 136 struct inode * inode = new_inode(configfs_sb);
137 if (inode) { 137 if (inode) {
138 inode->i_ino = get_next_ino();
138 inode->i_mapping->a_ops = &configfs_aops; 139 inode->i_mapping->a_ops = &configfs_aops;
139 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; 140 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info;
140 inode->i_op = &configfs_inode_operations; 141 inode->i_op = &configfs_inode_operations;
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 30a87b3dbcac..a4ed8380e98a 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -40,6 +40,7 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
40 struct inode *inode = new_inode(sb); 40 struct inode *inode = new_inode(sb);
41 41
42 if (inode) { 42 if (inode) {
43 inode->i_ino = get_next_ino();
43 inode->i_mode = mode; 44 inode->i_mode = mode;
44 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 45 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
45 switch (mode & S_IFMT) { 46 switch (mode & S_IFMT) {
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 19aa0d44d822..42f77b1dc72d 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2373,6 +2373,7 @@ static int ext4_mb_init_backend(struct super_block *sb)
2373 printk(KERN_ERR "EXT4-fs: can't get new inode\n"); 2373 printk(KERN_ERR "EXT4-fs: can't get new inode\n");
2374 goto err_freesgi; 2374 goto err_freesgi;
2375 } 2375 }
2376 sbi->s_buddy_cache->i_ino = get_next_ino();
2376 EXT4_I(sbi->s_buddy_cache)->i_disksize = 0; 2377 EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
2377 for (i = 0; i < ngroups; i++) { 2378 for (i = 0; i < ngroups; i++) {
2378 desc = ext4_get_group_desc(sb, i, NULL); 2379 desc = ext4_get_group_desc(sb, i, NULL);
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 79d1b4ea13e7..8c04eac5079d 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -260,6 +260,7 @@ vxfs_get_fake_inode(struct super_block *sbp, struct vxfs_inode_info *vip)
260 struct inode *ip = NULL; 260 struct inode *ip = NULL;
261 261
262 if ((ip = new_inode(sbp))) { 262 if ((ip = new_inode(sbp))) {
263 ip->i_ino = get_next_ino();
263 vxfs_iinit(ip, vip); 264 vxfs_iinit(ip, vip);
264 ip->i_mapping->a_ops = &vxfs_aops; 265 ip->i_mapping->a_ops = &vxfs_aops;
265 } 266 }
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 7367e177186f..4eba07661e5c 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -222,6 +222,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
222 if (!inode) 222 if (!inode)
223 return NULL; 223 return NULL;
224 224
225 inode->i_ino = get_next_ino();
225 inode->i_mode = mode; 226 inode->i_mode = mode;
226 inode->i_uid = fc->user_id; 227 inode->i_uid = fc->user_id;
227 inode->i_gid = fc->group_id; 228 inode->i_gid = fc->group_id;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 113eba3d3c38..8d0607b37266 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -455,6 +455,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
455 inode = new_inode(sb); 455 inode = new_inode(sb);
456 if (inode) { 456 if (inode) {
457 struct hugetlbfs_inode_info *info; 457 struct hugetlbfs_inode_info *info;
458 inode->i_ino = get_next_ino();
458 inode->i_mode = mode; 459 inode->i_mode = mode;
459 inode->i_uid = uid; 460 inode->i_uid = uid;
460 inode->i_gid = gid; 461 inode->i_gid = gid;
diff --git a/fs/inode.c b/fs/inode.c
index 46a3e120b196..2cd2e48f7a20 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -735,7 +735,7 @@ repeat:
735#define LAST_INO_BATCH 1024 735#define LAST_INO_BATCH 1024
736static DEFINE_PER_CPU(unsigned int, last_ino); 736static DEFINE_PER_CPU(unsigned int, last_ino);
737 737
738static unsigned int get_next_ino(void) 738unsigned int get_next_ino(void)
739{ 739{
740 unsigned int *p = &get_cpu_var(last_ino); 740 unsigned int *p = &get_cpu_var(last_ino);
741 unsigned int res = *p; 741 unsigned int res = *p;
@@ -753,6 +753,7 @@ static unsigned int get_next_ino(void)
753 put_cpu_var(last_ino); 753 put_cpu_var(last_ino);
754 return res; 754 return res;
755} 755}
756EXPORT_SYMBOL(get_next_ino);
756 757
757/** 758/**
758 * new_inode - obtain an inode 759 * new_inode - obtain an inode
@@ -776,7 +777,6 @@ struct inode *new_inode(struct super_block *sb)
776 if (inode) { 777 if (inode) {
777 spin_lock(&inode_lock); 778 spin_lock(&inode_lock);
778 __inode_sb_list_add(inode); 779 __inode_sb_list_add(inode);
779 inode->i_ino = get_next_ino();
780 inode->i_state = 0; 780 inode->i_state = 0;
781 spin_unlock(&inode_lock); 781 spin_unlock(&inode_lock);
782 } 782 }
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index a7ebd9d42dc8..75e115f1bd73 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -400,6 +400,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
400 if (inode) { 400 if (inode) {
401 ip = DLMFS_I(inode); 401 ip = DLMFS_I(inode);
402 402
403 inode->i_ino = get_next_ino();
403 inode->i_mode = mode; 404 inode->i_mode = mode;
404 inode->i_uid = current_fsuid(); 405 inode->i_uid = current_fsuid();
405 inode->i_gid = current_fsgid(); 406 inode->i_gid = current_fsgid();
@@ -425,6 +426,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
425 if (!inode) 426 if (!inode)
426 return NULL; 427 return NULL;
427 428
429 inode->i_ino = get_next_ino();
428 inode->i_mode = mode; 430 inode->i_mode = mode;
429 inode->i_uid = current_fsuid(); 431 inode->i_uid = current_fsuid();
430 inode->i_gid = current_fsgid(); 432 inode->i_gid = current_fsgid();
diff --git a/fs/pipe.c b/fs/pipe.c
index 37eb1ebeaa90..d2d7566ce68e 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -954,6 +954,8 @@ static struct inode * get_pipe_inode(void)
954 if (!inode) 954 if (!inode)
955 goto fail_inode; 955 goto fail_inode;
956 956
957 inode->i_ino = get_next_ino();
958
957 pipe = alloc_pipe_info(inode); 959 pipe = alloc_pipe_info(inode);
958 if (!pipe) 960 if (!pipe)
959 goto fail_iput; 961 goto fail_iput;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index fb2a5abd4e4f..9883f1e18332 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1603,6 +1603,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
1603 1603
1604 /* Common stuff */ 1604 /* Common stuff */
1605 ei = PROC_I(inode); 1605 ei = PROC_I(inode);
1606 inode->i_ino = get_next_ino();
1606 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 1607 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
1607 inode->i_op = &proc_def_inode_operations; 1608 inode->i_op = &proc_def_inode_operations;
1608 1609
@@ -2549,6 +2550,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
2549 2550
2550 /* Initialize the inode */ 2551 /* Initialize the inode */
2551 ei = PROC_I(inode); 2552 ei = PROC_I(inode);
2553 inode->i_ino = get_next_ino();
2552 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 2554 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2553 2555
2554 /* 2556 /*
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 2fc52552271d..b652cb00906b 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -23,6 +23,8 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
23 if (!inode) 23 if (!inode)
24 goto out; 24 goto out;
25 25
26 inode->i_ino = get_next_ino();
27
26 sysctl_head_get(head); 28 sysctl_head_get(head);
27 ei = PROC_I(inode); 29 ei = PROC_I(inode);
28 ei->sysctl = head; 30 ei->sysctl = head;
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index a5ebae70dc6d..67fadb1ad2c1 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -58,6 +58,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
58 struct inode * inode = new_inode(sb); 58 struct inode * inode = new_inode(sb);
59 59
60 if (inode) { 60 if (inode) {
61 inode->i_ino = get_next_ino();
61 inode_init_owner(inode, dir, mode); 62 inode_init_owner(inode, dir, mode);
62 inode->i_mapping->a_ops = &ramfs_aops; 63 inode->i_mapping->a_ops = &ramfs_aops;
63 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; 64 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index ba5312802aa9..63fd2c07cb57 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1580,6 +1580,7 @@ xfs_mapping_buftarg(
1580 XFS_BUFTARG_NAME(btp)); 1580 XFS_BUFTARG_NAME(btp));
1581 return ENOMEM; 1581 return ENOMEM;
1582 } 1582 }
1583 inode->i_ino = get_next_ino();
1583 inode->i_mode = S_IFBLK; 1584 inode->i_mode = S_IFBLK;
1584 inode->i_bdev = bdev; 1585 inode->i_bdev = bdev;
1585 inode->i_rdev = bdev->bd_dev; 1586 inode->i_rdev = bdev->bd_dev;