|
@@ -777,11 +777,10 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb,
|
|
* Currently we don't know the generation for parent directory, so
|
|
* Currently we don't know the generation for parent directory, so
|
|
* a generation of 0 means "accept any"
|
|
* a generation of 0 means "accept any"
|
|
*/
|
|
*/
|
|
- inode = iget(sb, ino);
|
|
|
|
- if (inode == NULL)
|
|
|
|
- return ERR_PTR(-ENOMEM);
|
|
|
|
- if (is_bad_inode(inode) ||
|
|
|
|
- (generation && inode->i_generation != generation)) {
|
|
|
|
|
|
+ inode = ext4_iget(sb, ino);
|
|
|
|
+ if (IS_ERR(inode))
|
|
|
|
+ return ERR_CAST(inode);
|
|
|
|
+ if (generation && inode->i_generation != generation) {
|
|
iput(inode);
|
|
iput(inode);
|
|
return ERR_PTR(-ESTALE);
|
|
return ERR_PTR(-ESTALE);
|
|
}
|
|
}
|
|
@@ -850,7 +849,6 @@ static struct quotactl_ops ext4_qctl_operations = {
|
|
static const struct super_operations ext4_sops = {
|
|
static const struct super_operations ext4_sops = {
|
|
.alloc_inode = ext4_alloc_inode,
|
|
.alloc_inode = ext4_alloc_inode,
|
|
.destroy_inode = ext4_destroy_inode,
|
|
.destroy_inode = ext4_destroy_inode,
|
|
- .read_inode = ext4_read_inode,
|
|
|
|
.write_inode = ext4_write_inode,
|
|
.write_inode = ext4_write_inode,
|
|
.dirty_inode = ext4_dirty_inode,
|
|
.dirty_inode = ext4_dirty_inode,
|
|
.delete_inode = ext4_delete_inode,
|
|
.delete_inode = ext4_delete_inode,
|
|
@@ -1805,6 +1803,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
|
|
unsigned long journal_devnum = 0;
|
|
unsigned long journal_devnum = 0;
|
|
unsigned long def_mount_opts;
|
|
unsigned long def_mount_opts;
|
|
struct inode *root;
|
|
struct inode *root;
|
|
|
|
+ int ret = -EINVAL;
|
|
int blocksize;
|
|
int blocksize;
|
|
int db_count;
|
|
int db_count;
|
|
int i;
|
|
int i;
|
|
@@ -2237,19 +2236,24 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
|
|
* so we can safely mount the rest of the filesystem now.
|
|
* so we can safely mount the rest of the filesystem now.
|
|
*/
|
|
*/
|
|
|
|
|
|
- root = iget(sb, EXT4_ROOT_INO);
|
|
|
|
- sb->s_root = d_alloc_root(root);
|
|
|
|
- if (!sb->s_root) {
|
|
|
|
|
|
+ root = ext4_iget(sb, EXT4_ROOT_INO);
|
|
|
|
+ if (IS_ERR(root)) {
|
|
printk(KERN_ERR "EXT4-fs: get root inode failed\n");
|
|
printk(KERN_ERR "EXT4-fs: get root inode failed\n");
|
|
- iput(root);
|
|
|
|
|
|
+ ret = PTR_ERR(root);
|
|
goto failed_mount4;
|
|
goto failed_mount4;
|
|
}
|
|
}
|
|
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
|
|
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
|
|
- dput(sb->s_root);
|
|
|
|
- sb->s_root = NULL;
|
|
|
|
|
|
+ iput(root);
|
|
printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n");
|
|
printk(KERN_ERR "EXT4-fs: corrupt root inode, run e2fsck\n");
|
|
goto failed_mount4;
|
|
goto failed_mount4;
|
|
}
|
|
}
|
|
|
|
+ sb->s_root = d_alloc_root(root);
|
|
|
|
+ if (!sb->s_root) {
|
|
|
|
+ printk(KERN_ERR "EXT4-fs: get root dentry failed\n");
|
|
|
|
+ iput(root);
|
|
|
|
+ ret = -ENOMEM;
|
|
|
|
+ goto failed_mount4;
|
|
|
|
+ }
|
|
|
|
|
|
ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY);
|
|
ext4_setup_super (sb, es, sb->s_flags & MS_RDONLY);
|
|
|
|
|
|
@@ -2330,7 +2334,7 @@ out_fail:
|
|
sb->s_fs_info = NULL;
|
|
sb->s_fs_info = NULL;
|
|
kfree(sbi);
|
|
kfree(sbi);
|
|
lock_kernel();
|
|
lock_kernel();
|
|
- return -EINVAL;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2366,8 +2370,8 @@ static journal_t *ext4_get_journal(struct super_block *sb,
|
|
* things happen if we iget() an unused inode, as the subsequent
|
|
* things happen if we iget() an unused inode, as the subsequent
|
|
* iput() will try to delete it. */
|
|
* iput() will try to delete it. */
|
|
|
|
|
|
- journal_inode = iget(sb, journal_inum);
|
|
|
|
- if (!journal_inode) {
|
|
|
|
|
|
+ journal_inode = ext4_iget(sb, journal_inum);
|
|
|
|
+ if (IS_ERR(journal_inode)) {
|
|
printk(KERN_ERR "EXT4-fs: no journal found.\n");
|
|
printk(KERN_ERR "EXT4-fs: no journal found.\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
@@ -2380,7 +2384,7 @@ static journal_t *ext4_get_journal(struct super_block *sb,
|
|
|
|
|
|
jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
|
|
jbd_debug(2, "Journal inode found at %p: %Ld bytes\n",
|
|
journal_inode, journal_inode->i_size);
|
|
journal_inode, journal_inode->i_size);
|
|
- if (is_bad_inode(journal_inode) || !S_ISREG(journal_inode->i_mode)) {
|
|
|
|
|
|
+ if (!S_ISREG(journal_inode->i_mode)) {
|
|
printk(KERN_ERR "EXT4-fs: invalid journal inode.\n");
|
|
printk(KERN_ERR "EXT4-fs: invalid journal inode.\n");
|
|
iput(journal_inode);
|
|
iput(journal_inode);
|
|
return NULL;
|
|
return NULL;
|