iget: stop EXT3 from using iget() and read_inode()
Stop the EXT3 filesystem from using iget() and read_inode(). Replace ext3_read_inode() with ext3_iget(), and call that instead of iget(). ext3_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. ext3_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: "Theodore Ts'o" <tytso@mit.edu> Acked-by: Jan Kara <jack@suse.cz> Cc: <linux-ext4@vger.kernel.org> 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>
This commit is contained in:

committed by
Linus Torvalds

parent
52fcf70329
commit
473043dcee
@@ -642,14 +642,15 @@ struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino)
|
||||
unsigned long max_ino = le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count);
|
||||
unsigned long block_group;
|
||||
int bit;
|
||||
struct buffer_head *bitmap_bh = NULL;
|
||||
struct buffer_head *bitmap_bh;
|
||||
struct inode *inode = NULL;
|
||||
long err = -EIO;
|
||||
|
||||
/* Error cases - e2fsck has already cleaned up for us */
|
||||
if (ino > max_ino) {
|
||||
ext3_warning(sb, __FUNCTION__,
|
||||
"bad orphan ino %lu! e2fsck was run?", ino);
|
||||
goto out;
|
||||
goto error;
|
||||
}
|
||||
|
||||
block_group = (ino - 1) / EXT3_INODES_PER_GROUP(sb);
|
||||
@@ -658,38 +659,49 @@ struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino)
|
||||
if (!bitmap_bh) {
|
||||
ext3_warning(sb, __FUNCTION__,
|
||||
"inode bitmap error for orphan %lu", ino);
|
||||
goto out;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Having the inode bit set should be a 100% indicator that this
|
||||
* is a valid orphan (no e2fsck run on fs). Orphans also include
|
||||
* inodes that were being truncated, so we can't check i_nlink==0.
|
||||
*/
|
||||
if (!ext3_test_bit(bit, bitmap_bh->b_data) ||
|
||||
!(inode = iget(sb, ino)) || is_bad_inode(inode) ||
|
||||
NEXT_ORPHAN(inode) > max_ino) {
|
||||
ext3_warning(sb, __FUNCTION__,
|
||||
"bad orphan inode %lu! e2fsck was run?", ino);
|
||||
printk(KERN_NOTICE "ext3_test_bit(bit=%d, block=%llu) = %d\n",
|
||||
bit, (unsigned long long)bitmap_bh->b_blocknr,
|
||||
ext3_test_bit(bit, bitmap_bh->b_data));
|
||||
printk(KERN_NOTICE "inode=%p\n", inode);
|
||||
if (inode) {
|
||||
printk(KERN_NOTICE "is_bad_inode(inode)=%d\n",
|
||||
is_bad_inode(inode));
|
||||
printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n",
|
||||
NEXT_ORPHAN(inode));
|
||||
printk(KERN_NOTICE "max_ino=%lu\n", max_ino);
|
||||
}
|
||||
/* Avoid freeing blocks if we got a bad deleted inode */
|
||||
if (inode && inode->i_nlink == 0)
|
||||
inode->i_blocks = 0;
|
||||
iput(inode);
|
||||
inode = NULL;
|
||||
}
|
||||
out:
|
||||
if (!ext3_test_bit(bit, bitmap_bh->b_data))
|
||||
goto bad_orphan;
|
||||
|
||||
inode = ext3_iget(sb, ino);
|
||||
if (IS_ERR(inode))
|
||||
goto iget_failed;
|
||||
|
||||
if (NEXT_ORPHAN(inode) > max_ino)
|
||||
goto bad_orphan;
|
||||
brelse(bitmap_bh);
|
||||
return inode;
|
||||
|
||||
iget_failed:
|
||||
err = PTR_ERR(inode);
|
||||
inode = NULL;
|
||||
bad_orphan:
|
||||
ext3_warning(sb, __FUNCTION__,
|
||||
"bad orphan inode %lu! e2fsck was run?", ino);
|
||||
printk(KERN_NOTICE "ext3_test_bit(bit=%d, block=%llu) = %d\n",
|
||||
bit, (unsigned long long)bitmap_bh->b_blocknr,
|
||||
ext3_test_bit(bit, bitmap_bh->b_data));
|
||||
printk(KERN_NOTICE "inode=%p\n", inode);
|
||||
if (inode) {
|
||||
printk(KERN_NOTICE "is_bad_inode(inode)=%d\n",
|
||||
is_bad_inode(inode));
|
||||
printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n",
|
||||
NEXT_ORPHAN(inode));
|
||||
printk(KERN_NOTICE "max_ino=%lu\n", max_ino);
|
||||
/* Avoid freeing blocks if we got a bad deleted inode */
|
||||
if (inode->i_nlink == 0)
|
||||
inode->i_blocks = 0;
|
||||
iput(inode);
|
||||
}
|
||||
brelse(bitmap_bh);
|
||||
error:
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
unsigned long ext3_count_free_inodes (struct super_block * sb)
|
||||
|
Reference in New Issue
Block a user