Commit d0b079483dd4cf6373f0ff234d5fdaef80c9588f

Authored by David Howells
Committed by Linus Torvalds
1 parent 17f95a7b44

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: 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 4 changed files with 40 additions and 23 deletions Side-by-side Diff

fs/freevxfs/vxfs_extern.h
... ... @@ -58,7 +58,7 @@
58 58 extern void vxfs_put_fake_inode(struct inode *);
59 59 extern struct vxfs_inode_info * vxfs_blkiget(struct super_block *, u_long, ino_t);
60 60 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);
62 62 extern void vxfs_clear_inode(struct inode *);
63 63  
64 64 /* vxfs_lookup.c */
fs/freevxfs/vxfs_inode.c
... ... @@ -129,7 +129,7 @@
129 129 * Description:
130 130 * Search the for inode number @ino in the filesystem
131 131 * 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.
133 133 */
134 134 static struct vxfs_inode_info *
135 135 __vxfs_iget(ino_t ino, struct inode *ilistp)
136 136  
... ... @@ -157,12 +157,12 @@
157 157 }
158 158  
159 159 printk(KERN_WARNING "vxfs: error on page %p\n", pp);
160   - return NULL;
  160 + return ERR_CAST(pp);
161 161  
162 162 fail:
163 163 printk(KERN_WARNING "vxfs: unable to read inode %ld\n", (unsigned long)ino);
164 164 vxfs_put_page(pp);
165   - return NULL;
  165 + return ERR_PTR(-ENOMEM);
166 166 }
167 167  
168 168 /**
... ... @@ -178,7 +178,10 @@
178 178 struct vxfs_inode_info *
179 179 vxfs_stiget(struct super_block *sbp, ino_t ino)
180 180 {
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;
182 185 }
183 186  
184 187 /**
185 188  
186 189  
187 190  
188 191  
189 192  
190 193  
... ... @@ -282,24 +285,33 @@
282 285 }
283 286  
284 287 /**
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
287 291 *
288 292 * 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.
291 295 */
292   -void
293   -vxfs_read_inode(struct inode *ip)
  296 +struct inode *
  297 +vxfs_iget(struct super_block *sbp, ino_t ino)
294 298 {
295   - struct super_block *sbp = ip->i_sb;
296 299 struct vxfs_inode_info *vip;
297 300 const struct address_space_operations *aops;
298   - ino_t ino = ip->i_ino;
  301 + struct inode *ip;
299 302  
300   - if (!(vip = __vxfs_iget(ino, VXFS_SBI(sbp)->vsi_ilist)))
301   - return;
  303 + ip = iget_locked(sbp, ino);
  304 + if (!ip)
  305 + return ERR_PTR(-ENOMEM);
  306 + if (!(ip->i_state & I_NEW))
  307 + return ip;
302 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 + }
  314 +
303 315 vxfs_iinit(ip, vip);
304 316  
305 317 if (VXFS_ISIMMED(vip))
... ... @@ -323,7 +335,8 @@
323 335 } else
324 336 init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev));
325 337  
326   - return;
  338 + unlock_new_inode(ip);
  339 + return ip;
327 340 }
328 341  
329 342 /**
fs/freevxfs/vxfs_lookup.c
... ... @@ -213,10 +213,10 @@
213 213 lock_kernel();
214 214 ino = vxfs_inode_by_name(dip, dp);
215 215 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)) {
218 218 unlock_kernel();
219   - return ERR_PTR(-EACCES);
  219 + return ERR_CAST(ip);
220 220 }
221 221 }
222 222 unlock_kernel();
fs/freevxfs/vxfs_super.c
... ... @@ -60,7 +60,6 @@
60 60 static int vxfs_remount(struct super_block *, int *, char *);
61 61  
62 62 static const struct super_operations vxfs_super_ops = {
63   - .read_inode = vxfs_read_inode,
64 63 .clear_inode = vxfs_clear_inode,
65 64 .put_super = vxfs_put_super,
66 65 .statfs = vxfs_statfs,
... ... @@ -153,6 +152,7 @@
153 152 struct buffer_head *bp = NULL;
154 153 u_long bsize;
155 154 struct inode *root;
  155 + int ret = -EINVAL;
156 156  
157 157 sbp->s_flags |= MS_RDONLY;
158 158  
... ... @@ -219,7 +219,11 @@
219 219 }
220 220  
221 221 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 + }
223 227 sbp->s_root = d_alloc_root(root);
224 228 if (!sbp->s_root) {
225 229 iput(root);
... ... @@ -236,7 +240,7 @@
236 240 out:
237 241 brelse(bp);
238 242 kfree(infp);
239   - return -EINVAL;
  243 + return ret;
240 244 }
241 245  
242 246 /*