Skip to contentSkip to conversation

list_for_each_entry in fs/dcache.c

PATCH New [email protected] 1 participant 1 message Jan 10, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 2/5 list_for_each_entry in fs/dcache.c

Hi.

First 2 are list_for_each_entry (thanks maks), second 2 list_for_each_safe. Boot tested.

---

 kj-domen/fs/dcache.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
fs/dcache.c renamed from fs/dcache.c~list-for-each-fs_dcache +4 -12
diff -puN fs/dcache.c~list-for-each-fs_dcache fs/dcache.c
@@ -334,12 +334,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) {
 		if (!atomic_read(&dentry->d_count)) {
 			__dget_locked(dentry);
 			__d_drop(dentry);
@@ -457,10 +455,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;
@@ -472,10 +467,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;

_