diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-12-30 02:02:50 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-12-31 18:07:44 -0500 |
commit | c38012daa7ad902a39a4213ba2b3fe50e81157ea (patch) | |
tree | 69dd3bdf2efe82f9bee13eaf729df7bf70e89381 | |
parent | 41080b5a240113328c607f22b849f653373db0ce (diff) |
nfsd race fixes: ext3
ext3 analog of the previous patch
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/ext3/ialloc.c | 6 | ||||
-rw-r--r-- | fs/ext3/namei.c | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 490bd0ed7896..5655fbcbd11f 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -579,7 +579,10 @@ got: | |||
579 | ext3_set_inode_flags(inode); | 579 | ext3_set_inode_flags(inode); |
580 | if (IS_DIRSYNC(inode)) | 580 | if (IS_DIRSYNC(inode)) |
581 | handle->h_sync = 1; | 581 | handle->h_sync = 1; |
582 | insert_inode_hash(inode); | 582 | if (insert_inode_locked(inode) < 0) { |
583 | err = -EINVAL; | ||
584 | goto fail_drop; | ||
585 | } | ||
583 | spin_lock(&sbi->s_next_gen_lock); | 586 | spin_lock(&sbi->s_next_gen_lock); |
584 | inode->i_generation = sbi->s_next_generation++; | 587 | inode->i_generation = sbi->s_next_generation++; |
585 | spin_unlock(&sbi->s_next_gen_lock); | 588 | spin_unlock(&sbi->s_next_gen_lock); |
@@ -627,6 +630,7 @@ fail_drop: | |||
627 | DQUOT_DROP(inode); | 630 | DQUOT_DROP(inode); |
628 | inode->i_flags |= S_NOQUOTA; | 631 | inode->i_flags |= S_NOQUOTA; |
629 | inode->i_nlink = 0; | 632 | inode->i_nlink = 0; |
633 | unlock_new_inode(inode); | ||
630 | iput(inode); | 634 | iput(inode); |
631 | brelse(bitmap_bh); | 635 | brelse(bitmap_bh); |
632 | return ERR_PTR(err); | 636 | return ERR_PTR(err); |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 3e5edc92aa0b..297ea8dfac7c 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -1652,9 +1652,11 @@ static int ext3_add_nondir(handle_t *handle, | |||
1652 | if (!err) { | 1652 | if (!err) { |
1653 | ext3_mark_inode_dirty(handle, inode); | 1653 | ext3_mark_inode_dirty(handle, inode); |
1654 | d_instantiate(dentry, inode); | 1654 | d_instantiate(dentry, inode); |
1655 | unlock_new_inode(inode); | ||
1655 | return 0; | 1656 | return 0; |
1656 | } | 1657 | } |
1657 | drop_nlink(inode); | 1658 | drop_nlink(inode); |
1659 | unlock_new_inode(inode); | ||
1658 | iput(inode); | 1660 | iput(inode); |
1659 | return err; | 1661 | return err; |
1660 | } | 1662 | } |
@@ -1765,6 +1767,7 @@ retry: | |||
1765 | dir_block = ext3_bread (handle, inode, 0, 1, &err); | 1767 | dir_block = ext3_bread (handle, inode, 0, 1, &err); |
1766 | if (!dir_block) { | 1768 | if (!dir_block) { |
1767 | drop_nlink(inode); /* is this nlink == 0? */ | 1769 | drop_nlink(inode); /* is this nlink == 0? */ |
1770 | unlock_new_inode(inode); | ||
1768 | ext3_mark_inode_dirty(handle, inode); | 1771 | ext3_mark_inode_dirty(handle, inode); |
1769 | iput (inode); | 1772 | iput (inode); |
1770 | goto out_stop; | 1773 | goto out_stop; |
@@ -1792,6 +1795,7 @@ retry: | |||
1792 | err = ext3_add_entry (handle, dentry, inode); | 1795 | err = ext3_add_entry (handle, dentry, inode); |
1793 | if (err) { | 1796 | if (err) { |
1794 | inode->i_nlink = 0; | 1797 | inode->i_nlink = 0; |
1798 | unlock_new_inode(inode); | ||
1795 | ext3_mark_inode_dirty(handle, inode); | 1799 | ext3_mark_inode_dirty(handle, inode); |
1796 | iput (inode); | 1800 | iput (inode); |
1797 | goto out_stop; | 1801 | goto out_stop; |
@@ -1800,6 +1804,7 @@ retry: | |||
1800 | ext3_update_dx_flag(dir); | 1804 | ext3_update_dx_flag(dir); |
1801 | ext3_mark_inode_dirty(handle, dir); | 1805 | ext3_mark_inode_dirty(handle, dir); |
1802 | d_instantiate(dentry, inode); | 1806 | d_instantiate(dentry, inode); |
1807 | unlock_new_inode(inode); | ||
1803 | out_stop: | 1808 | out_stop: |
1804 | ext3_journal_stop(handle); | 1809 | ext3_journal_stop(handle); |
1805 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) | 1810 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) |
@@ -2174,6 +2179,7 @@ retry: | |||
2174 | mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); | 2179 | mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); |
2175 | if (err) { | 2180 | if (err) { |
2176 | drop_nlink(inode); | 2181 | drop_nlink(inode); |
2182 | unlock_new_inode(inode); | ||
2177 | ext3_mark_inode_dirty(handle, inode); | 2183 | ext3_mark_inode_dirty(handle, inode); |
2178 | iput (inode); | 2184 | iput (inode); |
2179 | goto out_stop; | 2185 | goto out_stop; |
@@ -2221,7 +2227,14 @@ retry: | |||
2221 | inc_nlink(inode); | 2227 | inc_nlink(inode); |
2222 | atomic_inc(&inode->i_count); | 2228 | atomic_inc(&inode->i_count); |
2223 | 2229 | ||
2224 | err = ext3_add_nondir(handle, dentry, inode); | 2230 | err = ext3_add_entry(handle, dentry, inode); |
2231 | if (!err) { | ||
2232 | ext3_mark_inode_dirty(handle, inode); | ||
2233 | d_instantiate(dentry, inode); | ||
2234 | } else { | ||
2235 | drop_nlink(inode); | ||
2236 | iput(inode); | ||
2237 | } | ||
2225 | ext3_journal_stop(handle); | 2238 | ext3_journal_stop(handle); |
2226 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) | 2239 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) |
2227 | goto retry; | 2240 | goto retry; |