diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-04 08:23:01 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-11 15:36:37 -0400 |
commit | 1e2e547a93a00ebc21582c06ca3c6cfea2a309ee (patch) | |
tree | e31468774e0543997a15daa0409ef79a02d1438c | |
parent | d7760d638b140d53c6390a2fbee9b06460b43e9e (diff) |
do d_instantiate/unlock_new_inode combinations safely
For anything NFS-exported we do _not_ want to unlock new inode
before it has grown an alias; original set of fixes got the
ordering right, but missed the nasty complication in case of
lockdep being enabled - unlock_new_inode() does
lockdep_annotate_inode_mutex_key(inode)
which can only be done before anyone gets a chance to touch
->i_mutex. Unfortunately, flipping the order and doing
unlock_new_inode() before d_instantiate() opens a window when
mkdir can race with open-by-fhandle on a guessed fhandle, leading
to multiple aliases for a directory inode and all the breakage
that follows from that.
Correct solution: a new primitive (d_instantiate_new())
combining these two in the right order - lockdep annotate, then
d_instantiate(), then the rest of unlock_new_inode(). All
combinations of d_instantiate() with unlock_new_inode() should
be converted to that.
Cc: stable@kernel.org # 2.6.29 and later
Tested-by: Mike Marshall <hubcap@omnibond.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/btrfs/inode.c | 16 | ||||
-rw-r--r-- | fs/dcache.c | 22 | ||||
-rw-r--r-- | fs/ecryptfs/inode.c | 3 | ||||
-rw-r--r-- | fs/ext2/namei.c | 6 | ||||
-rw-r--r-- | fs/ext4/namei.c | 6 | ||||
-rw-r--r-- | fs/f2fs/namei.c | 12 | ||||
-rw-r--r-- | fs/jffs2/dir.c | 12 | ||||
-rw-r--r-- | fs/jfs/namei.c | 12 | ||||
-rw-r--r-- | fs/nilfs2/namei.c | 6 | ||||
-rw-r--r-- | fs/orangefs/namei.c | 9 | ||||
-rw-r--r-- | fs/reiserfs/namei.c | 12 | ||||
-rw-r--r-- | fs/udf/namei.c | 6 | ||||
-rw-r--r-- | fs/ufs/namei.c | 6 | ||||
-rw-r--r-- | include/linux/dcache.h | 1 |
14 files changed, 57 insertions, 72 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e064c49c9a9a..9e97cbb4f006 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6575,8 +6575,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
6575 | goto out_unlock_inode; | 6575 | goto out_unlock_inode; |
6576 | } else { | 6576 | } else { |
6577 | btrfs_update_inode(trans, root, inode); | 6577 | btrfs_update_inode(trans, root, inode); |
6578 | unlock_new_inode(inode); | 6578 | d_instantiate_new(dentry, inode); |
6579 | d_instantiate(dentry, inode); | ||
6580 | } | 6579 | } |
6581 | 6580 | ||
6582 | out_unlock: | 6581 | out_unlock: |
@@ -6652,8 +6651,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
6652 | goto out_unlock_inode; | 6651 | goto out_unlock_inode; |
6653 | 6652 | ||
6654 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | 6653 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; |
6655 | unlock_new_inode(inode); | 6654 | d_instantiate_new(dentry, inode); |
6656 | d_instantiate(dentry, inode); | ||
6657 | 6655 | ||
6658 | out_unlock: | 6656 | out_unlock: |
6659 | btrfs_end_transaction(trans); | 6657 | btrfs_end_transaction(trans); |
@@ -6798,12 +6796,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
6798 | if (err) | 6796 | if (err) |
6799 | goto out_fail_inode; | 6797 | goto out_fail_inode; |
6800 | 6798 | ||
6801 | d_instantiate(dentry, inode); | 6799 | d_instantiate_new(dentry, inode); |
6802 | /* | ||
6803 | * mkdir is special. We're unlocking after we call d_instantiate | ||
6804 | * to avoid a race with nfsd calling d_instantiate. | ||
6805 | */ | ||
6806 | unlock_new_inode(inode); | ||
6807 | drop_on_err = 0; | 6800 | drop_on_err = 0; |
6808 | 6801 | ||
6809 | out_fail: | 6802 | out_fail: |
@@ -10246,8 +10239,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
10246 | goto out_unlock_inode; | 10239 | goto out_unlock_inode; |
10247 | } | 10240 | } |
10248 | 10241 | ||
10249 | unlock_new_inode(inode); | 10242 | d_instantiate_new(dentry, inode); |
10250 | d_instantiate(dentry, inode); | ||
10251 | 10243 | ||
10252 | out_unlock: | 10244 | out_unlock: |
10253 | btrfs_end_transaction(trans); | 10245 | btrfs_end_transaction(trans); |
diff --git a/fs/dcache.c b/fs/dcache.c index 86d2de63461e..2acfc69878f5 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1899,6 +1899,28 @@ void d_instantiate(struct dentry *entry, struct inode * inode) | |||
1899 | } | 1899 | } |
1900 | EXPORT_SYMBOL(d_instantiate); | 1900 | EXPORT_SYMBOL(d_instantiate); |
1901 | 1901 | ||
1902 | /* | ||
1903 | * This should be equivalent to d_instantiate() + unlock_new_inode(), | ||
1904 | * with lockdep-related part of unlock_new_inode() done before | ||
1905 | * anything else. Use that instead of open-coding d_instantiate()/ | ||
1906 | * unlock_new_inode() combinations. | ||
1907 | */ | ||
1908 | void d_instantiate_new(struct dentry *entry, struct inode *inode) | ||
1909 | { | ||
1910 | BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); | ||
1911 | BUG_ON(!inode); | ||
1912 | lockdep_annotate_inode_mutex_key(inode); | ||
1913 | security_d_instantiate(entry, inode); | ||
1914 | spin_lock(&inode->i_lock); | ||
1915 | __d_instantiate(entry, inode); | ||
1916 | WARN_ON(!(inode->i_state & I_NEW)); | ||
1917 | inode->i_state &= ~I_NEW; | ||
1918 | smp_mb(); | ||
1919 | wake_up_bit(&inode->i_state, __I_NEW); | ||
1920 | spin_unlock(&inode->i_lock); | ||
1921 | } | ||
1922 | EXPORT_SYMBOL(d_instantiate_new); | ||
1923 | |||
1902 | /** | 1924 | /** |
1903 | * d_instantiate_no_diralias - instantiate a non-aliased dentry | 1925 | * d_instantiate_no_diralias - instantiate a non-aliased dentry |
1904 | * @entry: dentry to complete | 1926 | * @entry: dentry to complete |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 847904aa63a9..7bba8f2693b2 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -283,8 +283,7 @@ ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry, | |||
283 | iget_failed(ecryptfs_inode); | 283 | iget_failed(ecryptfs_inode); |
284 | goto out; | 284 | goto out; |
285 | } | 285 | } |
286 | unlock_new_inode(ecryptfs_inode); | 286 | d_instantiate_new(ecryptfs_dentry, ecryptfs_inode); |
287 | d_instantiate(ecryptfs_dentry, ecryptfs_inode); | ||
288 | out: | 287 | out: |
289 | return rc; | 288 | return rc; |
290 | } | 289 | } |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 55f7caadb093..152453a91877 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -41,8 +41,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) | |||
41 | { | 41 | { |
42 | int err = ext2_add_link(dentry, inode); | 42 | int err = ext2_add_link(dentry, inode); |
43 | if (!err) { | 43 | if (!err) { |
44 | unlock_new_inode(inode); | 44 | d_instantiate_new(dentry, inode); |
45 | d_instantiate(dentry, inode); | ||
46 | return 0; | 45 | return 0; |
47 | } | 46 | } |
48 | inode_dec_link_count(inode); | 47 | inode_dec_link_count(inode); |
@@ -255,8 +254,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) | |||
255 | if (err) | 254 | if (err) |
256 | goto out_fail; | 255 | goto out_fail; |
257 | 256 | ||
258 | unlock_new_inode(inode); | 257 | d_instantiate_new(dentry, inode); |
259 | d_instantiate(dentry, inode); | ||
260 | out: | 258 | out: |
261 | return err; | 259 | return err; |
262 | 260 | ||
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index b1f21e3a0763..4a09063ce1d2 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2411,8 +2411,7 @@ static int ext4_add_nondir(handle_t *handle, | |||
2411 | int err = ext4_add_entry(handle, dentry, inode); | 2411 | int err = ext4_add_entry(handle, dentry, inode); |
2412 | if (!err) { | 2412 | if (!err) { |
2413 | ext4_mark_inode_dirty(handle, inode); | 2413 | ext4_mark_inode_dirty(handle, inode); |
2414 | unlock_new_inode(inode); | 2414 | d_instantiate_new(dentry, inode); |
2415 | d_instantiate(dentry, inode); | ||
2416 | return 0; | 2415 | return 0; |
2417 | } | 2416 | } |
2418 | drop_nlink(inode); | 2417 | drop_nlink(inode); |
@@ -2651,8 +2650,7 @@ out_clear_inode: | |||
2651 | err = ext4_mark_inode_dirty(handle, dir); | 2650 | err = ext4_mark_inode_dirty(handle, dir); |
2652 | if (err) | 2651 | if (err) |
2653 | goto out_clear_inode; | 2652 | goto out_clear_inode; |
2654 | unlock_new_inode(inode); | 2653 | d_instantiate_new(dentry, inode); |
2655 | d_instantiate(dentry, inode); | ||
2656 | if (IS_DIRSYNC(dir)) | 2654 | if (IS_DIRSYNC(dir)) |
2657 | ext4_handle_sync(handle); | 2655 | ext4_handle_sync(handle); |
2658 | 2656 | ||
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index d5098efe577c..75e37fd720b2 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
@@ -294,8 +294,7 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, | |||
294 | 294 | ||
295 | alloc_nid_done(sbi, ino); | 295 | alloc_nid_done(sbi, ino); |
296 | 296 | ||
297 | d_instantiate(dentry, inode); | 297 | d_instantiate_new(dentry, inode); |
298 | unlock_new_inode(inode); | ||
299 | 298 | ||
300 | if (IS_DIRSYNC(dir)) | 299 | if (IS_DIRSYNC(dir)) |
301 | f2fs_sync_fs(sbi->sb, 1); | 300 | f2fs_sync_fs(sbi->sb, 1); |
@@ -597,8 +596,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, | |||
597 | err = page_symlink(inode, disk_link.name, disk_link.len); | 596 | err = page_symlink(inode, disk_link.name, disk_link.len); |
598 | 597 | ||
599 | err_out: | 598 | err_out: |
600 | d_instantiate(dentry, inode); | 599 | d_instantiate_new(dentry, inode); |
601 | unlock_new_inode(inode); | ||
602 | 600 | ||
603 | /* | 601 | /* |
604 | * Let's flush symlink data in order to avoid broken symlink as much as | 602 | * Let's flush symlink data in order to avoid broken symlink as much as |
@@ -661,8 +659,7 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
661 | 659 | ||
662 | alloc_nid_done(sbi, inode->i_ino); | 660 | alloc_nid_done(sbi, inode->i_ino); |
663 | 661 | ||
664 | d_instantiate(dentry, inode); | 662 | d_instantiate_new(dentry, inode); |
665 | unlock_new_inode(inode); | ||
666 | 663 | ||
667 | if (IS_DIRSYNC(dir)) | 664 | if (IS_DIRSYNC(dir)) |
668 | f2fs_sync_fs(sbi->sb, 1); | 665 | f2fs_sync_fs(sbi->sb, 1); |
@@ -713,8 +710,7 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry, | |||
713 | 710 | ||
714 | alloc_nid_done(sbi, inode->i_ino); | 711 | alloc_nid_done(sbi, inode->i_ino); |
715 | 712 | ||
716 | d_instantiate(dentry, inode); | 713 | d_instantiate_new(dentry, inode); |
717 | unlock_new_inode(inode); | ||
718 | 714 | ||
719 | if (IS_DIRSYNC(dir)) | 715 | if (IS_DIRSYNC(dir)) |
720 | f2fs_sync_fs(sbi->sb, 1); | 716 | f2fs_sync_fs(sbi->sb, 1); |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 0a754f38462e..e5a6deb38e1e 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -209,8 +209,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, | |||
209 | __func__, inode->i_ino, inode->i_mode, inode->i_nlink, | 209 | __func__, inode->i_ino, inode->i_mode, inode->i_nlink, |
210 | f->inocache->pino_nlink, inode->i_mapping->nrpages); | 210 | f->inocache->pino_nlink, inode->i_mapping->nrpages); |
211 | 211 | ||
212 | unlock_new_inode(inode); | 212 | d_instantiate_new(dentry, inode); |
213 | d_instantiate(dentry, inode); | ||
214 | return 0; | 213 | return 0; |
215 | 214 | ||
216 | fail: | 215 | fail: |
@@ -430,8 +429,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
430 | mutex_unlock(&dir_f->sem); | 429 | mutex_unlock(&dir_f->sem); |
431 | jffs2_complete_reservation(c); | 430 | jffs2_complete_reservation(c); |
432 | 431 | ||
433 | unlock_new_inode(inode); | 432 | d_instantiate_new(dentry, inode); |
434 | d_instantiate(dentry, inode); | ||
435 | return 0; | 433 | return 0; |
436 | 434 | ||
437 | fail: | 435 | fail: |
@@ -575,8 +573,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode | |||
575 | mutex_unlock(&dir_f->sem); | 573 | mutex_unlock(&dir_f->sem); |
576 | jffs2_complete_reservation(c); | 574 | jffs2_complete_reservation(c); |
577 | 575 | ||
578 | unlock_new_inode(inode); | 576 | d_instantiate_new(dentry, inode); |
579 | d_instantiate(dentry, inode); | ||
580 | return 0; | 577 | return 0; |
581 | 578 | ||
582 | fail: | 579 | fail: |
@@ -747,8 +744,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode | |||
747 | mutex_unlock(&dir_f->sem); | 744 | mutex_unlock(&dir_f->sem); |
748 | jffs2_complete_reservation(c); | 745 | jffs2_complete_reservation(c); |
749 | 746 | ||
750 | unlock_new_inode(inode); | 747 | d_instantiate_new(dentry, inode); |
751 | d_instantiate(dentry, inode); | ||
752 | return 0; | 748 | return 0; |
753 | 749 | ||
754 | fail: | 750 | fail: |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index b41596d71858..56c3fcbfe80e 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -178,8 +178,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode, | |||
178 | unlock_new_inode(ip); | 178 | unlock_new_inode(ip); |
179 | iput(ip); | 179 | iput(ip); |
180 | } else { | 180 | } else { |
181 | unlock_new_inode(ip); | 181 | d_instantiate_new(dentry, ip); |
182 | d_instantiate(dentry, ip); | ||
183 | } | 182 | } |
184 | 183 | ||
185 | out2: | 184 | out2: |
@@ -313,8 +312,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode) | |||
313 | unlock_new_inode(ip); | 312 | unlock_new_inode(ip); |
314 | iput(ip); | 313 | iput(ip); |
315 | } else { | 314 | } else { |
316 | unlock_new_inode(ip); | 315 | d_instantiate_new(dentry, ip); |
317 | d_instantiate(dentry, ip); | ||
318 | } | 316 | } |
319 | 317 | ||
320 | out2: | 318 | out2: |
@@ -1059,8 +1057,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, | |||
1059 | unlock_new_inode(ip); | 1057 | unlock_new_inode(ip); |
1060 | iput(ip); | 1058 | iput(ip); |
1061 | } else { | 1059 | } else { |
1062 | unlock_new_inode(ip); | 1060 | d_instantiate_new(dentry, ip); |
1063 | d_instantiate(dentry, ip); | ||
1064 | } | 1061 | } |
1065 | 1062 | ||
1066 | out2: | 1063 | out2: |
@@ -1447,8 +1444,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, | |||
1447 | unlock_new_inode(ip); | 1444 | unlock_new_inode(ip); |
1448 | iput(ip); | 1445 | iput(ip); |
1449 | } else { | 1446 | } else { |
1450 | unlock_new_inode(ip); | 1447 | d_instantiate_new(dentry, ip); |
1451 | d_instantiate(dentry, ip); | ||
1452 | } | 1448 | } |
1453 | 1449 | ||
1454 | out1: | 1450 | out1: |
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 1a2894aa0194..dd52d3f82e8d 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c | |||
@@ -46,8 +46,7 @@ static inline int nilfs_add_nondir(struct dentry *dentry, struct inode *inode) | |||
46 | int err = nilfs_add_link(dentry, inode); | 46 | int err = nilfs_add_link(dentry, inode); |
47 | 47 | ||
48 | if (!err) { | 48 | if (!err) { |
49 | d_instantiate(dentry, inode); | 49 | d_instantiate_new(dentry, inode); |
50 | unlock_new_inode(inode); | ||
51 | return 0; | 50 | return 0; |
52 | } | 51 | } |
53 | inode_dec_link_count(inode); | 52 | inode_dec_link_count(inode); |
@@ -243,8 +242,7 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
243 | goto out_fail; | 242 | goto out_fail; |
244 | 243 | ||
245 | nilfs_mark_inode_dirty(inode); | 244 | nilfs_mark_inode_dirty(inode); |
246 | d_instantiate(dentry, inode); | 245 | d_instantiate_new(dentry, inode); |
247 | unlock_new_inode(inode); | ||
248 | out: | 246 | out: |
249 | if (!err) | 247 | if (!err) |
250 | err = nilfs_transaction_commit(dir->i_sb); | 248 | err = nilfs_transaction_commit(dir->i_sb); |
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index 6e3134e6d98a..1b5707c44c3f 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c | |||
@@ -75,8 +75,7 @@ static int orangefs_create(struct inode *dir, | |||
75 | get_khandle_from_ino(inode), | 75 | get_khandle_from_ino(inode), |
76 | dentry); | 76 | dentry); |
77 | 77 | ||
78 | d_instantiate(dentry, inode); | 78 | d_instantiate_new(dentry, inode); |
79 | unlock_new_inode(inode); | ||
80 | orangefs_set_timeout(dentry); | 79 | orangefs_set_timeout(dentry); |
81 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; | 80 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; |
82 | ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; | 81 | ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; |
@@ -332,8 +331,7 @@ static int orangefs_symlink(struct inode *dir, | |||
332 | "Assigned symlink inode new number of %pU\n", | 331 | "Assigned symlink inode new number of %pU\n", |
333 | get_khandle_from_ino(inode)); | 332 | get_khandle_from_ino(inode)); |
334 | 333 | ||
335 | d_instantiate(dentry, inode); | 334 | d_instantiate_new(dentry, inode); |
336 | unlock_new_inode(inode); | ||
337 | orangefs_set_timeout(dentry); | 335 | orangefs_set_timeout(dentry); |
338 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; | 336 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; |
339 | ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; | 337 | ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; |
@@ -402,8 +400,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode | |||
402 | "Assigned dir inode new number of %pU\n", | 400 | "Assigned dir inode new number of %pU\n", |
403 | get_khandle_from_ino(inode)); | 401 | get_khandle_from_ino(inode)); |
404 | 402 | ||
405 | d_instantiate(dentry, inode); | 403 | d_instantiate_new(dentry, inode); |
406 | unlock_new_inode(inode); | ||
407 | orangefs_set_timeout(dentry); | 404 | orangefs_set_timeout(dentry); |
408 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; | 405 | ORANGEFS_I(inode)->getattr_time = jiffies - 1; |
409 | ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; | 406 | ORANGEFS_I(inode)->getattr_mask = STATX_BASIC_STATS; |
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index bd39a998843d..5089dac02660 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -687,8 +687,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mod | |||
687 | reiserfs_update_inode_transaction(inode); | 687 | reiserfs_update_inode_transaction(inode); |
688 | reiserfs_update_inode_transaction(dir); | 688 | reiserfs_update_inode_transaction(dir); |
689 | 689 | ||
690 | unlock_new_inode(inode); | 690 | d_instantiate_new(dentry, inode); |
691 | d_instantiate(dentry, inode); | ||
692 | retval = journal_end(&th); | 691 | retval = journal_end(&th); |
693 | 692 | ||
694 | out_failed: | 693 | out_failed: |
@@ -771,8 +770,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode | |||
771 | goto out_failed; | 770 | goto out_failed; |
772 | } | 771 | } |
773 | 772 | ||
774 | unlock_new_inode(inode); | 773 | d_instantiate_new(dentry, inode); |
775 | d_instantiate(dentry, inode); | ||
776 | retval = journal_end(&th); | 774 | retval = journal_end(&th); |
777 | 775 | ||
778 | out_failed: | 776 | out_failed: |
@@ -871,8 +869,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode | |||
871 | /* the above add_entry did not update dir's stat data */ | 869 | /* the above add_entry did not update dir's stat data */ |
872 | reiserfs_update_sd(&th, dir); | 870 | reiserfs_update_sd(&th, dir); |
873 | 871 | ||
874 | unlock_new_inode(inode); | 872 | d_instantiate_new(dentry, inode); |
875 | d_instantiate(dentry, inode); | ||
876 | retval = journal_end(&th); | 873 | retval = journal_end(&th); |
877 | out_failed: | 874 | out_failed: |
878 | reiserfs_write_unlock(dir->i_sb); | 875 | reiserfs_write_unlock(dir->i_sb); |
@@ -1187,8 +1184,7 @@ static int reiserfs_symlink(struct inode *parent_dir, | |||
1187 | goto out_failed; | 1184 | goto out_failed; |
1188 | } | 1185 | } |
1189 | 1186 | ||
1190 | unlock_new_inode(inode); | 1187 | d_instantiate_new(dentry, inode); |
1191 | d_instantiate(dentry, inode); | ||
1192 | retval = journal_end(&th); | 1188 | retval = journal_end(&th); |
1193 | out_failed: | 1189 | out_failed: |
1194 | reiserfs_write_unlock(parent_dir->i_sb); | 1190 | reiserfs_write_unlock(parent_dir->i_sb); |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 0458dd47e105..c586026508db 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -622,8 +622,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode) | |||
622 | if (fibh.sbh != fibh.ebh) | 622 | if (fibh.sbh != fibh.ebh) |
623 | brelse(fibh.ebh); | 623 | brelse(fibh.ebh); |
624 | brelse(fibh.sbh); | 624 | brelse(fibh.sbh); |
625 | unlock_new_inode(inode); | 625 | d_instantiate_new(dentry, inode); |
626 | d_instantiate(dentry, inode); | ||
627 | 626 | ||
628 | return 0; | 627 | return 0; |
629 | } | 628 | } |
@@ -733,8 +732,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
733 | inc_nlink(dir); | 732 | inc_nlink(dir); |
734 | dir->i_ctime = dir->i_mtime = current_time(dir); | 733 | dir->i_ctime = dir->i_mtime = current_time(dir); |
735 | mark_inode_dirty(dir); | 734 | mark_inode_dirty(dir); |
736 | unlock_new_inode(inode); | 735 | d_instantiate_new(dentry, inode); |
737 | d_instantiate(dentry, inode); | ||
738 | if (fibh.sbh != fibh.ebh) | 736 | if (fibh.sbh != fibh.ebh) |
739 | brelse(fibh.ebh); | 737 | brelse(fibh.ebh); |
740 | brelse(fibh.sbh); | 738 | brelse(fibh.sbh); |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 32545cd00ceb..d5f43ba76c59 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -39,8 +39,7 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode) | |||
39 | { | 39 | { |
40 | int err = ufs_add_link(dentry, inode); | 40 | int err = ufs_add_link(dentry, inode); |
41 | if (!err) { | 41 | if (!err) { |
42 | unlock_new_inode(inode); | 42 | d_instantiate_new(dentry, inode); |
43 | d_instantiate(dentry, inode); | ||
44 | return 0; | 43 | return 0; |
45 | } | 44 | } |
46 | inode_dec_link_count(inode); | 45 | inode_dec_link_count(inode); |
@@ -193,8 +192,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) | |||
193 | if (err) | 192 | if (err) |
194 | goto out_fail; | 193 | goto out_fail; |
195 | 194 | ||
196 | unlock_new_inode(inode); | 195 | d_instantiate_new(dentry, inode); |
197 | d_instantiate(dentry, inode); | ||
198 | return 0; | 196 | return 0; |
199 | 197 | ||
200 | out_fail: | 198 | out_fail: |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 94acbde17bb1..66c6e17e61e5 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -224,6 +224,7 @@ extern seqlock_t rename_lock; | |||
224 | * These are the low-level FS interfaces to the dcache.. | 224 | * These are the low-level FS interfaces to the dcache.. |
225 | */ | 225 | */ |
226 | extern void d_instantiate(struct dentry *, struct inode *); | 226 | extern void d_instantiate(struct dentry *, struct inode *); |
227 | extern void d_instantiate_new(struct dentry *, struct inode *); | ||
227 | extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *); | 228 | extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *); |
228 | extern struct dentry * d_instantiate_anon(struct dentry *, struct inode *); | 229 | extern struct dentry * d_instantiate_anon(struct dentry *, struct inode *); |
229 | extern int d_instantiate_no_diralias(struct dentry *, struct inode *); | 230 | extern int d_instantiate_no_diralias(struct dentry *, struct inode *); |