From mboxrd@z Thu Jan 1 00:00:00 1970 From: domen@coderock.org Subject: [patch 2/7] list_for_each_entry in fs/dcache.c Date: Mon, 20 Jun 2005 23:57:01 +0200 Message-ID: <20050620215701.214414000@nd47.coderock.org> Cc: linux-fsdevel@vger.kernel.org, Maximilian Attems , domen@coderock.org Return-path: Received: from coderock.org ([193.77.147.115]:19355 "EHLO trashy.coderock.org") by vger.kernel.org with ESMTP id S261962AbVFTWE4 (ORCPT ); Mon, 20 Jun 2005 18:04:56 -0400 To: viro@parcelfarce.linux.theplanet.co.uk Content-Disposition: inline; filename=list-for-each-fs_dcache.patch Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org From: Domen Puncer First 2 are list_for_each_entry (thanks maks), second 2 list_for_each_safe. Boot tested. Signed-off-by: Domen Puncer Signed-off-by: Maximilian Attems Signed-off-by: Domen Puncer --- dcache.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-) Index: quilt/fs/dcache.c =================================================================== --- quilt.orig/fs/dcache.c +++ quilt/fs/dcache.c @@ -335,12 +335,10 @@ struct dentry * d_find_alias(struct inod */ void d_prune_aliases(struct inode *inode) { - struct list_head *tmp, *head = &inode->i_dentry; + struct dentry *dentry; restart: spin_lock(&dcache_lock); - tmp = head; - while ((tmp = tmp->next) != head) { - struct dentry *dentry = list_entry(tmp, struct dentry, d_alias); + list_for_each_entry(dentry, &inode->i_dentry, d_alias) { spin_lock(&dentry->d_lock); if (!atomic_read(&dentry->d_count)) { __dget_locked(dentry); @@ -461,10 +459,7 @@ void shrink_dcache_sb(struct super_block * superblock to the most recent end of the unused list. */ spin_lock(&dcache_lock); - next = dentry_unused.next; - while (next != &dentry_unused) { - tmp = next; - next = tmp->next; + list_for_each_safe(tmp, next, &dentry_unused) { dentry = list_entry(tmp, struct dentry, d_lru); if (dentry->d_sb != sb) continue; @@ -476,10 +471,7 @@ void shrink_dcache_sb(struct super_block * Pass two ... free the dentries for this superblock. */ repeat: - next = dentry_unused.next; - while (next != &dentry_unused) { - tmp = next; - next = tmp->next; + list_for_each_safe(tmp, next, &dentry_unused) { dentry = list_entry(tmp, struct dentry, d_lru); if (dentry->d_sb != sb) continue; --