Index: linux-2.6.20.ep2/fs/eventpoll.c =================================================================== --- linux-2.6.20.ep2.orig/fs/eventpoll.c 2007-03-04 14:40:01.000000000 -0800 +++ linux-2.6.20.ep2/fs/eventpoll.c 2007-03-04 15:12:36.000000000 -0800 @@ -258,6 +258,7 @@ int maxevents, long timeout); static int eventpollfs_delete_dentry(struct dentry *dentry); static struct inode *ep_eventpoll_inode(void); +static struct inode *ep_create_inode(void); static int eventpollfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt); @@ -279,6 +280,9 @@ /* Virtual fs used to allocate inodes for eventpoll files */ static struct vfsmount *eventpoll_mnt __read_mostly; +/* Placeholder inode for eventpoll fds */ +static struct inode *eventpoll_inode; + /* File callbacks that implement the eventpoll file behaviour */ static const struct file_operations eventpoll_fops = { .release = ep_eventpoll_close, @@ -771,7 +775,10 @@ if (!dentry) goto eexit_4; dentry->d_op = &eventpollfs_dentry_operations; - d_add(dentry, inode); + /* Do not publish this dentry inside the global dentry hash table */ + dentry->d_flags &= ~DCACHE_UNHASHED; + d_instantiate(dentry, inode); + file->f_path.mnt = mntget(eventpoll_mnt); file->f_path.dentry = dentry; file->f_mapping = inode->i_mapping; @@ -1562,6 +1569,17 @@ static struct inode *ep_eventpoll_inode(void) { + + return igrab(eventpoll_inode); +} + +/* + * A single inode exist for all eventpoll files. On the contrary of pipes, + * eventpoll inodes has no per-instance data associated, so we can avoid + * the allocation of multiple of them. + */ +static struct inode *ep_create_inode(void) +{ int error = -ENOMEM; struct inode *inode = new_inode(eventpoll_mnt->mnt_sb); @@ -1626,10 +1644,14 @@ /* Mount the above commented virtual file system */ eventpoll_mnt = kern_mount(&eventpoll_fs_type); - error = PTR_ERR(eventpoll_mnt); if (IS_ERR(eventpoll_mnt)) goto epanic; + /* Create the single instance of inode for all eventpoll fds */ + eventpoll_inode = ep_create_inode(); + if (IS_ERR(eventpoll_inode)) + goto epanic; + DNPRINTK(3, (KERN_INFO "[%p] eventpoll: successfully initialized.\n", current)); return 0; @@ -1642,6 +1664,7 @@ static void __exit eventpoll_exit(void) { /* Undo all operations done inside eventpoll_init() */ + iput(eventpoll_inode); unregister_filesystem(&eventpoll_fs_type); mntput(eventpoll_mnt); kmem_cache_destroy(pwq_cache);