Lines Matching refs:dentry

111 static inline struct hlist_bl_head *in_lookup_hash(const struct dentry *parent,  in in_lookup_hash()
258 static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *ct, unsigned tcount) in dentry_cmp() argument
276 const unsigned char *cs = READ_ONCE(dentry->d_name.name); in dentry_cmp()
289 static inline struct external_name *external_name(struct dentry *dentry) in external_name() argument
291 return container_of(dentry->d_name.name, struct external_name, name[0]); in external_name()
296 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); in __d_free() local
298 kmem_cache_free(dentry_cache, dentry); in __d_free()
303 struct dentry *dentry = container_of(head, struct dentry, d_u.d_rcu); in __d_free_external() local
304 kfree(external_name(dentry)); in __d_free_external()
305 kmem_cache_free(dentry_cache, dentry); in __d_free_external()
308 static inline int dname_external(const struct dentry *dentry) in dname_external() argument
310 return dentry->d_name.name != dentry->d_iname; in dname_external()
313 void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry) in take_dentry_name_snapshot() argument
315 spin_lock(&dentry->d_lock); in take_dentry_name_snapshot()
316 name->name = dentry->d_name; in take_dentry_name_snapshot()
317 if (unlikely(dname_external(dentry))) { in take_dentry_name_snapshot()
318 atomic_inc(&external_name(dentry)->u.count); in take_dentry_name_snapshot()
320 memcpy(name->inline_name, dentry->d_iname, in take_dentry_name_snapshot()
321 dentry->d_name.len + 1); in take_dentry_name_snapshot()
324 spin_unlock(&dentry->d_lock); in take_dentry_name_snapshot()
339 static inline void __d_set_inode_and_type(struct dentry *dentry, in __d_set_inode_and_type() argument
345 dentry->d_inode = inode; in __d_set_inode_and_type()
346 flags = READ_ONCE(dentry->d_flags); in __d_set_inode_and_type()
349 smp_store_release(&dentry->d_flags, flags); in __d_set_inode_and_type()
352 static inline void __d_clear_type_and_inode(struct dentry *dentry) in __d_clear_type_and_inode() argument
354 unsigned flags = READ_ONCE(dentry->d_flags); in __d_clear_type_and_inode()
357 WRITE_ONCE(dentry->d_flags, flags); in __d_clear_type_and_inode()
358 dentry->d_inode = NULL; in __d_clear_type_and_inode()
359 if (dentry->d_flags & DCACHE_LRU_LIST) in __d_clear_type_and_inode()
363 static void dentry_free(struct dentry *dentry) in dentry_free() argument
365 WARN_ON(!hlist_unhashed(&dentry->d_u.d_alias)); in dentry_free()
366 if (unlikely(dname_external(dentry))) { in dentry_free()
367 struct external_name *p = external_name(dentry); in dentry_free()
369 call_rcu(&dentry->d_u.d_rcu, __d_free_external); in dentry_free()
374 if (dentry->d_flags & DCACHE_NORCU) in dentry_free()
375 __d_free(&dentry->d_u.d_rcu); in dentry_free()
377 call_rcu(&dentry->d_u.d_rcu, __d_free); in dentry_free()
384 static void dentry_unlink_inode(struct dentry * dentry) in dentry_unlink_inode() argument
385 __releases(dentry->d_lock) in dentry_unlink_inode()
386 __releases(dentry->d_inode->i_lock) in dentry_unlink_inode()
388 struct inode *inode = dentry->d_inode; in dentry_unlink_inode()
390 raw_write_seqcount_begin(&dentry->d_seq); in dentry_unlink_inode()
391 __d_clear_type_and_inode(dentry); in dentry_unlink_inode()
392 hlist_del_init(&dentry->d_u.d_alias); in dentry_unlink_inode()
393 raw_write_seqcount_end(&dentry->d_seq); in dentry_unlink_inode()
394 spin_unlock(&dentry->d_lock); in dentry_unlink_inode()
398 if (dentry->d_op && dentry->d_op->d_iput) in dentry_unlink_inode()
399 dentry->d_op->d_iput(dentry, inode); in dentry_unlink_inode()
423 #define D_FLAG_VERIFY(dentry,x) WARN_ON_ONCE(((dentry)->d_flags & (DCACHE_LRU_LIST | DCACHE_SHRINK_… argument
424 static void d_lru_add(struct dentry *dentry) in d_lru_add() argument
426 D_FLAG_VERIFY(dentry, 0); in d_lru_add()
427 dentry->d_flags |= DCACHE_LRU_LIST; in d_lru_add()
429 if (d_is_negative(dentry)) in d_lru_add()
431 WARN_ON_ONCE(!list_lru_add(&dentry->d_sb->s_dentry_lru, &dentry->d_lru)); in d_lru_add()
434 static void d_lru_del(struct dentry *dentry) in d_lru_del() argument
436 D_FLAG_VERIFY(dentry, DCACHE_LRU_LIST); in d_lru_del()
437 dentry->d_flags &= ~DCACHE_LRU_LIST; in d_lru_del()
439 if (d_is_negative(dentry)) in d_lru_del()
441 WARN_ON_ONCE(!list_lru_del(&dentry->d_sb->s_dentry_lru, &dentry->d_lru)); in d_lru_del()
444 static void d_shrink_del(struct dentry *dentry) in d_shrink_del() argument
446 D_FLAG_VERIFY(dentry, DCACHE_SHRINK_LIST | DCACHE_LRU_LIST); in d_shrink_del()
447 list_del_init(&dentry->d_lru); in d_shrink_del()
448 dentry->d_flags &= ~(DCACHE_SHRINK_LIST | DCACHE_LRU_LIST); in d_shrink_del()
452 static void d_shrink_add(struct dentry *dentry, struct list_head *list) in d_shrink_add() argument
454 D_FLAG_VERIFY(dentry, 0); in d_shrink_add()
455 list_add(&dentry->d_lru, list); in d_shrink_add()
456 dentry->d_flags |= DCACHE_SHRINK_LIST | DCACHE_LRU_LIST; in d_shrink_add()
466 static void d_lru_isolate(struct list_lru_one *lru, struct dentry *dentry) in d_lru_isolate() argument
468 D_FLAG_VERIFY(dentry, DCACHE_LRU_LIST); in d_lru_isolate()
469 dentry->d_flags &= ~DCACHE_LRU_LIST; in d_lru_isolate()
471 if (d_is_negative(dentry)) in d_lru_isolate()
473 list_lru_isolate(lru, &dentry->d_lru); in d_lru_isolate()
476 static void d_lru_shrink_move(struct list_lru_one *lru, struct dentry *dentry, in d_lru_shrink_move() argument
479 D_FLAG_VERIFY(dentry, DCACHE_LRU_LIST); in d_lru_shrink_move()
480 dentry->d_flags |= DCACHE_SHRINK_LIST; in d_lru_shrink_move()
481 if (d_is_negative(dentry)) in d_lru_shrink_move()
483 list_lru_isolate_move(lru, &dentry->d_lru, list); in d_lru_shrink_move()
486 static void ___d_drop(struct dentry *dentry) in ___d_drop() argument
494 if (unlikely(IS_ROOT(dentry))) in ___d_drop()
495 b = &dentry->d_sb->s_roots; in ___d_drop()
497 b = d_hash(dentry->d_name.hash); in ___d_drop()
500 __hlist_bl_del(&dentry->d_hash); in ___d_drop()
504 void __d_drop(struct dentry *dentry) in __d_drop() argument
506 if (!d_unhashed(dentry)) { in __d_drop()
507 ___d_drop(dentry); in __d_drop()
508 dentry->d_hash.pprev = NULL; in __d_drop()
509 write_seqcount_invalidate(&dentry->d_seq); in __d_drop()
532 void d_drop(struct dentry *dentry) in d_drop() argument
534 spin_lock(&dentry->d_lock); in d_drop()
535 __d_drop(dentry); in d_drop()
536 spin_unlock(&dentry->d_lock); in d_drop()
540 static inline void dentry_unlist(struct dentry *dentry, struct dentry *parent) in dentry_unlist() argument
542 struct dentry *next; in dentry_unlist()
547 dentry->d_flags |= DCACHE_DENTRY_KILLED; in dentry_unlist()
548 if (unlikely(list_empty(&dentry->d_child))) in dentry_unlist()
550 __list_del_entry(&dentry->d_child); in dentry_unlist()
570 while (dentry->d_child.next != &parent->d_subdirs) { in dentry_unlist()
571 next = list_entry(dentry->d_child.next, struct dentry, d_child); in dentry_unlist()
574 dentry->d_child.next = next->d_child.next; in dentry_unlist()
578 static void __dentry_kill(struct dentry *dentry) in __dentry_kill() argument
580 struct dentry *parent = NULL; in __dentry_kill()
582 if (!IS_ROOT(dentry)) in __dentry_kill()
583 parent = dentry->d_parent; in __dentry_kill()
588 lockref_mark_dead(&dentry->d_lockref); in __dentry_kill()
594 if (dentry->d_flags & DCACHE_OP_PRUNE) in __dentry_kill()
595 dentry->d_op->d_prune(dentry); in __dentry_kill()
597 if (dentry->d_flags & DCACHE_LRU_LIST) { in __dentry_kill()
598 if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) in __dentry_kill()
599 d_lru_del(dentry); in __dentry_kill()
602 __d_drop(dentry); in __dentry_kill()
603 dentry_unlist(dentry, parent); in __dentry_kill()
606 if (dentry->d_inode) in __dentry_kill()
607 dentry_unlink_inode(dentry); in __dentry_kill()
609 spin_unlock(&dentry->d_lock); in __dentry_kill()
611 if (dentry->d_op && dentry->d_op->d_release) in __dentry_kill()
612 dentry->d_op->d_release(dentry); in __dentry_kill()
614 spin_lock(&dentry->d_lock); in __dentry_kill()
615 if (dentry->d_flags & DCACHE_SHRINK_LIST) { in __dentry_kill()
616 dentry->d_flags |= DCACHE_MAY_FREE; in __dentry_kill()
619 spin_unlock(&dentry->d_lock); in __dentry_kill()
621 dentry_free(dentry); in __dentry_kill()
625 static struct dentry *__lock_parent(struct dentry *dentry) in __lock_parent() argument
627 struct dentry *parent; in __lock_parent()
629 spin_unlock(&dentry->d_lock); in __lock_parent()
631 parent = READ_ONCE(dentry->d_parent); in __lock_parent()
641 if (unlikely(parent != dentry->d_parent)) { in __lock_parent()
646 if (parent != dentry) in __lock_parent()
647 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); in __lock_parent()
653 static inline struct dentry *lock_parent(struct dentry *dentry) in lock_parent() argument
655 struct dentry *parent = dentry->d_parent; in lock_parent()
656 if (IS_ROOT(dentry)) in lock_parent()
660 return __lock_parent(dentry); in lock_parent()
663 static inline bool retain_dentry(struct dentry *dentry) in retain_dentry() argument
665 WARN_ON(d_in_lookup(dentry)); in retain_dentry()
668 if (unlikely(d_unhashed(dentry))) in retain_dentry()
671 if (unlikely(dentry->d_flags & DCACHE_DISCONNECTED)) in retain_dentry()
674 if (unlikely(dentry->d_flags & DCACHE_OP_DELETE)) { in retain_dentry()
675 if (dentry->d_op->d_delete(dentry)) in retain_dentry()
679 if (unlikely(dentry->d_flags & DCACHE_DONTCACHE)) in retain_dentry()
683 dentry->d_lockref.count--; in retain_dentry()
684 if (unlikely(!(dentry->d_flags & DCACHE_LRU_LIST))) in retain_dentry()
685 d_lru_add(dentry); in retain_dentry()
686 else if (unlikely(!(dentry->d_flags & DCACHE_REFERENCED))) in retain_dentry()
687 dentry->d_flags |= DCACHE_REFERENCED; in retain_dentry()
693 struct dentry *de; in d_mark_dontcache()
711 static struct dentry *dentry_kill(struct dentry *dentry) in dentry_kill() argument
712 __releases(dentry->d_lock) in dentry_kill()
714 struct inode *inode = dentry->d_inode; in dentry_kill()
715 struct dentry *parent = NULL; in dentry_kill()
720 if (!IS_ROOT(dentry)) { in dentry_kill()
721 parent = dentry->d_parent; in dentry_kill()
723 parent = __lock_parent(dentry); in dentry_kill()
724 if (likely(inode || !dentry->d_inode)) in dentry_kill()
729 inode = dentry->d_inode; in dentry_kill()
733 __dentry_kill(dentry); in dentry_kill()
737 spin_unlock(&dentry->d_lock); in dentry_kill()
739 spin_lock(&dentry->d_lock); in dentry_kill()
740 parent = lock_parent(dentry); in dentry_kill()
742 if (unlikely(dentry->d_lockref.count != 1)) { in dentry_kill()
743 dentry->d_lockref.count--; in dentry_kill()
744 } else if (likely(!retain_dentry(dentry))) { in dentry_kill()
745 __dentry_kill(dentry); in dentry_kill()
753 spin_unlock(&dentry->d_lock); in dentry_kill()
765 static inline bool fast_dput(struct dentry *dentry) in fast_dput() argument
774 if (unlikely(dentry->d_flags & DCACHE_OP_DELETE)) in fast_dput()
775 return lockref_put_or_lock(&dentry->d_lockref); in fast_dput()
781 ret = lockref_put_return(&dentry->d_lockref); in fast_dput()
789 spin_lock(&dentry->d_lock); in fast_dput()
790 if (dentry->d_lockref.count > 1) { in fast_dput()
791 dentry->d_lockref.count--; in fast_dput()
792 spin_unlock(&dentry->d_lock); in fast_dput()
832 d_flags = READ_ONCE(dentry->d_flags); in fast_dput()
837 if (d_flags == (DCACHE_REFERENCED | DCACHE_LRU_LIST) && !d_unhashed(dentry)) in fast_dput()
845 spin_lock(&dentry->d_lock); in fast_dput()
853 if (dentry->d_lockref.count) { in fast_dput()
854 spin_unlock(&dentry->d_lock); in fast_dput()
863 dentry->d_lockref.count = 1; in fast_dput()
894 void dput(struct dentry *dentry) in dput() argument
896 while (dentry) { in dput()
900 if (likely(fast_dput(dentry))) { in dput()
908 if (likely(retain_dentry(dentry))) { in dput()
909 spin_unlock(&dentry->d_lock); in dput()
913 dentry = dentry_kill(dentry); in dput()
918 static void __dput_to_list(struct dentry *dentry, struct list_head *list) in __dput_to_list() argument
919 __must_hold(&dentry->d_lock) in __dput_to_list()
921 if (dentry->d_flags & DCACHE_SHRINK_LIST) { in __dput_to_list()
923 --dentry->d_lockref.count; in __dput_to_list()
925 if (dentry->d_flags & DCACHE_LRU_LIST) in __dput_to_list()
926 d_lru_del(dentry); in __dput_to_list()
927 if (!--dentry->d_lockref.count) in __dput_to_list()
928 d_shrink_add(dentry, list); in __dput_to_list()
932 void dput_to_list(struct dentry *dentry, struct list_head *list) in dput_to_list() argument
935 if (likely(fast_dput(dentry))) { in dput_to_list()
940 if (!retain_dentry(dentry)) in dput_to_list()
941 __dput_to_list(dentry, list); in dput_to_list()
942 spin_unlock(&dentry->d_lock); in dput_to_list()
946 static inline void __dget_dlock(struct dentry *dentry) in __dget_dlock() argument
948 dentry->d_lockref.count++; in __dget_dlock()
951 static inline void __dget(struct dentry *dentry) in __dget() argument
953 lockref_get(&dentry->d_lockref); in __dget()
956 struct dentry *dget_parent(struct dentry *dentry) in dget_parent() argument
959 struct dentry *ret; in dget_parent()
967 seq = raw_seqcount_begin(&dentry->d_seq); in dget_parent()
968 ret = READ_ONCE(dentry->d_parent); in dget_parent()
972 if (!read_seqcount_retry(&dentry->d_seq, seq)) in dget_parent()
983 ret = dentry->d_parent; in dget_parent()
985 if (unlikely(ret != dentry->d_parent)) { in dget_parent()
998 static struct dentry * __d_find_any_alias(struct inode *inode) in __d_find_any_alias()
1000 struct dentry *alias; in __d_find_any_alias()
1004 alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias); in __d_find_any_alias()
1016 struct dentry *d_find_any_alias(struct inode *inode) in d_find_any_alias()
1018 struct dentry *de; in d_find_any_alias()
1027 static struct dentry *__d_find_alias(struct inode *inode) in __d_find_alias()
1029 struct dentry *alias; in __d_find_alias()
1060 struct dentry *d_find_alias(struct inode *inode) in d_find_alias()
1062 struct dentry *de = NULL; in d_find_alias()
1077 struct dentry *d_find_alias_rcu(struct inode *inode) in d_find_alias_rcu()
1080 struct dentry *de = NULL; in d_find_alias_rcu()
1087 de = hlist_entry(l->first, struct dentry, d_u.d_alias); in d_find_alias_rcu()
1104 struct dentry *dentry; in d_prune_aliases() local
1107 hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { in d_prune_aliases()
1108 spin_lock(&dentry->d_lock); in d_prune_aliases()
1109 if (!dentry->d_lockref.count) { in d_prune_aliases()
1110 struct dentry *parent = lock_parent(dentry); in d_prune_aliases()
1111 if (likely(!dentry->d_lockref.count)) { in d_prune_aliases()
1112 __dentry_kill(dentry); in d_prune_aliases()
1119 spin_unlock(&dentry->d_lock); in d_prune_aliases()
1136 static bool shrink_lock_dentry(struct dentry *dentry) in shrink_lock_dentry() argument
1139 struct dentry *parent; in shrink_lock_dentry()
1141 if (dentry->d_lockref.count) in shrink_lock_dentry()
1144 inode = dentry->d_inode; in shrink_lock_dentry()
1146 spin_unlock(&dentry->d_lock); in shrink_lock_dentry()
1148 spin_lock(&dentry->d_lock); in shrink_lock_dentry()
1149 if (unlikely(dentry->d_lockref.count)) in shrink_lock_dentry()
1152 if (unlikely(inode != dentry->d_inode)) in shrink_lock_dentry()
1156 parent = dentry->d_parent; in shrink_lock_dentry()
1157 if (IS_ROOT(dentry) || likely(spin_trylock(&parent->d_lock))) in shrink_lock_dentry()
1160 spin_unlock(&dentry->d_lock); in shrink_lock_dentry()
1162 if (unlikely(parent != dentry->d_parent)) { in shrink_lock_dentry()
1164 spin_lock(&dentry->d_lock); in shrink_lock_dentry()
1167 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); in shrink_lock_dentry()
1168 if (likely(!dentry->d_lockref.count)) in shrink_lock_dentry()
1180 struct dentry *dentry, *parent; in shrink_dentry_list() local
1182 dentry = list_entry(list->prev, struct dentry, d_lru); in shrink_dentry_list()
1183 spin_lock(&dentry->d_lock); in shrink_dentry_list()
1185 if (!shrink_lock_dentry(dentry)) { in shrink_dentry_list()
1188 d_shrink_del(dentry); in shrink_dentry_list()
1189 if (dentry->d_lockref.count < 0) in shrink_dentry_list()
1190 can_free = dentry->d_flags & DCACHE_MAY_FREE; in shrink_dentry_list()
1191 spin_unlock(&dentry->d_lock); in shrink_dentry_list()
1193 dentry_free(dentry); in shrink_dentry_list()
1197 d_shrink_del(dentry); in shrink_dentry_list()
1198 parent = dentry->d_parent; in shrink_dentry_list()
1199 if (parent != dentry) in shrink_dentry_list()
1201 __dentry_kill(dentry); in shrink_dentry_list()
1209 struct dentry *dentry = container_of(item, struct dentry, d_lru); in dentry_lru_isolate() local
1217 if (!spin_trylock(&dentry->d_lock)) in dentry_lru_isolate()
1225 if (dentry->d_lockref.count) { in dentry_lru_isolate()
1226 d_lru_isolate(lru, dentry); in dentry_lru_isolate()
1227 spin_unlock(&dentry->d_lock); in dentry_lru_isolate()
1231 if (dentry->d_flags & DCACHE_REFERENCED) { in dentry_lru_isolate()
1232 dentry->d_flags &= ~DCACHE_REFERENCED; in dentry_lru_isolate()
1233 spin_unlock(&dentry->d_lock); in dentry_lru_isolate()
1257 d_lru_shrink_move(lru, dentry, freeable); in dentry_lru_isolate()
1258 spin_unlock(&dentry->d_lock); in dentry_lru_isolate()
1290 struct dentry *dentry = container_of(item, struct dentry, d_lru); in dentry_lru_isolate_shrink() local
1297 if (!spin_trylock(&dentry->d_lock)) in dentry_lru_isolate_shrink()
1300 d_lru_shrink_move(lru, dentry, freeable); in dentry_lru_isolate_shrink()
1301 spin_unlock(&dentry->d_lock); in dentry_lru_isolate_shrink()
1348 static void d_walk(struct dentry *parent, void *data, in d_walk() argument
1349 enum d_walk_ret (*enter)(void *, struct dentry *)) in d_walk()
1351 struct dentry *this_parent; in d_walk()
1378 struct dentry *dentry = list_entry(tmp, struct dentry, d_child); in d_walk() local
1381 if (unlikely(dentry->d_flags & DCACHE_DENTRY_CURSOR)) in d_walk()
1384 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); in d_walk()
1386 ret = enter(data, dentry); in d_walk()
1391 spin_unlock(&dentry->d_lock); in d_walk()
1397 spin_unlock(&dentry->d_lock); in d_walk()
1401 if (!list_empty(&dentry->d_subdirs)) { in d_walk()
1403 spin_release(&dentry->d_lock.dep_map, _RET_IP_); in d_walk()
1404 this_parent = dentry; in d_walk()
1408 spin_unlock(&dentry->d_lock); in d_walk()
1416 struct dentry *child = this_parent; in d_walk()
1430 child = list_entry(next, struct dentry, d_child); in d_walk()
1459 static enum d_walk_ret path_check_mount(void *data, struct dentry *dentry) in path_check_mount() argument
1462 struct path path = { .mnt = info->mnt, .dentry = dentry }; in path_check_mount()
1464 if (likely(!d_mountpoint(dentry))) in path_check_mount()
1486 d_walk(parent->dentry, &data, path_check_mount); in path_has_submounts()
1501 int d_set_mounted(struct dentry *dentry) in d_set_mounted() argument
1503 struct dentry *p; in d_set_mounted()
1506 for (p = dentry->d_parent; !IS_ROOT(p); p = p->d_parent) { in d_set_mounted()
1515 spin_lock(&dentry->d_lock); in d_set_mounted()
1516 if (!d_unlinked(dentry)) { in d_set_mounted()
1518 if (!d_mountpoint(dentry)) { in d_set_mounted()
1519 dentry->d_flags |= DCACHE_MOUNTED; in d_set_mounted()
1523 spin_unlock(&dentry->d_lock); in d_set_mounted()
1545 struct dentry *start;
1548 struct dentry *victim;
1553 static enum d_walk_ret select_collect(void *_data, struct dentry *dentry) in select_collect() argument
1558 if (data->start == dentry) in select_collect()
1561 if (dentry->d_flags & DCACHE_SHRINK_LIST) { in select_collect()
1564 if (dentry->d_flags & DCACHE_LRU_LIST) in select_collect()
1565 d_lru_del(dentry); in select_collect()
1566 if (!dentry->d_lockref.count) { in select_collect()
1567 d_shrink_add(dentry, &data->dispose); in select_collect()
1582 static enum d_walk_ret select_collect2(void *_data, struct dentry *dentry) in select_collect2() argument
1587 if (data->start == dentry) in select_collect2()
1590 if (dentry->d_flags & DCACHE_SHRINK_LIST) { in select_collect2()
1591 if (!dentry->d_lockref.count) { in select_collect2()
1593 data->victim = dentry; in select_collect2()
1597 if (dentry->d_flags & DCACHE_LRU_LIST) in select_collect2()
1598 d_lru_del(dentry); in select_collect2()
1599 if (!dentry->d_lockref.count) in select_collect2()
1600 d_shrink_add(dentry, &data->dispose); in select_collect2()
1619 void shrink_dcache_parent(struct dentry *parent) in shrink_dcache_parent()
1638 struct dentry *parent; in shrink_dcache_parent()
1657 static enum d_walk_ret umount_check(void *_data, struct dentry *dentry) in umount_check() argument
1660 if (!list_empty(&dentry->d_subdirs)) in umount_check()
1664 if (dentry == _data && dentry->d_lockref.count == 1) in umount_check()
1669 dentry, in umount_check()
1670 dentry->d_inode ? in umount_check()
1671 dentry->d_inode->i_ino : 0UL, in umount_check()
1672 dentry, in umount_check()
1673 dentry->d_lockref.count, in umount_check()
1674 dentry->d_sb->s_type->name, in umount_check()
1675 dentry->d_sb->s_id); in umount_check()
1679 static void do_one_tree(struct dentry *dentry) in do_one_tree() argument
1681 shrink_dcache_parent(dentry); in do_one_tree()
1682 d_walk(dentry, dentry, umount_check); in do_one_tree()
1683 d_drop(dentry); in do_one_tree()
1684 dput(dentry); in do_one_tree()
1692 struct dentry *dentry; in shrink_dcache_for_umount() local
1696 dentry = sb->s_root; in shrink_dcache_for_umount()
1698 do_one_tree(dentry); in shrink_dcache_for_umount()
1701 dentry = dget(hlist_bl_entry(hlist_bl_first(&sb->s_roots), struct dentry, d_hash)); in shrink_dcache_for_umount()
1702 do_one_tree(dentry); in shrink_dcache_for_umount()
1706 static enum d_walk_ret find_submount(void *_data, struct dentry *dentry) in find_submount() argument
1708 struct dentry **victim = _data; in find_submount()
1709 if (d_mountpoint(dentry)) { in find_submount()
1710 __dget_dlock(dentry); in find_submount()
1711 *victim = dentry; in find_submount()
1721 void d_invalidate(struct dentry *dentry) in d_invalidate() argument
1724 spin_lock(&dentry->d_lock); in d_invalidate()
1725 if (d_unhashed(dentry)) { in d_invalidate()
1726 spin_unlock(&dentry->d_lock); in d_invalidate()
1729 __d_drop(dentry); in d_invalidate()
1730 spin_unlock(&dentry->d_lock); in d_invalidate()
1733 if (!dentry->d_inode) in d_invalidate()
1736 shrink_dcache_parent(dentry); in d_invalidate()
1738 struct dentry *victim = NULL; in d_invalidate()
1739 d_walk(dentry, &victim, find_submount); in d_invalidate()
1742 shrink_dcache_parent(dentry); in d_invalidate()
1762 static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) in __d_alloc()
1764 struct dentry *dentry; in __d_alloc() local
1768 dentry = kmem_cache_alloc_lru(dentry_cache, &sb->s_dentry_lru, in __d_alloc()
1770 if (!dentry) in __d_alloc()
1779 dentry->d_iname[DNAME_INLINE_LEN-1] = 0; in __d_alloc()
1782 dname = dentry->d_iname; in __d_alloc()
1789 kmem_cache_free(dentry_cache, dentry); in __d_alloc()
1795 dname = dentry->d_iname; in __d_alloc()
1798 dentry->d_name.len = name->len; in __d_alloc()
1799 dentry->d_name.hash = name->hash; in __d_alloc()
1804 smp_store_release(&dentry->d_name.name, dname); /* ^^^ */ in __d_alloc()
1806 dentry->d_lockref.count = 1; in __d_alloc()
1807 dentry->d_flags = 0; in __d_alloc()
1808 spin_lock_init(&dentry->d_lock); in __d_alloc()
1809 seqcount_spinlock_init(&dentry->d_seq, &dentry->d_lock); in __d_alloc()
1810 dentry->d_inode = NULL; in __d_alloc()
1811 dentry->d_parent = dentry; in __d_alloc()
1812 dentry->d_sb = sb; in __d_alloc()
1813 dentry->d_op = NULL; in __d_alloc()
1814 dentry->d_fsdata = NULL; in __d_alloc()
1815 INIT_HLIST_BL_NODE(&dentry->d_hash); in __d_alloc()
1816 INIT_LIST_HEAD(&dentry->d_lru); in __d_alloc()
1817 INIT_LIST_HEAD(&dentry->d_subdirs); in __d_alloc()
1818 INIT_HLIST_NODE(&dentry->d_u.d_alias); in __d_alloc()
1819 INIT_LIST_HEAD(&dentry->d_child); in __d_alloc()
1820 d_set_d_op(dentry, dentry->d_sb->s_d_op); in __d_alloc()
1822 if (dentry->d_op && dentry->d_op->d_init) { in __d_alloc()
1823 err = dentry->d_op->d_init(dentry); in __d_alloc()
1825 if (dname_external(dentry)) in __d_alloc()
1826 kfree(external_name(dentry)); in __d_alloc()
1827 kmem_cache_free(dentry_cache, dentry); in __d_alloc()
1834 return dentry; in __d_alloc()
1846 struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) in d_alloc()
1848 struct dentry *dentry = __d_alloc(parent->d_sb, name); in d_alloc() local
1849 if (!dentry) in d_alloc()
1857 dentry->d_parent = parent; in d_alloc()
1858 list_add(&dentry->d_child, &parent->d_subdirs); in d_alloc()
1861 return dentry; in d_alloc()
1865 struct dentry *d_alloc_anon(struct super_block *sb) in d_alloc_anon()
1871 struct dentry *d_alloc_cursor(struct dentry * parent) in d_alloc_cursor()
1873 struct dentry *dentry = d_alloc_anon(parent->d_sb); in d_alloc_cursor() local
1874 if (dentry) { in d_alloc_cursor()
1875 dentry->d_flags |= DCACHE_DENTRY_CURSOR; in d_alloc_cursor()
1876 dentry->d_parent = dget(parent); in d_alloc_cursor()
1878 return dentry; in d_alloc_cursor()
1896 struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) in d_alloc_pseudo()
1898 struct dentry *dentry = __d_alloc(sb, name); in d_alloc_pseudo() local
1899 if (likely(dentry)) in d_alloc_pseudo()
1900 dentry->d_flags |= DCACHE_NORCU; in d_alloc_pseudo()
1901 return dentry; in d_alloc_pseudo()
1904 struct dentry *d_alloc_name(struct dentry *parent, const char *name) in d_alloc_name()
1914 void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) in d_set_d_op() argument
1916 WARN_ON_ONCE(dentry->d_op); in d_set_d_op()
1917 WARN_ON_ONCE(dentry->d_flags & (DCACHE_OP_HASH | in d_set_d_op()
1923 dentry->d_op = op; in d_set_d_op()
1927 dentry->d_flags |= DCACHE_OP_HASH; in d_set_d_op()
1929 dentry->d_flags |= DCACHE_OP_COMPARE; in d_set_d_op()
1931 dentry->d_flags |= DCACHE_OP_REVALIDATE; in d_set_d_op()
1933 dentry->d_flags |= DCACHE_OP_WEAK_REVALIDATE; in d_set_d_op()
1935 dentry->d_flags |= DCACHE_OP_DELETE; in d_set_d_op()
1937 dentry->d_flags |= DCACHE_OP_PRUNE; in d_set_d_op()
1939 dentry->d_flags |= DCACHE_OP_REAL; in d_set_d_op()
1952 void d_set_fallthru(struct dentry *dentry) in d_set_fallthru() argument
1954 spin_lock(&dentry->d_lock); in d_set_fallthru()
1955 dentry->d_flags |= DCACHE_FALLTHRU; in d_set_fallthru()
1956 spin_unlock(&dentry->d_lock); in d_set_fallthru()
1995 static void __d_instantiate(struct dentry *dentry, struct inode *inode) in __d_instantiate() argument
1998 WARN_ON(d_in_lookup(dentry)); in __d_instantiate()
2000 spin_lock(&dentry->d_lock); in __d_instantiate()
2004 if (dentry->d_flags & DCACHE_LRU_LIST) in __d_instantiate()
2006 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); in __d_instantiate()
2007 raw_write_seqcount_begin(&dentry->d_seq); in __d_instantiate()
2008 __d_set_inode_and_type(dentry, inode, add_flags); in __d_instantiate()
2009 raw_write_seqcount_end(&dentry->d_seq); in __d_instantiate()
2010 fsnotify_update_flags(dentry); in __d_instantiate()
2011 spin_unlock(&dentry->d_lock); in __d_instantiate()
2029 void d_instantiate(struct dentry *entry, struct inode * inode) in d_instantiate()
2047 void d_instantiate_new(struct dentry *entry, struct inode *inode) in d_instantiate_new()
2063 struct dentry *d_make_root(struct inode *root_inode) in d_make_root()
2065 struct dentry *res = NULL; in d_make_root()
2078 static struct dentry *__d_instantiate_anon(struct dentry *dentry, in __d_instantiate_anon() argument
2082 struct dentry *res; in __d_instantiate_anon()
2085 security_d_instantiate(dentry, inode); in __d_instantiate_anon()
2090 dput(dentry); in __d_instantiate_anon()
2100 spin_lock(&dentry->d_lock); in __d_instantiate_anon()
2101 __d_set_inode_and_type(dentry, inode, add_flags); in __d_instantiate_anon()
2102 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); in __d_instantiate_anon()
2104 hlist_bl_lock(&dentry->d_sb->s_roots); in __d_instantiate_anon()
2105 hlist_bl_add_head(&dentry->d_hash, &dentry->d_sb->s_roots); in __d_instantiate_anon()
2106 hlist_bl_unlock(&dentry->d_sb->s_roots); in __d_instantiate_anon()
2108 spin_unlock(&dentry->d_lock); in __d_instantiate_anon()
2111 return dentry; in __d_instantiate_anon()
2118 struct dentry *d_instantiate_anon(struct dentry *dentry, struct inode *inode) in d_instantiate_anon() argument
2120 return __d_instantiate_anon(dentry, inode, true); in d_instantiate_anon()
2124 static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected) in __d_obtain_alias()
2126 struct dentry *tmp; in __d_obtain_alias()
2127 struct dentry *res; in __d_obtain_alias()
2169 struct dentry *d_obtain_alias(struct inode *inode) in d_obtain_alias()
2190 struct dentry *d_obtain_root(struct inode *inode) in d_obtain_root()
2212 struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, in d_add_ci() argument
2215 struct dentry *found, *res; in d_add_ci()
2221 found = d_hash_and_lookup(dentry->d_parent, name); in d_add_ci()
2226 if (d_in_lookup(dentry)) { in d_add_ci()
2227 found = d_alloc_parallel(dentry->d_parent, name, in d_add_ci()
2228 dentry->d_wait); in d_add_ci()
2234 found = d_alloc(dentry->d_parent, name); in d_add_ci()
2258 bool d_same_name(const struct dentry *dentry, const struct dentry *parent, in d_same_name() argument
2262 if (dentry->d_name.len != name->len) in d_same_name()
2264 return dentry_cmp(dentry, name->name, name->len) == 0; in d_same_name()
2266 return parent->d_op->d_compare(dentry, in d_same_name()
2267 dentry->d_name.len, dentry->d_name.name, in d_same_name()
2276 static noinline struct dentry *__d_lookup_rcu_op_compare( in __d_lookup_rcu_op_compare()
2277 const struct dentry *parent, in __d_lookup_rcu_op_compare()
2284 struct dentry *dentry; in __d_lookup_rcu_op_compare() local
2286 hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { in __d_lookup_rcu_op_compare()
2292 seq = raw_seqcount_begin(&dentry->d_seq); in __d_lookup_rcu_op_compare()
2293 if (dentry->d_parent != parent) in __d_lookup_rcu_op_compare()
2295 if (d_unhashed(dentry)) in __d_lookup_rcu_op_compare()
2297 if (dentry->d_name.hash != hashlen_hash(hashlen)) in __d_lookup_rcu_op_compare()
2299 tlen = dentry->d_name.len; in __d_lookup_rcu_op_compare()
2300 tname = dentry->d_name.name; in __d_lookup_rcu_op_compare()
2302 if (read_seqcount_retry(&dentry->d_seq, seq)) { in __d_lookup_rcu_op_compare()
2306 if (parent->d_op->d_compare(dentry, tlen, tname, name) != 0) in __d_lookup_rcu_op_compare()
2309 return dentry; in __d_lookup_rcu_op_compare()
2343 struct dentry *__d_lookup_rcu(const struct dentry *parent, in __d_lookup_rcu()
2351 struct dentry *dentry; in __d_lookup_rcu() local
2376 hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { in __d_lookup_rcu()
2396 seq = raw_seqcount_begin(&dentry->d_seq); in __d_lookup_rcu()
2397 if (dentry->d_parent != parent) in __d_lookup_rcu()
2399 if (d_unhashed(dentry)) in __d_lookup_rcu()
2401 if (dentry->d_name.hash_len != hashlen) in __d_lookup_rcu()
2403 if (dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0) in __d_lookup_rcu()
2406 return dentry; in __d_lookup_rcu()
2422 struct dentry *d_lookup(const struct dentry *parent, const struct qstr *name) in d_lookup()
2424 struct dentry *dentry; in d_lookup() local
2429 dentry = __d_lookup(parent, name); in d_lookup()
2430 if (dentry) in d_lookup()
2433 return dentry; in d_lookup()
2452 struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name) in __d_lookup()
2457 struct dentry *found = NULL; in __d_lookup()
2458 struct dentry *dentry; in __d_lookup() local
2482 hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { in __d_lookup()
2484 if (dentry->d_name.hash != hash) in __d_lookup()
2487 spin_lock(&dentry->d_lock); in __d_lookup()
2488 if (dentry->d_parent != parent) in __d_lookup()
2490 if (d_unhashed(dentry)) in __d_lookup()
2493 if (!d_same_name(dentry, parent, name)) in __d_lookup()
2496 dentry->d_lockref.count++; in __d_lookup()
2497 found = dentry; in __d_lookup()
2498 spin_unlock(&dentry->d_lock); in __d_lookup()
2501 spin_unlock(&dentry->d_lock); in __d_lookup()
2515 struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) in d_hash_and_lookup()
2553 void d_delete(struct dentry * dentry) in d_delete() argument
2555 struct inode *inode = dentry->d_inode; in d_delete()
2558 spin_lock(&dentry->d_lock); in d_delete()
2562 if (dentry->d_lockref.count == 1) { in d_delete()
2563 dentry->d_flags &= ~DCACHE_CANT_MOUNT; in d_delete()
2564 dentry_unlink_inode(dentry); in d_delete()
2566 __d_drop(dentry); in d_delete()
2567 spin_unlock(&dentry->d_lock); in d_delete()
2573 static void __d_rehash(struct dentry *entry) in __d_rehash()
2589 void d_rehash(struct dentry * entry) in d_rehash()
2616 static void d_wait_lookup(struct dentry *dentry) in d_wait_lookup() argument
2618 if (d_in_lookup(dentry)) { in d_wait_lookup()
2620 add_wait_queue(dentry->d_wait, &wait); in d_wait_lookup()
2623 spin_unlock(&dentry->d_lock); in d_wait_lookup()
2625 spin_lock(&dentry->d_lock); in d_wait_lookup()
2626 } while (d_in_lookup(dentry)); in d_wait_lookup()
2630 struct dentry *d_alloc_parallel(struct dentry *parent, in d_alloc_parallel()
2637 struct dentry *new = d_alloc(parent, name); in d_alloc_parallel()
2638 struct dentry *dentry; in d_alloc_parallel() local
2648 dentry = __d_lookup_rcu(parent, name, &d_seq); in d_alloc_parallel()
2649 if (unlikely(dentry)) { in d_alloc_parallel()
2650 if (!lockref_get_not_dead(&dentry->d_lockref)) { in d_alloc_parallel()
2654 if (read_seqcount_retry(&dentry->d_seq, d_seq)) { in d_alloc_parallel()
2656 dput(dentry); in d_alloc_parallel()
2661 return dentry; in d_alloc_parallel()
2686 hlist_bl_for_each_entry(dentry, node, b, d_u.d_in_lookup_hash) { in d_alloc_parallel()
2687 if (dentry->d_name.hash != hash) in d_alloc_parallel()
2689 if (dentry->d_parent != parent) in d_alloc_parallel()
2691 if (!d_same_name(dentry, parent, name)) in d_alloc_parallel()
2695 if (!lockref_get_not_dead(&dentry->d_lockref)) { in d_alloc_parallel()
2705 spin_lock(&dentry->d_lock); in d_alloc_parallel()
2706 d_wait_lookup(dentry); in d_alloc_parallel()
2713 if (unlikely(dentry->d_name.hash != hash)) in d_alloc_parallel()
2715 if (unlikely(dentry->d_parent != parent)) in d_alloc_parallel()
2717 if (unlikely(d_unhashed(dentry))) in d_alloc_parallel()
2719 if (unlikely(!d_same_name(dentry, parent, name))) in d_alloc_parallel()
2722 spin_unlock(&dentry->d_lock); in d_alloc_parallel()
2724 return dentry; in d_alloc_parallel()
2734 spin_unlock(&dentry->d_lock); in d_alloc_parallel()
2735 dput(dentry); in d_alloc_parallel()
2745 static wait_queue_head_t *__d_lookup_unhash(struct dentry *dentry) in __d_lookup_unhash() argument
2750 lockdep_assert_held(&dentry->d_lock); in __d_lookup_unhash()
2752 b = in_lookup_hash(dentry->d_parent, dentry->d_name.hash); in __d_lookup_unhash()
2754 dentry->d_flags &= ~DCACHE_PAR_LOOKUP; in __d_lookup_unhash()
2755 __hlist_bl_del(&dentry->d_u.d_in_lookup_hash); in __d_lookup_unhash()
2756 d_wait = dentry->d_wait; in __d_lookup_unhash()
2757 dentry->d_wait = NULL; in __d_lookup_unhash()
2759 INIT_HLIST_NODE(&dentry->d_u.d_alias); in __d_lookup_unhash()
2760 INIT_LIST_HEAD(&dentry->d_lru); in __d_lookup_unhash()
2764 void __d_lookup_unhash_wake(struct dentry *dentry) in __d_lookup_unhash_wake() argument
2766 spin_lock(&dentry->d_lock); in __d_lookup_unhash_wake()
2767 wake_up_all(__d_lookup_unhash(dentry)); in __d_lookup_unhash_wake()
2768 spin_unlock(&dentry->d_lock); in __d_lookup_unhash_wake()
2774 static inline void __d_add(struct dentry *dentry, struct inode *inode) in __d_add() argument
2779 spin_lock(&dentry->d_lock); in __d_add()
2780 if (unlikely(d_in_lookup(dentry))) { in __d_add()
2781 dir = dentry->d_parent->d_inode; in __d_add()
2783 d_wait = __d_lookup_unhash(dentry); in __d_add()
2787 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); in __d_add()
2788 raw_write_seqcount_begin(&dentry->d_seq); in __d_add()
2789 __d_set_inode_and_type(dentry, inode, add_flags); in __d_add()
2790 raw_write_seqcount_end(&dentry->d_seq); in __d_add()
2791 fsnotify_update_flags(dentry); in __d_add()
2793 __d_rehash(dentry); in __d_add()
2796 spin_unlock(&dentry->d_lock); in __d_add()
2810 void d_add(struct dentry *entry, struct inode *inode) in d_add()
2831 struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode) in d_exact_alias()
2833 struct dentry *alias; in d_exact_alias()
2866 static void swap_names(struct dentry *dentry, struct dentry *target) in swap_names() argument
2869 if (unlikely(dname_external(dentry))) { in swap_names()
2873 swap(target->d_name.name, dentry->d_name.name); in swap_names()
2879 memcpy(target->d_iname, dentry->d_name.name, in swap_names()
2880 dentry->d_name.len + 1); in swap_names()
2881 dentry->d_name.name = target->d_name.name; in swap_names()
2885 if (unlikely(dname_external(dentry))) { in swap_names()
2890 memcpy(dentry->d_iname, target->d_name.name, in swap_names()
2892 target->d_name.name = dentry->d_name.name; in swap_names()
2893 dentry->d_name.name = dentry->d_iname; in swap_names()
2901 swap(((long *) &dentry->d_iname)[i], in swap_names()
2906 swap(dentry->d_name.hash_len, target->d_name.hash_len); in swap_names()
2909 static void copy_name(struct dentry *dentry, struct dentry *target) in copy_name() argument
2912 if (unlikely(dname_external(dentry))) in copy_name()
2913 old_name = external_name(dentry); in copy_name()
2916 dentry->d_name = target->d_name; in copy_name()
2918 memcpy(dentry->d_iname, target->d_name.name, in copy_name()
2920 dentry->d_name.name = dentry->d_iname; in copy_name()
2921 dentry->d_name.hash_len = target->d_name.hash_len; in copy_name()
2938 static void __d_move(struct dentry *dentry, struct dentry *target, in __d_move() argument
2941 struct dentry *old_parent, *p; in __d_move()
2946 WARN_ON(!dentry->d_inode); in __d_move()
2947 if (WARN_ON(dentry == target)) in __d_move()
2950 BUG_ON(d_ancestor(target, dentry)); in __d_move()
2951 old_parent = dentry->d_parent; in __d_move()
2953 if (IS_ROOT(dentry)) { in __d_move()
2961 BUG_ON(p == dentry); in __d_move()
2967 spin_lock_nested(&dentry->d_lock, 2); in __d_move()
2976 write_seqcount_begin(&dentry->d_seq); in __d_move()
2980 if (!d_unhashed(dentry)) in __d_move()
2981 ___d_drop(dentry); in __d_move()
2986 dentry->d_parent = target->d_parent; in __d_move()
2988 copy_name(dentry, target); in __d_move()
2990 dentry->d_parent->d_lockref.count++; in __d_move()
2991 if (dentry != old_parent) /* wasn't IS_ROOT */ in __d_move()
2995 swap_names(dentry, target); in __d_move()
3000 list_move(&dentry->d_child, &dentry->d_parent->d_subdirs); in __d_move()
3001 __d_rehash(dentry); in __d_move()
3002 fsnotify_update_flags(dentry); in __d_move()
3003 fscrypt_handle_d_move(dentry); in __d_move()
3006 write_seqcount_end(&dentry->d_seq); in __d_move()
3011 if (dentry->d_parent != old_parent) in __d_move()
3012 spin_unlock(&dentry->d_parent->d_lock); in __d_move()
3013 if (dentry != old_parent) in __d_move()
3016 spin_unlock(&dentry->d_lock); in __d_move()
3028 void d_move(struct dentry *dentry, struct dentry *target) in d_move() argument
3031 __d_move(dentry, target, false); in d_move()
3041 void d_exchange(struct dentry *dentry1, struct dentry *dentry2) in d_exchange()
3063 struct dentry *d_ancestor(struct dentry *p1, struct dentry *p2) in d_ancestor()
3065 struct dentry *p; in d_ancestor()
3084 struct dentry *dentry, struct dentry *alias) in __d_unalias() argument
3091 if (alias->d_parent == dentry->d_parent) in __d_unalias()
3095 if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex)) in __d_unalias()
3097 m1 = &dentry->d_sb->s_vfs_rename_mutex; in __d_unalias()
3102 __d_move(alias, dentry, false); in __d_unalias()
3135 struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) in d_splice_alias() argument
3140 BUG_ON(!d_unhashed(dentry)); in d_splice_alias()
3145 security_d_instantiate(dentry, inode); in d_splice_alias()
3148 struct dentry *new = __d_find_any_alias(inode); in d_splice_alias()
3153 if (unlikely(d_ancestor(new, dentry))) { in d_splice_alias()
3160 dentry->d_name.name, in d_splice_alias()
3164 struct dentry *old_parent = dget(new->d_parent); in d_splice_alias()
3165 int err = __d_unalias(inode, dentry, new); in d_splice_alias()
3173 __d_move(new, dentry, false); in d_splice_alias()
3181 __d_add(dentry, inode); in d_splice_alias()
3202 bool is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) in is_subdir()
3229 static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry) in d_genocide_kill() argument
3231 struct dentry *root = data; in d_genocide_kill()
3232 if (dentry != root) { in d_genocide_kill()
3233 if (d_unhashed(dentry) || !dentry->d_inode) in d_genocide_kill()
3236 if (!(dentry->d_flags & DCACHE_GENOCIDE)) { in d_genocide_kill()
3237 dentry->d_flags |= DCACHE_GENOCIDE; in d_genocide_kill()
3238 dentry->d_lockref.count--; in d_genocide_kill()
3244 void d_genocide(struct dentry *parent) in d_genocide()
3251 struct dentry *dentry = file->f_path.dentry; in d_tmpfile() local
3254 BUG_ON(dentry->d_name.name != dentry->d_iname || in d_tmpfile()
3255 !hlist_unhashed(&dentry->d_u.d_alias) || in d_tmpfile()
3256 !d_unlinked(dentry)); in d_tmpfile()
3257 spin_lock(&dentry->d_parent->d_lock); in d_tmpfile()
3258 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); in d_tmpfile()
3259 dentry->d_name.len = sprintf(dentry->d_iname, "#%llu", in d_tmpfile()
3261 spin_unlock(&dentry->d_lock); in d_tmpfile()
3262 spin_unlock(&dentry->d_parent->d_lock); in d_tmpfile()
3263 d_instantiate(dentry, inode); in d_tmpfile()
3305 dentry_cache = KMEM_CACHE_USERCOPY(dentry, in dcache_init()