Commit 4b64f8f0 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (2/2) inode trimming

	procfs switched to alloc_inode/destroy_inode.
parent 628561a6
......@@ -876,7 +876,7 @@ static int comx_mkdir(struct inode *dir, struct dentry *dentry, int mode)
static int comx_rmdir(struct inode *dir, struct dentry *dentry)
{
struct proc_dir_entry *entry = dentry->d_inode->u.generic_ip;
struct proc_dir_entry *entry = PDE(dentry->d_inode);
struct net_device *dev = entry->data;
struct comx_channel *ch = dev->priv;
int ret;
......@@ -928,7 +928,7 @@ static struct dentry *comx_lookup(struct inode *dir, struct dentry *dentry)
struct proc_dir_entry *de;
struct inode *inode = NULL;
if ((de = (struct proc_dir_entry *) dir->u.generic_ip) != NULL) {
if ((de = PDE(dir)) != NULL) {
for (de = de->subdir ; de ; de = de->next) {
if ((de && de->low_ino) &&
(de->namelen == dentry->d_name.len) &&
......
......@@ -2280,7 +2280,7 @@ static ssize_t proc_write( struct file *file,
static int proc_status_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *apriv = (struct airo_info *)dev->priv;
CapabilityRid cap_rid;
......@@ -2289,8 +2289,6 @@ static int proc_status_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT;
dp = inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......@@ -2364,7 +2362,7 @@ static int proc_stats_rid_open( struct inode *inode,
struct file *file,
u16 rid ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *apriv = (struct airo_info *)dev->priv;
StatsRid stats;
......@@ -2372,9 +2370,6 @@ static int proc_stats_rid_open( struct inode *inode,
int *vals = stats.vals;
MOD_INC_USE_COUNT;
dp = inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......@@ -2433,7 +2428,7 @@ static void checkThrottle(ConfigRid *config) {
static void proc_config_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = file->private_data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
ConfigRid config;
......@@ -2442,7 +2437,6 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
int need_reset = 0;
if ( !data->writelen ) return;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
disable_MAC(ai);
readConfigRid(ai, &config);
......@@ -2629,7 +2623,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
static int proc_config_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
ConfigRid config;
......@@ -2637,8 +2631,6 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......@@ -2723,7 +2715,7 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
static void proc_SSID_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = (struct proc_data *)file->private_data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
SsidRid SSID_rid;
......@@ -2759,7 +2751,7 @@ inline static u8 hexVal(char c) {
static void proc_APList_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = (struct proc_data *)file->private_data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
APListRid APList_rid;
......@@ -2852,7 +2844,7 @@ static int set_wep_key(struct airo_info *ai, u16 index,
static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
int i;
......@@ -2862,7 +2854,6 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
memset(key, 0, sizeof(key));
dp = (struct proc_dir_entry *) inode->u.generic_ip;
data = (struct proc_data *)file->private_data;
if ( !data->writelen ) return;
......@@ -2894,7 +2885,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
static int proc_wepkey_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
char *ptr;
......@@ -2905,8 +2896,6 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......@@ -2948,7 +2937,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) {
static int proc_SSID_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
int i;
......@@ -2957,8 +2946,6 @@ static int proc_SSID_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......@@ -2996,7 +2983,7 @@ static int proc_SSID_open( struct inode *inode, struct file *file ) {
static int proc_APList_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
int i;
......@@ -3005,8 +2992,6 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......@@ -3048,7 +3033,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
static int proc_BSSList_open( struct inode *inode, struct file *file ) {
struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip;
struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv;
char *ptr;
......@@ -3059,8 +3044,6 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data));
......
......@@ -45,7 +45,7 @@ static ssize_t
proc_bus_pci_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
{
const struct inode *ino = file->f_dentry->d_inode;
const struct proc_dir_entry *dp = ino->u.generic_ip;
const struct proc_dir_entry *dp = PDE(ino);
struct pci_dev *dev = dp->data;
unsigned int pos = *ppos;
unsigned int cnt, size;
......@@ -127,7 +127,7 @@ static ssize_t
proc_bus_pci_write(struct file *file, const char *buf, size_t nbytes, loff_t *ppos)
{
const struct inode *ino = file->f_dentry->d_inode;
const struct proc_dir_entry *dp = ino->u.generic_ip;
const struct proc_dir_entry *dp = PDE(ino);
struct pci_dev *dev = dp->data;
int pos = *ppos;
int cnt;
......@@ -199,7 +199,7 @@ struct pci_filp_private {
static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
const struct proc_dir_entry *dp = inode->u.generic_ip;
const struct proc_dir_entry *dp = PDE(inode);
struct pci_dev *dev = dp->data;
#ifdef HAVE_PCI_MMAP
struct pci_filp_private *fpriv = file->private_data;
......@@ -241,7 +241,7 @@ static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned i
static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
{
struct inode *inode = file->f_dentry->d_inode;
const struct proc_dir_entry *dp = inode->u.generic_ip;
const struct proc_dir_entry *dp = PDE(inode);
struct pci_dev *dev = dp->data;
struct pci_filp_private *fpriv = file->private_data;
int ret;
......
......@@ -234,7 +234,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
static ssize_t isapnp_proc_bus_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
{
struct inode *ino = file->f_dentry->d_inode;
struct proc_dir_entry *dp = ino->u.generic_ip;
struct proc_dir_entry *dp = PDE(ino);
struct pci_dev *dev = dp->data;
int pos = *ppos;
int cnt, size = 256;
......
......@@ -5618,7 +5618,7 @@ ov511_control_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
void *arg = (void *) ularg;
int rc;
pde = (struct proc_dir_entry *) inode->u.generic_ip;
pde = PDE(inode);
if (!pde)
return -ENOENT;
......
......@@ -476,7 +476,7 @@ struct uhci_proc {
static int uhci_proc_open(struct inode *inode, struct file *file)
{
const struct proc_dir_entry *dp = inode->u.generic_ip;
const struct proc_dir_entry *dp = PDE(inode);
struct uhci *uhci = dp->data;
struct uhci_proc *up;
unsigned long flags;
......
......@@ -45,7 +45,7 @@ static ssize_t
proc_bus_zorro_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
{
struct inode *ino = file->f_dentry->d_inode;
struct proc_dir_entry *dp = ino->u.generic_ip;
struct proc_dir_entry *dp = PDE(ino);
struct zorro_dev *dev = dp->data;
struct ConfigDev cd;
int pos = *ppos;
......
This diff is collapsed.
......@@ -58,7 +58,7 @@ proc_file_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
char *start;
struct proc_dir_entry * dp;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
dp = PDE(inode);
if (!(page = (char*) __get_free_page(GFP_KERNEL)))
return -ENOMEM;
......@@ -128,7 +128,7 @@ proc_file_write(struct file * file, const char * buffer,
struct inode *inode = file->f_dentry->d_inode;
struct proc_dir_entry * dp;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
dp = PDE(inode);
if (!dp->write_proc)
return -EIO;
......@@ -221,13 +221,13 @@ static int make_inode_number(void)
static int proc_readlink(struct dentry *dentry, char *buffer, int buflen)
{
char *s=((struct proc_dir_entry *)dentry->d_inode->u.generic_ip)->data;
char *s=PDE(dentry->d_inode)->data;
return vfs_readlink(dentry, buffer, buflen, s);
}
static int proc_follow_link(struct dentry *dentry, struct nameidata *nd)
{
char *s=((struct proc_dir_entry *)dentry->d_inode->u.generic_ip)->data;
char *s=PDE(dentry->d_inode)->data;
return vfs_follow_link(nd, s);
}
......@@ -264,7 +264,7 @@ struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry)
error = -ENOENT;
inode = NULL;
de = (struct proc_dir_entry *) dir->u.generic_ip;
de = PDE(dir);
if (de) {
for (de = de->subdir; de ; de = de->next) {
if (!de || !de->low_ino)
......@@ -306,7 +306,7 @@ int proc_readdir(struct file * filp,
struct inode *inode = filp->f_dentry->d_inode;
ino = inode->i_ino;
de = (struct proc_dir_entry *) inode->u.generic_ip;
de = PDE(inode);
if (!de)
return -EINVAL;
i = filp->f_pos;
......@@ -413,7 +413,7 @@ static void proc_kill_inodes(struct proc_dir_entry *de)
if (dentry->d_op != &proc_dentry_operations)
continue;
inode = dentry->d_inode;
if (inode->u.generic_ip != de)
if (PDE(inode) != de)
continue;
fops = filp->f_op;
filp->f_op = NULL;
......
......@@ -58,7 +58,7 @@ void de_put(struct proc_dir_entry *de)
*/
static void proc_delete_inode(struct inode *inode)
{
struct proc_dir_entry *de = inode->u.generic_ip;
struct proc_dir_entry *de = PDE(inode);
inode->i_state = I_CLEAR;
......@@ -91,14 +91,51 @@ static int proc_statfs(struct super_block *sb, struct statfs *buf)
return 0;
}
static kmem_cache_t * proc_inode_cachep;
static struct inode *proc_alloc_inode(struct super_block *sb)
{
struct proc_inode *ei;
ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, SLAB_KERNEL);
if (!ei)
return NULL;
return &ei->vfs_inode;
}
static void proc_destroy_inode(struct inode *inode)
{
kmem_cache_free(proc_inode_cachep, PROC_I(inode));
}
static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
{
struct proc_inode *ei = (struct proc_inode *) foo;
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR)
inode_init_once(&ei->vfs_inode);
}
int __init proc_init_inodecache(void)
{
proc_inode_cachep = kmem_cache_create("proc_inode_cache",
sizeof(struct proc_inode),
0, SLAB_HWCACHE_ALIGN,
init_once, NULL);
if (proc_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
static struct super_operations proc_sops = {
alloc_inode: proc_alloc_inode,
destroy_inode: proc_destroy_inode,
read_inode: proc_read_inode,
put_inode: force_delete,
delete_inode: proc_delete_inode,
statfs: proc_statfs,
};
static int parse_options(char *options,uid_t *uid,gid_t *gid)
{
char *this_char,*value;
......@@ -147,7 +184,7 @@ printk("proc_iget: using deleted entry %s, count=%d\n", de->name, atomic_read(&d
if (!inode)
goto out_fail;
inode->u.generic_ip = (void *) de;
PROC_I(inode)->pde = de;
if (de) {
if (de->mode) {
inode->i_mode = de->mode;
......
......@@ -25,9 +25,13 @@ struct proc_dir_entry *proc_sys_root;
static DECLARE_FSTYPE(proc_fs_type, "proc", proc_read_super, FS_SINGLE);
extern int __init proc_init_inodecache(void);
void __init proc_root_init(void)
{
int err = register_filesystem(&proc_fs_type);
int err = proc_init_inodecache();
if (err)
return;
err = register_filesystem(&proc_fs_type);
if (err)
return;
proc_mnt = kern_mount(&proc_fs_type);
......
......@@ -289,7 +289,6 @@ extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long
#include <linux/pipe_fs_i.h>
/* #include <linux/umsdos_fs_i.h> */
#include <linux/romfs_fs_i.h>
#include <linux/proc_fs_i.h>
#include <linux/cramfs_fs_sb.h>
/*
......@@ -455,7 +454,6 @@ struct inode {
union {
/* struct umsdos_inode_info umsdos_i; */
struct romfs_inode_info romfs_i;
struct proc_inode_info proc_i;
void *generic_ip;
} u;
};
......
......@@ -205,4 +205,26 @@ extern struct proc_dir_entry proc_root;
#endif /* CONFIG_PROC_FS */
struct proc_inode {
struct task_struct *task;
int type;
union {
int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
int (*proc_read)(struct task_struct *task, char *page);
} op;
struct file *file;
struct proc_dir_entry *pde;
struct inode vfs_inode;
};
static inline struct proc_inode *PROC_I(struct inode *inode)
{
return list_entry(inode, struct proc_inode, vfs_inode);
}
static inline struct proc_dir_entry *PDE(struct inode *inode)
{
return PROC_I(inode)->pde;
}
#endif /* _LINUX_PROC_FS_H */
......@@ -677,7 +677,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char * buf,
size_t res;
ssize_t error;
de = (struct proc_dir_entry*) file->f_dentry->d_inode->u.generic_ip;
de = PDE(file->f_dentry->d_inode);
if (!de || !de->data)
return -ENOTDIR;
table = (struct ctl_table *) de->data;
......
......@@ -236,7 +236,7 @@ static ssize_t vlan_proc_read(struct file *file, char *buf,
if (count <= 0)
return 0;
dent = inode->u.generic_ip;
dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL))
return 0;
......
......@@ -498,8 +498,7 @@ static ssize_t proc_dev_atm_read(struct file *file,char *buf,size_t count,
if (count == 0) return 0;
page = get_free_page(GFP_KERNEL);
if (!page) return -ENOMEM;
dev = ((struct proc_dir_entry *) file->f_dentry->d_inode->u.generic_ip)
->data;
dev = PDE(file->f_dentry->d_inode)->data;
if (!dev->ops->proc_read)
length = -EINVAL;
else {
......@@ -521,8 +520,7 @@ static ssize_t proc_spec_atm_read(struct file *file,char *buf,size_t count,
unsigned long page;
int length;
int (*info)(loff_t,char *);
info = ((struct proc_dir_entry *) file->f_dentry->d_inode->u.generic_ip)
->data;
info = PDE(file->f_dentry->d_inode)->data;
if (count == 0) return 0;
page = get_free_page(GFP_KERNEL);
......
......@@ -500,7 +500,7 @@ int wanrouter_ioctl(struct inode *inode, struct file *file,
if ((cmd >> 8) != ROUTER_IOCTL)
return -EINVAL;
dent = inode->u.generic_ip;
dent = PDE(inode);
if ((dent == NULL) || (dent->data == NULL))
return -EINVAL;
......
......@@ -248,7 +248,7 @@ typedef struct wan_stat_entry
if (count <= 0)
return 0;
dent = inode->u.generic_ip;
dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL))
return 0;
......@@ -794,7 +794,7 @@ typedef struct wan_stat_entry
if (count <= 0)
return 0;
dent = inode->u.generic_ip;
dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL))
return 0;
......@@ -828,7 +828,7 @@ typedef struct wan_stat_entry
if (count <= 0)
return 0;
dent = inode->u.generic_ip;
dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL))
return -ENODATA;
err = verify_area(VERIFY_WRITE, buf, count);
......@@ -1068,7 +1068,7 @@ static int device_write(
if (err) return err;
dent = inode->u.generic_ip;
dent = PDE(inode);
if ((dent == NULL) || (dent->data == NULL))
return -ENODATA;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment