diff options
Diffstat (limited to 'fs/ocfs2/namei.c')
-rw-r--r-- | fs/ocfs2/namei.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index b1eb50ae4097..4cbb18f26c5f 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -408,23 +408,28 @@ static int ocfs2_mknod(struct inode *dir, | |||
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | status = ocfs2_add_entry(handle, dentry, inode, | 411 | /* |
412 | OCFS2_I(inode)->ip_blkno, parent_fe_bh, | 412 | * Do this before adding the entry to the directory. We add |
413 | &lookup); | 413 | * also set d_op after success so that ->d_iput() will cleanup |
414 | if (status < 0) { | 414 | * the dentry lock even if ocfs2_add_entry() fails below. |
415 | */ | ||
416 | status = ocfs2_dentry_attach_lock(dentry, inode, | ||
417 | OCFS2_I(dir)->ip_blkno); | ||
418 | if (status) { | ||
415 | mlog_errno(status); | 419 | mlog_errno(status); |
416 | goto leave; | 420 | goto leave; |
417 | } | 421 | } |
422 | dentry->d_op = &ocfs2_dentry_ops; | ||
418 | 423 | ||
419 | status = ocfs2_dentry_attach_lock(dentry, inode, | 424 | status = ocfs2_add_entry(handle, dentry, inode, |
420 | OCFS2_I(dir)->ip_blkno); | 425 | OCFS2_I(inode)->ip_blkno, parent_fe_bh, |
421 | if (status) { | 426 | &lookup); |
427 | if (status < 0) { | ||
422 | mlog_errno(status); | 428 | mlog_errno(status); |
423 | goto leave; | 429 | goto leave; |
424 | } | 430 | } |
425 | 431 | ||
426 | insert_inode_hash(inode); | 432 | insert_inode_hash(inode); |
427 | dentry->d_op = &ocfs2_dentry_ops; | ||
428 | d_instantiate(dentry, inode); | 433 | d_instantiate(dentry, inode); |
429 | status = 0; | 434 | status = 0; |
430 | leave: | 435 | leave: |
@@ -445,11 +450,6 @@ leave: | |||
445 | 450 | ||
446 | ocfs2_free_dir_lookup_result(&lookup); | 451 | ocfs2_free_dir_lookup_result(&lookup); |
447 | 452 | ||
448 | if ((status < 0) && inode) { | ||
449 | clear_nlink(inode); | ||
450 | iput(inode); | ||
451 | } | ||
452 | |||
453 | if (inode_ac) | 453 | if (inode_ac) |
454 | ocfs2_free_alloc_context(inode_ac); | 454 | ocfs2_free_alloc_context(inode_ac); |
455 | 455 | ||
@@ -459,6 +459,17 @@ leave: | |||
459 | if (meta_ac) | 459 | if (meta_ac) |
460 | ocfs2_free_alloc_context(meta_ac); | 460 | ocfs2_free_alloc_context(meta_ac); |
461 | 461 | ||
462 | /* | ||
463 | * We should call iput after the i_mutex of the bitmap been | ||
464 | * unlocked in ocfs2_free_alloc_context, or the | ||
465 | * ocfs2_delete_inode will mutex_lock again. | ||
466 | */ | ||
467 | if ((status < 0) && inode) { | ||
468 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; | ||
469 | clear_nlink(inode); | ||
470 | iput(inode); | ||
471 | } | ||
472 | |||
462 | mlog_exit(status); | 473 | mlog_exit(status); |
463 | 474 | ||
464 | return status; | 475 | return status; |
@@ -1771,22 +1782,27 @@ static int ocfs2_symlink(struct inode *dir, | |||
1771 | } | 1782 | } |
1772 | } | 1783 | } |
1773 | 1784 | ||
1774 | status = ocfs2_add_entry(handle, dentry, inode, | 1785 | /* |
1775 | le64_to_cpu(fe->i_blkno), parent_fe_bh, | 1786 | * Do this before adding the entry to the directory. We add |
1776 | &lookup); | 1787 | * also set d_op after success so that ->d_iput() will cleanup |
1777 | if (status < 0) { | 1788 | * the dentry lock even if ocfs2_add_entry() fails below. |
1789 | */ | ||
1790 | status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); | ||
1791 | if (status) { | ||
1778 | mlog_errno(status); | 1792 | mlog_errno(status); |
1779 | goto bail; | 1793 | goto bail; |
1780 | } | 1794 | } |
1795 | dentry->d_op = &ocfs2_dentry_ops; | ||
1781 | 1796 | ||
1782 | status = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); | 1797 | status = ocfs2_add_entry(handle, dentry, inode, |
1783 | if (status) { | 1798 | le64_to_cpu(fe->i_blkno), parent_fe_bh, |
1799 | &lookup); | ||
1800 | if (status < 0) { | ||
1784 | mlog_errno(status); | 1801 | mlog_errno(status); |
1785 | goto bail; | 1802 | goto bail; |
1786 | } | 1803 | } |
1787 | 1804 | ||
1788 | insert_inode_hash(inode); | 1805 | insert_inode_hash(inode); |
1789 | dentry->d_op = &ocfs2_dentry_ops; | ||
1790 | d_instantiate(dentry, inode); | 1806 | d_instantiate(dentry, inode); |
1791 | bail: | 1807 | bail: |
1792 | if (status < 0 && did_quota) | 1808 | if (status < 0 && did_quota) |
@@ -1811,6 +1827,7 @@ bail: | |||
1811 | if (xattr_ac) | 1827 | if (xattr_ac) |
1812 | ocfs2_free_alloc_context(xattr_ac); | 1828 | ocfs2_free_alloc_context(xattr_ac); |
1813 | if ((status < 0) && inode) { | 1829 | if ((status < 0) && inode) { |
1830 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SKIP_ORPHAN_DIR; | ||
1814 | clear_nlink(inode); | 1831 | clear_nlink(inode); |
1815 | iput(inode); | 1832 | iput(inode); |
1816 | } | 1833 | } |
@@ -1976,6 +1993,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
1976 | } | 1993 | } |
1977 | 1994 | ||
1978 | le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL); | 1995 | le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL); |
1996 | OCFS2_I(inode)->ip_flags &= ~OCFS2_INODE_SKIP_ORPHAN_DIR; | ||
1979 | 1997 | ||
1980 | /* Record which orphan dir our inode now resides | 1998 | /* Record which orphan dir our inode now resides |
1981 | * in. delete_inode will use this to determine which orphan | 1999 | * in. delete_inode will use this to determine which orphan |