diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-02 09:40:21 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-03 01:28:16 -0500 |
commit | 37750cdda36721fa7fa816f5f58258d2c013b248 (patch) | |
tree | 0c8f83e9865dc279f00881e71c442c7dfc198104 /fs/ufs | |
parent | 4787d45fa76b97e224a8299086bb5fb496275796 (diff) |
ufs: i_nlink races in rename()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r-- | fs/ufs/namei.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 12f39b9e4437..d6f681535eb8 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -306,7 +306,6 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
306 | new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page); | 306 | new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page); |
307 | if (!new_de) | 307 | if (!new_de) |
308 | goto out_dir; | 308 | goto out_dir; |
309 | inode_inc_link_count(old_inode); | ||
310 | ufs_set_link(new_dir, new_de, new_page, old_inode); | 309 | ufs_set_link(new_dir, new_de, new_page, old_inode); |
311 | new_inode->i_ctime = CURRENT_TIME_SEC; | 310 | new_inode->i_ctime = CURRENT_TIME_SEC; |
312 | if (dir_de) | 311 | if (dir_de) |
@@ -318,12 +317,9 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
318 | if (new_dir->i_nlink >= UFS_LINK_MAX) | 317 | if (new_dir->i_nlink >= UFS_LINK_MAX) |
319 | goto out_dir; | 318 | goto out_dir; |
320 | } | 319 | } |
321 | inode_inc_link_count(old_inode); | ||
322 | err = ufs_add_link(new_dentry, old_inode); | 320 | err = ufs_add_link(new_dentry, old_inode); |
323 | if (err) { | 321 | if (err) |
324 | inode_dec_link_count(old_inode); | ||
325 | goto out_dir; | 322 | goto out_dir; |
326 | } | ||
327 | if (dir_de) | 323 | if (dir_de) |
328 | inode_inc_link_count(new_dir); | 324 | inode_inc_link_count(new_dir); |
329 | } | 325 | } |
@@ -331,12 +327,11 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
331 | /* | 327 | /* |
332 | * Like most other Unix systems, set the ctime for inodes on a | 328 | * Like most other Unix systems, set the ctime for inodes on a |
333 | * rename. | 329 | * rename. |
334 | * inode_dec_link_count() will mark the inode dirty. | ||
335 | */ | 330 | */ |
336 | old_inode->i_ctime = CURRENT_TIME_SEC; | 331 | old_inode->i_ctime = CURRENT_TIME_SEC; |
337 | 332 | ||
338 | ufs_delete_entry(old_dir, old_de, old_page); | 333 | ufs_delete_entry(old_dir, old_de, old_page); |
339 | inode_dec_link_count(old_inode); | 334 | mark_inode_dirty(old_inode); |
340 | 335 | ||
341 | if (dir_de) { | 336 | if (dir_de) { |
342 | ufs_set_link(old_inode, dir_de, dir_page, new_dir); | 337 | ufs_set_link(old_inode, dir_de, dir_page, new_dir); |