Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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

qnx4_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>
Cc: Anders Larsen <al@alarsen.net>
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>

authored by

David Howells and committed by
Linus Torvalds
2b7e5bcb a1d4aebb

+38 -18
+32 -15
fs/qnx4/inode.c
··· 125 125 static void qnx4_put_super(struct super_block *sb); 126 126 static struct inode *qnx4_alloc_inode(struct super_block *sb); 127 127 static void qnx4_destroy_inode(struct inode *inode); 128 - static void qnx4_read_inode(struct inode *); 129 128 static int qnx4_remount(struct super_block *sb, int *flags, char *data); 130 129 static int qnx4_statfs(struct dentry *, struct kstatfs *); 131 130 ··· 132 133 { 133 134 .alloc_inode = qnx4_alloc_inode, 134 135 .destroy_inode = qnx4_destroy_inode, 135 - .read_inode = qnx4_read_inode, 136 136 .put_super = qnx4_put_super, 137 137 .statfs = qnx4_statfs, 138 138 .remount_fs = qnx4_remount, ··· 355 357 struct inode *root; 356 358 const char *errmsg; 357 359 struct qnx4_sb_info *qs; 360 + int ret = -EINVAL; 358 361 359 362 qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); 360 363 if (!qs) ··· 395 396 } 396 397 397 398 /* does root not have inode number QNX4_ROOT_INO ?? */ 398 - root = iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); 399 - if (!root) { 399 + root = qnx4_iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK); 400 + if (IS_ERR(root)) { 400 401 printk("qnx4: get inode failed\n"); 402 + ret = PTR_ERR(root); 401 403 goto out; 402 404 } 403 405 406 + ret = -ENOMEM; 404 407 s->s_root = d_alloc_root(root); 405 408 if (s->s_root == NULL) 406 409 goto outi; ··· 418 417 outnobh: 419 418 kfree(qs); 420 419 s->s_fs_info = NULL; 421 - return -EINVAL; 420 + return ret; 422 421 } 423 422 424 423 static void qnx4_put_super(struct super_block *sb) ··· 463 462 .bmap = qnx4_bmap 464 463 }; 465 464 466 - static void qnx4_read_inode(struct inode *inode) 465 + struct inode *qnx4_iget(struct super_block *sb, unsigned long ino) 467 466 { 468 467 struct buffer_head *bh; 469 468 struct qnx4_inode_entry *raw_inode; 470 - int block, ino; 471 - struct super_block *sb = inode->i_sb; 472 - struct qnx4_inode_entry *qnx4_inode = qnx4_raw_inode(inode); 469 + int block; 470 + struct qnx4_inode_entry *qnx4_inode; 471 + struct inode *inode; 473 472 474 - ino = inode->i_ino; 473 + inode = iget_locked(sb, ino); 474 + if (!inode) 475 + return ERR_PTR(-ENOMEM); 476 + if (!(inode->i_state & I_NEW)) 477 + return inode; 478 + 479 + qnx4_inode = qnx4_raw_inode(inode); 475 480 inode->i_mode = 0; 476 481 477 482 QNX4DEBUG(("Reading inode : [%d]\n", ino)); 478 483 if (!ino) { 479 - printk("qnx4: bad inode number on dev %s: %d is out of range\n", 484 + printk(KERN_ERR "qnx4: bad inode number on dev %s: %lu is " 485 + "out of range\n", 480 486 sb->s_id, ino); 481 - return; 487 + iget_failed(inode); 488 + return ERR_PTR(-EIO); 482 489 } 483 490 block = ino / QNX4_INODES_PER_BLOCK; 484 491 485 492 if (!(bh = sb_bread(sb, block))) { 486 493 printk("qnx4: major problem: unable to read inode from dev " 487 494 "%s\n", sb->s_id); 488 - return; 495 + iget_failed(inode); 496 + return ERR_PTR(-EIO); 489 497 } 490 498 raw_inode = ((struct qnx4_inode_entry *) bh->b_data) + 491 499 (ino % QNX4_INODES_PER_BLOCK); ··· 525 515 inode->i_op = &page_symlink_inode_operations; 526 516 inode->i_mapping->a_ops = &qnx4_aops; 527 517 qnx4_i(inode)->mmu_private = inode->i_size; 528 - } else 529 - printk("qnx4: bad inode %d on dev %s\n",ino,sb->s_id); 518 + } else { 519 + printk(KERN_ERR "qnx4: bad inode %lu on dev %s\n", 520 + ino, sb->s_id); 521 + iget_failed(inode); 522 + brelse(bh); 523 + return ERR_PTR(-EIO); 524 + } 530 525 brelse(bh); 526 + unlock_new_inode(inode); 527 + return inode; 531 528 } 532 529 533 530 static struct kmem_cache *qnx4_inode_cachep;
+5 -3
fs/qnx4/namei.c
··· 128 128 } 129 129 brelse(bh); 130 130 131 - if ((foundinode = iget(dir->i_sb, ino)) == NULL) { 131 + foundinode = qnx4_iget(dir->i_sb, ino); 132 + if (IS_ERR(foundinode)) { 132 133 unlock_kernel(); 133 - QNX4DEBUG(("qnx4: lookup->iget -> NULL\n")); 134 - return ERR_PTR(-EACCES); 134 + QNX4DEBUG(("qnx4: lookup->iget -> error %ld\n", 135 + PTR_ERR(foundinode))); 136 + return ERR_CAST(foundinode); 135 137 } 136 138 out: 137 139 unlock_kernel();
+1
include/linux/qnx4_fs.h
··· 110 110 struct inode vfs_inode; 111 111 }; 112 112 113 + extern struct inode *qnx4_iget(struct super_block *, unsigned long); 113 114 extern struct dentry *qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd); 114 115 extern unsigned long qnx4_count_free_blocks(struct super_block *sb); 115 116 extern unsigned long qnx4_block_map(struct inode *inode, long iblock);