提交 4cdeed86 编写于 作者: A Aneesh Kumar K.V 提交者: Theodore Ts'o

ext4: Don't leave behind a half-created inode if ext4_mkdir() fails

If ext4_mkdir() fails to allocate the initial block for the directory,
don't leave behind a half-created directory inode with the link count
left at one.  This was caused by an inappropriate call to ext4_dec_count().
Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: NMingming Cao <cmm@us.ibm.com>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 b73fce69
...@@ -1804,12 +1804,8 @@ static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode) ...@@ -1804,12 +1804,8 @@ static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode)
inode->i_fop = &ext4_dir_operations; inode->i_fop = &ext4_dir_operations;
inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize; inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
dir_block = ext4_bread (handle, inode, 0, 1, &err); dir_block = ext4_bread (handle, inode, 0, 1, &err);
if (!dir_block) { if (!dir_block)
ext4_dec_count(handle, inode); /* is this nlink == 0? */ goto out_clear_inode;
ext4_mark_inode_dirty(handle, inode);
iput (inode);
goto out_stop;
}
BUFFER_TRACE(dir_block, "get_write_access"); BUFFER_TRACE(dir_block, "get_write_access");
ext4_journal_get_write_access(handle, dir_block); ext4_journal_get_write_access(handle, dir_block);
de = (struct ext4_dir_entry_2 *) dir_block->b_data; de = (struct ext4_dir_entry_2 *) dir_block->b_data;
...@@ -1832,7 +1828,8 @@ static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode) ...@@ -1832,7 +1828,8 @@ static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode)
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
err = ext4_add_entry (handle, dentry, inode); err = ext4_add_entry (handle, dentry, inode);
if (err) { if (err) {
inode->i_nlink = 0; out_clear_inode:
clear_nlink(inode);
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
iput (inode); iput (inode);
goto out_stop; goto out_stop;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册