From 9bda5f681fd216b6a856b72940195e5335317bf1 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 24 May 2003 21:42:29 -0700 Subject: [PATCH] i_cdev/i_cindex new fields in struct inode - i_cdev and i_cindex. When we do open() on a character device we cache result of cdev lookup in inode and put the inode on a cyclic list anchored in cdev. If we already have that done, we don't bother with any lookups. When inode disappears it's removed from the list. When cdev gets unregistered we remove all cached references to it (and remove such inodes from the list). cdev is held until final fput() now. --- include/linux/cdev.h | 9 ++++----- include/linux/fs.h | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include/linux') diff --git a/include/linux/cdev.h b/include/linux/cdev.h index faa67d2f4323..191c800fa127 100644 --- a/include/linux/cdev.h +++ b/include/linux/cdev.h @@ -6,17 +6,14 @@ struct cdev { struct kobject kobj; struct module *owner; struct file_operations *ops; + struct list_head list; }; void cdev_init(struct cdev *, struct file_operations *); struct cdev *cdev_alloc(void); -static inline void cdev_put(struct cdev *p) -{ - if (p) - kobject_put(&p->kobj); -} +void cdev_put(struct cdev *p); struct kobject *cdev_get(struct cdev *); @@ -26,5 +23,7 @@ void cdev_del(struct cdev *); void cdev_unmap(dev_t, unsigned); +void cd_forget(struct inode *); + #endif #endif diff --git a/include/linux/fs.h b/include/linux/fs.h index 6b32c6ab8727..de57729940ef 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -382,6 +382,8 @@ struct inode { struct list_head i_devices; struct pipe_inode_info *i_pipe; struct block_device *i_bdev; + struct cdev *i_cdev; + int i_cindex; unsigned long i_dnotify_mask; /* Directory notify events */ struct dnotify_struct *i_dnotify; /* for directory notifications */ -- cgit v1.2.3