aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2007-10-17 02:29:53 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:57 -0400
commit37c42524d6090644206ae6d310d7e830bd3ccb47 (patch)
tree53dcaad31bb6b74d1d37491b56450a675490b88b /fs/dcache.c
parent44a2db43eb715b54618bf01520cc5d46376cdbe2 (diff)
shrink_dcache_sb speedup
This patch makes shrink_dcache_sb consistent with dentry pruning policy. On the first pass we iterate over dentry unused list and prepare some dentries for removal. However, since the existing code moves evicted dentries to the beginning of the LRU it can happen that fresh dentries from other superblocks will be inserted *before* our dentries. This can result in significant slowdown of shrink_dcache_sb(). Moreover, for virtual filesystems like unionfs which can call dput() during dentries kill existing code results in O(n^2) complexity. We observed 2 minutes shrink_dcache_sb() with only 35000 dentries. To avoid this effects we propose to isolate sb dentries at the end of LRU list. Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Kirill Korotaev <dev@openvz.org> Signed-off-by: Andrey Mirkin <amirkin@openvz.org> Cc: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 5cdd14e95858..42d290be0ac1 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -553,18 +553,18 @@ void shrink_dcache_sb(struct super_block * sb)
553 * superblock to the most recent end of the unused list. 553 * superblock to the most recent end of the unused list.
554 */ 554 */
555 spin_lock(&dcache_lock); 555 spin_lock(&dcache_lock);
556 list_for_each_safe(tmp, next, &dentry_unused) { 556 list_for_each_prev_safe(tmp, next, &dentry_unused) {
557 dentry = list_entry(tmp, struct dentry, d_lru); 557 dentry = list_entry(tmp, struct dentry, d_lru);
558 if (dentry->d_sb != sb) 558 if (dentry->d_sb != sb)
559 continue; 559 continue;
560 list_move(tmp, &dentry_unused); 560 list_move_tail(tmp, &dentry_unused);
561 } 561 }
562 562
563 /* 563 /*
564 * Pass two ... free the dentries for this superblock. 564 * Pass two ... free the dentries for this superblock.
565 */ 565 */
566repeat: 566repeat:
567 list_for_each_safe(tmp, next, &dentry_unused) { 567 list_for_each_prev_safe(tmp, next, &dentry_unused) {
568 dentry = list_entry(tmp, struct dentry, d_lru); 568 dentry = list_entry(tmp, struct dentry, d_lru);
569 if (dentry->d_sb != sb) 569 if (dentry->d_sb != sb)
570 continue; 570 continue;