diff options
author | David Howells <dhowells@redhat.com> | 2008-02-07 03:15:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:29 -0500 |
commit | 0a370e5de9e5a48eb4b268e9f5e2286b82f44012 (patch) | |
tree | 6ffdabfb1457657a4b888ae23e03fbc1d84601bf /fs/hostfs | |
parent | b88a27edcd3e96f826c291f8e34fdbb0a90bc9ca (diff) |
iget: stop HOSTFS from using iget() and read_inode()
Stop the HOSTFS filesystem from using iget() and read_inode(). Provide
hostfs_iget(), and call that instead of iget(). hostfs_iget() then uses
iget_locked() directly and returns a proper error code instead of an inode in
the event of an error.
hostfs_fill_sb_common() returns any error incurred when getting the root inode
instead of EINVAL.
Note that the contents of hostfs_kern.c need to be examined:
(*) hostfs_iget() should perhaps subsume init_inode() and hostfs_read_inode().
(*) It would appear that all hostfs inodes are the same inode because iget()
was being called with inode number 0 - which forms the lookup key.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Jeff Dike <jdike@addtoit.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/hostfs')
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 8966b050196e..2b9b35733aac 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -202,7 +202,7 @@ static char *follow_link(char *link) | |||
202 | return ERR_PTR(n); | 202 | return ERR_PTR(n); |
203 | } | 203 | } |
204 | 204 | ||
205 | static int read_inode(struct inode *ino) | 205 | static int hostfs_read_inode(struct inode *ino) |
206 | { | 206 | { |
207 | char *name; | 207 | char *name; |
208 | int err = 0; | 208 | int err = 0; |
@@ -233,6 +233,25 @@ static int read_inode(struct inode *ino) | |||
233 | return err; | 233 | return err; |
234 | } | 234 | } |
235 | 235 | ||
236 | static struct inode *hostfs_iget(struct super_block *sb) | ||
237 | { | ||
238 | struct inode *inode; | ||
239 | long ret; | ||
240 | |||
241 | inode = iget_locked(sb, 0); | ||
242 | if (!inode) | ||
243 | return ERR_PTR(-ENOMEM); | ||
244 | if (inode->i_state & I_NEW) { | ||
245 | ret = hostfs_read_inode(inode); | ||
246 | if (ret < 0) { | ||
247 | iget_failed(inode); | ||
248 | return ERR_PTR(ret); | ||
249 | } | ||
250 | unlock_new_inode(inode); | ||
251 | } | ||
252 | return inode; | ||
253 | } | ||
254 | |||
236 | int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) | 255 | int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf) |
237 | { | 256 | { |
238 | /* | 257 | /* |
@@ -303,17 +322,11 @@ static void hostfs_destroy_inode(struct inode *inode) | |||
303 | kfree(HOSTFS_I(inode)); | 322 | kfree(HOSTFS_I(inode)); |
304 | } | 323 | } |
305 | 324 | ||
306 | static void hostfs_read_inode(struct inode *inode) | ||
307 | { | ||
308 | read_inode(inode); | ||
309 | } | ||
310 | |||
311 | static const struct super_operations hostfs_sbops = { | 325 | static const struct super_operations hostfs_sbops = { |
312 | .alloc_inode = hostfs_alloc_inode, | 326 | .alloc_inode = hostfs_alloc_inode, |
313 | .drop_inode = generic_delete_inode, | 327 | .drop_inode = generic_delete_inode, |
314 | .delete_inode = hostfs_delete_inode, | 328 | .delete_inode = hostfs_delete_inode, |
315 | .destroy_inode = hostfs_destroy_inode, | 329 | .destroy_inode = hostfs_destroy_inode, |
316 | .read_inode = hostfs_read_inode, | ||
317 | .statfs = hostfs_statfs, | 330 | .statfs = hostfs_statfs, |
318 | }; | 331 | }; |
319 | 332 | ||
@@ -571,10 +584,11 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
571 | char *name; | 584 | char *name; |
572 | int error, fd; | 585 | int error, fd; |
573 | 586 | ||
574 | error = -ENOMEM; | 587 | inode = hostfs_iget(dir->i_sb); |
575 | inode = iget(dir->i_sb, 0); | 588 | if (IS_ERR(inode)) { |
576 | if (inode == NULL) | 589 | error = PTR_ERR(inode); |
577 | goto out; | 590 | goto out; |
591 | } | ||
578 | 592 | ||
579 | error = init_inode(inode, dentry); | 593 | error = init_inode(inode, dentry); |
580 | if (error) | 594 | if (error) |
@@ -615,10 +629,11 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry, | |||
615 | char *name; | 629 | char *name; |
616 | int err; | 630 | int err; |
617 | 631 | ||
618 | err = -ENOMEM; | 632 | inode = hostfs_iget(ino->i_sb); |
619 | inode = iget(ino->i_sb, 0); | 633 | if (IS_ERR(inode)) { |
620 | if (inode == NULL) | 634 | err = PTR_ERR(inode); |
621 | goto out; | 635 | goto out; |
636 | } | ||
622 | 637 | ||
623 | err = init_inode(inode, dentry); | 638 | err = init_inode(inode, dentry); |
624 | if (err) | 639 | if (err) |
@@ -736,11 +751,13 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) | |||
736 | { | 751 | { |
737 | struct inode *inode; | 752 | struct inode *inode; |
738 | char *name; | 753 | char *name; |
739 | int err = -ENOMEM; | 754 | int err; |
740 | 755 | ||
741 | inode = iget(dir->i_sb, 0); | 756 | inode = hostfs_iget(dir->i_sb); |
742 | if (inode == NULL) | 757 | if (IS_ERR(inode)) { |
758 | err = PTR_ERR(inode); | ||
743 | goto out; | 759 | goto out; |
760 | } | ||
744 | 761 | ||
745 | err = init_inode(inode, dentry); | 762 | err = init_inode(inode, dentry); |
746 | if (err) | 763 | if (err) |
@@ -952,9 +969,11 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) | |||
952 | 969 | ||
953 | sprintf(host_root_path, "%s/%s", root_ino, req_root); | 970 | sprintf(host_root_path, "%s/%s", root_ino, req_root); |
954 | 971 | ||
955 | root_inode = iget(sb, 0); | 972 | root_inode = hostfs_iget(sb); |
956 | if (root_inode == NULL) | 973 | if (IS_ERR(root_inode)) { |
974 | err = PTR_ERR(root_inode); | ||
957 | goto out_free; | 975 | goto out_free; |
976 | } | ||
958 | 977 | ||
959 | err = init_inode(root_inode, NULL); | 978 | err = init_inode(root_inode, NULL); |
960 | if (err) | 979 | if (err) |
@@ -972,7 +991,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent) | |||
972 | if (sb->s_root == NULL) | 991 | if (sb->s_root == NULL) |
973 | goto out_put; | 992 | goto out_put; |
974 | 993 | ||
975 | err = read_inode(root_inode); | 994 | err = hostfs_read_inode(root_inode); |
976 | if (err) { | 995 | if (err) { |
977 | /* No iput in this case because the dput does that for us */ | 996 | /* No iput in this case because the dput does that for us */ |
978 | dput(sb->s_root); | 997 | dput(sb->s_root); |