diff options
author | jiangyiwen <jiangyiwen@huawei.com> | 2014-06-23 16:22:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-23 19:47:45 -0400 |
commit | 595297a8f9bc27f8f4a537fd57ed6d0a2060fb46 (patch) | |
tree | bbcc1c207aebeac161f4a5f3d1c41c1e130e3498 /fs/ocfs2 | |
parent | f7a14f32e7e1e7e025d88e7b4c8e3cc99770f756 (diff) |
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: jiangyiwen <jiangyiwen@huawei.com>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/namei.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 879f9f36b607..8add6f1030d7 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -205,6 +205,21 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode) | |||
205 | return inode; | 205 | return inode; |
206 | } | 206 | } |
207 | 207 | ||
208 | static void ocfs2_cleanup_add_entry_failure(struct ocfs2_super *osb, | ||
209 | struct dentry *dentry, struct inode *inode) | ||
210 | { | ||
211 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; | ||
212 | |||
213 | ocfs2_simple_drop_lockres(osb, &dl->dl_lockres); | ||
214 | ocfs2_lock_res_free(&dl->dl_lockres); | ||
215 | BUG_ON(dl->dl_count != 1); | ||
216 | spin_lock(&dentry_attach_lock); | ||
217 | dentry->d_fsdata = NULL; | ||
218 | spin_unlock(&dentry_attach_lock); | ||
219 | kfree(dl); | ||
220 | iput(inode); | ||
221 | } | ||
222 | |||
208 | static int ocfs2_mknod(struct inode *dir, | 223 | static int ocfs2_mknod(struct inode *dir, |
209 | struct dentry *dentry, | 224 | struct dentry *dentry, |
210 | umode_t mode, | 225 | umode_t mode, |
@@ -231,6 +246,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
231 | sigset_t oldset; | 246 | sigset_t oldset; |
232 | int did_block_signals = 0; | 247 | int did_block_signals = 0; |
233 | struct posix_acl *default_acl = NULL, *acl = NULL; | 248 | struct posix_acl *default_acl = NULL, *acl = NULL; |
249 | struct ocfs2_dentry_lock *dl = NULL; | ||
234 | 250 | ||
235 | trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, | 251 | trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, |
236 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | 252 | (unsigned long long)OCFS2_I(dir)->ip_blkno, |
@@ -423,6 +439,8 @@ static int ocfs2_mknod(struct inode *dir, | |||
423 | goto leave; | 439 | goto leave; |
424 | } | 440 | } |
425 | 441 | ||
442 | dl = dentry->d_fsdata; | ||
443 | |||
426 | status = ocfs2_add_entry(handle, dentry, inode, | 444 | status = ocfs2_add_entry(handle, dentry, inode, |
427 | OCFS2_I(inode)->ip_blkno, parent_fe_bh, | 445 | OCFS2_I(inode)->ip_blkno, parent_fe_bh, |
428 | &lookup); | 446 | &lookup); |
@@ -469,6 +487,9 @@ leave: | |||
469 | * ocfs2_delete_inode will mutex_lock again. | 487 | * ocfs2_delete_inode will mutex_lock again. |
470 | */ | 488 | */ |
471 | if ((status < 0) && inode) { | 489 | if ((status < 0) && inode) { |
490 | if (dl) | ||
491 | ocfs2_cleanup_add_entry_failure(osb, dentry, inode); | ||
492 | |||
472 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; | 493 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; |
473 | clear_nlink(inode); | 494 | clear_nlink(inode); |
474 | iput(inode); | 495 | iput(inode); |
@@ -1734,6 +1755,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1734 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 1755 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
1735 | sigset_t oldset; | 1756 | sigset_t oldset; |
1736 | int did_block_signals = 0; | 1757 | int did_block_signals = 0; |
1758 | struct ocfs2_dentry_lock *dl = NULL; | ||
1737 | 1759 | ||
1738 | trace_ocfs2_symlink_begin(dir, dentry, symname, | 1760 | trace_ocfs2_symlink_begin(dir, dentry, symname, |
1739 | dentry->d_name.len, dentry->d_name.name); | 1761 | dentry->d_name.len, dentry->d_name.name); |
@@ -1922,6 +1944,8 @@ static int ocfs2_symlink(struct inode *dir, | |||
1922 | goto bail; | 1944 | goto bail; |
1923 | } | 1945 | } |
1924 | 1946 | ||
1947 | dl = dentry->d_fsdata; | ||
1948 | |||
1925 | status = ocfs2_add_entry(handle, dentry, inode, | 1949 | status = ocfs2_add_entry(handle, dentry, inode, |
1926 | le64_to_cpu(fe->i_blkno), parent_fe_bh, | 1950 | le64_to_cpu(fe->i_blkno), parent_fe_bh, |
1927 | &lookup); | 1951 | &lookup); |
@@ -1956,6 +1980,9 @@ bail: | |||
1956 | if (xattr_ac) | 1980 | if (xattr_ac) |
1957 | ocfs2_free_alloc_context(xattr_ac); | 1981 | ocfs2_free_alloc_context(xattr_ac); |
1958 | if ((status < 0) && inode) { | 1982 | if ((status < 0) && inode) { |
1983 | if (dl) | ||
1984 | ocfs2_cleanup_add_entry_failure(osb, dentry, inode); | ||
1985 | |||
1959 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; | 1986 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; |
1960 | clear_nlink(inode); | 1987 | clear_nlink(inode); |
1961 | iput(inode); | 1988 | iput(inode); |