diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-12-30 02:03:31 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-12-31 18:07:44 -0500 |
commit | 6b38e842bb832a3dbeb17e382404aef3c40ac5f9 (patch) | |
tree | c36830341781bf49ded16a0d5432647979a74ad8 /fs/ext4 | |
parent | c38012daa7ad902a39a4213ba2b3fe50e81157ea (diff) |
nfsd race fixes: ext4
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ialloc.c | 6 | ||||
-rw-r--r-- | fs/ext4/namei.c | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 08cac9fcace..6e6052879aa 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -826,7 +826,10 @@ got: | |||
826 | ext4_set_inode_flags(inode); | 826 | ext4_set_inode_flags(inode); |
827 | if (IS_DIRSYNC(inode)) | 827 | if (IS_DIRSYNC(inode)) |
828 | handle->h_sync = 1; | 828 | handle->h_sync = 1; |
829 | insert_inode_hash(inode); | 829 | if (insert_inode_locked(inode) < 0) { |
830 | err = -EINVAL; | ||
831 | goto fail_drop; | ||
832 | } | ||
830 | spin_lock(&sbi->s_next_gen_lock); | 833 | spin_lock(&sbi->s_next_gen_lock); |
831 | inode->i_generation = sbi->s_next_generation++; | 834 | inode->i_generation = sbi->s_next_generation++; |
832 | spin_unlock(&sbi->s_next_gen_lock); | 835 | spin_unlock(&sbi->s_next_gen_lock); |
@@ -881,6 +884,7 @@ fail_drop: | |||
881 | DQUOT_DROP(inode); | 884 | DQUOT_DROP(inode); |
882 | inode->i_flags |= S_NOQUOTA; | 885 | inode->i_flags |= S_NOQUOTA; |
883 | inode->i_nlink = 0; | 886 | inode->i_nlink = 0; |
887 | unlock_new_inode(inode); | ||
884 | iput(inode); | 888 | iput(inode); |
885 | brelse(bitmap_bh); | 889 | brelse(bitmap_bh); |
886 | return ERR_PTR(err); | 890 | return ERR_PTR(err); |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 63adcb79298..da98a9012fa 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -1693,9 +1693,11 @@ static int ext4_add_nondir(handle_t *handle, | |||
1693 | if (!err) { | 1693 | if (!err) { |
1694 | ext4_mark_inode_dirty(handle, inode); | 1694 | ext4_mark_inode_dirty(handle, inode); |
1695 | d_instantiate(dentry, inode); | 1695 | d_instantiate(dentry, inode); |
1696 | unlock_new_inode(inode); | ||
1696 | return 0; | 1697 | return 0; |
1697 | } | 1698 | } |
1698 | drop_nlink(inode); | 1699 | drop_nlink(inode); |
1700 | unlock_new_inode(inode); | ||
1699 | iput(inode); | 1701 | iput(inode); |
1700 | return err; | 1702 | return err; |
1701 | } | 1703 | } |
@@ -1830,6 +1832,7 @@ retry: | |||
1830 | if (err) { | 1832 | if (err) { |
1831 | out_clear_inode: | 1833 | out_clear_inode: |
1832 | clear_nlink(inode); | 1834 | clear_nlink(inode); |
1835 | unlock_new_inode(inode); | ||
1833 | ext4_mark_inode_dirty(handle, inode); | 1836 | ext4_mark_inode_dirty(handle, inode); |
1834 | iput(inode); | 1837 | iput(inode); |
1835 | goto out_stop; | 1838 | goto out_stop; |
@@ -1838,6 +1841,7 @@ out_clear_inode: | |||
1838 | ext4_update_dx_flag(dir); | 1841 | ext4_update_dx_flag(dir); |
1839 | ext4_mark_inode_dirty(handle, dir); | 1842 | ext4_mark_inode_dirty(handle, dir); |
1840 | d_instantiate(dentry, inode); | 1843 | d_instantiate(dentry, inode); |
1844 | unlock_new_inode(inode); | ||
1841 | out_stop: | 1845 | out_stop: |
1842 | ext4_journal_stop(handle); | 1846 | ext4_journal_stop(handle); |
1843 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) | 1847 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) |
@@ -2212,6 +2216,7 @@ retry: | |||
2212 | mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); | 2216 | mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); |
2213 | if (err) { | 2217 | if (err) { |
2214 | clear_nlink(inode); | 2218 | clear_nlink(inode); |
2219 | unlock_new_inode(inode); | ||
2215 | ext4_mark_inode_dirty(handle, inode); | 2220 | ext4_mark_inode_dirty(handle, inode); |
2216 | iput(inode); | 2221 | iput(inode); |
2217 | goto out_stop; | 2222 | goto out_stop; |
@@ -2262,7 +2267,14 @@ retry: | |||
2262 | ext4_inc_count(handle, inode); | 2267 | ext4_inc_count(handle, inode); |
2263 | atomic_inc(&inode->i_count); | 2268 | atomic_inc(&inode->i_count); |
2264 | 2269 | ||
2265 | err = ext4_add_nondir(handle, dentry, inode); | 2270 | err = ext4_add_entry(handle, dentry, inode); |
2271 | if (!err) { | ||
2272 | ext4_mark_inode_dirty(handle, inode); | ||
2273 | d_instantiate(dentry, inode); | ||
2274 | } else { | ||
2275 | drop_nlink(inode); | ||
2276 | iput(inode); | ||
2277 | } | ||
2266 | ext4_journal_stop(handle); | 2278 | ext4_journal_stop(handle); |
2267 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) | 2279 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) |
2268 | goto retry; | 2280 | goto retry; |