aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-07 03:15:51 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:29 -0500
commit755aedc15900ff7d83dd046f632af9a680b0c28f (patch)
treec4868834e52b00301e4d3cc1e450982b7d9fcf9b /fs
parent0a370e5de9e5a48eb4b268e9f5e2286b82f44012 (diff)
iget: stop HPPFS from using iget() and read_inode()
Stop the HPPFS filesystem from using iget() and read_inode(). Provide an hppfs_iget(), and call that instead of iget(). hppfs_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. hppfs_fill_sb_common() returns any error incurred when getting the root inode instead of EINVAL. Note that the contents of hppfs_kern.c need to be examined: (*) The HPPFS inode retains a pointer to the proc dentry it is shadowing, but whilst it does appear to retain a reference to it, it doesn't appear to destroy the reference if the inode goes away. (*) hppfs_iget() should perhaps subsume init_inode() and hppfs_read_inode(). (*) It would appear that all hppfs inodes are the same inode because iget() was being called with inode number 0, which forms the lookup key. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/hppfs/hppfs_kern.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
index affb7412125e..a1e1f0f61aa5 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs_kern.c
@@ -155,6 +155,20 @@ static void hppfs_read_inode(struct inode *ino)
155 ino->i_blocks = proc_ino->i_blocks; 155 ino->i_blocks = proc_ino->i_blocks;
156} 156}
157 157
158static struct inode *hppfs_iget(struct super_block *sb)
159{
160 struct inode *inode;
161
162 inode = iget_locked(sb, 0);
163 if (!inode)
164 return ERR_PTR(-ENOMEM);
165 if (inode->i_state & I_NEW) {
166 hppfs_read_inode(inode);
167 unlock_new_inode(inode);
168 }
169 return inode;
170}
171
158static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, 172static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
159 struct nameidata *nd) 173 struct nameidata *nd)
160{ 174{
@@ -190,9 +204,11 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
190 if(IS_ERR(proc_dentry)) 204 if(IS_ERR(proc_dentry))
191 return(proc_dentry); 205 return(proc_dentry);
192 206
193 inode = iget(ino->i_sb, 0); 207 inode = hppfs_iget(ino->i_sb);
194 if(inode == NULL) 208 if (IS_ERR(inode)) {
209 err = PTR_ERR(inode);
195 goto out_dput; 210 goto out_dput;
211 }
196 212
197 err = init_inode(inode, proc_dentry); 213 err = init_inode(inode, proc_dentry);
198 if(err) 214 if(err)
@@ -652,7 +668,6 @@ static void hppfs_destroy_inode(struct inode *inode)
652static const struct super_operations hppfs_sbops = { 668static const struct super_operations hppfs_sbops = {
653 .alloc_inode = hppfs_alloc_inode, 669 .alloc_inode = hppfs_alloc_inode,
654 .destroy_inode = hppfs_destroy_inode, 670 .destroy_inode = hppfs_destroy_inode,
655 .read_inode = hppfs_read_inode,
656 .delete_inode = hppfs_delete_inode, 671 .delete_inode = hppfs_delete_inode,
657 .statfs = hppfs_statfs, 672 .statfs = hppfs_statfs,
658}; 673};
@@ -745,9 +760,11 @@ static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
745 sb->s_magic = HPPFS_SUPER_MAGIC; 760 sb->s_magic = HPPFS_SUPER_MAGIC;
746 sb->s_op = &hppfs_sbops; 761 sb->s_op = &hppfs_sbops;
747 762
748 root_inode = iget(sb, 0); 763 root_inode = hppfs_iget(sb);
749 if(root_inode == NULL) 764 if (IS_ERR(root_inode)) {
765 err = PTR_ERR(root_inode);
750 goto out; 766 goto out;
767 }
751 768
752 err = init_inode(root_inode, proc_sb->s_root); 769 err = init_inode(root_inode, proc_sb->s_root);
753 if(err) 770 if(err)