[PATCH 2/2] eppic: dir_names - Convert mnt_hash to hlist from list

Kamalesh Babulal kamalesh at linux.vnet.ibm.com
Wed Dec 14 05:19:25 PST 2016


Linux kernel commit 38129a13e6e7 ("switch mnt_hash to hlist"),
moves mnt_hash from list_head to hlist_node. Introduce these
list type changes to iterate over the mounted filesystem and
walk dentries.

Signed-off-by: Kamalesh Babulal <kamalesh at linux.vnet.ibm.com>
---
 eppic_scripts/dir_names.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/eppic_scripts/dir_names.c b/eppic_scripts/dir_names.c
index dbe6d00..6f6eb41 100644
--- a/eppic_scripts/dir_names.c
+++ b/eppic_scripts/dir_names.c
@@ -26,9 +26,12 @@ void
 rm_names(struct dentry *dir)
 {
 	struct list_head *next, *head;
+	unsigned int hash_len;
+	int i;
 
 	memset(dir->d_iname, 0, 0x20);
-	memset(dir->d_name.name, 0, 0x20);
+	hash_len = *((unsigned int *)&dir->d_name);
+	memset(dir->d_name.name, 0, hash_len);
 
 	head = (struct list_head *)&(dir->d_subdirs);
 	next = (struct list_head *)dir->d_subdirs.next;
@@ -37,9 +40,9 @@ rm_names(struct dentry *dir)
 	{
 		struct dentry *child, *off = 0;
 
-		child = (struct dentry *)((unsigned long)next - (unsigned long)&(off->d_u));
+		child = (struct dentry *)((unsigned long)next - (unsigned long)&(off->d_child));
 		rm_names(child);
-		next = child->d_u.d_child.next;
+		next = child->d_child.next;
 	}
 
 	return;
@@ -49,29 +52,30 @@ int
 vfs()
 {
 	int i;
-	struct list_head *tab;
+	struct hlist_bl_head *tab;
+	unsigned int d_hash_size = d_hash_mask;
 
-	tab = (struct list_head *)mount_hashtable;
+	tab = (struct hlist_bl_head *)dentry_hashtable;
 
-	for (i = 0; i < 256; i++)
+	for (i = 0; i < d_hash_size; i++)
 	{
-		struct list_head *head, *next;
-
-		head = (struct list_head *) (tab + i);
-		next = (struct list_head *) head->next;
+		struct hlist_bl_head *head;
+		struct hlist_bl_node *head_node, *next;
 
-		if (!next)
+		head = (struct hlist_bl_head *) (tab + i);
+		head_node = head->first;
+		if (!head_node)
 			continue;
 
-		while (next != head)
+		next = head_node;
+
+		while (next)
 		{
-			struct mount *mntfs;
-			struct dentry *root;
+			struct dentry *root, *off = 0;
 
-			mntfs = (struct mount *)((unsigned long)next);
-			root = (struct dentry *)mntfs->mnt.mnt_root;
+			root = (struct dentry *)((unsigned long)next - (unsigned long)&(off->d_hash));
 			rm_names(root);
-			next = mntfs->mnt_hash.next;
+			next = next->next;
 		}
 	}
 	return 1;
-- 
2.7.4




More information about the kexec mailing list