diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-13 23:25:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-13 23:25:58 -0400 |
commit | 0ea97a2d61df729ccce75b00a2fa37d39a508ab6 (patch) | |
tree | 953c13d8309938b93af2c257de8f7b84004ae748 | |
parent | a66b4cd1e7163adb327838a3c81faaf6a9330d5a (diff) | |
parent | c7b15a8657da7f8d11269c7cc3d8beef10d26b43 (diff) |
Merge branch 'work.mkdir' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs icache updates from Al Viro:
- NFS mkdir/open_by_handle race fix
- analogous solution for FUSE, replacing the one currently in mainline
- new primitive to be used when discarding halfway set up inodes on
failed object creation; gives sane warranties re icache lookups not
returning such doomed by still not freed inodes. A bunch of
filesystems switched to that animal.
- Miklos' fix for last cycle regression in iget5_locked(); -stable will
need a slightly different variant, unfortunately.
- misc bits and pieces around things icache-related (in adfs and jfs).
* 'work.mkdir' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
jfs: don't bother with make_bad_inode() in ialloc()
adfs: don't put inodes into icache
new helper: inode_fake_hash()
vfs: don't evict uninitialized inode
jfs: switch to discard_new_inode()
ext2: make sure that partially set up inodes won't be returned by ext2_iget()
udf: switch to discard_new_inode()
ufs: switch to discard_new_inode()
btrfs: switch to discard_new_inode()
new primitive: discard_new_inode()
kill d_instantiate_no_diralias()
nfs_instantiate(): prevent multiple aliases for directory inode
-rw-r--r-- | fs/adfs/inode.c | 2 | ||||
-rw-r--r-- | fs/adfs/super.c | 1 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 106 | ||||
-rw-r--r-- | fs/dcache.c | 29 | ||||
-rw-r--r-- | fs/ext2/ialloc.c | 3 | ||||
-rw-r--r-- | fs/ext2/namei.c | 9 | ||||
-rw-r--r-- | fs/fuse/dir.c | 15 | ||||
-rw-r--r-- | fs/hfs/inode.c | 2 | ||||
-rw-r--r-- | fs/inode.c | 53 | ||||
-rw-r--r-- | fs/jfs/jfs_imap.c | 8 | ||||
-rw-r--r-- | fs/jfs/jfs_inode.c | 10 | ||||
-rw-r--r-- | fs/jfs/namei.c | 12 | ||||
-rw-r--r-- | fs/jfs/super.c | 2 | ||||
-rw-r--r-- | fs/nfs/dir.c | 9 | ||||
-rw-r--r-- | fs/udf/namei.c | 12 | ||||
-rw-r--r-- | fs/ufs/ialloc.c | 3 | ||||
-rw-r--r-- | fs/ufs/namei.c | 9 | ||||
-rw-r--r-- | fs/xfs/xfs_iops.c | 2 | ||||
-rw-r--r-- | include/linux/dcache.h | 1 | ||||
-rw-r--r-- | include/linux/fs.h | 17 |
20 files changed, 146 insertions, 159 deletions
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c index c836c425ca94..e91028d4340a 100644 --- a/fs/adfs/inode.c +++ b/fs/adfs/inode.c | |||
@@ -287,7 +287,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj) | |||
287 | ADFS_I(inode)->mmu_private = inode->i_size; | 287 | ADFS_I(inode)->mmu_private = inode->i_size; |
288 | } | 288 | } |
289 | 289 | ||
290 | insert_inode_hash(inode); | 290 | inode_fake_hash(inode); |
291 | 291 | ||
292 | out: | 292 | out: |
293 | return inode; | 293 | return inode; |
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index 71fa525d63a0..7e099a7a4eb1 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
@@ -291,6 +291,7 @@ static void destroy_inodecache(void) | |||
291 | static const struct super_operations adfs_sops = { | 291 | static const struct super_operations adfs_sops = { |
292 | .alloc_inode = adfs_alloc_inode, | 292 | .alloc_inode = adfs_alloc_inode, |
293 | .destroy_inode = adfs_destroy_inode, | 293 | .destroy_inode = adfs_destroy_inode, |
294 | .drop_inode = generic_delete_inode, | ||
294 | .write_inode = adfs_write_inode, | 295 | .write_inode = adfs_write_inode, |
295 | .put_super = adfs_put_super, | 296 | .put_super = adfs_put_super, |
296 | .statfs = adfs_statfs, | 297 | .statfs = adfs_statfs, |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index eba61bcb9bb3..def3ada0f0b8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6335,8 +6335,10 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
6335 | location->type = BTRFS_INODE_ITEM_KEY; | 6335 | location->type = BTRFS_INODE_ITEM_KEY; |
6336 | 6336 | ||
6337 | ret = btrfs_insert_inode_locked(inode); | 6337 | ret = btrfs_insert_inode_locked(inode); |
6338 | if (ret < 0) | 6338 | if (ret < 0) { |
6339 | iput(inode); | ||
6339 | goto fail; | 6340 | goto fail; |
6341 | } | ||
6340 | 6342 | ||
6341 | path->leave_spinning = 1; | 6343 | path->leave_spinning = 1; |
6342 | ret = btrfs_insert_empty_items(trans, root, path, key, sizes, nitems); | 6344 | ret = btrfs_insert_empty_items(trans, root, path, key, sizes, nitems); |
@@ -6395,12 +6397,11 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, | |||
6395 | return inode; | 6397 | return inode; |
6396 | 6398 | ||
6397 | fail_unlock: | 6399 | fail_unlock: |
6398 | unlock_new_inode(inode); | 6400 | discard_new_inode(inode); |
6399 | fail: | 6401 | fail: |
6400 | if (dir && name) | 6402 | if (dir && name) |
6401 | BTRFS_I(dir)->index_cnt--; | 6403 | BTRFS_I(dir)->index_cnt--; |
6402 | btrfs_free_path(path); | 6404 | btrfs_free_path(path); |
6403 | iput(inode); | ||
6404 | return ERR_PTR(ret); | 6405 | return ERR_PTR(ret); |
6405 | } | 6406 | } |
6406 | 6407 | ||
@@ -6505,7 +6506,6 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
6505 | struct btrfs_root *root = BTRFS_I(dir)->root; | 6506 | struct btrfs_root *root = BTRFS_I(dir)->root; |
6506 | struct inode *inode = NULL; | 6507 | struct inode *inode = NULL; |
6507 | int err; | 6508 | int err; |
6508 | int drop_inode = 0; | ||
6509 | u64 objectid; | 6509 | u64 objectid; |
6510 | u64 index = 0; | 6510 | u64 index = 0; |
6511 | 6511 | ||
@@ -6527,6 +6527,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
6527 | mode, &index); | 6527 | mode, &index); |
6528 | if (IS_ERR(inode)) { | 6528 | if (IS_ERR(inode)) { |
6529 | err = PTR_ERR(inode); | 6529 | err = PTR_ERR(inode); |
6530 | inode = NULL; | ||
6530 | goto out_unlock; | 6531 | goto out_unlock; |
6531 | } | 6532 | } |
6532 | 6533 | ||
@@ -6541,31 +6542,24 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
6541 | 6542 | ||
6542 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | 6543 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
6543 | if (err) | 6544 | if (err) |
6544 | goto out_unlock_inode; | 6545 | goto out_unlock; |
6545 | 6546 | ||
6546 | err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), | 6547 | err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), |
6547 | 0, index); | 6548 | 0, index); |
6548 | if (err) { | 6549 | if (err) |
6549 | goto out_unlock_inode; | 6550 | goto out_unlock; |
6550 | } else { | 6551 | |
6551 | btrfs_update_inode(trans, root, inode); | 6552 | btrfs_update_inode(trans, root, inode); |
6552 | d_instantiate_new(dentry, inode); | 6553 | d_instantiate_new(dentry, inode); |
6553 | } | ||
6554 | 6554 | ||
6555 | out_unlock: | 6555 | out_unlock: |
6556 | btrfs_end_transaction(trans); | 6556 | btrfs_end_transaction(trans); |
6557 | btrfs_btree_balance_dirty(fs_info); | 6557 | btrfs_btree_balance_dirty(fs_info); |
6558 | if (drop_inode) { | 6558 | if (err && inode) { |
6559 | inode_dec_link_count(inode); | 6559 | inode_dec_link_count(inode); |
6560 | iput(inode); | 6560 | discard_new_inode(inode); |
6561 | } | 6561 | } |
6562 | return err; | 6562 | return err; |
6563 | |||
6564 | out_unlock_inode: | ||
6565 | drop_inode = 1; | ||
6566 | unlock_new_inode(inode); | ||
6567 | goto out_unlock; | ||
6568 | |||
6569 | } | 6563 | } |
6570 | 6564 | ||
6571 | static int btrfs_create(struct inode *dir, struct dentry *dentry, | 6565 | static int btrfs_create(struct inode *dir, struct dentry *dentry, |
@@ -6575,7 +6569,6 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
6575 | struct btrfs_trans_handle *trans; | 6569 | struct btrfs_trans_handle *trans; |
6576 | struct btrfs_root *root = BTRFS_I(dir)->root; | 6570 | struct btrfs_root *root = BTRFS_I(dir)->root; |
6577 | struct inode *inode = NULL; | 6571 | struct inode *inode = NULL; |
6578 | int drop_inode_on_err = 0; | ||
6579 | int err; | 6572 | int err; |
6580 | u64 objectid; | 6573 | u64 objectid; |
6581 | u64 index = 0; | 6574 | u64 index = 0; |
@@ -6598,9 +6591,9 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
6598 | mode, &index); | 6591 | mode, &index); |
6599 | if (IS_ERR(inode)) { | 6592 | if (IS_ERR(inode)) { |
6600 | err = PTR_ERR(inode); | 6593 | err = PTR_ERR(inode); |
6594 | inode = NULL; | ||
6601 | goto out_unlock; | 6595 | goto out_unlock; |
6602 | } | 6596 | } |
6603 | drop_inode_on_err = 1; | ||
6604 | /* | 6597 | /* |
6605 | * If the active LSM wants to access the inode during | 6598 | * If the active LSM wants to access the inode during |
6606 | * d_instantiate it needs these. Smack checks to see | 6599 | * d_instantiate it needs these. Smack checks to see |
@@ -6613,33 +6606,28 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
6613 | 6606 | ||
6614 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | 6607 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
6615 | if (err) | 6608 | if (err) |
6616 | goto out_unlock_inode; | 6609 | goto out_unlock; |
6617 | 6610 | ||
6618 | err = btrfs_update_inode(trans, root, inode); | 6611 | err = btrfs_update_inode(trans, root, inode); |
6619 | if (err) | 6612 | if (err) |
6620 | goto out_unlock_inode; | 6613 | goto out_unlock; |
6621 | 6614 | ||
6622 | err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), | 6615 | err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), |
6623 | 0, index); | 6616 | 0, index); |
6624 | if (err) | 6617 | if (err) |
6625 | goto out_unlock_inode; | 6618 | goto out_unlock; |
6626 | 6619 | ||
6627 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; | 6620 | BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops; |
6628 | d_instantiate_new(dentry, inode); | 6621 | d_instantiate_new(dentry, inode); |
6629 | 6622 | ||
6630 | out_unlock: | 6623 | out_unlock: |
6631 | btrfs_end_transaction(trans); | 6624 | btrfs_end_transaction(trans); |
6632 | if (err && drop_inode_on_err) { | 6625 | if (err && inode) { |
6633 | inode_dec_link_count(inode); | 6626 | inode_dec_link_count(inode); |
6634 | iput(inode); | 6627 | discard_new_inode(inode); |
6635 | } | 6628 | } |
6636 | btrfs_btree_balance_dirty(fs_info); | 6629 | btrfs_btree_balance_dirty(fs_info); |
6637 | return err; | 6630 | return err; |
6638 | |||
6639 | out_unlock_inode: | ||
6640 | unlock_new_inode(inode); | ||
6641 | goto out_unlock; | ||
6642 | |||
6643 | } | 6631 | } |
6644 | 6632 | ||
6645 | static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | 6633 | static int btrfs_link(struct dentry *old_dentry, struct inode *dir, |
@@ -6748,6 +6736,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
6748 | S_IFDIR | mode, &index); | 6736 | S_IFDIR | mode, &index); |
6749 | if (IS_ERR(inode)) { | 6737 | if (IS_ERR(inode)) { |
6750 | err = PTR_ERR(inode); | 6738 | err = PTR_ERR(inode); |
6739 | inode = NULL; | ||
6751 | goto out_fail; | 6740 | goto out_fail; |
6752 | } | 6741 | } |
6753 | 6742 | ||
@@ -6758,34 +6747,30 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
6758 | 6747 | ||
6759 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | 6748 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
6760 | if (err) | 6749 | if (err) |
6761 | goto out_fail_inode; | 6750 | goto out_fail; |
6762 | 6751 | ||
6763 | btrfs_i_size_write(BTRFS_I(inode), 0); | 6752 | btrfs_i_size_write(BTRFS_I(inode), 0); |
6764 | err = btrfs_update_inode(trans, root, inode); | 6753 | err = btrfs_update_inode(trans, root, inode); |
6765 | if (err) | 6754 | if (err) |
6766 | goto out_fail_inode; | 6755 | goto out_fail; |
6767 | 6756 | ||
6768 | err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), | 6757 | err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), |
6769 | dentry->d_name.name, | 6758 | dentry->d_name.name, |
6770 | dentry->d_name.len, 0, index); | 6759 | dentry->d_name.len, 0, index); |
6771 | if (err) | 6760 | if (err) |
6772 | goto out_fail_inode; | 6761 | goto out_fail; |
6773 | 6762 | ||
6774 | d_instantiate_new(dentry, inode); | 6763 | d_instantiate_new(dentry, inode); |
6775 | drop_on_err = 0; | 6764 | drop_on_err = 0; |
6776 | 6765 | ||
6777 | out_fail: | 6766 | out_fail: |
6778 | btrfs_end_transaction(trans); | 6767 | btrfs_end_transaction(trans); |
6779 | if (drop_on_err) { | 6768 | if (err && inode) { |
6780 | inode_dec_link_count(inode); | 6769 | inode_dec_link_count(inode); |
6781 | iput(inode); | 6770 | discard_new_inode(inode); |
6782 | } | 6771 | } |
6783 | btrfs_btree_balance_dirty(fs_info); | 6772 | btrfs_btree_balance_dirty(fs_info); |
6784 | return err; | 6773 | return err; |
6785 | |||
6786 | out_fail_inode: | ||
6787 | unlock_new_inode(inode); | ||
6788 | goto out_fail; | ||
6789 | } | 6774 | } |
6790 | 6775 | ||
6791 | static noinline int uncompress_inline(struct btrfs_path *path, | 6776 | static noinline int uncompress_inline(struct btrfs_path *path, |
@@ -10115,7 +10100,6 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
10115 | struct btrfs_key key; | 10100 | struct btrfs_key key; |
10116 | struct inode *inode = NULL; | 10101 | struct inode *inode = NULL; |
10117 | int err; | 10102 | int err; |
10118 | int drop_inode = 0; | ||
10119 | u64 objectid; | 10103 | u64 objectid; |
10120 | u64 index = 0; | 10104 | u64 index = 0; |
10121 | int name_len; | 10105 | int name_len; |
@@ -10148,6 +10132,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
10148 | objectid, S_IFLNK|S_IRWXUGO, &index); | 10132 | objectid, S_IFLNK|S_IRWXUGO, &index); |
10149 | if (IS_ERR(inode)) { | 10133 | if (IS_ERR(inode)) { |
10150 | err = PTR_ERR(inode); | 10134 | err = PTR_ERR(inode); |
10135 | inode = NULL; | ||
10151 | goto out_unlock; | 10136 | goto out_unlock; |
10152 | } | 10137 | } |
10153 | 10138 | ||
@@ -10164,12 +10149,12 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
10164 | 10149 | ||
10165 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); | 10150 | err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name); |
10166 | if (err) | 10151 | if (err) |
10167 | goto out_unlock_inode; | 10152 | goto out_unlock; |
10168 | 10153 | ||
10169 | path = btrfs_alloc_path(); | 10154 | path = btrfs_alloc_path(); |
10170 | if (!path) { | 10155 | if (!path) { |
10171 | err = -ENOMEM; | 10156 | err = -ENOMEM; |
10172 | goto out_unlock_inode; | 10157 | goto out_unlock; |
10173 | } | 10158 | } |
10174 | key.objectid = btrfs_ino(BTRFS_I(inode)); | 10159 | key.objectid = btrfs_ino(BTRFS_I(inode)); |
10175 | key.offset = 0; | 10160 | key.offset = 0; |
@@ -10179,7 +10164,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
10179 | datasize); | 10164 | datasize); |
10180 | if (err) { | 10165 | if (err) { |
10181 | btrfs_free_path(path); | 10166 | btrfs_free_path(path); |
10182 | goto out_unlock_inode; | 10167 | goto out_unlock; |
10183 | } | 10168 | } |
10184 | leaf = path->nodes[0]; | 10169 | leaf = path->nodes[0]; |
10185 | ei = btrfs_item_ptr(leaf, path->slots[0], | 10170 | ei = btrfs_item_ptr(leaf, path->slots[0], |
@@ -10211,26 +10196,19 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
10211 | if (!err) | 10196 | if (!err) |
10212 | err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, | 10197 | err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, |
10213 | BTRFS_I(inode), 0, index); | 10198 | BTRFS_I(inode), 0, index); |
10214 | if (err) { | 10199 | if (err) |
10215 | drop_inode = 1; | 10200 | goto out_unlock; |
10216 | goto out_unlock_inode; | ||
10217 | } | ||
10218 | 10201 | ||
10219 | d_instantiate_new(dentry, inode); | 10202 | d_instantiate_new(dentry, inode); |
10220 | 10203 | ||
10221 | out_unlock: | 10204 | out_unlock: |
10222 | btrfs_end_transaction(trans); | 10205 | btrfs_end_transaction(trans); |
10223 | if (drop_inode) { | 10206 | if (err && inode) { |
10224 | inode_dec_link_count(inode); | 10207 | inode_dec_link_count(inode); |
10225 | iput(inode); | 10208 | discard_new_inode(inode); |
10226 | } | 10209 | } |
10227 | btrfs_btree_balance_dirty(fs_info); | 10210 | btrfs_btree_balance_dirty(fs_info); |
10228 | return err; | 10211 | return err; |
10229 | |||
10230 | out_unlock_inode: | ||
10231 | drop_inode = 1; | ||
10232 | unlock_new_inode(inode); | ||
10233 | goto out_unlock; | ||
10234 | } | 10212 | } |
10235 | 10213 | ||
10236 | static int __btrfs_prealloc_file_range(struct inode *inode, int mode, | 10214 | static int __btrfs_prealloc_file_range(struct inode *inode, int mode, |
@@ -10439,14 +10417,14 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
10439 | 10417 | ||
10440 | ret = btrfs_init_inode_security(trans, inode, dir, NULL); | 10418 | ret = btrfs_init_inode_security(trans, inode, dir, NULL); |
10441 | if (ret) | 10419 | if (ret) |
10442 | goto out_inode; | 10420 | goto out; |
10443 | 10421 | ||
10444 | ret = btrfs_update_inode(trans, root, inode); | 10422 | ret = btrfs_update_inode(trans, root, inode); |
10445 | if (ret) | 10423 | if (ret) |
10446 | goto out_inode; | 10424 | goto out; |
10447 | ret = btrfs_orphan_add(trans, BTRFS_I(inode)); | 10425 | ret = btrfs_orphan_add(trans, BTRFS_I(inode)); |
10448 | if (ret) | 10426 | if (ret) |
10449 | goto out_inode; | 10427 | goto out; |
10450 | 10428 | ||
10451 | /* | 10429 | /* |
10452 | * We set number of links to 0 in btrfs_new_inode(), and here we set | 10430 | * We set number of links to 0 in btrfs_new_inode(), and here we set |
@@ -10456,21 +10434,15 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
10456 | * d_tmpfile() -> inode_dec_link_count() -> drop_nlink() | 10434 | * d_tmpfile() -> inode_dec_link_count() -> drop_nlink() |
10457 | */ | 10435 | */ |
10458 | set_nlink(inode, 1); | 10436 | set_nlink(inode, 1); |
10459 | unlock_new_inode(inode); | ||
10460 | d_tmpfile(dentry, inode); | 10437 | d_tmpfile(dentry, inode); |
10438 | unlock_new_inode(inode); | ||
10461 | mark_inode_dirty(inode); | 10439 | mark_inode_dirty(inode); |
10462 | |||
10463 | out: | 10440 | out: |
10464 | btrfs_end_transaction(trans); | 10441 | btrfs_end_transaction(trans); |
10465 | if (ret) | 10442 | if (ret && inode) |
10466 | iput(inode); | 10443 | discard_new_inode(inode); |
10467 | btrfs_btree_balance_dirty(fs_info); | 10444 | btrfs_btree_balance_dirty(fs_info); |
10468 | return ret; | 10445 | return ret; |
10469 | |||
10470 | out_inode: | ||
10471 | unlock_new_inode(inode); | ||
10472 | goto out; | ||
10473 | |||
10474 | } | 10446 | } |
10475 | 10447 | ||
10476 | __attribute__((const)) | 10448 | __attribute__((const)) |
diff --git a/fs/dcache.c b/fs/dcache.c index ceb7b491d1b9..34226c20d196 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -1889,40 +1889,13 @@ void d_instantiate_new(struct dentry *entry, struct inode *inode) | |||
1889 | spin_lock(&inode->i_lock); | 1889 | spin_lock(&inode->i_lock); |
1890 | __d_instantiate(entry, inode); | 1890 | __d_instantiate(entry, inode); |
1891 | WARN_ON(!(inode->i_state & I_NEW)); | 1891 | WARN_ON(!(inode->i_state & I_NEW)); |
1892 | inode->i_state &= ~I_NEW; | 1892 | inode->i_state &= ~I_NEW & ~I_CREATING; |
1893 | smp_mb(); | 1893 | smp_mb(); |
1894 | wake_up_bit(&inode->i_state, __I_NEW); | 1894 | wake_up_bit(&inode->i_state, __I_NEW); |
1895 | spin_unlock(&inode->i_lock); | 1895 | spin_unlock(&inode->i_lock); |
1896 | } | 1896 | } |
1897 | EXPORT_SYMBOL(d_instantiate_new); | 1897 | EXPORT_SYMBOL(d_instantiate_new); |
1898 | 1898 | ||
1899 | /** | ||
1900 | * d_instantiate_no_diralias - instantiate a non-aliased dentry | ||
1901 | * @entry: dentry to complete | ||
1902 | * @inode: inode to attach to this dentry | ||
1903 | * | ||
1904 | * Fill in inode information in the entry. If a directory alias is found, then | ||
1905 | * return an error (and drop inode). Together with d_materialise_unique() this | ||
1906 | * guarantees that a directory inode may never have more than one alias. | ||
1907 | */ | ||
1908 | int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) | ||
1909 | { | ||
1910 | BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); | ||
1911 | |||
1912 | security_d_instantiate(entry, inode); | ||
1913 | spin_lock(&inode->i_lock); | ||
1914 | if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { | ||
1915 | spin_unlock(&inode->i_lock); | ||
1916 | iput(inode); | ||
1917 | return -EBUSY; | ||
1918 | } | ||
1919 | __d_instantiate(entry, inode); | ||
1920 | spin_unlock(&inode->i_lock); | ||
1921 | |||
1922 | return 0; | ||
1923 | } | ||
1924 | EXPORT_SYMBOL(d_instantiate_no_diralias); | ||
1925 | |||
1926 | struct dentry *d_make_root(struct inode *root_inode) | 1899 | struct dentry *d_make_root(struct inode *root_inode) |
1927 | { | 1900 | { |
1928 | struct dentry *res = NULL; | 1901 | struct dentry *res = NULL; |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 6484199b35d1..5c3d7b7e4975 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -611,8 +611,7 @@ fail_drop: | |||
611 | dquot_drop(inode); | 611 | dquot_drop(inode); |
612 | inode->i_flags |= S_NOQUOTA; | 612 | inode->i_flags |= S_NOQUOTA; |
613 | clear_nlink(inode); | 613 | clear_nlink(inode); |
614 | unlock_new_inode(inode); | 614 | discard_new_inode(inode); |
615 | iput(inode); | ||
616 | return ERR_PTR(err); | 615 | return ERR_PTR(err); |
617 | 616 | ||
618 | fail: | 617 | fail: |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 152453a91877..0c26dcc5d850 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -45,8 +45,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) | |||
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | inode_dec_link_count(inode); | 47 | inode_dec_link_count(inode); |
48 | unlock_new_inode(inode); | 48 | discard_new_inode(inode); |
49 | iput(inode); | ||
50 | return err; | 49 | return err; |
51 | } | 50 | } |
52 | 51 | ||
@@ -192,8 +191,7 @@ out: | |||
192 | 191 | ||
193 | out_fail: | 192 | out_fail: |
194 | inode_dec_link_count(inode); | 193 | inode_dec_link_count(inode); |
195 | unlock_new_inode(inode); | 194 | discard_new_inode(inode); |
196 | iput (inode); | ||
197 | goto out; | 195 | goto out; |
198 | } | 196 | } |
199 | 197 | ||
@@ -261,8 +259,7 @@ out: | |||
261 | out_fail: | 259 | out_fail: |
262 | inode_dec_link_count(inode); | 260 | inode_dec_link_count(inode); |
263 | inode_dec_link_count(inode); | 261 | inode_dec_link_count(inode); |
264 | unlock_new_inode(inode); | 262 | discard_new_inode(inode); |
265 | iput(inode); | ||
266 | out_dir: | 263 | out_dir: |
267 | inode_dec_link_count(dir); | 264 | inode_dec_link_count(dir); |
268 | goto out; | 265 | goto out; |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index c979329311c8..d80aab0d5982 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -539,6 +539,7 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_args *args, | |||
539 | { | 539 | { |
540 | struct fuse_entry_out outarg; | 540 | struct fuse_entry_out outarg; |
541 | struct inode *inode; | 541 | struct inode *inode; |
542 | struct dentry *d; | ||
542 | int err; | 543 | int err; |
543 | struct fuse_forget_link *forget; | 544 | struct fuse_forget_link *forget; |
544 | 545 | ||
@@ -570,11 +571,17 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_args *args, | |||
570 | } | 571 | } |
571 | kfree(forget); | 572 | kfree(forget); |
572 | 573 | ||
573 | err = d_instantiate_no_diralias(entry, inode); | 574 | d_drop(entry); |
574 | if (err) | 575 | d = d_splice_alias(inode, entry); |
575 | return err; | 576 | if (IS_ERR(d)) |
577 | return PTR_ERR(d); | ||
576 | 578 | ||
577 | fuse_change_entry_timeout(entry, &outarg); | 579 | if (d) { |
580 | fuse_change_entry_timeout(d, &outarg); | ||
581 | dput(d); | ||
582 | } else { | ||
583 | fuse_change_entry_timeout(entry, &outarg); | ||
584 | } | ||
578 | fuse_invalidate_attr(dir); | 585 | fuse_invalidate_attr(dir); |
579 | return 0; | 586 | return 0; |
580 | 587 | ||
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 2a16111d312f..a2dfa1b2a89c 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -541,7 +541,7 @@ static struct dentry *hfs_file_lookup(struct inode *dir, struct dentry *dentry, | |||
541 | HFS_I(inode)->rsrc_inode = dir; | 541 | HFS_I(inode)->rsrc_inode = dir; |
542 | HFS_I(dir)->rsrc_inode = inode; | 542 | HFS_I(dir)->rsrc_inode = inode; |
543 | igrab(dir); | 543 | igrab(dir); |
544 | hlist_add_fake(&inode->i_hash); | 544 | inode_fake_hash(inode); |
545 | mark_inode_dirty(inode); | 545 | mark_inode_dirty(inode); |
546 | dont_mount(dentry); | 546 | dont_mount(dentry); |
547 | out: | 547 | out: |
diff --git a/fs/inode.c b/fs/inode.c index 8c86c809ca17..a06de4454232 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -804,6 +804,10 @@ repeat: | |||
804 | __wait_on_freeing_inode(inode); | 804 | __wait_on_freeing_inode(inode); |
805 | goto repeat; | 805 | goto repeat; |
806 | } | 806 | } |
807 | if (unlikely(inode->i_state & I_CREATING)) { | ||
808 | spin_unlock(&inode->i_lock); | ||
809 | return ERR_PTR(-ESTALE); | ||
810 | } | ||
807 | __iget(inode); | 811 | __iget(inode); |
808 | spin_unlock(&inode->i_lock); | 812 | spin_unlock(&inode->i_lock); |
809 | return inode; | 813 | return inode; |
@@ -831,6 +835,10 @@ repeat: | |||
831 | __wait_on_freeing_inode(inode); | 835 | __wait_on_freeing_inode(inode); |
832 | goto repeat; | 836 | goto repeat; |
833 | } | 837 | } |
838 | if (unlikely(inode->i_state & I_CREATING)) { | ||
839 | spin_unlock(&inode->i_lock); | ||
840 | return ERR_PTR(-ESTALE); | ||
841 | } | ||
834 | __iget(inode); | 842 | __iget(inode); |
835 | spin_unlock(&inode->i_lock); | 843 | spin_unlock(&inode->i_lock); |
836 | return inode; | 844 | return inode; |
@@ -961,13 +969,26 @@ void unlock_new_inode(struct inode *inode) | |||
961 | lockdep_annotate_inode_mutex_key(inode); | 969 | lockdep_annotate_inode_mutex_key(inode); |
962 | spin_lock(&inode->i_lock); | 970 | spin_lock(&inode->i_lock); |
963 | WARN_ON(!(inode->i_state & I_NEW)); | 971 | WARN_ON(!(inode->i_state & I_NEW)); |
964 | inode->i_state &= ~I_NEW; | 972 | inode->i_state &= ~I_NEW & ~I_CREATING; |
965 | smp_mb(); | 973 | smp_mb(); |
966 | wake_up_bit(&inode->i_state, __I_NEW); | 974 | wake_up_bit(&inode->i_state, __I_NEW); |
967 | spin_unlock(&inode->i_lock); | 975 | spin_unlock(&inode->i_lock); |
968 | } | 976 | } |
969 | EXPORT_SYMBOL(unlock_new_inode); | 977 | EXPORT_SYMBOL(unlock_new_inode); |
970 | 978 | ||
979 | void discard_new_inode(struct inode *inode) | ||
980 | { | ||
981 | lockdep_annotate_inode_mutex_key(inode); | ||
982 | spin_lock(&inode->i_lock); | ||
983 | WARN_ON(!(inode->i_state & I_NEW)); | ||
984 | inode->i_state &= ~I_NEW; | ||
985 | smp_mb(); | ||
986 | wake_up_bit(&inode->i_state, __I_NEW); | ||
987 | spin_unlock(&inode->i_lock); | ||
988 | iput(inode); | ||
989 | } | ||
990 | EXPORT_SYMBOL(discard_new_inode); | ||
991 | |||
971 | /** | 992 | /** |
972 | * lock_two_nondirectories - take two i_mutexes on non-directory objects | 993 | * lock_two_nondirectories - take two i_mutexes on non-directory objects |
973 | * | 994 | * |
@@ -1029,6 +1050,7 @@ struct inode *inode_insert5(struct inode *inode, unsigned long hashval, | |||
1029 | { | 1050 | { |
1030 | struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); | 1051 | struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); |
1031 | struct inode *old; | 1052 | struct inode *old; |
1053 | bool creating = inode->i_state & I_CREATING; | ||
1032 | 1054 | ||
1033 | again: | 1055 | again: |
1034 | spin_lock(&inode_hash_lock); | 1056 | spin_lock(&inode_hash_lock); |
@@ -1039,6 +1061,8 @@ again: | |||
1039 | * Use the old inode instead of the preallocated one. | 1061 | * Use the old inode instead of the preallocated one. |
1040 | */ | 1062 | */ |
1041 | spin_unlock(&inode_hash_lock); | 1063 | spin_unlock(&inode_hash_lock); |
1064 | if (IS_ERR(old)) | ||
1065 | return NULL; | ||
1042 | wait_on_inode(old); | 1066 | wait_on_inode(old); |
1043 | if (unlikely(inode_unhashed(old))) { | 1067 | if (unlikely(inode_unhashed(old))) { |
1044 | iput(old); | 1068 | iput(old); |
@@ -1060,6 +1084,8 @@ again: | |||
1060 | inode->i_state |= I_NEW; | 1084 | inode->i_state |= I_NEW; |
1061 | hlist_add_head(&inode->i_hash, head); | 1085 | hlist_add_head(&inode->i_hash, head); |
1062 | spin_unlock(&inode->i_lock); | 1086 | spin_unlock(&inode->i_lock); |
1087 | if (!creating) | ||
1088 | inode_sb_list_add(inode); | ||
1063 | unlock: | 1089 | unlock: |
1064 | spin_unlock(&inode_hash_lock); | 1090 | spin_unlock(&inode_hash_lock); |
1065 | 1091 | ||
@@ -1094,12 +1120,13 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, | |||
1094 | struct inode *inode = ilookup5(sb, hashval, test, data); | 1120 | struct inode *inode = ilookup5(sb, hashval, test, data); |
1095 | 1121 | ||
1096 | if (!inode) { | 1122 | if (!inode) { |
1097 | struct inode *new = new_inode(sb); | 1123 | struct inode *new = alloc_inode(sb); |
1098 | 1124 | ||
1099 | if (new) { | 1125 | if (new) { |
1126 | new->i_state = 0; | ||
1100 | inode = inode_insert5(new, hashval, test, set, data); | 1127 | inode = inode_insert5(new, hashval, test, set, data); |
1101 | if (unlikely(inode != new)) | 1128 | if (unlikely(inode != new)) |
1102 | iput(new); | 1129 | destroy_inode(new); |
1103 | } | 1130 | } |
1104 | } | 1131 | } |
1105 | return inode; | 1132 | return inode; |
@@ -1128,6 +1155,8 @@ again: | |||
1128 | inode = find_inode_fast(sb, head, ino); | 1155 | inode = find_inode_fast(sb, head, ino); |
1129 | spin_unlock(&inode_hash_lock); | 1156 | spin_unlock(&inode_hash_lock); |
1130 | if (inode) { | 1157 | if (inode) { |
1158 | if (IS_ERR(inode)) | ||
1159 | return NULL; | ||
1131 | wait_on_inode(inode); | 1160 | wait_on_inode(inode); |
1132 | if (unlikely(inode_unhashed(inode))) { | 1161 | if (unlikely(inode_unhashed(inode))) { |
1133 | iput(inode); | 1162 | iput(inode); |
@@ -1165,6 +1194,8 @@ again: | |||
1165 | */ | 1194 | */ |
1166 | spin_unlock(&inode_hash_lock); | 1195 | spin_unlock(&inode_hash_lock); |
1167 | destroy_inode(inode); | 1196 | destroy_inode(inode); |
1197 | if (IS_ERR(old)) | ||
1198 | return NULL; | ||
1168 | inode = old; | 1199 | inode = old; |
1169 | wait_on_inode(inode); | 1200 | wait_on_inode(inode); |
1170 | if (unlikely(inode_unhashed(inode))) { | 1201 | if (unlikely(inode_unhashed(inode))) { |
@@ -1282,7 +1313,7 @@ struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, | |||
1282 | inode = find_inode(sb, head, test, data); | 1313 | inode = find_inode(sb, head, test, data); |
1283 | spin_unlock(&inode_hash_lock); | 1314 | spin_unlock(&inode_hash_lock); |
1284 | 1315 | ||
1285 | return inode; | 1316 | return IS_ERR(inode) ? NULL : inode; |
1286 | } | 1317 | } |
1287 | EXPORT_SYMBOL(ilookup5_nowait); | 1318 | EXPORT_SYMBOL(ilookup5_nowait); |
1288 | 1319 | ||
@@ -1338,6 +1369,8 @@ again: | |||
1338 | spin_unlock(&inode_hash_lock); | 1369 | spin_unlock(&inode_hash_lock); |
1339 | 1370 | ||
1340 | if (inode) { | 1371 | if (inode) { |
1372 | if (IS_ERR(inode)) | ||
1373 | return NULL; | ||
1341 | wait_on_inode(inode); | 1374 | wait_on_inode(inode); |
1342 | if (unlikely(inode_unhashed(inode))) { | 1375 | if (unlikely(inode_unhashed(inode))) { |
1343 | iput(inode); | 1376 | iput(inode); |
@@ -1421,12 +1454,17 @@ int insert_inode_locked(struct inode *inode) | |||
1421 | } | 1454 | } |
1422 | if (likely(!old)) { | 1455 | if (likely(!old)) { |
1423 | spin_lock(&inode->i_lock); | 1456 | spin_lock(&inode->i_lock); |
1424 | inode->i_state |= I_NEW; | 1457 | inode->i_state |= I_NEW | I_CREATING; |
1425 | hlist_add_head(&inode->i_hash, head); | 1458 | hlist_add_head(&inode->i_hash, head); |
1426 | spin_unlock(&inode->i_lock); | 1459 | spin_unlock(&inode->i_lock); |
1427 | spin_unlock(&inode_hash_lock); | 1460 | spin_unlock(&inode_hash_lock); |
1428 | return 0; | 1461 | return 0; |
1429 | } | 1462 | } |
1463 | if (unlikely(old->i_state & I_CREATING)) { | ||
1464 | spin_unlock(&old->i_lock); | ||
1465 | spin_unlock(&inode_hash_lock); | ||
1466 | return -EBUSY; | ||
1467 | } | ||
1430 | __iget(old); | 1468 | __iget(old); |
1431 | spin_unlock(&old->i_lock); | 1469 | spin_unlock(&old->i_lock); |
1432 | spin_unlock(&inode_hash_lock); | 1470 | spin_unlock(&inode_hash_lock); |
@@ -1443,7 +1481,10 @@ EXPORT_SYMBOL(insert_inode_locked); | |||
1443 | int insert_inode_locked4(struct inode *inode, unsigned long hashval, | 1481 | int insert_inode_locked4(struct inode *inode, unsigned long hashval, |
1444 | int (*test)(struct inode *, void *), void *data) | 1482 | int (*test)(struct inode *, void *), void *data) |
1445 | { | 1483 | { |
1446 | struct inode *old = inode_insert5(inode, hashval, test, NULL, data); | 1484 | struct inode *old; |
1485 | |||
1486 | inode->i_state |= I_CREATING; | ||
1487 | old = inode_insert5(inode, hashval, test, NULL, data); | ||
1447 | 1488 | ||
1448 | if (old != inode) { | 1489 | if (old != inode) { |
1449 | iput(old); | 1490 | iput(old); |
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index f36ef68905a7..93e8c590ff5c 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c | |||
@@ -491,13 +491,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary) | |||
491 | /* release the page */ | 491 | /* release the page */ |
492 | release_metapage(mp); | 492 | release_metapage(mp); |
493 | 493 | ||
494 | /* | 494 | inode_fake_hash(ip); |
495 | * __mark_inode_dirty expects inodes to be hashed. Since we don't | ||
496 | * want special inodes in the fileset inode space, we make them | ||
497 | * appear hashed, but do not put on any lists. hlist_del() | ||
498 | * will work fine and require no locking. | ||
499 | */ | ||
500 | hlist_add_fake(&ip->i_hash); | ||
501 | 495 | ||
502 | return (ip); | 496 | return (ip); |
503 | } | 497 | } |
diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c index 5e9b7bb3aabf..4572b7cf183d 100644 --- a/fs/jfs/jfs_inode.c +++ b/fs/jfs/jfs_inode.c | |||
@@ -61,8 +61,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode) | |||
61 | inode = new_inode(sb); | 61 | inode = new_inode(sb); |
62 | if (!inode) { | 62 | if (!inode) { |
63 | jfs_warn("ialloc: new_inode returned NULL!"); | 63 | jfs_warn("ialloc: new_inode returned NULL!"); |
64 | rc = -ENOMEM; | 64 | return ERR_PTR(-ENOMEM); |
65 | goto fail; | ||
66 | } | 65 | } |
67 | 66 | ||
68 | jfs_inode = JFS_IP(inode); | 67 | jfs_inode = JFS_IP(inode); |
@@ -70,8 +69,6 @@ struct inode *ialloc(struct inode *parent, umode_t mode) | |||
70 | rc = diAlloc(parent, S_ISDIR(mode), inode); | 69 | rc = diAlloc(parent, S_ISDIR(mode), inode); |
71 | if (rc) { | 70 | if (rc) { |
72 | jfs_warn("ialloc: diAlloc returned %d!", rc); | 71 | jfs_warn("ialloc: diAlloc returned %d!", rc); |
73 | if (rc == -EIO) | ||
74 | make_bad_inode(inode); | ||
75 | goto fail_put; | 72 | goto fail_put; |
76 | } | 73 | } |
77 | 74 | ||
@@ -141,9 +138,10 @@ fail_drop: | |||
141 | dquot_drop(inode); | 138 | dquot_drop(inode); |
142 | inode->i_flags |= S_NOQUOTA; | 139 | inode->i_flags |= S_NOQUOTA; |
143 | clear_nlink(inode); | 140 | clear_nlink(inode); |
144 | unlock_new_inode(inode); | 141 | discard_new_inode(inode); |
142 | return ERR_PTR(rc); | ||
143 | |||
145 | fail_put: | 144 | fail_put: |
146 | iput(inode); | 145 | iput(inode); |
147 | fail: | ||
148 | return ERR_PTR(rc); | 146 | return ERR_PTR(rc); |
149 | } | 147 | } |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 56c3fcbfe80e..14528c0ffe63 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -175,8 +175,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode, | |||
175 | if (rc) { | 175 | if (rc) { |
176 | free_ea_wmap(ip); | 176 | free_ea_wmap(ip); |
177 | clear_nlink(ip); | 177 | clear_nlink(ip); |
178 | unlock_new_inode(ip); | 178 | discard_new_inode(ip); |
179 | iput(ip); | ||
180 | } else { | 179 | } else { |
181 | d_instantiate_new(dentry, ip); | 180 | d_instantiate_new(dentry, ip); |
182 | } | 181 | } |
@@ -309,8 +308,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode) | |||
309 | if (rc) { | 308 | if (rc) { |
310 | free_ea_wmap(ip); | 309 | free_ea_wmap(ip); |
311 | clear_nlink(ip); | 310 | clear_nlink(ip); |
312 | unlock_new_inode(ip); | 311 | discard_new_inode(ip); |
313 | iput(ip); | ||
314 | } else { | 312 | } else { |
315 | d_instantiate_new(dentry, ip); | 313 | d_instantiate_new(dentry, ip); |
316 | } | 314 | } |
@@ -1054,8 +1052,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, | |||
1054 | if (rc) { | 1052 | if (rc) { |
1055 | free_ea_wmap(ip); | 1053 | free_ea_wmap(ip); |
1056 | clear_nlink(ip); | 1054 | clear_nlink(ip); |
1057 | unlock_new_inode(ip); | 1055 | discard_new_inode(ip); |
1058 | iput(ip); | ||
1059 | } else { | 1056 | } else { |
1060 | d_instantiate_new(dentry, ip); | 1057 | d_instantiate_new(dentry, ip); |
1061 | } | 1058 | } |
@@ -1441,8 +1438,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, | |||
1441 | if (rc) { | 1438 | if (rc) { |
1442 | free_ea_wmap(ip); | 1439 | free_ea_wmap(ip); |
1443 | clear_nlink(ip); | 1440 | clear_nlink(ip); |
1444 | unlock_new_inode(ip); | 1441 | discard_new_inode(ip); |
1445 | iput(ip); | ||
1446 | } else { | 1442 | } else { |
1447 | d_instantiate_new(dentry, ip); | 1443 | d_instantiate_new(dentry, ip); |
1448 | } | 1444 | } |
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index f08571433aba..09da5cf14e27 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
@@ -581,7 +581,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) | |||
581 | inode->i_ino = 0; | 581 | inode->i_ino = 0; |
582 | inode->i_size = i_size_read(sb->s_bdev->bd_inode); | 582 | inode->i_size = i_size_read(sb->s_bdev->bd_inode); |
583 | inode->i_mapping->a_ops = &jfs_metapage_aops; | 583 | inode->i_mapping->a_ops = &jfs_metapage_aops; |
584 | hlist_add_fake(&inode->i_hash); | 584 | inode_fake_hash(inode); |
585 | mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); | 585 | mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); |
586 | 586 | ||
587 | sbi->direct_inode = inode; | 587 | sbi->direct_inode = inode; |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index f447b1a24350..d7f158c3efc8 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1643,6 +1643,7 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, | |||
1643 | struct dentry *parent = dget_parent(dentry); | 1643 | struct dentry *parent = dget_parent(dentry); |
1644 | struct inode *dir = d_inode(parent); | 1644 | struct inode *dir = d_inode(parent); |
1645 | struct inode *inode; | 1645 | struct inode *inode; |
1646 | struct dentry *d; | ||
1646 | int error = -EACCES; | 1647 | int error = -EACCES; |
1647 | 1648 | ||
1648 | d_drop(dentry); | 1649 | d_drop(dentry); |
@@ -1664,10 +1665,12 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, | |||
1664 | goto out_error; | 1665 | goto out_error; |
1665 | } | 1666 | } |
1666 | inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label); | 1667 | inode = nfs_fhget(dentry->d_sb, fhandle, fattr, label); |
1667 | error = PTR_ERR(inode); | 1668 | d = d_splice_alias(inode, dentry); |
1668 | if (IS_ERR(inode)) | 1669 | if (IS_ERR(d)) { |
1670 | error = PTR_ERR(d); | ||
1669 | goto out_error; | 1671 | goto out_error; |
1670 | d_add(dentry, inode); | 1672 | } |
1673 | dput(d); | ||
1671 | out: | 1674 | out: |
1672 | dput(parent); | 1675 | dput(parent); |
1673 | return 0; | 1676 | return 0; |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 06f37ddd2997..58cc2414992b 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -602,8 +602,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode) | |||
602 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); | 602 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
603 | if (unlikely(!fi)) { | 603 | if (unlikely(!fi)) { |
604 | inode_dec_link_count(inode); | 604 | inode_dec_link_count(inode); |
605 | unlock_new_inode(inode); | 605 | discard_new_inode(inode); |
606 | iput(inode); | ||
607 | return err; | 606 | return err; |
608 | } | 607 | } |
609 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 608 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
@@ -694,8 +693,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
694 | fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); | 693 | fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); |
695 | if (!fi) { | 694 | if (!fi) { |
696 | inode_dec_link_count(inode); | 695 | inode_dec_link_count(inode); |
697 | unlock_new_inode(inode); | 696 | discard_new_inode(inode); |
698 | iput(inode); | ||
699 | goto out; | 697 | goto out; |
700 | } | 698 | } |
701 | set_nlink(inode, 2); | 699 | set_nlink(inode, 2); |
@@ -713,8 +711,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
713 | if (!fi) { | 711 | if (!fi) { |
714 | clear_nlink(inode); | 712 | clear_nlink(inode); |
715 | mark_inode_dirty(inode); | 713 | mark_inode_dirty(inode); |
716 | unlock_new_inode(inode); | 714 | discard_new_inode(inode); |
717 | iput(inode); | ||
718 | goto out; | 715 | goto out; |
719 | } | 716 | } |
720 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 717 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
@@ -1041,8 +1038,7 @@ out: | |||
1041 | out_no_entry: | 1038 | out_no_entry: |
1042 | up_write(&iinfo->i_data_sem); | 1039 | up_write(&iinfo->i_data_sem); |
1043 | inode_dec_link_count(inode); | 1040 | inode_dec_link_count(inode); |
1044 | unlock_new_inode(inode); | 1041 | discard_new_inode(inode); |
1045 | iput(inode); | ||
1046 | goto out; | 1042 | goto out; |
1047 | } | 1043 | } |
1048 | 1044 | ||
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index e1ef0f0a1353..02c0a4be4212 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c | |||
@@ -343,8 +343,7 @@ cg_found: | |||
343 | fail_remove_inode: | 343 | fail_remove_inode: |
344 | mutex_unlock(&sbi->s_lock); | 344 | mutex_unlock(&sbi->s_lock); |
345 | clear_nlink(inode); | 345 | clear_nlink(inode); |
346 | unlock_new_inode(inode); | 346 | discard_new_inode(inode); |
347 | iput(inode); | ||
348 | UFSD("EXIT (FAILED): err %d\n", err); | 347 | UFSD("EXIT (FAILED): err %d\n", err); |
349 | return ERR_PTR(err); | 348 | return ERR_PTR(err); |
350 | failed: | 349 | failed: |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index d5f43ba76c59..9ef40f100415 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
@@ -43,8 +43,7 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode) | |||
43 | return 0; | 43 | return 0; |
44 | } | 44 | } |
45 | inode_dec_link_count(inode); | 45 | inode_dec_link_count(inode); |
46 | unlock_new_inode(inode); | 46 | discard_new_inode(inode); |
47 | iput(inode); | ||
48 | return err; | 47 | return err; |
49 | } | 48 | } |
50 | 49 | ||
@@ -142,8 +141,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, | |||
142 | 141 | ||
143 | out_fail: | 142 | out_fail: |
144 | inode_dec_link_count(inode); | 143 | inode_dec_link_count(inode); |
145 | unlock_new_inode(inode); | 144 | discard_new_inode(inode); |
146 | iput(inode); | ||
147 | return err; | 145 | return err; |
148 | } | 146 | } |
149 | 147 | ||
@@ -198,8 +196,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) | |||
198 | out_fail: | 196 | out_fail: |
199 | inode_dec_link_count(inode); | 197 | inode_dec_link_count(inode); |
200 | inode_dec_link_count(inode); | 198 | inode_dec_link_count(inode); |
201 | unlock_new_inode(inode); | 199 | discard_new_inode(inode); |
202 | iput (inode); | ||
203 | out_dir: | 200 | out_dir: |
204 | inode_dec_link_count(dir); | 201 | inode_dec_link_count(dir); |
205 | return err; | 202 | return err; |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 0fa29f39d658..3a75de777843 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -1253,7 +1253,7 @@ xfs_setup_inode( | |||
1253 | 1253 | ||
1254 | inode_sb_list_add(inode); | 1254 | inode_sb_list_add(inode); |
1255 | /* make the inode look hashed for the writeback code */ | 1255 | /* make the inode look hashed for the writeback code */ |
1256 | hlist_add_fake(&inode->i_hash); | 1256 | inode_fake_hash(inode); |
1257 | 1257 | ||
1258 | inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid); | 1258 | inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid); |
1259 | inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid); | 1259 | inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid); |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 66c6e17e61e5..0b83629a3d8f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -227,7 +227,6 @@ extern void d_instantiate(struct dentry *, struct inode *); | |||
227 | extern void d_instantiate_new(struct dentry *, struct inode *); | 227 | extern void d_instantiate_new(struct dentry *, struct inode *); |
228 | extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *); | 228 | extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *); |
229 | extern struct dentry * d_instantiate_anon(struct dentry *, struct inode *); | 229 | extern struct dentry * d_instantiate_anon(struct dentry *, struct inode *); |
230 | extern int d_instantiate_no_diralias(struct dentry *, struct inode *); | ||
231 | extern void __d_drop(struct dentry *dentry); | 230 | extern void __d_drop(struct dentry *dentry); |
232 | extern void d_drop(struct dentry *dentry); | 231 | extern void d_drop(struct dentry *dentry); |
233 | extern void d_delete(struct dentry *); | 232 | extern void d_delete(struct dentry *); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 7899737a9a3e..180334710596 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -688,6 +688,17 @@ static inline int inode_unhashed(struct inode *inode) | |||
688 | } | 688 | } |
689 | 689 | ||
690 | /* | 690 | /* |
691 | * __mark_inode_dirty expects inodes to be hashed. Since we don't | ||
692 | * want special inodes in the fileset inode space, we make them | ||
693 | * appear hashed, but do not put on any lists. hlist_del() | ||
694 | * will work fine and require no locking. | ||
695 | */ | ||
696 | static inline void inode_fake_hash(struct inode *inode) | ||
697 | { | ||
698 | hlist_add_fake(&inode->i_hash); | ||
699 | } | ||
700 | |||
701 | /* | ||
691 | * inode->i_mutex nesting subclasses for the lock validator: | 702 | * inode->i_mutex nesting subclasses for the lock validator: |
692 | * | 703 | * |
693 | * 0: the object of the current VFS operation | 704 | * 0: the object of the current VFS operation |
@@ -2017,6 +2028,8 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) | |||
2017 | * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper | 2028 | * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper |
2018 | * and work dirs among overlayfs mounts. | 2029 | * and work dirs among overlayfs mounts. |
2019 | * | 2030 | * |
2031 | * I_CREATING New object's inode in the middle of setting up. | ||
2032 | * | ||
2020 | * Q: What is the difference between I_WILL_FREE and I_FREEING? | 2033 | * Q: What is the difference between I_WILL_FREE and I_FREEING? |
2021 | */ | 2034 | */ |
2022 | #define I_DIRTY_SYNC (1 << 0) | 2035 | #define I_DIRTY_SYNC (1 << 0) |
@@ -2037,7 +2050,8 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) | |||
2037 | #define __I_DIRTY_TIME_EXPIRED 12 | 2050 | #define __I_DIRTY_TIME_EXPIRED 12 |
2038 | #define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) | 2051 | #define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) |
2039 | #define I_WB_SWITCH (1 << 13) | 2052 | #define I_WB_SWITCH (1 << 13) |
2040 | #define I_OVL_INUSE (1 << 14) | 2053 | #define I_OVL_INUSE (1 << 14) |
2054 | #define I_CREATING (1 << 15) | ||
2041 | 2055 | ||
2042 | #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) | 2056 | #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) |
2043 | #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) | 2057 | #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) |
@@ -2919,6 +2933,7 @@ extern void lockdep_annotate_inode_mutex_key(struct inode *inode); | |||
2919 | static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { }; | 2933 | static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { }; |
2920 | #endif | 2934 | #endif |
2921 | extern void unlock_new_inode(struct inode *); | 2935 | extern void unlock_new_inode(struct inode *); |
2936 | extern void discard_new_inode(struct inode *); | ||
2922 | extern unsigned int get_next_ino(void); | 2937 | extern unsigned int get_next_ino(void); |
2923 | extern void evict_inodes(struct super_block *sb); | 2938 | extern void evict_inodes(struct super_block *sb); |
2924 | 2939 | ||