提交 595297a8 编写于 作者: J jiangyiwen 提交者: Linus Torvalds

ocfs2: manually do the iput once ocfs2_add_entry failed in ocfs2_symlink and ocfs2_mknod

When the call to ocfs2_add_entry() failed in ocfs2_symlink() and
ocfs2_mknod(), iput() will not be called during dput(dentry) because no
d_instantiate(), and this will lead to umount hung.
Signed-off-by: Njiangyiwen <jiangyiwen@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: NMark Fasheh <mfasheh@suse.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 f7a14f32
...@@ -205,6 +205,21 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode) ...@@ -205,6 +205,21 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode)
return inode; return inode;
} }
static void ocfs2_cleanup_add_entry_failure(struct ocfs2_super *osb,
struct dentry *dentry, struct inode *inode)
{
struct ocfs2_dentry_lock *dl = dentry->d_fsdata;
ocfs2_simple_drop_lockres(osb, &dl->dl_lockres);
ocfs2_lock_res_free(&dl->dl_lockres);
BUG_ON(dl->dl_count != 1);
spin_lock(&dentry_attach_lock);
dentry->d_fsdata = NULL;
spin_unlock(&dentry_attach_lock);
kfree(dl);
iput(inode);
}
static int ocfs2_mknod(struct inode *dir, static int ocfs2_mknod(struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
umode_t mode, umode_t mode,
...@@ -231,6 +246,7 @@ static int ocfs2_mknod(struct inode *dir, ...@@ -231,6 +246,7 @@ static int ocfs2_mknod(struct inode *dir,
sigset_t oldset; sigset_t oldset;
int did_block_signals = 0; int did_block_signals = 0;
struct posix_acl *default_acl = NULL, *acl = NULL; struct posix_acl *default_acl = NULL, *acl = NULL;
struct ocfs2_dentry_lock *dl = NULL;
trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name,
(unsigned long long)OCFS2_I(dir)->ip_blkno, (unsigned long long)OCFS2_I(dir)->ip_blkno,
...@@ -423,6 +439,8 @@ static int ocfs2_mknod(struct inode *dir, ...@@ -423,6 +439,8 @@ static int ocfs2_mknod(struct inode *dir,
goto leave; goto leave;
} }
dl = dentry->d_fsdata;
status = ocfs2_add_entry(handle, dentry, inode, status = ocfs2_add_entry(handle, dentry, inode,
OCFS2_I(inode)->ip_blkno, parent_fe_bh, OCFS2_I(inode)->ip_blkno, parent_fe_bh,
&lookup); &lookup);
...@@ -469,6 +487,9 @@ static int ocfs2_mknod(struct inode *dir, ...@@ -469,6 +487,9 @@ static int ocfs2_mknod(struct inode *dir,
* ocfs2_delete_inode will mutex_lock again. * ocfs2_delete_inode will mutex_lock again.
*/ */
if ((status < 0) && inode) { if ((status < 0) && inode) {
if (dl)
ocfs2_cleanup_add_entry_failure(osb, dentry, inode);
OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR;
clear_nlink(inode); clear_nlink(inode);
iput(inode); iput(inode);
...@@ -1734,6 +1755,7 @@ static int ocfs2_symlink(struct inode *dir, ...@@ -1734,6 +1755,7 @@ static int ocfs2_symlink(struct inode *dir,
struct ocfs2_dir_lookup_result lookup = { NULL, }; struct ocfs2_dir_lookup_result lookup = { NULL, };
sigset_t oldset; sigset_t oldset;
int did_block_signals = 0; int did_block_signals = 0;
struct ocfs2_dentry_lock *dl = NULL;
trace_ocfs2_symlink_begin(dir, dentry, symname, trace_ocfs2_symlink_begin(dir, dentry, symname,
dentry->d_name.len, dentry->d_name.name); dentry->d_name.len, dentry->d_name.name);
...@@ -1922,6 +1944,8 @@ static int ocfs2_symlink(struct inode *dir, ...@@ -1922,6 +1944,8 @@ static int ocfs2_symlink(struct inode *dir,
goto bail; goto bail;
} }
dl = dentry->d_fsdata;
status = ocfs2_add_entry(handle, dentry, inode, status = ocfs2_add_entry(handle, dentry, inode,
le64_to_cpu(fe->i_blkno), parent_fe_bh, le64_to_cpu(fe->i_blkno), parent_fe_bh,
&lookup); &lookup);
...@@ -1956,6 +1980,9 @@ static int ocfs2_symlink(struct inode *dir, ...@@ -1956,6 +1980,9 @@ static int ocfs2_symlink(struct inode *dir,
if (xattr_ac) if (xattr_ac)
ocfs2_free_alloc_context(xattr_ac); ocfs2_free_alloc_context(xattr_ac);
if ((status < 0) && inode) { if ((status < 0) && inode) {
if (dl)
ocfs2_cleanup_add_entry_failure(osb, dentry, inode);
OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR;
clear_nlink(inode); clear_nlink(inode);
iput(inode); iput(inode);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册