diff options
author | Nick Piggin <npiggin@kernel.dk> | 2011-01-07 01:49:38 -0500 |
---|---|---|
committer | Nick Piggin <npiggin@kernel.dk> | 2011-01-07 01:50:23 -0500 |
commit | b5c84bf6f6fa3a7dfdcb556023a62953574b60ee (patch) | |
tree | 7a2c299a180713e21d5cb653cb933121adf53c31 /fs/dcache.c | |
parent | 949854d02455080d20cd3e1db28a3a18daf7599d (diff) |
fs: dcache remove dcache_lock
dcache_lock no longer protects anything. remove it.
Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r-- | fs/dcache.c | 160 |
1 files changed, 20 insertions, 140 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index a9bc4ecc21e1..0dbae053b664 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -54,11 +54,10 @@ | |||
54 | * - d_alias, d_inode | 54 | * - d_alias, d_inode |
55 | * | 55 | * |
56 | * Ordering: | 56 | * Ordering: |
57 | * dcache_lock | 57 | * dcache_inode_lock |
58 | * dcache_inode_lock | 58 | * dentry->d_lock |
59 | * dentry->d_lock | 59 | * dcache_lru_lock |
60 | * dcache_lru_lock | 60 | * dcache_hash_lock |
61 | * dcache_hash_lock | ||
62 | * | 61 | * |
63 | * If there is an ancestor relationship: | 62 | * If there is an ancestor relationship: |
64 | * dentry->d_parent->...->d_parent->d_lock | 63 | * dentry->d_parent->...->d_parent->d_lock |
@@ -77,12 +76,10 @@ EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure); | |||
77 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_inode_lock); | 76 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_inode_lock); |
78 | static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_hash_lock); | 77 | static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_hash_lock); |
79 | static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lru_lock); | 78 | static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lru_lock); |
80 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(dcache_lock); | ||
81 | __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock); | 79 | __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock); |
82 | 80 | ||
83 | EXPORT_SYMBOL(rename_lock); | 81 | EXPORT_SYMBOL(rename_lock); |
84 | EXPORT_SYMBOL(dcache_inode_lock); | 82 | EXPORT_SYMBOL(dcache_inode_lock); |
85 | EXPORT_SYMBOL(dcache_lock); | ||
86 | 83 | ||
87 | static struct kmem_cache *dentry_cache __read_mostly; | 84 | static struct kmem_cache *dentry_cache __read_mostly; |
88 | 85 | ||
@@ -139,7 +136,7 @@ static void __d_free(struct rcu_head *head) | |||
139 | } | 136 | } |
140 | 137 | ||
141 | /* | 138 | /* |
142 | * no dcache_lock, please. | 139 | * no locks, please. |
143 | */ | 140 | */ |
144 | static void d_free(struct dentry *dentry) | 141 | static void d_free(struct dentry *dentry) |
145 | { | 142 | { |
@@ -162,7 +159,6 @@ static void d_free(struct dentry *dentry) | |||
162 | static void dentry_iput(struct dentry * dentry) | 159 | static void dentry_iput(struct dentry * dentry) |
163 | __releases(dentry->d_lock) | 160 | __releases(dentry->d_lock) |
164 | __releases(dcache_inode_lock) | 161 | __releases(dcache_inode_lock) |
165 | __releases(dcache_lock) | ||
166 | { | 162 | { |
167 | struct inode *inode = dentry->d_inode; | 163 | struct inode *inode = dentry->d_inode; |
168 | if (inode) { | 164 | if (inode) { |
@@ -170,7 +166,6 @@ static void dentry_iput(struct dentry * dentry) | |||
170 | list_del_init(&dentry->d_alias); | 166 | list_del_init(&dentry->d_alias); |
171 | spin_unlock(&dentry->d_lock); | 167 | spin_unlock(&dentry->d_lock); |
172 | spin_unlock(&dcache_inode_lock); | 168 | spin_unlock(&dcache_inode_lock); |
173 | spin_unlock(&dcache_lock); | ||
174 | if (!inode->i_nlink) | 169 | if (!inode->i_nlink) |
175 | fsnotify_inoderemove(inode); | 170 | fsnotify_inoderemove(inode); |
176 | if (dentry->d_op && dentry->d_op->d_iput) | 171 | if (dentry->d_op && dentry->d_op->d_iput) |
@@ -180,7 +175,6 @@ static void dentry_iput(struct dentry * dentry) | |||
180 | } else { | 175 | } else { |
181 | spin_unlock(&dentry->d_lock); | 176 | spin_unlock(&dentry->d_lock); |
182 | spin_unlock(&dcache_inode_lock); | 177 | spin_unlock(&dcache_inode_lock); |
183 | spin_unlock(&dcache_lock); | ||
184 | } | 178 | } |
185 | } | 179 | } |
186 | 180 | ||
@@ -235,14 +229,13 @@ static void dentry_lru_move_tail(struct dentry *dentry) | |||
235 | * | 229 | * |
236 | * If this is the root of the dentry tree, return NULL. | 230 | * If this is the root of the dentry tree, return NULL. |
237 | * | 231 | * |
238 | * dcache_lock and d_lock and d_parent->d_lock must be held by caller, and | 232 | * dentry->d_lock and parent->d_lock must be held by caller, and are dropped by |
239 | * are dropped by d_kill. | 233 | * d_kill. |
240 | */ | 234 | */ |
241 | static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) | 235 | static struct dentry *d_kill(struct dentry *dentry, struct dentry *parent) |
242 | __releases(dentry->d_lock) | 236 | __releases(dentry->d_lock) |
243 | __releases(parent->d_lock) | 237 | __releases(parent->d_lock) |
244 | __releases(dcache_inode_lock) | 238 | __releases(dcache_inode_lock) |
245 | __releases(dcache_lock) | ||
246 | { | 239 | { |
247 | dentry->d_parent = NULL; | 240 | dentry->d_parent = NULL; |
248 | list_del(&dentry->d_u.d_child); | 241 | list_del(&dentry->d_u.d_child); |
@@ -285,11 +278,9 @@ EXPORT_SYMBOL(__d_drop); | |||
285 | 278 | ||
286 | void d_drop(struct dentry *dentry) | 279 | void d_drop(struct dentry *dentry) |
287 | { | 280 | { |
288 | spin_lock(&dcache_lock); | ||
289 | spin_lock(&dentry->d_lock); | 281 | spin_lock(&dentry->d_lock); |
290 | __d_drop(dentry); | 282 | __d_drop(dentry); |
291 | spin_unlock(&dentry->d_lock); | 283 | spin_unlock(&dentry->d_lock); |
292 | spin_unlock(&dcache_lock); | ||
293 | } | 284 | } |
294 | EXPORT_SYMBOL(d_drop); | 285 | EXPORT_SYMBOL(d_drop); |
295 | 286 | ||
@@ -337,21 +328,10 @@ repeat: | |||
337 | else | 328 | else |
338 | parent = dentry->d_parent; | 329 | parent = dentry->d_parent; |
339 | if (dentry->d_count == 1) { | 330 | if (dentry->d_count == 1) { |
340 | if (!spin_trylock(&dcache_lock)) { | ||
341 | /* | ||
342 | * Something of a livelock possibility we could avoid | ||
343 | * by taking dcache_lock and trying again, but we | ||
344 | * want to reduce dcache_lock anyway so this will | ||
345 | * get improved. | ||
346 | */ | ||
347 | drop1: | ||
348 | spin_unlock(&dentry->d_lock); | ||
349 | goto repeat; | ||
350 | } | ||
351 | if (!spin_trylock(&dcache_inode_lock)) { | 331 | if (!spin_trylock(&dcache_inode_lock)) { |
352 | drop2: | 332 | drop2: |
353 | spin_unlock(&dcache_lock); | 333 | spin_unlock(&dentry->d_lock); |
354 | goto drop1; | 334 | goto repeat; |
355 | } | 335 | } |
356 | if (parent && !spin_trylock(&parent->d_lock)) { | 336 | if (parent && !spin_trylock(&parent->d_lock)) { |
357 | spin_unlock(&dcache_inode_lock); | 337 | spin_unlock(&dcache_inode_lock); |
@@ -363,7 +343,6 @@ drop2: | |||
363 | spin_unlock(&dentry->d_lock); | 343 | spin_unlock(&dentry->d_lock); |
364 | if (parent) | 344 | if (parent) |
365 | spin_unlock(&parent->d_lock); | 345 | spin_unlock(&parent->d_lock); |
366 | spin_unlock(&dcache_lock); | ||
367 | return; | 346 | return; |
368 | } | 347 | } |
369 | 348 | ||
@@ -387,7 +366,6 @@ drop2: | |||
387 | if (parent) | 366 | if (parent) |
388 | spin_unlock(&parent->d_lock); | 367 | spin_unlock(&parent->d_lock); |
389 | spin_unlock(&dcache_inode_lock); | 368 | spin_unlock(&dcache_inode_lock); |
390 | spin_unlock(&dcache_lock); | ||
391 | return; | 369 | return; |
392 | 370 | ||
393 | unhash_it: | 371 | unhash_it: |
@@ -418,11 +396,9 @@ int d_invalidate(struct dentry * dentry) | |||
418 | /* | 396 | /* |
419 | * If it's already been dropped, return OK. | 397 | * If it's already been dropped, return OK. |
420 | */ | 398 | */ |
421 | spin_lock(&dcache_lock); | ||
422 | spin_lock(&dentry->d_lock); | 399 | spin_lock(&dentry->d_lock); |
423 | if (d_unhashed(dentry)) { | 400 | if (d_unhashed(dentry)) { |
424 | spin_unlock(&dentry->d_lock); | 401 | spin_unlock(&dentry->d_lock); |
425 | spin_unlock(&dcache_lock); | ||
426 | return 0; | 402 | return 0; |
427 | } | 403 | } |
428 | /* | 404 | /* |
@@ -431,9 +407,7 @@ int d_invalidate(struct dentry * dentry) | |||
431 | */ | 407 | */ |
432 | if (!list_empty(&dentry->d_subdirs)) { | 408 | if (!list_empty(&dentry->d_subdirs)) { |
433 | spin_unlock(&dentry->d_lock); | 409 | spin_unlock(&dentry->d_lock); |
434 | spin_unlock(&dcache_lock); | ||
435 | shrink_dcache_parent(dentry); | 410 | shrink_dcache_parent(dentry); |
436 | spin_lock(&dcache_lock); | ||
437 | spin_lock(&dentry->d_lock); | 411 | spin_lock(&dentry->d_lock); |
438 | } | 412 | } |
439 | 413 | ||
@@ -450,19 +424,17 @@ int d_invalidate(struct dentry * dentry) | |||
450 | if (dentry->d_count > 1) { | 424 | if (dentry->d_count > 1) { |
451 | if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode)) { | 425 | if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode)) { |
452 | spin_unlock(&dentry->d_lock); | 426 | spin_unlock(&dentry->d_lock); |
453 | spin_unlock(&dcache_lock); | ||
454 | return -EBUSY; | 427 | return -EBUSY; |
455 | } | 428 | } |
456 | } | 429 | } |
457 | 430 | ||
458 | __d_drop(dentry); | 431 | __d_drop(dentry); |
459 | spin_unlock(&dentry->d_lock); | 432 | spin_unlock(&dentry->d_lock); |
460 | spin_unlock(&dcache_lock); | ||
461 | return 0; | 433 | return 0; |
462 | } | 434 | } |
463 | EXPORT_SYMBOL(d_invalidate); | 435 | EXPORT_SYMBOL(d_invalidate); |
464 | 436 | ||
465 | /* This must be called with dcache_lock and d_lock held */ | 437 | /* This must be called with d_lock held */ |
466 | static inline struct dentry * __dget_locked_dlock(struct dentry *dentry) | 438 | static inline struct dentry * __dget_locked_dlock(struct dentry *dentry) |
467 | { | 439 | { |
468 | dentry->d_count++; | 440 | dentry->d_count++; |
@@ -470,7 +442,7 @@ static inline struct dentry * __dget_locked_dlock(struct dentry *dentry) | |||
470 | return dentry; | 442 | return dentry; |
471 | } | 443 | } |
472 | 444 | ||
473 | /* This should be called _only_ with dcache_lock held */ | 445 | /* This must be called with d_lock held */ |
474 | static inline struct dentry * __dget_locked(struct dentry *dentry) | 446 | static inline struct dentry * __dget_locked(struct dentry *dentry) |
475 | { | 447 | { |
476 | spin_lock(&dentry->d_lock); | 448 | spin_lock(&dentry->d_lock); |
@@ -575,11 +547,9 @@ struct dentry *d_find_alias(struct inode *inode) | |||
575 | struct dentry *de = NULL; | 547 | struct dentry *de = NULL; |
576 | 548 | ||
577 | if (!list_empty(&inode->i_dentry)) { | 549 | if (!list_empty(&inode->i_dentry)) { |
578 | spin_lock(&dcache_lock); | ||
579 | spin_lock(&dcache_inode_lock); | 550 | spin_lock(&dcache_inode_lock); |
580 | de = __d_find_alias(inode, 0); | 551 | de = __d_find_alias(inode, 0); |
581 | spin_unlock(&dcache_inode_lock); | 552 | spin_unlock(&dcache_inode_lock); |
582 | spin_unlock(&dcache_lock); | ||
583 | } | 553 | } |
584 | return de; | 554 | return de; |
585 | } | 555 | } |
@@ -593,7 +563,6 @@ void d_prune_aliases(struct inode *inode) | |||
593 | { | 563 | { |
594 | struct dentry *dentry; | 564 | struct dentry *dentry; |
595 | restart: | 565 | restart: |
596 | spin_lock(&dcache_lock); | ||
597 | spin_lock(&dcache_inode_lock); | 566 | spin_lock(&dcache_inode_lock); |
598 | list_for_each_entry(dentry, &inode->i_dentry, d_alias) { | 567 | list_for_each_entry(dentry, &inode->i_dentry, d_alias) { |
599 | spin_lock(&dentry->d_lock); | 568 | spin_lock(&dentry->d_lock); |
@@ -602,14 +571,12 @@ restart: | |||
602 | __d_drop(dentry); | 571 | __d_drop(dentry); |
603 | spin_unlock(&dentry->d_lock); | 572 | spin_unlock(&dentry->d_lock); |
604 | spin_unlock(&dcache_inode_lock); | 573 | spin_unlock(&dcache_inode_lock); |
605 | spin_unlock(&dcache_lock); | ||
606 | dput(dentry); | 574 | dput(dentry); |
607 | goto restart; | 575 | goto restart; |
608 | } | 576 | } |
609 | spin_unlock(&dentry->d_lock); | 577 | spin_unlock(&dentry->d_lock); |
610 | } | 578 | } |
611 | spin_unlock(&dcache_inode_lock); | 579 | spin_unlock(&dcache_inode_lock); |
612 | spin_unlock(&dcache_lock); | ||
613 | } | 580 | } |
614 | EXPORT_SYMBOL(d_prune_aliases); | 581 | EXPORT_SYMBOL(d_prune_aliases); |
615 | 582 | ||
@@ -625,17 +592,14 @@ static void prune_one_dentry(struct dentry *dentry, struct dentry *parent) | |||
625 | __releases(dentry->d_lock) | 592 | __releases(dentry->d_lock) |
626 | __releases(parent->d_lock) | 593 | __releases(parent->d_lock) |
627 | __releases(dcache_inode_lock) | 594 | __releases(dcache_inode_lock) |
628 | __releases(dcache_lock) | ||
629 | { | 595 | { |
630 | __d_drop(dentry); | 596 | __d_drop(dentry); |
631 | dentry = d_kill(dentry, parent); | 597 | dentry = d_kill(dentry, parent); |
632 | 598 | ||
633 | /* | 599 | /* |
634 | * Prune ancestors. Locking is simpler than in dput(), | 600 | * Prune ancestors. |
635 | * because dcache_lock needs to be taken anyway. | ||
636 | */ | 601 | */ |
637 | while (dentry) { | 602 | while (dentry) { |
638 | spin_lock(&dcache_lock); | ||
639 | spin_lock(&dcache_inode_lock); | 603 | spin_lock(&dcache_inode_lock); |
640 | again: | 604 | again: |
641 | spin_lock(&dentry->d_lock); | 605 | spin_lock(&dentry->d_lock); |
@@ -653,7 +617,6 @@ again: | |||
653 | spin_unlock(&parent->d_lock); | 617 | spin_unlock(&parent->d_lock); |
654 | spin_unlock(&dentry->d_lock); | 618 | spin_unlock(&dentry->d_lock); |
655 | spin_unlock(&dcache_inode_lock); | 619 | spin_unlock(&dcache_inode_lock); |
656 | spin_unlock(&dcache_lock); | ||
657 | return; | 620 | return; |
658 | } | 621 | } |
659 | 622 | ||
@@ -702,8 +665,7 @@ relock: | |||
702 | spin_unlock(&dcache_lru_lock); | 665 | spin_unlock(&dcache_lru_lock); |
703 | 666 | ||
704 | prune_one_dentry(dentry, parent); | 667 | prune_one_dentry(dentry, parent); |
705 | /* dcache_lock, dcache_inode_lock and dentry->d_lock dropped */ | 668 | /* dcache_inode_lock and dentry->d_lock dropped */ |
706 | spin_lock(&dcache_lock); | ||
707 | spin_lock(&dcache_inode_lock); | 669 | spin_lock(&dcache_inode_lock); |
708 | spin_lock(&dcache_lru_lock); | 670 | spin_lock(&dcache_lru_lock); |
709 | } | 671 | } |
@@ -725,7 +687,6 @@ static void __shrink_dcache_sb(struct super_block *sb, int *count, int flags) | |||
725 | LIST_HEAD(tmp); | 687 | LIST_HEAD(tmp); |
726 | int cnt = *count; | 688 | int cnt = *count; |
727 | 689 | ||
728 | spin_lock(&dcache_lock); | ||
729 | spin_lock(&dcache_inode_lock); | 690 | spin_lock(&dcache_inode_lock); |
730 | relock: | 691 | relock: |
731 | spin_lock(&dcache_lru_lock); | 692 | spin_lock(&dcache_lru_lock); |
@@ -766,7 +727,6 @@ relock: | |||
766 | list_splice(&referenced, &sb->s_dentry_lru); | 727 | list_splice(&referenced, &sb->s_dentry_lru); |
767 | spin_unlock(&dcache_lru_lock); | 728 | spin_unlock(&dcache_lru_lock); |
768 | spin_unlock(&dcache_inode_lock); | 729 | spin_unlock(&dcache_inode_lock); |
769 | spin_unlock(&dcache_lock); | ||
770 | } | 730 | } |
771 | 731 | ||
772 | /** | 732 | /** |
@@ -788,7 +748,6 @@ static void prune_dcache(int count) | |||
788 | 748 | ||
789 | if (unused == 0 || count == 0) | 749 | if (unused == 0 || count == 0) |
790 | return; | 750 | return; |
791 | spin_lock(&dcache_lock); | ||
792 | if (count >= unused) | 751 | if (count >= unused) |
793 | prune_ratio = 1; | 752 | prune_ratio = 1; |
794 | else | 753 | else |
@@ -825,11 +784,9 @@ static void prune_dcache(int count) | |||
825 | if (down_read_trylock(&sb->s_umount)) { | 784 | if (down_read_trylock(&sb->s_umount)) { |
826 | if ((sb->s_root != NULL) && | 785 | if ((sb->s_root != NULL) && |
827 | (!list_empty(&sb->s_dentry_lru))) { | 786 | (!list_empty(&sb->s_dentry_lru))) { |
828 | spin_unlock(&dcache_lock); | ||
829 | __shrink_dcache_sb(sb, &w_count, | 787 | __shrink_dcache_sb(sb, &w_count, |
830 | DCACHE_REFERENCED); | 788 | DCACHE_REFERENCED); |
831 | pruned -= w_count; | 789 | pruned -= w_count; |
832 | spin_lock(&dcache_lock); | ||
833 | } | 790 | } |
834 | up_read(&sb->s_umount); | 791 | up_read(&sb->s_umount); |
835 | } | 792 | } |
@@ -845,7 +802,6 @@ static void prune_dcache(int count) | |||
845 | if (p) | 802 | if (p) |
846 | __put_super(p); | 803 | __put_super(p); |
847 | spin_unlock(&sb_lock); | 804 | spin_unlock(&sb_lock); |
848 | spin_unlock(&dcache_lock); | ||
849 | } | 805 | } |
850 | 806 | ||
851 | /** | 807 | /** |
@@ -859,7 +815,6 @@ void shrink_dcache_sb(struct super_block *sb) | |||
859 | { | 815 | { |
860 | LIST_HEAD(tmp); | 816 | LIST_HEAD(tmp); |
861 | 817 | ||
862 | spin_lock(&dcache_lock); | ||
863 | spin_lock(&dcache_inode_lock); | 818 | spin_lock(&dcache_inode_lock); |
864 | spin_lock(&dcache_lru_lock); | 819 | spin_lock(&dcache_lru_lock); |
865 | while (!list_empty(&sb->s_dentry_lru)) { | 820 | while (!list_empty(&sb->s_dentry_lru)) { |
@@ -868,7 +823,6 @@ void shrink_dcache_sb(struct super_block *sb) | |||
868 | } | 823 | } |
869 | spin_unlock(&dcache_lru_lock); | 824 | spin_unlock(&dcache_lru_lock); |
870 | spin_unlock(&dcache_inode_lock); | 825 | spin_unlock(&dcache_inode_lock); |
871 | spin_unlock(&dcache_lock); | ||
872 | } | 826 | } |
873 | EXPORT_SYMBOL(shrink_dcache_sb); | 827 | EXPORT_SYMBOL(shrink_dcache_sb); |
874 | 828 | ||
@@ -885,12 +839,10 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) | |||
885 | BUG_ON(!IS_ROOT(dentry)); | 839 | BUG_ON(!IS_ROOT(dentry)); |
886 | 840 | ||
887 | /* detach this root from the system */ | 841 | /* detach this root from the system */ |
888 | spin_lock(&dcache_lock); | ||
889 | spin_lock(&dentry->d_lock); | 842 | spin_lock(&dentry->d_lock); |
890 | dentry_lru_del(dentry); | 843 | dentry_lru_del(dentry); |
891 | __d_drop(dentry); | 844 | __d_drop(dentry); |
892 | spin_unlock(&dentry->d_lock); | 845 | spin_unlock(&dentry->d_lock); |
893 | spin_unlock(&dcache_lock); | ||
894 | 846 | ||
895 | for (;;) { | 847 | for (;;) { |
896 | /* descend to the first leaf in the current subtree */ | 848 | /* descend to the first leaf in the current subtree */ |
@@ -899,7 +851,6 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) | |||
899 | 851 | ||
900 | /* this is a branch with children - detach all of them | 852 | /* this is a branch with children - detach all of them |
901 | * from the system in one go */ | 853 | * from the system in one go */ |
902 | spin_lock(&dcache_lock); | ||
903 | spin_lock(&dentry->d_lock); | 854 | spin_lock(&dentry->d_lock); |
904 | list_for_each_entry(loop, &dentry->d_subdirs, | 855 | list_for_each_entry(loop, &dentry->d_subdirs, |
905 | d_u.d_child) { | 856 | d_u.d_child) { |
@@ -910,7 +861,6 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) | |||
910 | spin_unlock(&loop->d_lock); | 861 | spin_unlock(&loop->d_lock); |
911 | } | 862 | } |
912 | spin_unlock(&dentry->d_lock); | 863 | spin_unlock(&dentry->d_lock); |
913 | spin_unlock(&dcache_lock); | ||
914 | 864 | ||
915 | /* move to the first child */ | 865 | /* move to the first child */ |
916 | dentry = list_entry(dentry->d_subdirs.next, | 866 | dentry = list_entry(dentry->d_subdirs.next, |
@@ -977,8 +927,7 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry) | |||
977 | 927 | ||
978 | /* | 928 | /* |
979 | * destroy the dentries attached to a superblock on unmounting | 929 | * destroy the dentries attached to a superblock on unmounting |
980 | * - we don't need to use dentry->d_lock, and only need dcache_lock when | 930 | * - we don't need to use dentry->d_lock because: |
981 | * removing the dentry from the system lists and hashes because: | ||
982 | * - the superblock is detached from all mountings and open files, so the | 931 | * - the superblock is detached from all mountings and open files, so the |
983 | * dentry trees will not be rearranged by the VFS | 932 | * dentry trees will not be rearranged by the VFS |
984 | * - s_umount is write-locked, so the memory pressure shrinker will ignore | 933 | * - s_umount is write-locked, so the memory pressure shrinker will ignore |
@@ -1029,7 +978,6 @@ rename_retry: | |||
1029 | this_parent = parent; | 978 | this_parent = parent; |
1030 | seq = read_seqbegin(&rename_lock); | 979 | seq = read_seqbegin(&rename_lock); |
1031 | 980 | ||
1032 | spin_lock(&dcache_lock); | ||
1033 | if (d_mountpoint(parent)) | 981 | if (d_mountpoint(parent)) |
1034 | goto positive; | 982 | goto positive; |
1035 | spin_lock(&this_parent->d_lock); | 983 | spin_lock(&this_parent->d_lock); |
@@ -1075,7 +1023,6 @@ resume: | |||
1075 | if (this_parent != child->d_parent || | 1023 | if (this_parent != child->d_parent || |
1076 | read_seqretry(&rename_lock, seq)) { | 1024 | read_seqretry(&rename_lock, seq)) { |
1077 | spin_unlock(&this_parent->d_lock); | 1025 | spin_unlock(&this_parent->d_lock); |
1078 | spin_unlock(&dcache_lock); | ||
1079 | rcu_read_unlock(); | 1026 | rcu_read_unlock(); |
1080 | goto rename_retry; | 1027 | goto rename_retry; |
1081 | } | 1028 | } |
@@ -1084,12 +1031,10 @@ resume: | |||
1084 | goto resume; | 1031 | goto resume; |
1085 | } | 1032 | } |
1086 | spin_unlock(&this_parent->d_lock); | 1033 | spin_unlock(&this_parent->d_lock); |
1087 | spin_unlock(&dcache_lock); | ||
1088 | if (read_seqretry(&rename_lock, seq)) | 1034 | if (read_seqretry(&rename_lock, seq)) |
1089 | goto rename_retry; | 1035 | goto rename_retry; |
1090 | return 0; /* No mount points found in tree */ | 1036 | return 0; /* No mount points found in tree */ |
1091 | positive: | 1037 | positive: |
1092 | spin_unlock(&dcache_lock); | ||
1093 | if (read_seqretry(&rename_lock, seq)) | 1038 | if (read_seqretry(&rename_lock, seq)) |
1094 | goto rename_retry; | 1039 | goto rename_retry; |
1095 | return 1; | 1040 | return 1; |
@@ -1121,7 +1066,6 @@ rename_retry: | |||
1121 | this_parent = parent; | 1066 | this_parent = parent; |
1122 | seq = read_seqbegin(&rename_lock); | 1067 | seq = read_seqbegin(&rename_lock); |
1123 | 1068 | ||
1124 | spin_lock(&dcache_lock); | ||
1125 | spin_lock(&this_parent->d_lock); | 1069 | spin_lock(&this_parent->d_lock); |
1126 | repeat: | 1070 | repeat: |
1127 | next = this_parent->d_subdirs.next; | 1071 | next = this_parent->d_subdirs.next; |
@@ -1185,7 +1129,6 @@ resume: | |||
1185 | if (this_parent != child->d_parent || | 1129 | if (this_parent != child->d_parent || |
1186 | read_seqretry(&rename_lock, seq)) { | 1130 | read_seqretry(&rename_lock, seq)) { |
1187 | spin_unlock(&this_parent->d_lock); | 1131 | spin_unlock(&this_parent->d_lock); |
1188 | spin_unlock(&dcache_lock); | ||
1189 | rcu_read_unlock(); | 1132 | rcu_read_unlock(); |
1190 | goto rename_retry; | 1133 | goto rename_retry; |
1191 | } | 1134 | } |
@@ -1195,7 +1138,6 @@ resume: | |||
1195 | } | 1138 | } |
1196 | out: | 1139 | out: |
1197 | spin_unlock(&this_parent->d_lock); | 1140 | spin_unlock(&this_parent->d_lock); |
1198 | spin_unlock(&dcache_lock); | ||
1199 | if (read_seqretry(&rename_lock, seq)) | 1141 | if (read_seqretry(&rename_lock, seq)) |
1200 | goto rename_retry; | 1142 | goto rename_retry; |
1201 | return found; | 1143 | return found; |
@@ -1297,7 +1239,6 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) | |||
1297 | INIT_LIST_HEAD(&dentry->d_u.d_child); | 1239 | INIT_LIST_HEAD(&dentry->d_u.d_child); |
1298 | 1240 | ||
1299 | if (parent) { | 1241 | if (parent) { |
1300 | spin_lock(&dcache_lock); | ||
1301 | spin_lock(&parent->d_lock); | 1242 | spin_lock(&parent->d_lock); |
1302 | spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); | 1243 | spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); |
1303 | dentry->d_parent = dget_dlock(parent); | 1244 | dentry->d_parent = dget_dlock(parent); |
@@ -1305,7 +1246,6 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) | |||
1305 | list_add(&dentry->d_u.d_child, &parent->d_subdirs); | 1246 | list_add(&dentry->d_u.d_child, &parent->d_subdirs); |
1306 | spin_unlock(&dentry->d_lock); | 1247 | spin_unlock(&dentry->d_lock); |
1307 | spin_unlock(&parent->d_lock); | 1248 | spin_unlock(&parent->d_lock); |
1308 | spin_unlock(&dcache_lock); | ||
1309 | } | 1249 | } |
1310 | 1250 | ||
1311 | this_cpu_inc(nr_dentry); | 1251 | this_cpu_inc(nr_dentry); |
@@ -1325,7 +1265,6 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name) | |||
1325 | } | 1265 | } |
1326 | EXPORT_SYMBOL(d_alloc_name); | 1266 | EXPORT_SYMBOL(d_alloc_name); |
1327 | 1267 | ||
1328 | /* the caller must hold dcache_lock */ | ||
1329 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) | 1268 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) |
1330 | { | 1269 | { |
1331 | spin_lock(&dentry->d_lock); | 1270 | spin_lock(&dentry->d_lock); |
@@ -1354,11 +1293,9 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode) | |||
1354 | void d_instantiate(struct dentry *entry, struct inode * inode) | 1293 | void d_instantiate(struct dentry *entry, struct inode * inode) |
1355 | { | 1294 | { |
1356 | BUG_ON(!list_empty(&entry->d_alias)); | 1295 | BUG_ON(!list_empty(&entry->d_alias)); |
1357 | spin_lock(&dcache_lock); | ||
1358 | spin_lock(&dcache_inode_lock); | 1296 | spin_lock(&dcache_inode_lock); |
1359 | __d_instantiate(entry, inode); | 1297 | __d_instantiate(entry, inode); |
1360 | spin_unlock(&dcache_inode_lock); | 1298 | spin_unlock(&dcache_inode_lock); |
1361 | spin_unlock(&dcache_lock); | ||
1362 | security_d_instantiate(entry, inode); | 1299 | security_d_instantiate(entry, inode); |
1363 | } | 1300 | } |
1364 | EXPORT_SYMBOL(d_instantiate); | 1301 | EXPORT_SYMBOL(d_instantiate); |
@@ -1422,11 +1359,9 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) | |||
1422 | 1359 | ||
1423 | BUG_ON(!list_empty(&entry->d_alias)); | 1360 | BUG_ON(!list_empty(&entry->d_alias)); |
1424 | 1361 | ||
1425 | spin_lock(&dcache_lock); | ||
1426 | spin_lock(&dcache_inode_lock); | 1362 | spin_lock(&dcache_inode_lock); |
1427 | result = __d_instantiate_unique(entry, inode); | 1363 | result = __d_instantiate_unique(entry, inode); |
1428 | spin_unlock(&dcache_inode_lock); | 1364 | spin_unlock(&dcache_inode_lock); |
1429 | spin_unlock(&dcache_lock); | ||
1430 | 1365 | ||
1431 | if (!result) { | 1366 | if (!result) { |
1432 | security_d_instantiate(entry, inode); | 1367 | security_d_instantiate(entry, inode); |
@@ -1515,12 +1450,11 @@ struct dentry *d_obtain_alias(struct inode *inode) | |||
1515 | } | 1450 | } |
1516 | tmp->d_parent = tmp; /* make sure dput doesn't croak */ | 1451 | tmp->d_parent = tmp; /* make sure dput doesn't croak */ |
1517 | 1452 | ||
1518 | spin_lock(&dcache_lock); | 1453 | |
1519 | spin_lock(&dcache_inode_lock); | 1454 | spin_lock(&dcache_inode_lock); |
1520 | res = __d_find_alias(inode, 0); | 1455 | res = __d_find_alias(inode, 0); |
1521 | if (res) { | 1456 | if (res) { |
1522 | spin_unlock(&dcache_inode_lock); | 1457 | spin_unlock(&dcache_inode_lock); |
1523 | spin_unlock(&dcache_lock); | ||
1524 | dput(tmp); | 1458 | dput(tmp); |
1525 | goto out_iput; | 1459 | goto out_iput; |
1526 | } | 1460 | } |
@@ -1538,7 +1472,6 @@ struct dentry *d_obtain_alias(struct inode *inode) | |||
1538 | spin_unlock(&tmp->d_lock); | 1472 | spin_unlock(&tmp->d_lock); |
1539 | spin_unlock(&dcache_inode_lock); | 1473 | spin_unlock(&dcache_inode_lock); |
1540 | 1474 | ||
1541 | spin_unlock(&dcache_lock); | ||
1542 | return tmp; | 1475 | return tmp; |
1543 | 1476 | ||
1544 | out_iput: | 1477 | out_iput: |
@@ -1568,21 +1501,18 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) | |||
1568 | struct dentry *new = NULL; | 1501 | struct dentry *new = NULL; |
1569 | 1502 | ||
1570 | if (inode && S_ISDIR(inode->i_mode)) { | 1503 | if (inode && S_ISDIR(inode->i_mode)) { |
1571 | spin_lock(&dcache_lock); | ||
1572 | spin_lock(&dcache_inode_lock); | 1504 | spin_lock(&dcache_inode_lock); |
1573 | new = __d_find_alias(inode, 1); | 1505 | new = __d_find_alias(inode, 1); |
1574 | if (new) { | 1506 | if (new) { |
1575 | BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); | 1507 | BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); |
1576 | spin_unlock(&dcache_inode_lock); | 1508 | spin_unlock(&dcache_inode_lock); |
1577 | spin_unlock(&dcache_lock); | ||
1578 | security_d_instantiate(new, inode); | 1509 | security_d_instantiate(new, inode); |
1579 | d_move(new, dentry); | 1510 | d_move(new, dentry); |
1580 | iput(inode); | 1511 | iput(inode); |
1581 | } else { | 1512 | } else { |
1582 | /* already taking dcache_lock, so d_add() by hand */ | 1513 | /* already taking dcache_inode_lock, so d_add() by hand */ |
1583 | __d_instantiate(dentry, inode); | 1514 | __d_instantiate(dentry, inode); |
1584 | spin_unlock(&dcache_inode_lock); | 1515 | spin_unlock(&dcache_inode_lock); |
1585 | spin_unlock(&dcache_lock); | ||
1586 | security_d_instantiate(dentry, inode); | 1516 | security_d_instantiate(dentry, inode); |
1587 | d_rehash(dentry); | 1517 | d_rehash(dentry); |
1588 | } | 1518 | } |
@@ -1655,12 +1585,10 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | |||
1655 | * Negative dentry: instantiate it unless the inode is a directory and | 1585 | * Negative dentry: instantiate it unless the inode is a directory and |
1656 | * already has a dentry. | 1586 | * already has a dentry. |
1657 | */ | 1587 | */ |
1658 | spin_lock(&dcache_lock); | ||
1659 | spin_lock(&dcache_inode_lock); | 1588 | spin_lock(&dcache_inode_lock); |
1660 | if (!S_ISDIR(inode->i_mode) || list_empty(&inode->i_dentry)) { | 1589 | if (!S_ISDIR(inode->i_mode) || list_empty(&inode->i_dentry)) { |
1661 | __d_instantiate(found, inode); | 1590 | __d_instantiate(found, inode); |
1662 | spin_unlock(&dcache_inode_lock); | 1591 | spin_unlock(&dcache_inode_lock); |
1663 | spin_unlock(&dcache_lock); | ||
1664 | security_d_instantiate(found, inode); | 1592 | security_d_instantiate(found, inode); |
1665 | return found; | 1593 | return found; |
1666 | } | 1594 | } |
@@ -1672,7 +1600,6 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, | |||
1672 | new = list_entry(inode->i_dentry.next, struct dentry, d_alias); | 1600 | new = list_entry(inode->i_dentry.next, struct dentry, d_alias); |
1673 | dget_locked(new); | 1601 | dget_locked(new); |
1674 | spin_unlock(&dcache_inode_lock); | 1602 | spin_unlock(&dcache_inode_lock); |
1675 | spin_unlock(&dcache_lock); | ||
1676 | security_d_instantiate(found, inode); | 1603 | security_d_instantiate(found, inode); |
1677 | d_move(new, found); | 1604 | d_move(new, found); |
1678 | iput(inode); | 1605 | iput(inode); |
@@ -1843,7 +1770,6 @@ int d_validate(struct dentry *dentry, struct dentry *dparent) | |||
1843 | { | 1770 | { |
1844 | struct dentry *child; | 1771 | struct dentry *child; |
1845 | 1772 | ||
1846 | spin_lock(&dcache_lock); | ||
1847 | spin_lock(&dparent->d_lock); | 1773 | spin_lock(&dparent->d_lock); |
1848 | list_for_each_entry(child, &dparent->d_subdirs, d_u.d_child) { | 1774 | list_for_each_entry(child, &dparent->d_subdirs, d_u.d_child) { |
1849 | if (dentry == child) { | 1775 | if (dentry == child) { |
@@ -1851,12 +1777,10 @@ int d_validate(struct dentry *dentry, struct dentry *dparent) | |||
1851 | __dget_locked_dlock(dentry); | 1777 | __dget_locked_dlock(dentry); |
1852 | spin_unlock(&dentry->d_lock); | 1778 | spin_unlock(&dentry->d_lock); |
1853 | spin_unlock(&dparent->d_lock); | 1779 | spin_unlock(&dparent->d_lock); |
1854 | spin_unlock(&dcache_lock); | ||
1855 | return 1; | 1780 | return 1; |
1856 | } | 1781 | } |
1857 | } | 1782 | } |
1858 | spin_unlock(&dparent->d_lock); | 1783 | spin_unlock(&dparent->d_lock); |
1859 | spin_unlock(&dcache_lock); | ||
1860 | 1784 | ||
1861 | return 0; | 1785 | return 0; |
1862 | } | 1786 | } |
@@ -1889,7 +1813,6 @@ void d_delete(struct dentry * dentry) | |||
1889 | /* | 1813 | /* |
1890 | * Are we the only user? | 1814 | * Are we the only user? |
1891 | */ | 1815 | */ |
1892 | spin_lock(&dcache_lock); | ||
1893 | spin_lock(&dcache_inode_lock); | 1816 | spin_lock(&dcache_inode_lock); |
1894 | spin_lock(&dentry->d_lock); | 1817 | spin_lock(&dentry->d_lock); |
1895 | isdir = S_ISDIR(dentry->d_inode->i_mode); | 1818 | isdir = S_ISDIR(dentry->d_inode->i_mode); |
@@ -1905,7 +1828,6 @@ void d_delete(struct dentry * dentry) | |||
1905 | 1828 | ||
1906 | spin_unlock(&dentry->d_lock); | 1829 | spin_unlock(&dentry->d_lock); |
1907 | spin_unlock(&dcache_inode_lock); | 1830 | spin_unlock(&dcache_inode_lock); |
1908 | spin_unlock(&dcache_lock); | ||
1909 | 1831 | ||
1910 | fsnotify_nameremove(dentry, isdir); | 1832 | fsnotify_nameremove(dentry, isdir); |
1911 | } | 1833 | } |
@@ -1932,13 +1854,11 @@ static void _d_rehash(struct dentry * entry) | |||
1932 | 1854 | ||
1933 | void d_rehash(struct dentry * entry) | 1855 | void d_rehash(struct dentry * entry) |
1934 | { | 1856 | { |
1935 | spin_lock(&dcache_lock); | ||
1936 | spin_lock(&entry->d_lock); | 1857 | spin_lock(&entry->d_lock); |
1937 | spin_lock(&dcache_hash_lock); | 1858 | spin_lock(&dcache_hash_lock); |
1938 | _d_rehash(entry); | 1859 | _d_rehash(entry); |
1939 | spin_unlock(&dcache_hash_lock); | 1860 | spin_unlock(&dcache_hash_lock); |
1940 | spin_unlock(&entry->d_lock); | 1861 | spin_unlock(&entry->d_lock); |
1941 | spin_unlock(&dcache_lock); | ||
1942 | } | 1862 | } |
1943 | EXPORT_SYMBOL(d_rehash); | 1863 | EXPORT_SYMBOL(d_rehash); |
1944 | 1864 | ||
@@ -1961,11 +1881,9 @@ void dentry_update_name_case(struct dentry *dentry, struct qstr *name) | |||
1961 | BUG_ON(!mutex_is_locked(&dentry->d_inode->i_mutex)); | 1881 | BUG_ON(!mutex_is_locked(&dentry->d_inode->i_mutex)); |
1962 | BUG_ON(dentry->d_name.len != name->len); /* d_lookup gives this */ | 1882 | BUG_ON(dentry->d_name.len != name->len); /* d_lookup gives this */ |
1963 | 1883 | ||
1964 | spin_lock(&dcache_lock); | ||
1965 | spin_lock(&dentry->d_lock); | 1884 | spin_lock(&dentry->d_lock); |
1966 | memcpy((unsigned char *)dentry->d_name.name, name->name, name->len); | 1885 | memcpy((unsigned char *)dentry->d_name.name, name->name, name->len); |
1967 | spin_unlock(&dentry->d_lock); | 1886 | spin_unlock(&dentry->d_lock); |
1968 | spin_unlock(&dcache_lock); | ||
1969 | } | 1887 | } |
1970 | EXPORT_SYMBOL(dentry_update_name_case); | 1888 | EXPORT_SYMBOL(dentry_update_name_case); |
1971 | 1889 | ||
@@ -2058,14 +1976,14 @@ static void dentry_unlock_parents_for_move(struct dentry *dentry, | |||
2058 | * The hash value has to match the hash queue that the dentry is on.. | 1976 | * The hash value has to match the hash queue that the dentry is on.. |
2059 | */ | 1977 | */ |
2060 | /* | 1978 | /* |
2061 | * d_move_locked - move a dentry | 1979 | * d_move - move a dentry |
2062 | * @dentry: entry to move | 1980 | * @dentry: entry to move |
2063 | * @target: new dentry | 1981 | * @target: new dentry |
2064 | * | 1982 | * |
2065 | * Update the dcache to reflect the move of a file name. Negative | 1983 | * Update the dcache to reflect the move of a file name. Negative |
2066 | * dcache entries should not be moved in this way. | 1984 | * dcache entries should not be moved in this way. |
2067 | */ | 1985 | */ |
2068 | static void d_move_locked(struct dentry * dentry, struct dentry * target) | 1986 | void d_move(struct dentry * dentry, struct dentry * target) |
2069 | { | 1987 | { |
2070 | if (!dentry->d_inode) | 1988 | if (!dentry->d_inode) |
2071 | printk(KERN_WARNING "VFS: moving negative dcache entry\n"); | 1989 | printk(KERN_WARNING "VFS: moving negative dcache entry\n"); |
@@ -2114,22 +2032,6 @@ static void d_move_locked(struct dentry * dentry, struct dentry * target) | |||
2114 | spin_unlock(&dentry->d_lock); | 2032 | spin_unlock(&dentry->d_lock); |
2115 | write_sequnlock(&rename_lock); | 2033 | write_sequnlock(&rename_lock); |
2116 | } | 2034 | } |
2117 | |||
2118 | /** | ||
2119 | * d_move - move a dentry | ||
2120 | * @dentry: entry to move | ||
2121 | * @target: new dentry | ||
2122 | * | ||
2123 | * Update the dcache to reflect the move of a file name. Negative | ||
2124 | * dcache entries should not be moved in this way. | ||
2125 | */ | ||
2126 | |||
2127 | void d_move(struct dentry * dentry, struct dentry * target) | ||
2128 | { | ||
2129 | spin_lock(&dcache_lock); | ||
2130 | d_move_locked(dentry, target); | ||
2131 | spin_unlock(&dcache_lock); | ||
2132 | } | ||
2133 | EXPORT_SYMBOL(d_move); | 2035 | EXPORT_SYMBOL(d_move); |
2134 | 2036 | ||
2135 | /** | 2037 | /** |
@@ -2155,13 +2057,12 @@ struct dentry *d_ancestor(struct dentry *p1, struct dentry *p2) | |||
2155 | * This helper attempts to cope with remotely renamed directories | 2057 | * This helper attempts to cope with remotely renamed directories |
2156 | * | 2058 | * |
2157 | * It assumes that the caller is already holding | 2059 | * It assumes that the caller is already holding |
2158 | * dentry->d_parent->d_inode->i_mutex and the dcache_lock | 2060 | * dentry->d_parent->d_inode->i_mutex and the dcache_inode_lock |
2159 | * | 2061 | * |
2160 | * Note: If ever the locking in lock_rename() changes, then please | 2062 | * Note: If ever the locking in lock_rename() changes, then please |
2161 | * remember to update this too... | 2063 | * remember to update this too... |
2162 | */ | 2064 | */ |
2163 | static struct dentry *__d_unalias(struct dentry *dentry, struct dentry *alias) | 2065 | static struct dentry *__d_unalias(struct dentry *dentry, struct dentry *alias) |
2164 | __releases(dcache_lock) | ||
2165 | __releases(dcache_inode_lock) | 2066 | __releases(dcache_inode_lock) |
2166 | { | 2067 | { |
2167 | struct mutex *m1 = NULL, *m2 = NULL; | 2068 | struct mutex *m1 = NULL, *m2 = NULL; |
@@ -2185,11 +2086,10 @@ static struct dentry *__d_unalias(struct dentry *dentry, struct dentry *alias) | |||
2185 | goto out_err; | 2086 | goto out_err; |
2186 | m2 = &alias->d_parent->d_inode->i_mutex; | 2087 | m2 = &alias->d_parent->d_inode->i_mutex; |
2187 | out_unalias: | 2088 | out_unalias: |
2188 | d_move_locked(alias, dentry); | 2089 | d_move(alias, dentry); |
2189 | ret = alias; | 2090 | ret = alias; |
2190 | out_err: | 2091 | out_err: |
2191 | spin_unlock(&dcache_inode_lock); | 2092 | spin_unlock(&dcache_inode_lock); |
2192 | spin_unlock(&dcache_lock); | ||
2193 | if (m2) | 2093 | if (m2) |
2194 | mutex_unlock(m2); | 2094 | mutex_unlock(m2); |
2195 | if (m1) | 2095 | if (m1) |
@@ -2249,7 +2149,6 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) | |||
2249 | 2149 | ||
2250 | BUG_ON(!d_unhashed(dentry)); | 2150 | BUG_ON(!d_unhashed(dentry)); |
2251 | 2151 | ||
2252 | spin_lock(&dcache_lock); | ||
2253 | spin_lock(&dcache_inode_lock); | 2152 | spin_lock(&dcache_inode_lock); |
2254 | 2153 | ||
2255 | if (!inode) { | 2154 | if (!inode) { |
@@ -2295,7 +2194,6 @@ found: | |||
2295 | spin_unlock(&dcache_hash_lock); | 2194 | spin_unlock(&dcache_hash_lock); |
2296 | spin_unlock(&actual->d_lock); | 2195 | spin_unlock(&actual->d_lock); |
2297 | spin_unlock(&dcache_inode_lock); | 2196 | spin_unlock(&dcache_inode_lock); |
2298 | spin_unlock(&dcache_lock); | ||
2299 | out_nolock: | 2197 | out_nolock: |
2300 | if (actual == dentry) { | 2198 | if (actual == dentry) { |
2301 | security_d_instantiate(dentry, inode); | 2199 | security_d_instantiate(dentry, inode); |
@@ -2307,7 +2205,6 @@ out_nolock: | |||
2307 | 2205 | ||
2308 | shouldnt_be_hashed: | 2206 | shouldnt_be_hashed: |
2309 | spin_unlock(&dcache_inode_lock); | 2207 | spin_unlock(&dcache_inode_lock); |
2310 | spin_unlock(&dcache_lock); | ||
2311 | BUG(); | 2208 | BUG(); |
2312 | } | 2209 | } |
2313 | EXPORT_SYMBOL_GPL(d_materialise_unique); | 2210 | EXPORT_SYMBOL_GPL(d_materialise_unique); |
@@ -2421,11 +2318,9 @@ char *__d_path(const struct path *path, struct path *root, | |||
2421 | int error; | 2318 | int error; |
2422 | 2319 | ||
2423 | prepend(&res, &buflen, "\0", 1); | 2320 | prepend(&res, &buflen, "\0", 1); |
2424 | spin_lock(&dcache_lock); | ||
2425 | write_seqlock(&rename_lock); | 2321 | write_seqlock(&rename_lock); |
2426 | error = prepend_path(path, root, &res, &buflen); | 2322 | error = prepend_path(path, root, &res, &buflen); |
2427 | write_sequnlock(&rename_lock); | 2323 | write_sequnlock(&rename_lock); |
2428 | spin_unlock(&dcache_lock); | ||
2429 | 2324 | ||
2430 | if (error) | 2325 | if (error) |
2431 | return ERR_PTR(error); | 2326 | return ERR_PTR(error); |
@@ -2487,14 +2382,12 @@ char *d_path(const struct path *path, char *buf, int buflen) | |||
2487 | return path->dentry->d_op->d_dname(path->dentry, buf, buflen); | 2382 | return path->dentry->d_op->d_dname(path->dentry, buf, buflen); |
2488 | 2383 | ||
2489 | get_fs_root(current->fs, &root); | 2384 | get_fs_root(current->fs, &root); |
2490 | spin_lock(&dcache_lock); | ||
2491 | write_seqlock(&rename_lock); | 2385 | write_seqlock(&rename_lock); |
2492 | tmp = root; | 2386 | tmp = root; |
2493 | error = path_with_deleted(path, &tmp, &res, &buflen); | 2387 | error = path_with_deleted(path, &tmp, &res, &buflen); |
2494 | if (error) | 2388 | if (error) |
2495 | res = ERR_PTR(error); | 2389 | res = ERR_PTR(error); |
2496 | write_sequnlock(&rename_lock); | 2390 | write_sequnlock(&rename_lock); |
2497 | spin_unlock(&dcache_lock); | ||
2498 | path_put(&root); | 2391 | path_put(&root); |
2499 | return res; | 2392 | return res; |
2500 | } | 2393 | } |
@@ -2520,14 +2413,12 @@ char *d_path_with_unreachable(const struct path *path, char *buf, int buflen) | |||
2520 | return path->dentry->d_op->d_dname(path->dentry, buf, buflen); | 2413 | return path->dentry->d_op->d_dname(path->dentry, buf, buflen); |
2521 | 2414 | ||
2522 | get_fs_root(current->fs, &root); | 2415 | get_fs_root(current->fs, &root); |
2523 | spin_lock(&dcache_lock); | ||
2524 | write_seqlock(&rename_lock); | 2416 | write_seqlock(&rename_lock); |
2525 | tmp = root; | 2417 | tmp = root; |
2526 | error = path_with_deleted(path, &tmp, &res, &buflen); | 2418 | error = path_with_deleted(path, &tmp, &res, &buflen); |
2527 | if (!error && !path_equal(&tmp, &root)) | 2419 | if (!error && !path_equal(&tmp, &root)) |
2528 | error = prepend_unreachable(&res, &buflen); | 2420 | error = prepend_unreachable(&res, &buflen); |
2529 | write_sequnlock(&rename_lock); | 2421 | write_sequnlock(&rename_lock); |
2530 | spin_unlock(&dcache_lock); | ||
2531 | path_put(&root); | 2422 | path_put(&root); |
2532 | if (error) | 2423 | if (error) |
2533 | res = ERR_PTR(error); | 2424 | res = ERR_PTR(error); |
@@ -2594,11 +2485,9 @@ char *dentry_path_raw(struct dentry *dentry, char *buf, int buflen) | |||
2594 | { | 2485 | { |
2595 | char *retval; | 2486 | char *retval; |
2596 | 2487 | ||
2597 | spin_lock(&dcache_lock); | ||
2598 | write_seqlock(&rename_lock); | 2488 | write_seqlock(&rename_lock); |
2599 | retval = __dentry_path(dentry, buf, buflen); | 2489 | retval = __dentry_path(dentry, buf, buflen); |
2600 | write_sequnlock(&rename_lock); | 2490 | write_sequnlock(&rename_lock); |
2601 | spin_unlock(&dcache_lock); | ||
2602 | 2491 | ||
2603 | return retval; | 2492 | return retval; |
2604 | } | 2493 | } |
@@ -2609,7 +2498,6 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen) | |||
2609 | char *p = NULL; | 2498 | char *p = NULL; |
2610 | char *retval; | 2499 | char *retval; |
2611 | 2500 | ||
2612 | spin_lock(&dcache_lock); | ||
2613 | write_seqlock(&rename_lock); | 2501 | write_seqlock(&rename_lock); |
2614 | if (d_unlinked(dentry)) { | 2502 | if (d_unlinked(dentry)) { |
2615 | p = buf + buflen; | 2503 | p = buf + buflen; |
@@ -2619,12 +2507,10 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen) | |||
2619 | } | 2507 | } |
2620 | retval = __dentry_path(dentry, buf, buflen); | 2508 | retval = __dentry_path(dentry, buf, buflen); |
2621 | write_sequnlock(&rename_lock); | 2509 | write_sequnlock(&rename_lock); |
2622 | spin_unlock(&dcache_lock); | ||
2623 | if (!IS_ERR(retval) && p) | 2510 | if (!IS_ERR(retval) && p) |
2624 | *p = '/'; /* restore '/' overriden with '\0' */ | 2511 | *p = '/'; /* restore '/' overriden with '\0' */ |
2625 | return retval; | 2512 | return retval; |
2626 | Elong: | 2513 | Elong: |
2627 | spin_unlock(&dcache_lock); | ||
2628 | return ERR_PTR(-ENAMETOOLONG); | 2514 | return ERR_PTR(-ENAMETOOLONG); |
2629 | } | 2515 | } |
2630 | 2516 | ||
@@ -2658,7 +2544,6 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size) | |||
2658 | get_fs_root_and_pwd(current->fs, &root, &pwd); | 2544 | get_fs_root_and_pwd(current->fs, &root, &pwd); |
2659 | 2545 | ||
2660 | error = -ENOENT; | 2546 | error = -ENOENT; |
2661 | spin_lock(&dcache_lock); | ||
2662 | write_seqlock(&rename_lock); | 2547 | write_seqlock(&rename_lock); |
2663 | if (!d_unlinked(pwd.dentry)) { | 2548 | if (!d_unlinked(pwd.dentry)) { |
2664 | unsigned long len; | 2549 | unsigned long len; |
@@ -2669,7 +2554,6 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size) | |||
2669 | prepend(&cwd, &buflen, "\0", 1); | 2554 | prepend(&cwd, &buflen, "\0", 1); |
2670 | error = prepend_path(&pwd, &tmp, &cwd, &buflen); | 2555 | error = prepend_path(&pwd, &tmp, &cwd, &buflen); |
2671 | write_sequnlock(&rename_lock); | 2556 | write_sequnlock(&rename_lock); |
2672 | spin_unlock(&dcache_lock); | ||
2673 | 2557 | ||
2674 | if (error) | 2558 | if (error) |
2675 | goto out; | 2559 | goto out; |
@@ -2690,7 +2574,6 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size) | |||
2690 | } | 2574 | } |
2691 | } else { | 2575 | } else { |
2692 | write_sequnlock(&rename_lock); | 2576 | write_sequnlock(&rename_lock); |
2693 | spin_unlock(&dcache_lock); | ||
2694 | } | 2577 | } |
2695 | 2578 | ||
2696 | out: | 2579 | out: |
@@ -2776,7 +2659,6 @@ void d_genocide(struct dentry *root) | |||
2776 | rename_retry: | 2659 | rename_retry: |
2777 | this_parent = root; | 2660 | this_parent = root; |
2778 | seq = read_seqbegin(&rename_lock); | 2661 | seq = read_seqbegin(&rename_lock); |
2779 | spin_lock(&dcache_lock); | ||
2780 | spin_lock(&this_parent->d_lock); | 2662 | spin_lock(&this_parent->d_lock); |
2781 | repeat: | 2663 | repeat: |
2782 | next = this_parent->d_subdirs.next; | 2664 | next = this_parent->d_subdirs.next; |
@@ -2823,7 +2705,6 @@ resume: | |||
2823 | if (this_parent != child->d_parent || | 2705 | if (this_parent != child->d_parent || |
2824 | read_seqretry(&rename_lock, seq)) { | 2706 | read_seqretry(&rename_lock, seq)) { |
2825 | spin_unlock(&this_parent->d_lock); | 2707 | spin_unlock(&this_parent->d_lock); |
2826 | spin_unlock(&dcache_lock); | ||
2827 | rcu_read_unlock(); | 2708 | rcu_read_unlock(); |
2828 | goto rename_retry; | 2709 | goto rename_retry; |
2829 | } | 2710 | } |
@@ -2832,7 +2713,6 @@ resume: | |||
2832 | goto resume; | 2713 | goto resume; |
2833 | } | 2714 | } |
2834 | spin_unlock(&this_parent->d_lock); | 2715 | spin_unlock(&this_parent->d_lock); |
2835 | spin_unlock(&dcache_lock); | ||
2836 | if (read_seqretry(&rename_lock, seq)) | 2716 | if (read_seqretry(&rename_lock, seq)) |
2837 | goto rename_retry; | 2717 | goto rename_retry; |
2838 | } | 2718 | } |