Skip to content

Commit d0b0794

Browse files
dhowellsLinus Torvalds
authored andcommitted
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. [[email protected]: coding-style fixes] Signed-off-by: David Howells <[email protected]> Acked-by: Christoph Hellwig <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 17f95a7 commit d0b0794

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

fs/freevxfs/vxfs_extern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extern struct inode * vxfs_get_fake_inode(struct super_block *,
5858
extern void vxfs_put_fake_inode(struct inode *);
5959
extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t);
6060
extern struct vxfs_inode_info * vxfs_stiget(struct super_block *, ino_t);
61-
extern void vxfs_read_inode(struct inode *);
61+
extern struct inode * vxfs_iget(struct super_block *, ino_t);
6262
extern void vxfs_clear_inode(struct inode *);
6363

6464
/* vxfs_lookup.c */

fs/freevxfs/vxfs_inode.c

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino)
129129
* Description:
130130
* Search the for inode number @ino in the filesystem
131131
* described by @sbp. Use the specified inode table (@ilistp).
132-
* Returns the matching VxFS inode on success, else a NULL pointer.
132+
* Returns the matching VxFS inode on success, else an error code.
133133
*/
134134
static struct vxfs_inode_info *
135135
__vxfs_iget(ino_t ino, struct inode *ilistp)
@@ -157,12 +157,12 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
157157
}
158158

159159
printk(KERN_WARNING "vxfs: error on page %p\n", pp);
160-
return NULL;
160+
return ERR_CAST(pp);
161161

162162
fail:
163163
printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino);
164164
vxfs_put_page(pp);
165-
return NULL;
165+
return ERR_PTR(-ENOMEM);
166166
}
167167

168168
/**
@@ -178,7 +178,10 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
178178
struct vxfs_inode_info *
179179
vxfs_stiget(struct super_block *sbp, ino_t ino)
180180
{
181-
return __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist);
181+
struct vxfs_inode_info *vip;
182+
183+
vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_stilist);
184+
return IS_ERR(vip) ? NULL : vip;
182185
}
183186

184187
/**
@@ -282,23 +285,32 @@ vxfs_put_fake_inode(struct inode *ip)
282285
}
283286

284287
/**
285-
* vxfs_read_inode - fill in inode information
286-
* @ip: inode pointer to fill
288+
* vxfs_iget - get an inode
289+
* @sbp: the superblock to get the inode for
290+
* @ino: the number of the inode to get
287291
*
288292
* Description:
289-
* vxfs_read_inode reads the disk inode for @ip and fills
290-
* in all relevant fields in @ip.
293+
* vxfs_read_inode creates an inode, reads the disk inode for @ino and fills
294+
* in all relevant fields in the new inode.
291295
*/
292-
void
293-
vxfs_read_inode(struct inode *ip)
296+
struct inode *
297+
vxfs_iget(struct super_block *sbp, ino_t ino)
294298
{
295-
struct super_block *sbp = ip->i_sb;
296299
struct vxfs_inode_info *vip;
297300
const struct address_space_operations *aops;
298-
ino_t ino = ip->i_ino;
299-
300-
if (!(vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist)))
301-
return;
301+
struct inode *ip;
302+
303+
ip = iget_locked(sbp, ino);
304+
if (!ip)
305+
return ERR_PTR(-ENOMEM);
306+
if (!(ip->i_state & I_NEW))
307+
return ip;
308+
309+
vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist);
310+
if (IS_ERR(vip)) {
311+
iget_failed(ip);
312+
return ERR_CAST(vip);
313+
}
302314

303315
vxfs_iinit(ip, vip);
304316

@@ -323,7 +335,8 @@ vxfs_read_inode(struct inode *ip)
323335
} else
324336
init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev));
325337

326-
return;
338+
unlock_new_inode(ip);
339+
return ip;
327340
}
328341

329342
/**

fs/freevxfs/vxfs_lookup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd)
213213
lock_kernel();
214214
ino = vxfs_inode_by_name(dip, dp);
215215
if (ino) {
216-
ip = iget(dip->i_sb, ino);
217-
if (!ip) {
216+
ip = vxfs_iget(dip->i_sb, ino);
217+
if (IS_ERR(ip)) {
218218
unlock_kernel();
219-
return ERR_PTR(-EACCES);
219+
return ERR_CAST(ip);
220220
}
221221
}
222222
unlock_kernel();

fs/freevxfs/vxfs_super.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static int vxfs_statfs(struct dentry *, struct kstatfs *);
6060
static int vxfs_remount(struct super_block *, int *, char *);
6161

6262
static const struct super_operations vxfs_super_ops = {
63-
.read_inode = vxfs_read_inode,
6463
.clear_inode = vxfs_clear_inode,
6564
.put_super = vxfs_put_super,
6665
.statfs = vxfs_statfs,
@@ -153,6 +152,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
153152
struct buffer_head *bp = NULL;
154153
u_long bsize;
155154
struct inode *root;
155+
int ret = -EINVAL;
156156

157157
sbp->s_flags |= MS_RDONLY;
158158

@@ -219,7 +219,11 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
219219
}
220220

221221
sbp->s_op = &vxfs_super_ops;
222-
root = iget(sbp, VXFS_ROOT_INO);
222+
root = vxfs_iget(sbp, VXFS_ROOT_INO);
223+
if (IS_ERR(root)) {
224+
ret = PTR_ERR(root);
225+
goto out;
226+
}
223227
sbp->s_root = d_alloc_root(root);
224228
if (!sbp->s_root) {
225229
iput(root);
@@ -236,7 +240,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
236240
out:
237241
brelse(bp);
238242
kfree(infp);
239-
return -EINVAL;
243+
return ret;
240244
}
241245

242246
/*

0 commit comments

Comments
 (0)