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()
1680 static void do_one_tree(struct dentry *dentry) in do_one_tree() argument
1682 shrink_dcache_parent(dentry); in do_one_tree()
1683 d_walk(dentry, dentry, umount_check); in do_one_tree()
1684 d_drop(dentry); in do_one_tree()
1685 dput(dentry); in do_one_tree()
1693 struct dentry *dentry; in shrink_dcache_for_umount() local
1697 dentry = sb->s_root; in shrink_dcache_for_umount()
1699 do_one_tree(dentry); in shrink_dcache_for_umount()
1702 dentry = dget(hlist_bl_entry(hlist_bl_first(&sb->s_roots), struct dentry, d_hash)); in shrink_dcache_for_umount()
1703 do_one_tree(dentry); in shrink_dcache_for_umount()
1707 static enum d_walk_ret find_submount(void *_data, struct dentry *dentry) in find_submount() argument
1709 struct dentry **victim = _data; in find_submount()
1710 if (d_mountpoint(dentry)) { in find_submount()
1711 __dget_dlock(dentry); in find_submount()
1712 *victim = dentry; in find_submount()
1722 void d_invalidate(struct dentry *dentry) in d_invalidate() argument
1725 spin_lock(&dentry->d_lock); in d_invalidate()
1726 if (d_unhashed(dentry)) { in d_invalidate()
1727 spin_unlock(&dentry->d_lock); in d_invalidate()
1730 __d_drop(dentry); in d_invalidate()
1731 spin_unlock(&dentry->d_lock); in d_invalidate()
1734 if (!dentry->d_inode) in d_invalidate()
1737 shrink_dcache_parent(dentry); in d_invalidate()
1739 struct dentry *victim = NULL; in d_invalidate()
1740 d_walk(dentry, &victim, find_submount); in d_invalidate()
1743 shrink_dcache_parent(dentry); in d_invalidate()
1763 static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) in __d_alloc()
1765 struct dentry *dentry; in __d_alloc() local
1769 dentry = kmem_cache_alloc_lru(dentry_cache, &sb->s_dentry_lru, in __d_alloc()
1771 if (!dentry) in __d_alloc()
1780 dentry->d_iname[DNAME_INLINE_LEN-1] = 0; in __d_alloc()
1783 dname = dentry->d_iname; in __d_alloc()
1790 kmem_cache_free(dentry_cache, dentry); in __d_alloc()
1796 dname = dentry->d_iname; in __d_alloc()
1799 dentry->d_name.len = name->len; in __d_alloc()
1800 dentry->d_name.hash = name->hash; in __d_alloc()
1805 smp_store_release(&dentry->d_name.name, dname); /* ^^^ */ in __d_alloc()
1807 dentry->d_lockref.count = 1; in __d_alloc()
1808 dentry->d_flags = 0; in __d_alloc()
1809 spin_lock_init(&dentry->d_lock); in __d_alloc()
1810 seqcount_spinlock_init(&dentry->d_seq, &dentry->d_lock); in __d_alloc()
1811 dentry->d_inode = NULL; in __d_alloc()
1812 dentry->d_parent = dentry; in __d_alloc()
1813 dentry->d_sb = sb; in __d_alloc()
1814 dentry->d_op = NULL; in __d_alloc()
1815 dentry->d_fsdata = NULL; in __d_alloc()
1816 INIT_HLIST_BL_NODE(&dentry->d_hash); in __d_alloc()
1817 INIT_LIST_HEAD(&dentry->d_lru); in __d_alloc()
1818 INIT_LIST_HEAD(&dentry->d_subdirs); in __d_alloc()
1819 INIT_HLIST_NODE(&dentry->d_u.d_alias); in __d_alloc()
1820 INIT_LIST_HEAD(&dentry->d_child); in __d_alloc()
1821 d_set_d_op(dentry, dentry->d_sb->s_d_op); in __d_alloc()
1823 if (dentry->d_op && dentry->d_op->d_init) { in __d_alloc()
1824 err = dentry->d_op->d_init(dentry); in __d_alloc()
1826 if (dname_external(dentry)) in __d_alloc()
1827 kfree(external_name(dentry)); in __d_alloc()
1828 kmem_cache_free(dentry_cache, dentry); in __d_alloc()
1835 return dentry; in __d_alloc()
1847 struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) in d_alloc()
1849 struct dentry *dentry = __d_alloc(parent->d_sb, name); in d_alloc() local
1850 if (!dentry) in d_alloc()
1858 dentry->d_parent = parent; in d_alloc()
1859 list_add(&dentry->d_child, &parent->d_subdirs); in d_alloc()
1862 return dentry; in d_alloc()
1866 struct dentry *d_alloc_anon(struct super_block *sb) in d_alloc_anon()
1872 struct dentry *d_alloc_cursor(struct dentry * parent) in d_alloc_cursor()
1874 struct dentry *dentry = d_alloc_anon(parent->d_sb); in d_alloc_cursor() local
1875 if (dentry) { in d_alloc_cursor()
1876 dentry->d_flags |= DCACHE_DENTRY_CURSOR; in d_alloc_cursor()
1877 dentry->d_parent = dget(parent); in d_alloc_cursor()
1879 return dentry; in d_alloc_cursor()
1897 struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) in d_alloc_pseudo()
1899 struct dentry *dentry = __d_alloc(sb, name); in d_alloc_pseudo() local
1900 if (likely(dentry)) in d_alloc_pseudo()
1901 dentry->d_flags |= DCACHE_NORCU; in d_alloc_pseudo()
1902 return dentry; in d_alloc_pseudo()
1905 struct dentry *d_alloc_name(struct dentry *parent, const char *name) in d_alloc_name()
1915 void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) in d_set_d_op() argument
1917 WARN_ON_ONCE(dentry->d_op); in d_set_d_op()
1918 WARN_ON_ONCE(dentry->d_flags & (DCACHE_OP_HASH | in d_set_d_op()
1924 dentry->d_op = op; in d_set_d_op()
1928 dentry->d_flags |= DCACHE_OP_HASH; in d_set_d_op()
1930 dentry->d_flags |= DCACHE_OP_COMPARE; in d_set_d_op()
1932 dentry->d_flags |= DCACHE_OP_REVALIDATE; in d_set_d_op()
1934 dentry->d_flags |= DCACHE_OP_WEAK_REVALIDATE; in d_set_d_op()
1936 dentry->d_flags |= DCACHE_OP_DELETE; in d_set_d_op()
1938 dentry->d_flags |= DCACHE_OP_PRUNE; in d_set_d_op()
1940 dentry->d_flags |= DCACHE_OP_REAL; in d_set_d_op()
1953 void d_set_fallthru(struct dentry *dentry) in d_set_fallthru() argument
1955 spin_lock(&dentry->d_lock); in d_set_fallthru()
1956 dentry->d_flags |= DCACHE_FALLTHRU; in d_set_fallthru()
1957 spin_unlock(&dentry->d_lock); in d_set_fallthru()
1996 static void __d_instantiate(struct dentry *dentry, struct inode *inode) in __d_instantiate() argument
1999 WARN_ON(d_in_lookup(dentry)); in __d_instantiate()
2001 spin_lock(&dentry->d_lock); in __d_instantiate()
2005 if (dentry->d_flags & DCACHE_LRU_LIST) in __d_instantiate()
2007 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); in __d_instantiate()
2008 raw_write_seqcount_begin(&dentry->d_seq); in __d_instantiate()
2009 __d_set_inode_and_type(dentry, inode, add_flags); in __d_instantiate()
2010 raw_write_seqcount_end(&dentry->d_seq); in __d_instantiate()
2011 fsnotify_update_flags(dentry); in __d_instantiate()
2012 spin_unlock(&dentry->d_lock); in __d_instantiate()
2030 void d_instantiate(struct dentry *entry, struct inode * inode) in d_instantiate()
2048 void d_instantiate_new(struct dentry *entry, struct inode *inode) in d_instantiate_new()
2064 struct dentry *d_make_root(struct inode *root_inode) in d_make_root()
2066 struct dentry *res = NULL; in d_make_root()
2079 static struct dentry *__d_instantiate_anon(struct dentry *dentry, in __d_instantiate_anon() argument
2083 struct dentry *res; in __d_instantiate_anon()
2086 security_d_instantiate(dentry, inode); in __d_instantiate_anon()
2091 dput(dentry); in __d_instantiate_anon()
2101 spin_lock(&dentry->d_lock); in __d_instantiate_anon()
2102 __d_set_inode_and_type(dentry, inode, add_flags); in __d_instantiate_anon()
2103 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); in __d_instantiate_anon()
2105 hlist_bl_lock(&dentry->d_sb->s_roots); in __d_instantiate_anon()
2106 hlist_bl_add_head(&dentry->d_hash, &dentry->d_sb->s_roots); in __d_instantiate_anon()
2107 hlist_bl_unlock(&dentry->d_sb->s_roots); in __d_instantiate_anon()
2109 spin_unlock(&dentry->d_lock); in __d_instantiate_anon()
2112 return dentry; in __d_instantiate_anon()
2119 struct dentry *d_instantiate_anon(struct dentry *dentry, struct inode *inode) in d_instantiate_anon() argument
2121 return __d_instantiate_anon(dentry, inode, true); in d_instantiate_anon()
2125 static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected) in __d_obtain_alias()
2127 struct dentry *tmp; in __d_obtain_alias()
2128 struct dentry *res; in __d_obtain_alias()
2170 struct dentry *d_obtain_alias(struct inode *inode) in d_obtain_alias()
2191 struct dentry *d_obtain_root(struct inode *inode) in d_obtain_root()
2213 struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, in d_add_ci() argument
2216 struct dentry *found, *res; in d_add_ci()
2222 found = d_hash_and_lookup(dentry->d_parent, name); in d_add_ci()
2227 if (d_in_lookup(dentry)) { in d_add_ci()
2228 found = d_alloc_parallel(dentry->d_parent, name, in d_add_ci()
2229 dentry->d_wait); in d_add_ci()
2235 found = d_alloc(dentry->d_parent, name); in d_add_ci()
2259 bool d_same_name(const struct dentry *dentry, const struct dentry *parent, in d_same_name() argument
2263 if (dentry->d_name.len != name->len) in d_same_name()
2265 return dentry_cmp(dentry, name->name, name->len) == 0; in d_same_name()
2267 return parent->d_op->d_compare(dentry, in d_same_name()
2268 dentry->d_name.len, dentry->d_name.name, in d_same_name()
2277 static noinline struct dentry *__d_lookup_rcu_op_compare( in __d_lookup_rcu_op_compare()
2278 const struct dentry *parent, in __d_lookup_rcu_op_compare()
2285 struct dentry *dentry; in __d_lookup_rcu_op_compare() local
2287 hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { in __d_lookup_rcu_op_compare()
2293 seq = raw_seqcount_begin(&dentry->d_seq); in __d_lookup_rcu_op_compare()
2294 if (dentry->d_parent != parent) in __d_lookup_rcu_op_compare()
2296 if (d_unhashed(dentry)) in __d_lookup_rcu_op_compare()
2298 if (dentry->d_name.hash != hashlen_hash(hashlen)) in __d_lookup_rcu_op_compare()
2300 tlen = dentry->d_name.len; in __d_lookup_rcu_op_compare()
2301 tname = dentry->d_name.name; in __d_lookup_rcu_op_compare()
2303 if (read_seqcount_retry(&dentry->d_seq, seq)) { in __d_lookup_rcu_op_compare()
2307 if (parent->d_op->d_compare(dentry, tlen, tname, name) != 0) in __d_lookup_rcu_op_compare()
2310 return dentry; in __d_lookup_rcu_op_compare()
2344 struct dentry *__d_lookup_rcu(const struct dentry *parent, in __d_lookup_rcu()
2352 struct dentry *dentry; in __d_lookup_rcu() local
2377 hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { in __d_lookup_rcu()
2397 seq = raw_seqcount_begin(&dentry->d_seq); in __d_lookup_rcu()
2398 if (dentry->d_parent != parent) in __d_lookup_rcu()
2400 if (d_unhashed(dentry)) in __d_lookup_rcu()
2402 if (dentry->d_name.hash_len != hashlen) in __d_lookup_rcu()
2404 if (dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0) in __d_lookup_rcu()
2407 return dentry; in __d_lookup_rcu()
2423 struct dentry *d_lookup(const struct dentry *parent, const struct qstr *name) in d_lookup()
2425 struct dentry *dentry; in d_lookup() local
2430 dentry = __d_lookup(parent, name); in d_lookup()
2431 if (dentry) in d_lookup()
2434 return dentry; in d_lookup()
2453 struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name) in __d_lookup()
2458 struct dentry *found = NULL; in __d_lookup()
2459 struct dentry *dentry; in __d_lookup() local
2483 hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { in __d_lookup()
2485 if (dentry->d_name.hash != hash) in __d_lookup()
2488 spin_lock(&dentry->d_lock); in __d_lookup()
2489 if (dentry->d_parent != parent) in __d_lookup()
2491 if (d_unhashed(dentry)) in __d_lookup()
2494 if (!d_same_name(dentry, parent, name)) in __d_lookup()
2497 dentry->d_lockref.count++; in __d_lookup()
2498 found = dentry; in __d_lookup()
2499 spin_unlock(&dentry->d_lock); in __d_lookup()
2502 spin_unlock(&dentry->d_lock); in __d_lookup()
2516 struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) in d_hash_and_lookup()
2554 void d_delete(struct dentry * dentry) in d_delete() argument
2556 struct inode *inode = dentry->d_inode; in d_delete()
2559 spin_lock(&dentry->d_lock); in d_delete()
2563 if (dentry->d_lockref.count == 1) { in d_delete()
2564 dentry->d_flags &= ~DCACHE_CANT_MOUNT; in d_delete()
2565 dentry_unlink_inode(dentry); in d_delete()
2567 __d_drop(dentry); in d_delete()
2568 spin_unlock(&dentry->d_lock); in d_delete()
2574 static void __d_rehash(struct dentry *entry) in __d_rehash()
2590 void d_rehash(struct dentry * entry) in d_rehash()
2617 static void d_wait_lookup(struct dentry *dentry) in d_wait_lookup() argument
2619 if (d_in_lookup(dentry)) { in d_wait_lookup()
2621 add_wait_queue(dentry->d_wait, &wait); in d_wait_lookup()
2624 spin_unlock(&dentry->d_lock); in d_wait_lookup()
2626 spin_lock(&dentry->d_lock); in d_wait_lookup()
2627 } while (d_in_lookup(dentry)); in d_wait_lookup()
2631 struct dentry *d_alloc_parallel(struct dentry *parent, in d_alloc_parallel()
2638 struct dentry *new = d_alloc(parent, name); in d_alloc_parallel()
2639 struct dentry *dentry; in d_alloc_parallel() local
2649 dentry = __d_lookup_rcu(parent, name, &d_seq); in d_alloc_parallel()
2650 if (unlikely(dentry)) { in d_alloc_parallel()
2651 if (!lockref_get_not_dead(&dentry->d_lockref)) { in d_alloc_parallel()
2655 if (read_seqcount_retry(&dentry->d_seq, d_seq)) { in d_alloc_parallel()
2657 dput(dentry); in d_alloc_parallel()
2662 return dentry; in d_alloc_parallel()
2687 hlist_bl_for_each_entry(dentry, node, b, d_u.d_in_lookup_hash) { in d_alloc_parallel()
2688 if (dentry->d_name.hash != hash) in d_alloc_parallel()
2690 if (dentry->d_parent != parent) in d_alloc_parallel()
2692 if (!d_same_name(dentry, parent, name)) in d_alloc_parallel()
2696 if (!lockref_get_not_dead(&dentry->d_lockref)) { in d_alloc_parallel()
2706 spin_lock(&dentry->d_lock); in d_alloc_parallel()
2707 d_wait_lookup(dentry); in d_alloc_parallel()
2714 if (unlikely(dentry->d_name.hash != hash)) in d_alloc_parallel()
2716 if (unlikely(dentry->d_parent != parent)) in d_alloc_parallel()
2718 if (unlikely(d_unhashed(dentry))) in d_alloc_parallel()
2720 if (unlikely(!d_same_name(dentry, parent, name))) in d_alloc_parallel()
2723 spin_unlock(&dentry->d_lock); in d_alloc_parallel()
2725 return dentry; in d_alloc_parallel()
2735 spin_unlock(&dentry->d_lock); in d_alloc_parallel()
2736 dput(dentry); in d_alloc_parallel()
2746 static wait_queue_head_t *__d_lookup_unhash(struct dentry *dentry) in __d_lookup_unhash() argument
2751 lockdep_assert_held(&dentry->d_lock); in __d_lookup_unhash()
2753 b = in_lookup_hash(dentry->d_parent, dentry->d_name.hash); in __d_lookup_unhash()
2755 dentry->d_flags &= ~DCACHE_PAR_LOOKUP; in __d_lookup_unhash()
2756 __hlist_bl_del(&dentry->d_u.d_in_lookup_hash); in __d_lookup_unhash()
2757 d_wait = dentry->d_wait; in __d_lookup_unhash()
2758 dentry->d_wait = NULL; in __d_lookup_unhash()
2760 INIT_HLIST_NODE(&dentry->d_u.d_alias); in __d_lookup_unhash()
2761 INIT_LIST_HEAD(&dentry->d_lru); in __d_lookup_unhash()
2765 void __d_lookup_unhash_wake(struct dentry *dentry) in __d_lookup_unhash_wake() argument
2767 spin_lock(&dentry->d_lock); in __d_lookup_unhash_wake()
2768 wake_up_all(__d_lookup_unhash(dentry)); in __d_lookup_unhash_wake()
2769 spin_unlock(&dentry->d_lock); in __d_lookup_unhash_wake()
2775 static inline void __d_add(struct dentry *dentry, struct inode *inode) in __d_add() argument
2780 spin_lock(&dentry->d_lock); in __d_add()
2781 if (unlikely(d_in_lookup(dentry))) { in __d_add()
2782 dir = dentry->d_parent->d_inode; in __d_add()
2784 d_wait = __d_lookup_unhash(dentry); in __d_add()
2788 hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry); in __d_add()
2789 raw_write_seqcount_begin(&dentry->d_seq); in __d_add()
2790 __d_set_inode_and_type(dentry, inode, add_flags); in __d_add()
2791 raw_write_seqcount_end(&dentry->d_seq); in __d_add()
2792 fsnotify_update_flags(dentry); in __d_add()
2794 __d_rehash(dentry); in __d_add()
2797 spin_unlock(&dentry->d_lock); in __d_add()
2811 void d_add(struct dentry *entry, struct inode *inode) in d_add()
2832 struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode) in d_exact_alias()
2834 struct dentry *alias; in d_exact_alias()
2867 static void swap_names(struct dentry *dentry, struct dentry *target) in swap_names() argument
2870 if (unlikely(dname_external(dentry))) { in swap_names()
2874 swap(target->d_name.name, dentry->d_name.name); in swap_names()
2880 memcpy(target->d_iname, dentry->d_name.name, in swap_names()
2881 dentry->d_name.len + 1); in swap_names()
2882 dentry->d_name.name = target->d_name.name; in swap_names()
2886 if (unlikely(dname_external(dentry))) { in swap_names()
2891 memcpy(dentry->d_iname, target->d_name.name, in swap_names()
2893 target->d_name.name = dentry->d_name.name; in swap_names()
2894 dentry->d_name.name = dentry->d_iname; in swap_names()
2902 swap(((long *) &dentry->d_iname)[i], in swap_names()
2907 swap(dentry->d_name.hash_len, target->d_name.hash_len); in swap_names()
2910 static void copy_name(struct dentry *dentry, struct dentry *target) in copy_name() argument
2913 if (unlikely(dname_external(dentry))) in copy_name()
2914 old_name = external_name(dentry); in copy_name()
2917 dentry->d_name = target->d_name; in copy_name()
2919 memcpy(dentry->d_iname, target->d_name.name, in copy_name()
2921 dentry->d_name.name = dentry->d_iname; in copy_name()
2922 dentry->d_name.hash_len = target->d_name.hash_len; in copy_name()
2939 static void __d_move(struct dentry *dentry, struct dentry *target, in __d_move() argument
2942 struct dentry *old_parent, *p; in __d_move()
2947 WARN_ON(!dentry->d_inode); in __d_move()
2948 if (WARN_ON(dentry == target)) in __d_move()
2951 BUG_ON(d_ancestor(target, dentry)); in __d_move()
2952 old_parent = dentry->d_parent; in __d_move()
2954 if (IS_ROOT(dentry)) { in __d_move()
2962 BUG_ON(p == dentry); in __d_move()
2968 spin_lock_nested(&dentry->d_lock, 2); in __d_move()
2977 write_seqcount_begin(&dentry->d_seq); in __d_move()
2981 if (!d_unhashed(dentry)) in __d_move()
2982 ___d_drop(dentry); in __d_move()
2987 dentry->d_parent = target->d_parent; in __d_move()
2989 copy_name(dentry, target); in __d_move()
2991 dentry->d_parent->d_lockref.count++; in __d_move()
2992 if (dentry != old_parent) /* wasn't IS_ROOT */ in __d_move()
2996 swap_names(dentry, target); in __d_move()
3001 list_move(&dentry->d_child, &dentry->d_parent->d_subdirs); in __d_move()
3002 __d_rehash(dentry); in __d_move()
3003 fsnotify_update_flags(dentry); in __d_move()
3004 fscrypt_handle_d_move(dentry); in __d_move()
3007 write_seqcount_end(&dentry->d_seq); in __d_move()
3012 if (dentry->d_parent != old_parent) in __d_move()
3013 spin_unlock(&dentry->d_parent->d_lock); in __d_move()
3014 if (dentry != old_parent) in __d_move()
3017 spin_unlock(&dentry->d_lock); in __d_move()
3029 void d_move(struct dentry *dentry, struct dentry *target) in d_move() argument
3032 __d_move(dentry, target, false); in d_move()
3042 void d_exchange(struct dentry *dentry1, struct dentry *dentry2) in d_exchange()
3064 struct dentry *d_ancestor(struct dentry *p1, struct dentry *p2) in d_ancestor()
3066 struct dentry *p; in d_ancestor()
3085 struct dentry *dentry, struct dentry *alias) in __d_unalias() argument
3092 if (alias->d_parent == dentry->d_parent) in __d_unalias()
3096 if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex)) in __d_unalias()
3098 m1 = &dentry->d_sb->s_vfs_rename_mutex; in __d_unalias()
3103 __d_move(alias, dentry, false); in __d_unalias()
3136 struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) in d_splice_alias() argument
3141 BUG_ON(!d_unhashed(dentry)); in d_splice_alias()
3146 security_d_instantiate(dentry, inode); in d_splice_alias()
3149 struct dentry *new = __d_find_any_alias(inode); in d_splice_alias()
3154 if (unlikely(d_ancestor(new, dentry))) { in d_splice_alias()
3161 dentry->d_name.name, in d_splice_alias()
3165 struct dentry *old_parent = dget(new->d_parent); in d_splice_alias()
3166 int err = __d_unalias(inode, dentry, new); in d_splice_alias()
3174 __d_move(new, dentry, false); in d_splice_alias()
3182 __d_add(dentry, inode); in d_splice_alias()
3203 bool is_subdir(struct dentry *new_dentry, struct dentry *old_dentry) in is_subdir()
3230 static enum d_walk_ret d_genocide_kill(void *data, struct dentry *dentry) in d_genocide_kill() argument
3232 struct dentry *root = data; in d_genocide_kill()
3233 if (dentry != root) { in d_genocide_kill()
3234 if (d_unhashed(dentry) || !dentry->d_inode) in d_genocide_kill()
3237 if (!(dentry->d_flags & DCACHE_GENOCIDE)) { in d_genocide_kill()
3238 dentry->d_flags |= DCACHE_GENOCIDE; in d_genocide_kill()
3239 dentry->d_lockref.count--; in d_genocide_kill()
3245 void d_genocide(struct dentry *parent) in d_genocide()
3254 struct dentry *dentry = file->f_path.dentry; in d_tmpfile() local
3257 BUG_ON(dentry->d_name.name != dentry->d_iname || in d_tmpfile()
3258 !hlist_unhashed(&dentry->d_u.d_alias) || in d_tmpfile()
3259 !d_unlinked(dentry)); in d_tmpfile()
3260 spin_lock(&dentry->d_parent->d_lock); in d_tmpfile()
3261 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); in d_tmpfile()
3262 dentry->d_name.len = sprintf(dentry->d_iname, "#%llu", in d_tmpfile()
3264 spin_unlock(&dentry->d_lock); in d_tmpfile()
3265 spin_unlock(&dentry->d_parent->d_lock); in d_tmpfile()
3266 d_instantiate(dentry, inode); in d_tmpfile()
3308 dentry_cache = KMEM_CACHE_USERCOPY(dentry, in dcache_init()