aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/dcache.c6
-rw-r--r--include/linux/list.h12
2 files changed, 15 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;
diff --git a/include/linux/list.h b/include/linux/list.h
index ad9dcb9e3375..b0cf0135fe3e 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -478,6 +478,18 @@ static inline void list_splice_init_rcu(struct list_head *list,
478 pos = n, n = pos->next) 478 pos = n, n = pos->next)
479 479
480/** 480/**
481 * list_for_each_prev_safe - iterate over a list backwards safe against removal
482 of list entry
483 * @pos: the &struct list_head to use as a loop cursor.
484 * @n: another &struct list_head to use as temporary storage
485 * @head: the head for your list.
486 */
487#define list_for_each_prev_safe(pos, n, head) \
488 for (pos = (head)->prev, n = pos->prev; \
489 prefetch(pos->prev), pos != (head); \
490 pos = n, n = pos->prev)
491
492/**
481 * list_for_each_entry - iterate over list of given type 493 * list_for_each_entry - iterate over list of given type
482 * @pos: the type * to use as a loop cursor. 494 * @pos: the type * to use as a loop cursor.
483 * @head: the head for your list. 495 * @head: the head for your list.