From ea69cc0bcabfc8c417ba89396376dabc5bc8f74d Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Tue, 16 Oct 2007 23:29:53 -0700 Subject: [PATCH] --- yaml --- r: 70681 b: refs/heads/master c: 37c42524d6090644206ae6d310d7e830bd3ccb47 h: refs/heads/master i: 70679: 57d95c1a4836052bc442b72c94c6b2f2623e3828 v: v3 --- [refs] | 2 +- trunk/fs/dcache.c | 6 +++--- trunk/include/linux/list.h | 12 ++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 635882d8ffab..276f0c9da11d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 44a2db43eb715b54618bf01520cc5d46376cdbe2 +refs/heads/master: 37c42524d6090644206ae6d310d7e830bd3ccb47 diff --git a/trunk/fs/dcache.c b/trunk/fs/dcache.c index 5cdd14e95858..42d290be0ac1 100644 --- a/trunk/fs/dcache.c +++ b/trunk/fs/dcache.c @@ -553,18 +553,18 @@ void shrink_dcache_sb(struct super_block * sb) * superblock to the most recent end of the unused list. */ spin_lock(&dcache_lock); - list_for_each_safe(tmp, next, &dentry_unused) { + list_for_each_prev_safe(tmp, next, &dentry_unused) { dentry = list_entry(tmp, struct dentry, d_lru); if (dentry->d_sb != sb) continue; - list_move(tmp, &dentry_unused); + list_move_tail(tmp, &dentry_unused); } /* * Pass two ... free the dentries for this superblock. */ repeat: - list_for_each_safe(tmp, next, &dentry_unused) { + list_for_each_prev_safe(tmp, next, &dentry_unused) { dentry = list_entry(tmp, struct dentry, d_lru); if (dentry->d_sb != sb) continue; diff --git a/trunk/include/linux/list.h b/trunk/include/linux/list.h index ad9dcb9e3375..b0cf0135fe3e 100644 --- a/trunk/include/linux/list.h +++ b/trunk/include/linux/list.h @@ -477,6 +477,18 @@ static inline void list_splice_init_rcu(struct list_head *list, for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) +/** + * list_for_each_prev_safe - iterate over a list backwards safe against removal + of list entry + * @pos: the &struct list_head to use as a loop cursor. + * @n: another &struct list_head to use as temporary storage + * @head: the head for your list. + */ +#define list_for_each_prev_safe(pos, n, head) \ + for (pos = (head)->prev, n = pos->prev; \ + prefetch(pos->prev), pos != (head); \ + pos = n, n = pos->prev) + /** * list_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop cursor.