On Sat, Feb 02, 2008 at 10:55:24AM -0500, Theodore Ts'o wrote: > In the mm tree is a patch queued up to nuke iget(). So replace use of > iget() with iget_locked(). I will be pushing this to Linus shortly. Oops, wrong version of the patch; this is the correct one. - Ted ext4: Replace use of iget() with iget_locked() Signed-off-by: "Theodore Ts'o" <tytso@xxxxxxx> --- diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 575b521..d45fcaa 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -805,9 +805,17 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) * 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 (!ext4_test_bit(bit, bitmap_bh->b_data) || - !(inode = iget(sb, ino)) || is_bad_inode(inode) || - NEXT_ORPHAN(inode) > max_ino) { + if (!ext4_test_bit(bit, bitmap_bh->b_data)) + goto bad_orphan_inode; + inode = iget_locked(sb, ino); + if (!inode) + goto bad_orphan_inode; + if (inode->i_state & I_NEW) { + sb->s_op->read_inode(inode); + unlock_new_inode(inode); + } + if (is_bad_inode(inode) || NEXT_ORPHAN(inode) > max_ino) { + bad_orphan_inode: ext4_warning(sb, __FUNCTION__, "bad orphan inode %lu! e2fsck was run?", ino); printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n", diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 67b6d8a..57dd8fb 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1041,11 +1041,16 @@ static struct dentry *ext4_lookup(struct inode * dir, struct dentry *dentry, str "bad inode number: %lu", ino); inode = NULL; } else - inode = iget(dir->i_sb, ino); + inode = iget_locked(dir->i_sb, ino); if (!inode) return ERR_PTR(-EACCES); + if (inode->i_state & I_NEW) { + inode->i_sb->s_op->read_inode(inode); + unlock_new_inode(inode); + } + if (is_bad_inode(inode)) { iput(inode); return ERR_PTR(-ENOENT); @@ -1080,11 +1085,16 @@ struct dentry *ext4_get_parent(struct dentry *child) "bad inode number: %lu", ino); inode = NULL; } else - inode = iget(child->d_inode->i_sb, ino); + inode = iget_locked(child->d_inode->i_sb, ino); if (!inode) return ERR_PTR(-EACCES); + if (inode->i_state & I_NEW) { + inode->i_sb->s_op->read_inode(inode); + unlock_new_inode(inode); + } + if (is_bad_inode(inode)) { iput(inode); return ERR_PTR(-ENOENT); diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 4fbba60..ebdca31 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -779,7 +779,11 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) "No reserved GDT blocks, can't resize"); return -EPERM; } - inode = iget(sb, EXT4_RESIZE_INO); + inode = iget_locked(sb, EXT4_RESIZE_INO); + if (inode && (inode->i_state & I_NEW)) { + sb->s_op->read_inode(inode); + unlock_new_inode(inode); + } if (!inode || is_bad_inode(inode)) { ext4_warning(sb, __FUNCTION__, "Error opening resize inode"); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 055a0cd..1ef0359 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -777,9 +777,13 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb, * Currently we don't know the generation for parent directory, so * a generation of 0 means "accept any" */ - inode = iget(sb, ino); + inode = iget_locked(sb, ino); if (inode == NULL) return ERR_PTR(-ENOMEM); + if (inode->i_state & I_NEW) { + sb->s_op->read_inode(inode); + unlock_new_inode(inode); + } if (is_bad_inode(inode) || (generation && inode->i_generation != generation)) { iput(inode); @@ -2243,7 +2247,15 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) * so we can safely mount the rest of the filesystem now. */ - root = iget(sb, EXT4_ROOT_INO); + root = iget_locked(sb, EXT4_ROOT_INO); + if (!root) { + printk(KERN_ERR "EXT4-fs: iget_locked for root inode failed\n"); + goto failed_mount4; + } + if (root->i_state & I_NEW) { + sb->s_op->read_inode(root); + unlock_new_inode(root); + } sb->s_root = d_alloc_root(root); if (!sb->s_root) { printk(KERN_ERR "EXT4-fs: get root inode failed\n"); @@ -2372,11 +2384,15 @@ static journal_t *ext4_get_journal(struct super_block *sb, * things happen if we iget() an unused inode, as the subsequent * iput() will try to delete it. */ - journal_inode = iget(sb, journal_inum); + journal_inode = iget_locked(sb, journal_inum); if (!journal_inode) { - printk(KERN_ERR "EXT4-fs: no journal found.\n"); + printk(KERN_ERR "EXT4-fs: iget_locked for journal inode failed.\n"); return NULL; } + if (journal_inode->i_state & I_NEW) { + sb->s_op->read_inode(journal_inode); + unlock_new_inode(journal_inode); + } if (!journal_inode->i_nlink) { make_bad_inode(journal_inode); iput(journal_inode); - To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html