Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dentries: Extract common code to remove dentry from lru

Extract the common code to remove a dentry from the lru into a new function
dentry_lru_remove().

Two call sites used list_del() instead of list_del_init(). AFAIK the
performance of both is the same. dentry_lru_remove() does a list_del_init().

As a result dentry->d_lru is now always empty when a dentry is freed.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christoph Lameter and committed by
Linus Torvalds
4a0962ab cf28b486

+14 -28
+14 -28
fs/dcache.c
··· 95 95 call_rcu(&dentry->d_u.d_rcu, d_callback); 96 96 } 97 97 98 + static void dentry_lru_remove(struct dentry *dentry) 99 + { 100 + if (!list_empty(&dentry->d_lru)) { 101 + list_del_init(&dentry->d_lru); 102 + dentry_stat.nr_unused--; 103 + } 104 + } 105 + 98 106 /* 99 107 * Release the dentry's inode, using the filesystem 100 108 * d_iput() operation if defined. ··· 219 211 unhash_it: 220 212 __d_drop(dentry); 221 213 kill_it: 222 - /* If dentry was on d_lru list 223 - * delete it from there 224 - */ 225 - if (!list_empty(&dentry->d_lru)) { 226 - list_del(&dentry->d_lru); 227 - dentry_stat.nr_unused--; 228 - } 214 + dentry_lru_remove(dentry); 229 215 dentry = d_kill(dentry); 230 216 if (dentry) 231 217 goto repeat; ··· 287 285 static inline struct dentry * __dget_locked(struct dentry *dentry) 288 286 { 289 287 atomic_inc(&dentry->d_count); 290 - if (!list_empty(&dentry->d_lru)) { 291 - dentry_stat.nr_unused--; 292 - list_del_init(&dentry->d_lru); 293 - } 288 + dentry_lru_remove(dentry); 294 289 return dentry; 295 290 } 296 291 ··· 403 404 404 405 if (dentry->d_op && dentry->d_op->d_delete) 405 406 dentry->d_op->d_delete(dentry); 406 - if (!list_empty(&dentry->d_lru)) { 407 - list_del(&dentry->d_lru); 408 - dentry_stat.nr_unused--; 409 - } 407 + dentry_lru_remove(dentry); 410 408 __d_drop(dentry); 411 409 dentry = d_kill(dentry); 412 410 spin_lock(&dcache_lock); ··· 592 596 593 597 /* detach this root from the system */ 594 598 spin_lock(&dcache_lock); 595 - if (!list_empty(&dentry->d_lru)) { 596 - dentry_stat.nr_unused--; 597 - list_del_init(&dentry->d_lru); 598 - } 599 + dentry_lru_remove(dentry); 599 600 __d_drop(dentry); 600 601 spin_unlock(&dcache_lock); 601 602 ··· 606 613 spin_lock(&dcache_lock); 607 614 list_for_each_entry(loop, &dentry->d_subdirs, 608 615 d_u.d_child) { 609 - if (!list_empty(&loop->d_lru)) { 610 - dentry_stat.nr_unused--; 611 - list_del_init(&loop->d_lru); 612 - } 613 - 616 + dentry_lru_remove(loop); 614 617 __d_drop(loop); 615 618 cond_resched_lock(&dcache_lock); 616 619 } ··· 788 799 struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child); 789 800 next = tmp->next; 790 801 791 - if (!list_empty(&dentry->d_lru)) { 792 - dentry_stat.nr_unused--; 793 - list_del_init(&dentry->d_lru); 794 - } 802 + dentry_lru_remove(dentry); 795 803 /* 796 804 * move only zero ref count dentries to the end 797 805 * of the unused list for prune_dcache