diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-09-26 21:17:52 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-09-26 21:17:52 -0400 |
| commit | e4502c63f56aeca887ced37f24e0def1ef11cec8 (patch) | |
| tree | d63e8969b4f6b39565eaeeac8e9c2a400fd18a0b | |
| parent | 2c80929c4c4d54e568b07ab85877d5fd38f4b02f (diff) | |
ufs: deal with nfsd/iget races
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | fs/ufs/ialloc.c | 6 | ||||
| -rw-r--r-- | fs/ufs/namei.c | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index a9cc75ffa925..7caa01652888 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c | |||
| @@ -298,7 +298,10 @@ cg_found: | |||
| 298 | ufsi->i_oeftflag = 0; | 298 | ufsi->i_oeftflag = 0; |
| 299 | ufsi->i_dir_start_lookup = 0; | 299 | ufsi->i_dir_start_lookup = 0; |
| 300 | memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1)); | 300 | memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1)); |
| 301 | insert_inode_hash(inode); | 301 | if (insert_inode_locked(inode) < 0) { |
| 302 | err = -EIO; | ||
| 303 | goto failed; | ||
| 304 | } | ||
| 302 | mark_inode_dirty(inode); | 305 | mark_inode_dirty(inode); |
| 303 | 306 | ||
| 304 | if (uspi->fs_magic == UFS2_MAGIC) { | 307 | if (uspi->fs_magic == UFS2_MAGIC) { |
| @@ -337,6 +340,7 @@ cg_found: | |||
| 337 | fail_remove_inode: | 340 | fail_remove_inode: |
| 338 | unlock_ufs(sb); | 341 | unlock_ufs(sb); |
| 339 | clear_nlink(inode); | 342 | clear_nlink(inode); |
| 343 | unlock_new_inode(inode); | ||
| 340 | iput(inode); | 344 | iput(inode); |
| 341 | UFSD("EXIT (FAILED): err %d\n", err); | 345 | UFSD("EXIT (FAILED): err %d\n", err); |
| 342 | return ERR_PTR(err); | 346 | return ERR_PTR(err); |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 2df62a73f20c..fd65deb4b5f0 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
| @@ -38,10 +38,12 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode) | |||
| 38 | { | 38 | { |
| 39 | int err = ufs_add_link(dentry, inode); | 39 | int err = ufs_add_link(dentry, inode); |
| 40 | if (!err) { | 40 | if (!err) { |
| 41 | unlock_new_inode(inode); | ||
| 41 | d_instantiate(dentry, inode); | 42 | d_instantiate(dentry, inode); |
| 42 | return 0; | 43 | return 0; |
| 43 | } | 44 | } |
| 44 | inode_dec_link_count(inode); | 45 | inode_dec_link_count(inode); |
| 46 | unlock_new_inode(inode); | ||
| 45 | iput(inode); | 47 | iput(inode); |
| 46 | return err; | 48 | return err; |
| 47 | } | 49 | } |
| @@ -155,6 +157,7 @@ out_notlocked: | |||
| 155 | 157 | ||
| 156 | out_fail: | 158 | out_fail: |
| 157 | inode_dec_link_count(inode); | 159 | inode_dec_link_count(inode); |
| 160 | unlock_new_inode(inode); | ||
| 158 | iput(inode); | 161 | iput(inode); |
| 159 | goto out; | 162 | goto out; |
| 160 | } | 163 | } |
| @@ -210,6 +213,7 @@ out: | |||
| 210 | out_fail: | 213 | out_fail: |
| 211 | inode_dec_link_count(inode); | 214 | inode_dec_link_count(inode); |
| 212 | inode_dec_link_count(inode); | 215 | inode_dec_link_count(inode); |
| 216 | unlock_new_inode(inode); | ||
| 213 | iput (inode); | 217 | iput (inode); |
| 214 | inode_dec_link_count(dir); | 218 | inode_dec_link_count(dir); |
| 215 | unlock_ufs(dir->i_sb); | 219 | unlock_ufs(dir->i_sb); |
