OpenVZ Forum


Home » Mailing lists » Devel » [patch 0/5][RFC - ipv4/udp checkpoint/restart] dumping/restoring the IPV4/UDP sockets
[patch 1/5][RFC - ipv4/udp checkpoint/restart] : add lookup for unhashed inode [message #18769 is a reply to message #18768] Wed, 06 June 2007 12:18 Go to previous messageGo to previous message
Daniel Lezcano is currently offline  Daniel Lezcano
Messages: 417
Registered: June 2006
Senior Member
The socket relies on the sockfs. In some cases, the socket are orphans and
it is not possible to access them via a file descriptor, this is the case for
example for timewait sockets. Hopefully, an inode is still usable to specify
a socket. This one can be retrieved from /proc/net/tcp for orphan sockets or
from a fstat.

When a socket is created the socket inode is added to the sockfs.
Unfortunatly, this one is not stored into the hashed inode list, so
I need a helper to browse the inode list contained in the superblock 
of the sockfs.

This is one solution, another solution is to stored the inode into
the hashed list when socket is created.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
 fs/inode.c         |   29 +++++++++++++++++++++++++++++
 include/linux/fs.h |    1 +
 2 files changed, 30 insertions(+)

Index: 2.6.20-cr/fs/inode.c
===================================================================
--- 2.6.20-cr.orig/fs/inode.c
+++ 2.6.20-cr/fs/inode.c
@@ -877,6 +877,35 @@
 
 EXPORT_SYMBOL(ilookup);
 
+
+/**
+ * ilookup_unhased - search for an inode in the superblock
+ * @sb:		super block of file system to search
+ * @ino:	inode number to search for
+ *
+ * The ilookup_unhashed browse the superblock inode list to find the inode.
+ *
+ * If the inode is found in the inode list stored in the superblock, the inode is
+ * with an incremented reference count.
+ *
+ * Otherwise NULL is returned.
+ */
+struct inode *ilookup_unhashed(struct super_block *sb, unsigned long ino)
+{
+	struct inode *inode = NULL;
+
+	spin_lock(&inode_lock);
+	list_for_each_entry(inode, &sb->s_inodes, i_sb_list)
+		if (inode->i_ino == ino) {
+			__iget(inode);
+			break;
+		}
+	spin_unlock(&inode_lock);
+	return inode;
+
+}
+EXPORT_SYMBOL(ilookup_unhashed);
+
 /**
  * iget5_locked - obtain an inode from a mounted file system
  * @sb:		super block of file system
Index: 2.6.20-cr/include/linux/fs.h
===================================================================
--- 2.6.20-cr.orig/include/linux/fs.h
+++ 2.6.20-cr/include/linux/fs.h
@@ -1657,6 +1657,7 @@
 extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
 		int (*test)(struct inode *, void *), void *data);
 extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
+extern struct inode *ilookup_unhashed(struct super_block *sb, unsigned long ino);
 
 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
 extern struct inode * iget_locked(struct super_block *, unsigned long);

-- 
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Pid namespaces approaches testing results
Next Topic: Re: checkpointing and restoring processes
Goto Forum:
  


Current Time: Tue Sep 09 14:43:43 GMT 2025

Total time taken to generate the page: 0.08699 seconds