Commit 755aedc15900ff7d83dd046f632af9a680b0c28f
Committed by
Linus Torvalds
1 parent
0a370e5de9
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 22 additions and 5 deletions Side-by-side Diff
fs/hppfs/hppfs_kern.c
... | ... | @@ -155,6 +155,20 @@ |
155 | 155 | ino->i_blocks = proc_ino->i_blocks; |
156 | 156 | } |
157 | 157 | |
158 | +static 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 | + | |
158 | 172 | static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, |
159 | 173 | struct nameidata *nd) |
160 | 174 | { |
161 | 175 | |
... | ... | @@ -190,9 +204,11 @@ |
190 | 204 | if(IS_ERR(proc_dentry)) |
191 | 205 | return(proc_dentry); |
192 | 206 | |
193 | - inode = iget(ino->i_sb, 0); | |
194 | - if(inode == NULL) | |
207 | + inode = hppfs_iget(ino->i_sb); | |
208 | + if (IS_ERR(inode)) { | |
209 | + err = PTR_ERR(inode); | |
195 | 210 | goto out_dput; |
211 | + } | |
196 | 212 | |
197 | 213 | err = init_inode(inode, proc_dentry); |
198 | 214 | if(err) |
... | ... | @@ -652,7 +668,6 @@ |
652 | 668 | static const struct super_operations hppfs_sbops = { |
653 | 669 | .alloc_inode = hppfs_alloc_inode, |
654 | 670 | .destroy_inode = hppfs_destroy_inode, |
655 | - .read_inode = hppfs_read_inode, | |
656 | 671 | .delete_inode = hppfs_delete_inode, |
657 | 672 | .statfs = hppfs_statfs, |
658 | 673 | }; |
659 | 674 | |
... | ... | @@ -745,9 +760,11 @@ |
745 | 760 | sb->s_magic = HPPFS_SUPER_MAGIC; |
746 | 761 | sb->s_op = &hppfs_sbops; |
747 | 762 | |
748 | - root_inode = iget(sb, 0); | |
749 | - if(root_inode == NULL) | |
763 | + root_inode = hppfs_iget(sb); | |
764 | + if (IS_ERR(root_inode)) { | |
765 | + err = PTR_ERR(root_inode); | |
750 | 766 | goto out; |
767 | + } | |
751 | 768 | |
752 | 769 | err = init_inode(root_inode, proc_sb->s_root); |
753 | 770 | if(err) |