Skip to content

Commit

Permalink
[PATCH] inode_diet: Replace inode.u.generic_ip with inode.i_private
Browse files Browse the repository at this point in the history
The following patches reduce the size of the VFS inode structure by 28 bytes
on a UP x86.  (It would be more on an x86_64 system).  This is a 10% reduction
in the inode size on a UP kernel that is configured in a production mode
(i.e., with no spinlock or other debugging functions enabled; if you want to
save memory taken up by in-core inodes, the first thing you should do is
disable the debugging options; they are responsible for a huge amount of bloat
in the VFS inode structure).

This patch:

The filesystem or device-specific pointer in the inode is inside a union,
which is pretty pointless given that all 30+ users of this field have been
using the void pointer.  Get rid of the union and rename it to i_private, with
a comment to explain who is allowed to use the void pointer.  This is just a
cleanup, but it allows us to reuse the union 'u' for something something where
the union will actually be used.

[[email protected]: powerpc build fix]
Signed-off-by: "Theodore Ts'o" <[email protected]>
Signed-off-by: Judith Lebzelter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
tytso authored and Linus Torvalds committed Sep 27, 2006
1 parent 6a1d980 commit 8e18e29
Show file tree
Hide file tree
Showing 36 changed files with 88 additions and 90 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ spufs_new_file(struct super_block *sb, struct dentry *dentry,
ret = 0;
inode->i_op = &spufs_file_iops;
inode->i_fop = fops;
inode->u.generic_ip = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
d_add(dentry, inode);
out:
return ret;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/hvCall_inst.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int hcall_inst_seq_open(struct inode *inode, struct file *file)

rc = seq_open(file, &hcall_inst_seq_ops);
seq = file->private_data;
seq->private = file->f_dentry->d_inode->u.generic_ip;
seq->private = file->f_dentry->d_inode->i_private;

return rc;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode)

static void hypfs_drop_inode(struct inode *inode)
{
kfree(inode->u.generic_ip);
kfree(inode->i_private);
generic_delete_inode(inode);
}

static int hypfs_open(struct inode *inode, struct file *filp)
{
char *data = filp->f_dentry->d_inode->u.generic_ip;
char *data = filp->f_dentry->d_inode->i_private;
struct hypfs_sb_info *fs_info;

if (filp->f_mode & FMODE_WRITE) {
Expand Down Expand Up @@ -352,7 +352,7 @@ static struct dentry *hypfs_create_file(struct super_block *sb,
parent->d_inode->i_nlink++;
} else
BUG();
inode->u.generic_ip = data;
inode->i_private = data;
d_instantiate(dentry, inode);
dget(dentry);
return dentry;
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kernel/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ debug_open(struct inode *inode, struct file *file)
debug_info_t *debug_info, *debug_info_snapshot;

down(&debug_lock);
debug_info = (struct debug_info*)file->f_dentry->d_inode->u.generic_ip;
debug_info = file->f_dentry->d_inode->i_private;
/* find debug view */
for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
if (!debug_info->views[i])
Expand Down
2 changes: 1 addition & 1 deletion block/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static int blk_trace_remove(request_queue_t *q)

static int blk_dropped_open(struct inode *inode, struct file *filp)
{
filp->private_data = inode->u.generic_ip;
filp->private_data = inode->i_private;

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/i2c/chips/tps65010.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static int dbg_show(struct seq_file *s, void *_)

static int dbg_tps_open(struct inode *inode, struct file *file)
{
return single_open(file, dbg_show, inode->u.generic_ip);
return single_open(file, dbg_show, inode->i_private);
}

static struct file_operations debug_fops = {
Expand Down
12 changes: 6 additions & 6 deletions drivers/infiniband/hw/ipath/ipath_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->u.generic_ip = data;
inode->i_private = data;
if ((mode & S_IFMT) == S_IFDIR) {
inode->i_op = &simple_dir_inode_operations;
inode->i_nlink++;
Expand Down Expand Up @@ -119,7 +119,7 @@ static ssize_t atomic_counters_read(struct file *file, char __user *buf,
u16 i;
struct ipath_devdata *dd;

dd = file->f_dentry->d_inode->u.generic_ip;
dd = file->f_dentry->d_inode->i_private;

for (i = 0; i < NUM_COUNTERS; i++)
counters[i] = ipath_snap_cntr(dd, i);
Expand All @@ -139,7 +139,7 @@ static ssize_t atomic_node_info_read(struct file *file, char __user *buf,
struct ipath_devdata *dd;
u64 guid;

dd = file->f_dentry->d_inode->u.generic_ip;
dd = file->f_dentry->d_inode->i_private;

guid = be64_to_cpu(dd->ipath_guid);

Expand Down Expand Up @@ -178,7 +178,7 @@ static ssize_t atomic_port_info_read(struct file *file, char __user *buf,
u32 tmp, tmp2;
struct ipath_devdata *dd;

dd = file->f_dentry->d_inode->u.generic_ip;
dd = file->f_dentry->d_inode->i_private;

/* so we only initialize non-zero fields. */
memset(portinfo, 0, sizeof portinfo);
Expand Down Expand Up @@ -325,7 +325,7 @@ static ssize_t flash_read(struct file *file, char __user *buf,
goto bail;
}

dd = file->f_dentry->d_inode->u.generic_ip;
dd = file->f_dentry->d_inode->i_private;
if (ipath_eeprom_read(dd, pos, tmp, count)) {
ipath_dev_err(dd, "failed to read from flash\n");
ret = -ENXIO;
Expand Down Expand Up @@ -381,7 +381,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
goto bail_tmp;
}

dd = file->f_dentry->d_inode->u.generic_ip;
dd = file->f_dentry->d_inode->i_private;
if (ipath_eeprom_write(dd, pos, tmp, count)) {
ret = -ENXIO;
ipath_dev_err(dd, "failed to write to flash\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/infiniband/ulp/ipoib/ipoib_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int ipoib_mcg_open(struct inode *inode, struct file *file)
return ret;

seq = file->private_data;
seq->private = inode->u.generic_ip;
seq->private = inode->i_private;

return 0;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ static int ipoib_path_open(struct inode *inode, struct file *file)
return ret;

seq = file->private_data;
seq->private = inode->u.generic_ip;
seq->private = inode->i_private;

return 0;
}
Expand Down
16 changes: 8 additions & 8 deletions drivers/misc/ibmasm/ibmasmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static struct dentry *ibmasmfs_create_file (struct super_block *sb,
}

inode->i_fop = fops;
inode->u.generic_ip = data;
inode->i_private = data;

d_add(dentry, inode);
return dentry;
Expand Down Expand Up @@ -244,15 +244,15 @@ static int command_file_open(struct inode *inode, struct file *file)
{
struct ibmasmfs_command_data *command_data;

if (!inode->u.generic_ip)
if (!inode->i_private)
return -ENODEV;

command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL);
if (!command_data)
return -ENOMEM;

command_data->command = NULL;
command_data->sp = inode->u.generic_ip;
command_data->sp = inode->i_private;
file->private_data = command_data;
return 0;
}
Expand Down Expand Up @@ -351,10 +351,10 @@ static int event_file_open(struct inode *inode, struct file *file)
struct ibmasmfs_event_data *event_data;
struct service_processor *sp;

if (!inode->u.generic_ip)
if (!inode->i_private)
return -ENODEV;

sp = inode->u.generic_ip;
sp = inode->i_private;

event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL);
if (!event_data)
Expand Down Expand Up @@ -439,14 +439,14 @@ static int r_heartbeat_file_open(struct inode *inode, struct file *file)
{
struct ibmasmfs_heartbeat_data *rhbeat;

if (!inode->u.generic_ip)
if (!inode->i_private)
return -ENODEV;

rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL);
if (!rhbeat)
return -ENOMEM;

rhbeat->sp = (struct service_processor *)inode->u.generic_ip;
rhbeat->sp = inode->i_private;
rhbeat->active = 0;
ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat);
file->private_data = rhbeat;
Expand Down Expand Up @@ -508,7 +508,7 @@ static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf,

static int remote_settings_file_open(struct inode *inode, struct file *file)
{
file->private_data = inode->u.generic_ip;
file->private_data = inode->i_private;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/vlsi_ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typedef void irqreturn_t;

/* PDE() introduced in 2.5.4 */
#ifdef CONFIG_PROC_FS
#define PDE(inode) ((inode)->u.generic_ip)
#define PDE(inode) ((inode)->i_private)
#endif

/* irda crc16 calculation exported in 2.5.42 */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static ssize_t write_file_dummy(struct file *file, const char __user *buf,

static int open_file_generic(struct inode *inode, struct file *file)
{
file->private_data = inode->u.generic_ip;
file->private_data = inode->i_private;
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/oprofile/oprofilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ static ssize_t ulong_write_file(struct file * file, char const __user * buf, siz

static int default_open(struct inode * inode, struct file * filp)
{
if (inode->u.generic_ip)
filp->private_data = inode->u.generic_ip;
if (inode->i_private)
filp->private_data = inode->i_private;
return 0;
}

Expand Down Expand Up @@ -158,7 +158,7 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
if (!d)
return -EFAULT;

d->d_inode->u.generic_ip = val;
d->d_inode->i_private = val;
return 0;
}

Expand All @@ -171,7 +171,7 @@ int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
if (!d)
return -EFAULT;

d->d_inode->u.generic_ip = val;
d->d_inode->i_private = val;
return 0;
}

Expand All @@ -197,7 +197,7 @@ int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
if (!d)
return -EFAULT;

d->d_inode->u.generic_ip = val;
d->d_inode->i_private = val;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/pci/hotplug/cpqphp_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct ctrl_dbg {

static int open(struct inode *inode, struct file *file)
{
struct controller *ctrl = inode->u.generic_ip;
struct controller *ctrl = inode->i_private;
struct ctrl_dbg *dbg;
int retval = -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
if (imajor(inode) == USB_DEVICE_MAJOR)
dev = usbdev_lookup_minor(iminor(inode));
if (!dev)
dev = inode->u.generic_ip;
dev = inode->i_private;
if (!dev) {
kfree(ps);
goto out;
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/core/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)

static int default_open (struct inode *inode, struct file *file)
{
if (inode->u.generic_ip)
file->private_data = inode->u.generic_ip;
if (inode->i_private)
file->private_data = inode->i_private;

return 0;
}
Expand Down Expand Up @@ -509,7 +509,7 @@ static struct dentry *fs_create_file (const char *name, mode_t mode,
} else {
if (dentry->d_inode) {
if (data)
dentry->d_inode->u.generic_ip = data;
dentry->d_inode->i_private = data;
if (fops)
dentry->d_inode->i_fop = fops;
dentry->d_inode->i_uid = uid;
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/gadget/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
static int
ep_open (struct inode *inode, struct file *fd)
{
struct ep_data *data = inode->u.generic_ip;
struct ep_data *data = inode->i_private;
int value = -EBUSY;

if (down_interruptible (&data->lock) != 0)
Expand Down Expand Up @@ -1909,7 +1909,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
static int
dev_open (struct inode *inode, struct file *fd)
{
struct dev_data *dev = inode->u.generic_ip;
struct dev_data *dev = inode->i_private;
int value = -EBUSY;

if (dev->state == STATE_DEV_DISABLED) {
Expand Down Expand Up @@ -1970,7 +1970,7 @@ gadgetfs_make_inode (struct super_block *sb,
inode->i_blocks = 0;
inode->i_atime = inode->i_mtime = inode->i_ctime
= CURRENT_TIME;
inode->u.generic_ip = data;
inode->i_private = data;
inode->i_fop = fops;
}
return inode;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/isp116x-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ static int isp116x_show_dbg(struct seq_file *s, void *unused)

static int isp116x_open_seq(struct inode *inode, struct file *file)
{
return single_open(file, isp116x_show_dbg, inode->u.generic_ip);
return single_open(file, isp116x_show_dbg, inode->i_private);
}

static struct file_operations isp116x_debug_fops = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/uhci-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ struct uhci_debug {

static int uhci_debug_open(struct inode *inode, struct file *file)
{
struct uhci_hcd *uhci = inode->u.generic_ip;
struct uhci_hcd *uhci = inode->i_private;
struct uhci_debug *up;
int ret = -ENOMEM;
unsigned long flags;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/mon/mon_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static int mon_stat_open(struct inode *inode, struct file *file)
if ((sp = kmalloc(sizeof(struct snap), GFP_KERNEL)) == NULL)
return -ENOMEM;

mbus = inode->u.generic_ip;
mbus = inode->i_private;

sp->slen = snprintf(sp->str, STAT_BUF_SIZE,
"nreaders %d events %u text_lost %u\n",
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/mon/mon_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
int rc;

mutex_lock(&mon_lock);
mbus = inode->u.generic_ip;
mbus = inode->i_private;
ubus = mbus->u_bus;

rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
Expand Down Expand Up @@ -401,7 +401,7 @@ static int mon_text_release(struct inode *inode, struct file *file)
struct mon_event_text *ep;

mutex_lock(&mon_lock);
mbus = inode->u.generic_ip;
mbus = inode->i_private;

if (mbus->nreaders <= 0) {
printk(KERN_ERR TAG ": consistency error on close\n");
Expand Down
2 changes: 1 addition & 1 deletion fs/autofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static void autofs_read_inode(struct inode *inode)

inode->i_op = &autofs_symlink_inode_operations;
sl = &sbi->symlink[n];
inode->u.generic_ip = sl;
inode->i_private = sl;
inode->i_mode = S_IFLNK | S_IRWXUGO;
inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = sl->mtime;
inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0;
Expand Down
2 changes: 1 addition & 1 deletion fs/autofs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* Nothing to release.. */
static void *autofs_follow_link(struct dentry *dentry, struct nameidata *nd)
{
char *s=((struct autofs_symlink *)dentry->d_inode->u.generic_ip)->data;
char *s=((struct autofs_symlink *)dentry->d_inode->i_private)->data;
nd_set_link(nd, s);
return NULL;
}
Expand Down
Loading

0 comments on commit 8e18e29

Please sign in to comment.