diff options
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); |