Commit d0b07948 authored by David Howells's avatar David Howells Committed by Linus Torvalds

iget: stop FreeVXFS from using iget() and read_inode()

Stop the FreeVXFS filesystem from using iget() and read_inode().  Replace
vxfs_read_inode() with vxfs_iget(), and call that instead of iget().
vxfs_iget() then uses iget_locked() directly and returns a proper error code
instead of an inode in the event of an error.

vxfs_fill_super() returns any error incurred when getting the root inode
instead of EINVAL.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 17f95a7b
...@@ -58,7 +58,7 @@ extern struct inode * vxfs_get_fake_inode(struct super_block *, ...@@ -58,7 +58,7 @@ extern struct inode * vxfs_get_fake_inode(struct super_block *,
extern void vxfs_put_fake_inode(struct inode *); extern void vxfs_put_fake_inode(struct inode *);
extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t); extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t);
extern struct vxfs_inode_info * vxfs_stiget(struct super_block *, ino_t); extern struct vxfs_inode_info * vxfs_stiget(struct super_block *, ino_t);
extern void vxfs_read_inode(struct inode *); extern struct inode * vxfs_iget(struct super_block *, ino_t);
extern void vxfs_clear_inode(struct inode *); extern void vxfs_clear_inode(struct inode *);
/* vxfs_lookup.c */ /* vxfs_lookup.c */
......
...@@ -129,7 +129,7 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino) ...@@ -129,7 +129,7 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino)
* Description: * Description:
* Search the for inode number @ino in the filesystem * Search the for inode number @ino in the filesystem
* described by @sbp. Use the specified inode table (@ilistp). * described by @sbp. Use the specified inode table (@ilistp).
* Returns the matching VxFS inode on success, else a NULL pointer. * Returns the matching VxFS inode on success, else an error code.
*/ */
static struct vxfs_inode_info * static struct vxfs_inode_info *
__vxfs_iget(ino_t ino, struct inode *ilistp) __vxfs_iget(ino_t ino, struct inode *ilistp)
...@@ -157,12 +157,12 @@ __vxfs_iget(ino_t ino, struct inode *ilistp) ...@@ -157,12 +157,12 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
} }
printk(KERN_WARNING "vxfs: error on page %p\n", pp); printk(KERN_WARNING "vxfs: error on page %p\n", pp);
return NULL; return ERR_CAST(pp);
fail: fail:
printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino); printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino);
vxfs_put_page(pp); vxfs_put_page(pp);
return NULL; return ERR_PTR(-ENOMEM);
} }
/** /**
...@@ -178,7 +178,10 @@ __vxfs_iget(ino_t ino, struct inode *ilistp) ...@@ -178,7 +178,10 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
struct vxfs_inode_info * struct vxfs_inode_info *
vxfs_stiget(struct super_block *sbp, ino_t ino) vxfs_stiget(struct super_block *sbp, ino_t ino)
{ {
return __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist); struct vxfs_inode_info *vip;
vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist);
return IS_ERR(vip) ? NULL : vip;
} }
/** /**
...@@ -282,23 +285,32 @@ vxfs_put_fake_inode(struct inode *ip) ...@@ -282,23 +285,32 @@ vxfs_put_fake_inode(struct inode *ip)
} }
/** /**
* vxfs_read_inode - fill in inode information * vxfs_iget - get an inode
* @ip: inode pointer to fill * @sbp: the superblock to get the inode for
* @ino: the number of the inode to get
* *
* Description: * Description:
* vxfs_read_inode reads the disk inode for @ip and fills * vxfs_read_inode creates an inode, reads the disk inode for @ino and fills
* in all relevant fields in @ip. * in all relevant fields in the new inode.
*/ */
void struct inode *
vxfs_read_inode(struct inode *ip) vxfs_iget(struct super_block *sbp, ino_t ino)
{ {
struct super_block *sbp = ip->i_sb;
struct vxfs_inode_info *vip; struct vxfs_inode_info *vip;
const struct address_space_operations *aops; const struct address_space_operations *aops;
ino_t ino = ip->i_ino; struct inode *ip;
if (!(vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist))) ip = iget_locked(sbp, ino);
return; if (!ip)
return ERR_PTR(-ENOMEM);
if (!(ip->i_state & I_NEW))
return ip;
vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist);
if (IS_ERR(vip)) {
iget_failed(ip);
return ERR_CAST(vip);
}
vxfs_iinit(ip, vip); vxfs_iinit(ip, vip);
...@@ -323,7 +335,8 @@ vxfs_read_inode(struct inode *ip) ...@@ -323,7 +335,8 @@ vxfs_read_inode(struct inode *ip)
} else } else
init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev)); init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev));
return; unlock_new_inode(ip);
return ip;
} }
/** /**
......
...@@ -213,10 +213,10 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd) ...@@ -213,10 +213,10 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd)
lock_kernel(); lock_kernel();
ino = vxfs_inode_by_name(dip, dp); ino = vxfs_inode_by_name(dip, dp);
if (ino) { if (ino) {
ip = iget(dip->i_sb, ino); ip = vxfs_iget(dip->i_sb, ino);
if (!ip) { if (IS_ERR(ip)) {
unlock_kernel(); unlock_kernel();
return ERR_PTR(-EACCES); return ERR_CAST(ip);
} }
} }
unlock_kernel(); unlock_kernel();
......
...@@ -60,7 +60,6 @@ static int vxfs_statfs(struct dentry *, struct kstatfs *); ...@@ -60,7 +60,6 @@ static int vxfs_statfs(struct dentry *, struct kstatfs *);
static int vxfs_remount(struct super_block *, int *, char *); static int vxfs_remount(struct super_block *, int *, char *);
static const struct super_operations vxfs_super_ops = { static const struct super_operations vxfs_super_ops = {
.read_inode = vxfs_read_inode,
.clear_inode = vxfs_clear_inode, .clear_inode = vxfs_clear_inode,
.put_super = vxfs_put_super, .put_super = vxfs_put_super,
.statfs = vxfs_statfs, .statfs = vxfs_statfs,
...@@ -153,6 +152,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -153,6 +152,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
struct buffer_head *bp = NULL; struct buffer_head *bp = NULL;
u_long bsize; u_long bsize;
struct inode *root; struct inode *root;
int ret = -EINVAL;
sbp->s_flags |= MS_RDONLY; sbp->s_flags |= MS_RDONLY;
...@@ -219,7 +219,11 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -219,7 +219,11 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
} }
sbp->s_op = &vxfs_super_ops; sbp->s_op = &vxfs_super_ops;
root = iget(sbp, VXFS_ROOT_INO); root = vxfs_iget(sbp, VXFS_ROOT_INO);
if (IS_ERR(root)) {
ret = PTR_ERR(root);
goto out;
}
sbp->s_root = d_alloc_root(root); sbp->s_root = d_alloc_root(root);
if (!sbp->s_root) { if (!sbp->s_root) {
iput(root); iput(root);
...@@ -236,7 +240,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) ...@@ -236,7 +240,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
out: out:
brelse(bp); brelse(bp);
kfree(infp); kfree(infp);
return -EINVAL; return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment