nfsd race fixes: ext3
ext3 analog of the previous patch Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -579,7 +579,10 @@ got:
|
|||||||
ext3_set_inode_flags(inode);
|
ext3_set_inode_flags(inode);
|
||||||
if (IS_DIRSYNC(inode))
|
if (IS_DIRSYNC(inode))
|
||||||
handle->h_sync = 1;
|
handle->h_sync = 1;
|
||||||
insert_inode_hash(inode);
|
if (insert_inode_locked(inode) < 0) {
|
||||||
|
err = -EINVAL;
|
||||||
|
goto fail_drop;
|
||||||
|
}
|
||||||
spin_lock(&sbi->s_next_gen_lock);
|
spin_lock(&sbi->s_next_gen_lock);
|
||||||
inode->i_generation = sbi->s_next_generation++;
|
inode->i_generation = sbi->s_next_generation++;
|
||||||
spin_unlock(&sbi->s_next_gen_lock);
|
spin_unlock(&sbi->s_next_gen_lock);
|
||||||
@@ -627,6 +630,7 @@ fail_drop:
|
|||||||
DQUOT_DROP(inode);
|
DQUOT_DROP(inode);
|
||||||
inode->i_flags |= S_NOQUOTA;
|
inode->i_flags |= S_NOQUOTA;
|
||||||
inode->i_nlink = 0;
|
inode->i_nlink = 0;
|
||||||
|
unlock_new_inode(inode);
|
||||||
iput(inode);
|
iput(inode);
|
||||||
brelse(bitmap_bh);
|
brelse(bitmap_bh);
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(err);
|
||||||
|
@@ -1652,9 +1652,11 @@ static int ext3_add_nondir(handle_t *handle,
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
ext3_mark_inode_dirty(handle, inode);
|
ext3_mark_inode_dirty(handle, inode);
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
|
unlock_new_inode(inode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
drop_nlink(inode);
|
drop_nlink(inode);
|
||||||
|
unlock_new_inode(inode);
|
||||||
iput(inode);
|
iput(inode);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -1765,6 +1767,7 @@ retry:
|
|||||||
dir_block = ext3_bread (handle, inode, 0, 1, &err);
|
dir_block = ext3_bread (handle, inode, 0, 1, &err);
|
||||||
if (!dir_block) {
|
if (!dir_block) {
|
||||||
drop_nlink(inode); /* is this nlink == 0? */
|
drop_nlink(inode); /* is this nlink == 0? */
|
||||||
|
unlock_new_inode(inode);
|
||||||
ext3_mark_inode_dirty(handle, inode);
|
ext3_mark_inode_dirty(handle, inode);
|
||||||
iput (inode);
|
iput (inode);
|
||||||
goto out_stop;
|
goto out_stop;
|
||||||
@@ -1792,6 +1795,7 @@ retry:
|
|||||||
err = ext3_add_entry (handle, dentry, inode);
|
err = ext3_add_entry (handle, dentry, inode);
|
||||||
if (err) {
|
if (err) {
|
||||||
inode->i_nlink = 0;
|
inode->i_nlink = 0;
|
||||||
|
unlock_new_inode(inode);
|
||||||
ext3_mark_inode_dirty(handle, inode);
|
ext3_mark_inode_dirty(handle, inode);
|
||||||
iput (inode);
|
iput (inode);
|
||||||
goto out_stop;
|
goto out_stop;
|
||||||
@@ -1800,6 +1804,7 @@ retry:
|
|||||||
ext3_update_dx_flag(dir);
|
ext3_update_dx_flag(dir);
|
||||||
ext3_mark_inode_dirty(handle, dir);
|
ext3_mark_inode_dirty(handle, dir);
|
||||||
d_instantiate(dentry, inode);
|
d_instantiate(dentry, inode);
|
||||||
|
unlock_new_inode(inode);
|
||||||
out_stop:
|
out_stop:
|
||||||
ext3_journal_stop(handle);
|
ext3_journal_stop(handle);
|
||||||
if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
|
if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
|
||||||
@@ -2174,6 +2179,7 @@ retry:
|
|||||||
mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
|
mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
|
||||||
if (err) {
|
if (err) {
|
||||||
drop_nlink(inode);
|
drop_nlink(inode);
|
||||||
|
unlock_new_inode(inode);
|
||||||
ext3_mark_inode_dirty(handle, inode);
|
ext3_mark_inode_dirty(handle, inode);
|
||||||
iput (inode);
|
iput (inode);
|
||||||
goto out_stop;
|
goto out_stop;
|
||||||
@@ -2221,7 +2227,14 @@ retry:
|
|||||||
inc_nlink(inode);
|
inc_nlink(inode);
|
||||||
atomic_inc(&inode->i_count);
|
atomic_inc(&inode->i_count);
|
||||||
|
|
||||||
err = ext3_add_nondir(handle, dentry, inode);
|
err = ext3_add_entry(handle, dentry, inode);
|
||||||
|
if (!err) {
|
||||||
|
ext3_mark_inode_dirty(handle, inode);
|
||||||
|
d_instantiate(dentry, inode);
|
||||||
|
} else {
|
||||||
|
drop_nlink(inode);
|
||||||
|
iput(inode);
|
||||||
|
}
|
||||||
ext3_journal_stop(handle);
|
ext3_journal_stop(handle);
|
||||||
if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
|
if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
|
||||||
goto retry;
|
goto retry;
|
||||||
|
Reference in New Issue
Block a user