Commit 96eb5419412fbc7f39fa45d987034c5d0e6e1202

Authored by David Howells
Committed by Linus Torvalds
1 parent 62328a0239

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

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

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

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Will Dyson <will_dyson@pobox.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 1 changed file with 25 additions and 14 deletions Side-by-side Diff

... ... @@ -35,7 +35,7 @@
35 35 static int befs_readpage(struct file *file, struct page *page);
36 36 static sector_t befs_bmap(struct address_space *mapping, sector_t block);
37 37 static struct dentry *befs_lookup(struct inode *, struct dentry *, struct nameidata *);
38   -static void befs_read_inode(struct inode *ino);
  38 +static struct inode *befs_iget(struct super_block *, unsigned long);
39 39 static struct inode *befs_alloc_inode(struct super_block *sb);
40 40 static void befs_destroy_inode(struct inode *inode);
41 41 static int befs_init_inodecache(void);
... ... @@ -52,7 +52,6 @@
52 52 static int parse_options(char *, befs_mount_options *);
53 53  
54 54 static const struct super_operations befs_sops = {
55   - .read_inode = befs_read_inode, /* initialize & read inode */
56 55 .alloc_inode = befs_alloc_inode, /* allocate a new inode */
57 56 .destroy_inode = befs_destroy_inode, /* deallocate an inode */
58 57 .put_super = befs_put_super, /* uninit super */
... ... @@ -198,9 +197,9 @@
198 197 return ERR_PTR(-ENODATA);
199 198 }
200 199  
201   - inode = iget(dir->i_sb, (ino_t) offset);
202   - if (!inode)
203   - return ERR_PTR(-EACCES);
  200 + inode = befs_iget(dir->i_sb, (ino_t) offset);
  201 + if (IS_ERR(inode))
  202 + return ERR_CAST(inode);
204 203  
205 204 d_add(dentry, inode);
206 205  
207 206  
208 207  
209 208  
210 209  
... ... @@ -296,18 +295,24 @@
296 295 inode_init_once(&bi->vfs_inode);
297 296 }
298 297  
299   -static void
300   -befs_read_inode(struct inode *inode)
  298 +static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
301 299 {
302 300 struct buffer_head *bh = NULL;
303 301 befs_inode *raw_inode = NULL;
304 302  
305   - struct super_block *sb = inode->i_sb;
306 303 befs_sb_info *befs_sb = BEFS_SB(sb);
307 304 befs_inode_info *befs_ino = NULL;
  305 + struct inode *inode;
  306 + long ret = -EIO;
308 307  
309   - befs_debug(sb, "---> befs_read_inode() " "inode = %lu", inode->i_ino);
  308 + befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
310 309  
  310 + inode = iget_locked(sb, ino);
  311 + if (IS_ERR(inode))
  312 + return inode;
  313 + if (!(inode->i_state & I_NEW))
  314 + return inode;
  315 +
311 316 befs_ino = BEFS_I(inode);
312 317  
313 318 /* convert from vfs's inode number to befs's inode number */
314 319  
315 320  
... ... @@ -402,15 +407,16 @@
402 407  
403 408 brelse(bh);
404 409 befs_debug(sb, "<--- befs_read_inode()");
405   - return;
  410 + unlock_new_inode(inode);
  411 + return inode;
406 412  
407 413 unacquire_bh:
408 414 brelse(bh);
409 415  
410 416 unacquire_none:
411   - make_bad_inode(inode);
  417 + iget_failed(inode);
412 418 befs_debug(sb, "<--- befs_read_inode() - Bad inode");
413   - return;
  419 + return ERR_PTR(ret);
414 420 }
415 421  
416 422 /* Initialize the inode cache. Called at fs setup.
... ... @@ -752,6 +758,7 @@
752 758 befs_sb_info *befs_sb;
753 759 befs_super_block *disk_sb;
754 760 struct inode *root;
  761 + long ret = -EINVAL;
755 762  
756 763 const unsigned long sb_block = 0;
757 764 const off_t x86_sb_off = 512;
... ... @@ -833,7 +840,11 @@
833 840 /* Set real blocksize of fs */
834 841 sb_set_blocksize(sb, (ulong) befs_sb->block_size);
835 842 sb->s_op = (struct super_operations *) &befs_sops;
836   - root = iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir)));
  843 + root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir)));
  844 + if (IS_ERR(root)) {
  845 + ret = PTR_ERR(root);
  846 + goto unacquire_priv_sbp;
  847 + }
837 848 sb->s_root = d_alloc_root(root);
838 849 if (!sb->s_root) {
839 850 iput(root);
... ... @@ -868,7 +879,7 @@
868 879  
869 880 unacquire_none:
870 881 sb->s_fs_info = NULL;
871   - return -EINVAL;
  882 + return ret;
872 883 }
873 884  
874 885 static int