2001-12-02 11:31:38

by Jeff Garzik

[permalink] [raw]
Subject: PATCH 2.4.17.2: make ext2 smaller

diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/include/linux/ext2_fs.h linux-e2all/include/linux/ext2_fs.h
--- linux-2.4.17-pre2/include/linux/ext2_fs.h Thu Nov 22 19:46:52 2001
+++ linux-e2all/include/linux/ext2_fs.h Sun Dec 2 11:04:09 2001
@@ -16,6 +16,10 @@
#ifndef _LINUX_EXT2_FS_H
#define _LINUX_EXT2_FS_H

+#ifndef E2STATIC
+#define E2STATIC
+#endif
+
#include <linux/types.h>

/*
@@ -546,86 +550,86 @@
# define NORET_AND noreturn,

/* balloc.c */
-extern int ext2_bg_has_super(struct super_block *sb, int group);
-extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
-extern int ext2_new_block (struct inode *, unsigned long,
+E2STATIC int ext2_bg_has_super(struct super_block *sb, int group);
+E2STATIC unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
+E2STATIC int ext2_new_block (struct inode *, unsigned long,
__u32 *, __u32 *, int *);
-extern void ext2_free_blocks (struct inode *, unsigned long,
+E2STATIC void ext2_free_blocks (struct inode *, unsigned long,
unsigned long);
-extern unsigned long ext2_count_free_blocks (struct super_block *);
-extern void ext2_check_blocks_bitmap (struct super_block *);
-extern struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
+E2STATIC unsigned long ext2_count_free_blocks (struct super_block *);
+E2STATIC void ext2_check_blocks_bitmap (struct super_block *);
+E2STATIC struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned int block_group,
struct buffer_head ** bh);

/* dir.c */
-extern int ext2_add_link (struct dentry *, struct inode *);
-extern ino_t ext2_inode_by_name(struct inode *, struct dentry *);
-extern int ext2_make_empty(struct inode *, struct inode *);
-extern struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct dentry *, struct page **);
-extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
-extern int ext2_empty_dir (struct inode *);
-extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
-extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *);
+E2STATIC int ext2_add_link (struct dentry *, struct inode *);
+E2STATIC ino_t ext2_inode_by_name(struct inode *, struct dentry *);
+E2STATIC int ext2_make_empty(struct inode *, struct inode *);
+E2STATIC struct ext2_dir_entry_2 * ext2_find_entry (struct inode *,struct dentry *, struct page **);
+E2STATIC int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
+E2STATIC int ext2_empty_dir (struct inode *);
+E2STATIC struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
+E2STATIC void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *);

/* fsync.c */
-extern int ext2_sync_file (struct file *, struct dentry *, int);
-extern int ext2_fsync_inode (struct inode *, int);
+E2STATIC int ext2_sync_file (struct file *, struct dentry *, int);
+E2STATIC int ext2_fsync_inode (struct inode *, int);

/* ialloc.c */
-extern struct inode * ext2_new_inode (const struct inode *, int);
-extern void ext2_free_inode (struct inode *);
-extern unsigned long ext2_count_free_inodes (struct super_block *);
-extern void ext2_check_inodes_bitmap (struct super_block *);
-extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
+E2STATIC struct inode * ext2_new_inode (const struct inode *, int);
+E2STATIC void ext2_free_inode (struct inode *);
+E2STATIC unsigned long ext2_count_free_inodes (struct super_block *);
+E2STATIC void ext2_check_inodes_bitmap (struct super_block *);
+E2STATIC unsigned long ext2_count_free (struct buffer_head *, unsigned);

/* inode.c */
-extern void ext2_read_inode (struct inode *);
-extern void ext2_write_inode (struct inode *, int);
-extern void ext2_put_inode (struct inode *);
-extern void ext2_delete_inode (struct inode *);
-extern int ext2_sync_inode (struct inode *);
-extern void ext2_discard_prealloc (struct inode *);
-extern void ext2_truncate (struct inode *);
+E2STATIC void ext2_read_inode (struct inode *);
+E2STATIC void ext2_write_inode (struct inode *, int);
+E2STATIC void ext2_put_inode (struct inode *);
+E2STATIC void ext2_delete_inode (struct inode *);
+E2STATIC int ext2_sync_inode (struct inode *);
+E2STATIC void ext2_discard_prealloc (struct inode *);
+E2STATIC void ext2_truncate (struct inode *);

/* ioctl.c */
-extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
+E2STATIC int ext2_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);

/* super.c */
-extern void ext2_error (struct super_block *, const char *, const char *, ...)
+E2STATIC void ext2_error (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
-extern NORET_TYPE void ext2_panic (struct super_block *, const char *,
+E2STATIC NORET_TYPE void ext2_panic (struct super_block *, const char *,
const char *, ...)
__attribute__ ((NORET_AND format (printf, 3, 4)));
-extern void ext2_warning (struct super_block *, const char *, const char *, ...)
+E2STATIC void ext2_warning (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
-extern void ext2_update_dynamic_rev (struct super_block *sb);
-extern void ext2_put_super (struct super_block *);
-extern void ext2_write_super (struct super_block *);
-extern int ext2_remount (struct super_block *, int *, char *);
-extern struct super_block * ext2_read_super (struct super_block *,void *,int);
-extern int ext2_statfs (struct super_block *, struct statfs *);
+E2STATIC void ext2_update_dynamic_rev (struct super_block *sb);
+E2STATIC void ext2_put_super (struct super_block *);
+E2STATIC void ext2_write_super (struct super_block *);
+E2STATIC int ext2_remount (struct super_block *, int *, char *);
+E2STATIC struct super_block * ext2_read_super (struct super_block *,void *,int);
+E2STATIC int ext2_statfs (struct super_block *, struct statfs *);

/*
* Inodes and files operations
*/

/* dir.c */
-extern struct file_operations ext2_dir_operations;
+E2STATIC struct file_operations ext2_dir_operations;

/* file.c */
-extern struct inode_operations ext2_file_inode_operations;
-extern struct file_operations ext2_file_operations;
+E2STATIC struct inode_operations ext2_file_inode_operations;
+E2STATIC struct file_operations ext2_file_operations;

/* inode.c */
-extern struct address_space_operations ext2_aops;
+E2STATIC struct address_space_operations ext2_aops;

/* namei.c */
-extern struct inode_operations ext2_dir_inode_operations;
+E2STATIC struct inode_operations ext2_dir_inode_operations;

/* symlink.c */
-extern struct inode_operations ext2_fast_symlink_inode_operations;
+E2STATIC struct inode_operations ext2_fast_symlink_inode_operations;

#endif /* __KERNEL__ */

diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/Config.in linux-e2all/fs/Config.in
--- linux-2.4.17-pre2/fs/Config.in Mon Nov 12 17:34:16 2001
+++ linux-e2all/fs/Config.in Sun Dec 2 11:04:51 2001
@@ -77,6 +77,9 @@
tristate 'ROM file system support' CONFIG_ROMFS_FS

tristate 'Second extended fs support' CONFIG_EXT2_FS
+if [ "$CONFIG_EXT2_FS" = "y" -o "$CONFIG_EXT2_FS" = "m" ]; then
+ bool ' Memory-intensive final production build' CONFIG_EXT2_FS_FINAL
+fi

tristate 'System V/Xenix/V7/Coherent file system support' CONFIG_SYSV_FS

diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/Makefile linux-e2all/fs/ext2/Makefile
--- linux-2.4.17-pre2/fs/ext2/Makefile Thu Oct 11 15:05:18 2001
+++ linux-e2all/fs/ext2/Makefile Sun Dec 2 10:55:43 2001
@@ -9,8 +9,14 @@

O_TARGET := ext2.o

+
+ifdef CONFIG_EXT2_FS_FINAL
+obj-y := ext2_all.o
+else
obj-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
ioctl.o namei.o super.o symlink.o
+endif
+
obj-m := $(O_TARGET)

include $(TOPDIR)/Rules.make
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/balloc.c linux-e2all/fs/ext2/balloc.c
--- linux-2.4.17-pre2/fs/ext2/balloc.c Fri Oct 5 19:23:53 2001
+++ linux-e2all/fs/ext2/balloc.c Sun Dec 2 10:58:08 2001
@@ -35,7 +35,7 @@

#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)

-struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
+E2STATIC struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
unsigned int block_group,
struct buffer_head ** bh)
{
@@ -248,7 +248,7 @@
}

/* Free given blocks, update quota and i_blocks field */
-void ext2_free_blocks (struct inode * inode, unsigned long block,
+E2STATIC void ext2_free_blocks (struct inode * inode, unsigned long block,
unsigned long count)
{
struct buffer_head * bh;
@@ -354,7 +354,7 @@
* bitmap, and then for any free bit if that fails.
* This function also updates quota and i_blocks field.
*/
-int ext2_new_block (struct inode * inode, unsigned long goal,
+E2STATIC int ext2_new_block (struct inode * inode, unsigned long goal,
u32 * prealloc_count, u32 * prealloc_block, int * err)
{
struct buffer_head * bh;
@@ -614,7 +614,7 @@

}

-unsigned long ext2_count_free_blocks (struct super_block * sb)
+E2STATIC unsigned long ext2_count_free_blocks (struct super_block * sb)
{
#ifdef EXT2FS_DEBUG
struct ext2_super_block * es;
@@ -673,7 +673,7 @@
}
}

-int ext2_group_sparse(int group)
+E2STATIC int ext2_group_sparse(int group)
{
return (test_root(group, 3) || test_root(group, 5) ||
test_root(group, 7));
@@ -687,7 +687,7 @@
* Return the number of blocks used by the superblock (primary or backup)
* in this group. Currently this will be only 0 or 1.
*/
-int ext2_bg_has_super(struct super_block *sb, int group)
+E2STATIC int ext2_bg_has_super(struct super_block *sb, int group)
{
if (EXT2_HAS_RO_COMPAT_FEATURE(sb,EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)&&
!ext2_group_sparse(group))
@@ -704,7 +704,7 @@
* (primary or backup) in this group. In the future there may be a
* different number of descriptor blocks in each group.
*/
-unsigned long ext2_bg_num_gdb(struct super_block *sb, int group)
+E2STATIC unsigned long ext2_bg_num_gdb(struct super_block *sb, int group)
{
if (EXT2_HAS_RO_COMPAT_FEATURE(sb,EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)&&
!ext2_group_sparse(group))
@@ -714,7 +714,7 @@

#ifdef CONFIG_EXT2_CHECK
/* Called at mount-time, super-block is locked */
-void ext2_check_blocks_bitmap (struct super_block * sb)
+E2STATIC void ext2_check_blocks_bitmap (struct super_block * sb)
{
struct buffer_head * bh;
struct ext2_super_block * es;
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/bitmap.c linux-e2all/fs/ext2/bitmap.c
--- linux-2.4.17-pre2/fs/ext2/bitmap.c Wed Sep 27 20:41:33 2000
+++ linux-e2all/fs/ext2/bitmap.c Sun Dec 2 11:17:37 2001
@@ -10,10 +10,11 @@
#include <linux/fs.h>
#include <linux/ext2_fs.h>

+#ifdef EXT2FS_DEBUG

static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};

-unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
+E2STATIC unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
{
unsigned int i;
unsigned long sum = 0;
@@ -25,3 +26,5 @@
nibblemap[(map->b_data[i] >> 4) & 0xf];
return (sum);
}
+
+#endif /* EXT2FS_DEBUG */
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/dir.c linux-e2all/fs/ext2/dir.c
--- linux-2.4.17-pre2/fs/ext2/dir.c Mon Sep 17 20:16:30 2001
+++ linux-e2all/fs/ext2/dir.c Sun Dec 2 11:00:01 2001
@@ -297,7 +297,7 @@
* (as a parameter - res_dir). Page is returned mapped and unlocked.
* Entry is guaranteed to be valid.
*/
-struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
+E2STATIC struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
struct dentry *dentry, struct page ** res_page)
{
const char *name = dentry->d_name.name;
@@ -340,7 +340,7 @@
return de;
}

-struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
+E2STATIC struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
{
struct page *page = ext2_get_page(dir, 0);
ext2_dirent *de = NULL;
@@ -352,7 +352,7 @@
return de;
}

-ino_t ext2_inode_by_name(struct inode * dir, struct dentry *dentry)
+E2STATIC ino_t ext2_inode_by_name(struct inode * dir, struct dentry *dentry)
{
ino_t res = 0;
struct ext2_dir_entry_2 * de;
@@ -368,7 +368,7 @@
}

/* Releases the page */
-void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
+E2STATIC void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
struct page *page, struct inode *inode)
{
unsigned from = (char *) de - (char *) page_address(page);
@@ -391,7 +391,7 @@
/*
* Parent is locked.
*/
-int ext2_add_link (struct dentry *dentry, struct inode *inode)
+E2STATIC int ext2_add_link (struct dentry *dentry, struct inode *inode)
{
struct inode *dir = dentry->d_parent->d_inode;
const char *name = dentry->d_name.name;
@@ -465,7 +465,7 @@
* ext2_delete_entry deletes a directory entry by merging it with the
* previous entry. Page is up-to-date. Releases the page.
*/
-int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
+E2STATIC int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )
{
struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host;
@@ -500,7 +500,7 @@
/*
* Set the first fragment of directory.
*/
-int ext2_make_empty(struct inode *inode, struct inode *parent)
+E2STATIC int ext2_make_empty(struct inode *inode, struct inode *parent)
{
struct address_space *mapping = inode->i_mapping;
struct page *page = grab_cache_page(mapping, 0);
@@ -541,7 +541,7 @@
/*
* routine to check that the specified directory is empty (for rmdir)
*/
-int ext2_empty_dir (struct inode * inode)
+E2STATIC int ext2_empty_dir (struct inode * inode)
{
struct page *page = NULL;
unsigned long i, npages = dir_pages(inode);
@@ -583,7 +583,7 @@
return 0;
}

-struct file_operations ext2_dir_operations = {
+E2STATIC struct file_operations ext2_dir_operations = {
read: generic_read_dir,
readdir: ext2_readdir,
ioctl: ext2_ioctl,
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/ext2_all.c linux-e2all/fs/ext2/ext2_all.c
--- linux-2.4.17-pre2/fs/ext2/ext2_all.c Thu Jan 1 00:00:00 1970
+++ linux-e2all/fs/ext2/ext2_all.c Sun Dec 2 11:13:49 2001
@@ -0,0 +1,12 @@
+#define E2STATIC static
+#include "balloc.c"
+#include "bitmap.c"
+#include "dir.c"
+#include "file.c"
+#include "fsync.c"
+#include "ialloc.c"
+#include "inode.c"
+#include "ioctl.c"
+#include "namei.c"
+#include "super.c"
+#include "symlink.c"
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/file.c linux-e2all/fs/ext2/file.c
--- linux-2.4.17-pre2/fs/ext2/file.c Thu Oct 11 15:05:18 2001
+++ linux-e2all/fs/ext2/file.c Sun Dec 2 11:02:54 2001
@@ -38,7 +38,7 @@
* We have mostly NULL's here: the current defaults are ok for
* the ext2 filesystem.
*/
-struct file_operations ext2_file_operations = {
+E2STATIC struct file_operations ext2_file_operations = {
llseek: generic_file_llseek,
read: generic_file_read,
write: generic_file_write,
@@ -49,6 +49,6 @@
fsync: ext2_sync_file,
};

-struct inode_operations ext2_file_inode_operations = {
+E2STATIC struct inode_operations ext2_file_inode_operations = {
truncate: ext2_truncate,
};
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/fsync.c linux-e2all/fs/ext2/fsync.c
--- linux-2.4.17-pre2/fs/ext2/fsync.c Mon Sep 17 20:16:30 2001
+++ linux-e2all/fs/ext2/fsync.c Sun Dec 2 11:02:43 2001
@@ -33,13 +33,13 @@
* even pass file to fsync ?
*/

-int ext2_sync_file(struct file * file, struct dentry *dentry, int datasync)
+E2STATIC int ext2_sync_file(struct file * file, struct dentry *dentry, int datasync)
{
struct inode *inode = dentry->d_inode;
return ext2_fsync_inode(inode, datasync);
}

-int ext2_fsync_inode(struct inode *inode, int datasync)
+E2STATIC int ext2_fsync_inode(struct inode *inode, int datasync)
{
int err;

diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/ialloc.c linux-e2all/fs/ext2/ialloc.c
--- linux-2.4.17-pre2/fs/ext2/ialloc.c Sun Nov 11 17:59:56 2001
+++ linux-e2all/fs/ext2/ialloc.c Sun Dec 2 11:02:35 2001
@@ -147,7 +147,7 @@
* though), and then we'd have two inodes sharing the
* same inode number and space on the harddisk.
*/
-void ext2_free_inode (struct inode * inode)
+E2STATIC void ext2_free_inode (struct inode * inode)
{
struct super_block * sb = inode->i_sb;
int is_directory;
@@ -312,7 +312,7 @@
return group;
}

-struct inode * ext2_new_inode (const struct inode * dir, int mode)
+E2STATIC struct inode * ext2_new_inode (const struct inode * dir, int mode)
{
struct super_block * sb;
struct buffer_head * bh;
@@ -437,7 +437,7 @@
goto repeat;
}

-unsigned long ext2_count_free_inodes (struct super_block * sb)
+E2STATIC unsigned long ext2_count_free_inodes (struct super_block * sb)
{
#ifdef EXT2FS_DEBUG
struct ext2_super_block * es;
@@ -474,7 +474,7 @@

#ifdef CONFIG_EXT2_CHECK
/* Called at mount-time, super-block is locked */
-void ext2_check_inodes_bitmap (struct super_block * sb)
+E2STATIC void ext2_check_inodes_bitmap (struct super_block * sb)
{
struct ext2_super_block * es = sb->u.ext2_sb.s_es;
unsigned long desc_count = 0, bitmap_count = 0;
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/inode.c linux-e2all/fs/ext2/inode.c
--- linux-2.4.17-pre2/fs/ext2/inode.c Wed Nov 21 22:07:25 2001
+++ linux-e2all/fs/ext2/inode.c Sun Dec 2 11:02:11 2001
@@ -41,7 +41,7 @@
/*
* Called at each iput()
*/
-void ext2_put_inode (struct inode * inode)
+E2STATIC void ext2_put_inode (struct inode * inode)
{
ext2_discard_prealloc (inode);
}
@@ -49,7 +49,7 @@
/*
* Called at the last iput() if i_nlink is zero.
*/
-void ext2_delete_inode (struct inode * inode)
+E2STATIC void ext2_delete_inode (struct inode * inode)
{
lock_kernel();

@@ -72,7 +72,7 @@
clear_inode(inode); /* We must guarantee clearing of inode... */
}

-void ext2_discard_prealloc (struct inode * inode)
+E2STATIC void ext2_discard_prealloc (struct inode * inode)
{
#ifdef EXT2_PREALLOCATE
lock_kernel();
@@ -596,7 +596,7 @@
{
return generic_direct_IO(rw, inode, iobuf, blocknr, blocksize, ext2_get_block);
}
-struct address_space_operations ext2_aops = {
+E2STATIC struct address_space_operations ext2_aops = {
readpage: ext2_readpage,
writepage: ext2_writepage,
sync_page: block_sync_page,
@@ -786,7 +786,7 @@
ext2_free_data(inode, p, q);
}

-void ext2_truncate (struct inode * inode)
+E2STATIC void ext2_truncate (struct inode * inode)
{
u32 *i_data = inode->u.ext2_i.i_data;
int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
@@ -879,7 +879,7 @@
mark_inode_dirty(inode);
}

-void ext2_read_inode (struct inode * inode)
+E2STATIC void ext2_read_inode (struct inode * inode)
{
struct buffer_head * bh;
struct ext2_inode * raw_inode;
@@ -1148,14 +1148,14 @@
return err;
}

-void ext2_write_inode (struct inode * inode, int wait)
+E2STATIC void ext2_write_inode (struct inode * inode, int wait)
{
lock_kernel();
ext2_update_inode (inode, wait);
unlock_kernel();
}

-int ext2_sync_inode (struct inode *inode)
+E2STATIC int ext2_sync_inode (struct inode *inode)
{
return ext2_update_inode (inode, 1);
}
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/ioctl.c linux-e2all/fs/ext2/ioctl.c
--- linux-2.4.17-pre2/fs/ext2/ioctl.c Wed Sep 27 20:41:33 2000
+++ linux-e2all/fs/ext2/ioctl.c Sun Dec 2 11:01:29 2001
@@ -13,7 +13,7 @@
#include <asm/uaccess.h>


-int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
+E2STATIC int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
{
unsigned int flags;
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/namei.c linux-e2all/fs/ext2/namei.c
--- linux-2.4.17-pre2/fs/ext2/namei.c Thu Oct 4 05:57:36 2001
+++ linux-e2all/fs/ext2/namei.c Sun Dec 2 11:01:22 2001
@@ -335,7 +335,7 @@
return err;
}

-struct inode_operations ext2_dir_inode_operations = {
+E2STATIC struct inode_operations ext2_dir_inode_operations = {
create: ext2_create,
lookup: ext2_lookup,
link: ext2_link,
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/super.c linux-e2all/fs/ext2/super.c
--- linux-2.4.17-pre2/fs/ext2/super.c Sat Dec 1 04:16:03 2001
+++ linux-e2all/fs/ext2/super.c Sun Dec 2 11:01:09 2001
@@ -33,7 +33,7 @@

static char error_buf[1024];

-void ext2_error (struct super_block * sb, const char * function,
+E2STATIC void ext2_error (struct super_block * sb, const char * function,
const char * fmt, ...)
{
va_list args;
@@ -63,7 +63,7 @@
}
}

-NORET_TYPE void ext2_panic (struct super_block * sb, const char * function,
+NORET_TYPE E2STATIC void ext2_panic (struct super_block * sb, const char * function,
const char * fmt, ...)
{
va_list args;
@@ -83,7 +83,7 @@
bdevname(sb->s_dev), function, error_buf);
}

-void ext2_warning (struct super_block * sb, const char * function,
+E2STATIC void ext2_warning (struct super_block * sb, const char * function,
const char * fmt, ...)
{
va_list args;
@@ -95,7 +95,7 @@
bdevname(sb->s_dev), function, error_buf);
}

-void ext2_update_dynamic_rev(struct super_block *sb)
+E2STATIC void ext2_update_dynamic_rev(struct super_block *sb)
{
struct ext2_super_block *es = EXT2_SB(sb)->s_es;

@@ -120,7 +120,7 @@
*/
}

-void ext2_put_super (struct super_block * sb)
+E2STATIC void ext2_put_super (struct super_block * sb)
{
int db_count;
int i;
@@ -397,7 +397,7 @@
return res;
}

-struct super_block * ext2_read_super (struct super_block * sb, void * data,
+E2STATIC struct super_block * ext2_read_super (struct super_block * sb, void * data,
int silent)
{
struct buffer_head * bh;
@@ -685,7 +685,7 @@
* set s_state to EXT2_VALID_FS after some corrections.
*/

-void ext2_write_super (struct super_block * sb)
+E2STATIC void ext2_write_super (struct super_block * sb)
{
struct ext2_super_block * es;

@@ -704,7 +704,7 @@
sb->s_dirt = 0;
}

-int ext2_remount (struct super_block * sb, int * flags, char * data)
+E2STATIC int ext2_remount (struct super_block * sb, int * flags, char * data)
{
struct ext2_super_block * es;
unsigned short resuid = sb->u.ext2_sb.s_resuid;
@@ -758,7 +758,7 @@
return 0;
}

-int ext2_statfs (struct super_block * sb, struct statfs * buf)
+E2STATIC int ext2_statfs (struct super_block * sb, struct statfs * buf)
{
unsigned long overhead;
int i;
@@ -820,5 +820,5 @@

EXPORT_NO_SYMBOLS;

-module_init(init_ext2_fs)
-module_exit(exit_ext2_fs)
+module_init(init_ext2_fs);
+module_exit(exit_ext2_fs);
diff -Naur -X /g/g/lib/dontdiff linux-2.4.17-pre2/fs/ext2/symlink.c linux-e2all/fs/ext2/symlink.c
--- linux-2.4.17-pre2/fs/ext2/symlink.c Wed Sep 27 20:41:33 2000
+++ linux-e2all/fs/ext2/symlink.c Sun Dec 2 11:00:10 2001
@@ -32,7 +32,7 @@
return vfs_follow_link(nd, s);
}

-struct inode_operations ext2_fast_symlink_inode_operations = {
+E2STATIC struct inode_operations ext2_fast_symlink_inode_operations = {
readlink: ext2_readlink,
follow_link: ext2_follow_link,
};


Attachments:
ext2-small.patch (22.71 kB)

2001-12-02 11:55:06

by Keith Owens

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

On Sun, 02 Dec 2001 06:31:17 -0500,
Jeff Garzik <[email protected]> wrote:
>Simply, all ext2 files are #include'd into a single file, ext2_all.c,
>and all functions and data structures are declared static.

I like it. With kbuild 2.5 the generation of ext2_all.c (I prefer
ext2_static.c) can be automated.

objlink(ext2.o balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o ioctl.o
namei.o super.o symlink.o)
select(CONFIG_EXT2_FS ext2.o)
make_static(ext2)

make_static(xxxx), which does not exist yet -

* Checks if CONFIG_MAKE_STATIC is set.
* Takes the objlink information from the kbuild 2.5 database.
* Automatically creates xxxx_static.c as a series of #include
statements for the source files derived from objlink.
* Replaces the objlink data with objlink(xxxx.o xxxx_static.o).
* Compiles xxxx_static.c with -DXXXX_STATIC=static.

The code that is normally linked into xxxx.o has to be manually changed
to add XXXX_STATIC before a make_static(xxxx) command can be added.

2001-12-02 12:33:36

by Ingo Oeser

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

On Sun, Dec 02, 2001 at 10:54:34PM +1100, Keith Owens wrote:
> On Sun, 02 Dec 2001 06:31:17 -0500,
> Jeff Garzik <[email protected]> wrote:
> >Simply, all ext2 files are #include'd into a single file, ext2_all.c,
> >and all functions and data structures are declared static.
>
> I like it.

Me also. Except for the KSTATIC spread all over the Kernel.

> With kbuild 2.5 the generation of ext2_all.c (I prefer
> ext2_static.c) can be automated.
>
> The code that is normally linked into xxxx.o has to be manually changed
> to add XXXX_STATIC before a make_static(xxxx) command can be added.

Even this doesn't have to be done manually. Everything that is
not covered by EXPORT_SYMBOL() in this case can be static, since
it belongs only to this subsystem and is not oficially exported
to other ones, which is a BUG if something depend on it with
CONFIG_MAKE_STATIC enabled.

Now if GCC had an option to make all symbols static by default,
which are not also declared extern...

Regards

Ingo Oeser
--
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth

2001-12-02 13:01:21

by Jeff Garzik

[permalink] [raw]
Subject: PATCH 2.4.17.2: CONFIG_FINAL, make kernel smaller

Ingo Oeser wrote:
> On Sun, Dec 02, 2001 at 10:54:34PM +1100, Keith Owens wrote:
> > On Sun, 02 Dec 2001 06:31:17 -0500,
> > Jeff Garzik <[email protected]> wrote:
> > >Simply, all ext2 files are #include'd into a single file, ext2_all.c,
> > >and all functions and data structures are declared static.
> >
> > I like it.
>
> Me also. Except for the KSTATIC spread all over the Kernel.

Yes :/ The source code is definitely uglier. Maybe 'kstatic' would be
better on the eyes.

I just converted reiserfs and linux/kernel directories to KSTATIC.
ftp://ftp.kernel.org/pub/linux/kernel/people/jgarzik/patches/2.4.17/config-final-2.4.17.2.patch.gz
(should appear on ftp.kernel.org and mirrors soon, if not already)

Bytes saved/eliminated:
ext2: 1135
reiserfs: 2966
kernel: 2578

total: 6679 bytes saved

The conversion of linux/kernel was surprising... I only changed two
'int' variables to KSTATIC. That implies to me that the majority of the
space savings might simply come from the better packing created when
compiling all the files into a single .o.

I would like to also point out a nice fringe benefit: since an entire
subsystem/driver is compiled together, you find bugs. I have found
[tiny, unimportant] bugs in all the code I have converted to KSTATIC so
far.

> [jgarzik@rum linux-e2all]$ ls -l vmlinux* arch/i386/boot/bzImage*
> -rw-r--r-- 1 jgarzik jgarzik 1030123 Dec 2 07:50 arch/i386/boot/bzImage
> -rw-r--r-- 1 jgarzik jgarzik 1030263 Dec 2 06:04 arch/i386/boot/bzImage.orig
> -rwxr-xr-x 1 jgarzik jgarzik 2809087 Dec 2 07:50 vmlinux*
> -rwxr-xr-x 1 jgarzik jgarzik 2815766 Dec 2 06:04 vmlinux.orig*

--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno

2001-12-02 13:03:53

by Jeff Garzik

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Ingo Oeser wrote:
> On Sun, Dec 02, 2001 at 10:54:34PM +1100, Keith Owens wrote:
> > With kbuild 2.5 the generation of ext2_all.c (I prefer
> > ext2_static.c) can be automated.

> > The code that is normally linked into xxxx.o has to be manually changed
> > to add XXXX_STATIC before a make_static(xxxx) command can be added.

> Even this doesn't have to be done manually. Everything that is
> not covered by EXPORT_SYMBOL() in this case can be static, since

And if !MODULE, then even EXPORT_SYMBOL symbols can become static, if
they are not used outside the compilation unit.

--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno

2001-12-02 13:08:11

by Jeff Garzik

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: CONFIG_FINAL, make kernel smaller

Jeff Garzik wrote:
> The conversion of linux/kernel was surprising... I only changed two
> 'int' variables to KSTATIC. That implies to me that the majority of the
> space savings might simply come from the better packing created when
> compiling all the files into a single .o.

Note that this implies we can get some code size savings without marking
all the functions KSTATIC... simply compiling them together gets a gain,
although not one as big as is possible with all applicable functions
marked.

Jeff


--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno

2001-12-02 13:40:44

by Ingo Oeser

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

On Sun, Dec 02, 2001 at 08:03:27AM -0500, Jeff Garzik wrote:
> Ingo Oeser wrote:
> > Even this doesn't have to be done manually. Everything that is
> > not covered by EXPORT_SYMBOL() in this case can be static, since
>
> And if !MODULE, then even EXPORT_SYMBOL symbols can become static, if
> they are not used outside the compilation unit.

If your compilation units are greater than the current
granularity of modules: Yes.

EXPORT_SYMBOL() symbols are Kernel-API, which is also exported to
3rd-party vendors with binary modules. So it makes little sense
to me to make them static.

PS: Have a nice 1st Advent ;-)

Regards

Ingo Oeser
--
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth

2001-12-02 13:48:25

by Jeff Garzik

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Ingo Oeser wrote:
>
> On Sun, Dec 02, 2001 at 08:03:27AM -0500, Jeff Garzik wrote:
> > Ingo Oeser wrote:
> > > Even this doesn't have to be done manually. Everything that is
> > > not covered by EXPORT_SYMBOL() in this case can be static, since
> >
> > And if !MODULE, then even EXPORT_SYMBOL symbols can become static, if
> > they are not used outside the compilation unit.
>
> If your compilation units are greater than the current
> granularity of modules: Yes.
>
> EXPORT_SYMBOL() symbols are Kernel-API, which is also exported to
> 3rd-party vendors with binary modules. So it makes little sense
> to me to make them static.

If !MODULES, modules are not supported by that kernel. It is completely
safe to make such functions static, if not used outside the compilation
unit. For all other cases, it is indeed wrong to make such them static.

Jeff


--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno

2001-12-02 13:53:25

by Ingo Oeser

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

On Sun, Dec 02, 2001 at 08:47:58AM -0500, Jeff Garzik wrote:
> Ingo Oeser wrote:
> >
> > On Sun, Dec 02, 2001 at 08:03:27AM -0500, Jeff Garzik wrote:
> > > And if !MODULE, then even EXPORT_SYMBOL symbols can become static, if
~~~~~~~[1]
> > > they are not used outside the compilation unit.
> >
> > If your compilation units are greater than the current
> > granularity of modules: Yes.
> >
> > EXPORT_SYMBOL() symbols are Kernel-API, which is also exported to
> > 3rd-party vendors with binary modules. So it makes little sense
> > to me to make them static.
>
> If !MODULES, modules are not supported by that kernel. It is completely
~~~~~~~~[2]
> safe to make such functions static, if not used outside the compilation
> unit. For all other cases, it is indeed wrong to make such them static.

Ahh! I thought with [1] you meant, that the compilation unit is
not compiled as a module. But with [2] it makes a lot of sense of
course ;-)

Sorry for my confusion.

Regards

Ingo Oeser
--
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth

2001-12-02 16:14:30

by Christer Weinigel

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Jeff Garzik wrote:
>This patch applies an obvious technique to the kernel: increase the
>amount of code compiled in a single compilation unit, to increase the
>overall knowledge the compiler has of the code, to allow for better
>optimization and dead code removal. KDE does this, with definite
>success, though they definitely are not the first to do this.
>
>Results from 2.4.17-pre2 plus the attached patch: 1135 bytes saved in
>vmlinux, simply from making all the functions static.
>(*.orig is prior to my patch. kernel is P2 SMP-based)
>> [jgarzik@rum linux-e2all]$ ls -l vmlinux* arch/i386/boot/bzImage*
>> -rw-r--r-- 1 jgarzik jgarzik 1030259 Dec 2 06:18 arch/i386/boot/bzImage
>> -rw-r--r-- 1 jgarzik jgarzik 1030263 Dec 2 06:04 arch/i386/boot/bzImage.orig
>> -rwxr-xr-x 1 jgarzik jgarzik 2814631 Dec 2 06:18 vmlinux*
>> -rwxr-xr-x 1 jgarzik jgarzik 2815766 Dec 2 06:04 vmlinux.orig*

I think that you've only saved some symbols in the vmlinux file, symbols
that will get stripped off anyway when building the bzImage. If you
want to see the real difference, remove the second "remove $$$tmppiggy"
from arch/i386/boot/compressed/Makefile and look at the _tmp_NNNNNpiggy
file left there.

/Christer
--
"Just how much can I get away with and still go to heaven?"

2001-12-02 16:54:51

by Martin Dalecki

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Jeff Garzik wrote:
>
> I do not plan to submit this patch to Linus/Marcelo.
>
> This patch applies an obvious technique to the kernel: increase the
> amount of code compiled in a single compilation unit, to increase the
> overall knowledge the compiler has of the code, to allow for better
> optimization and dead code removal. KDE does this, with definite
> success, though they definitely are not the first to do this.
>
> Simply, all ext2 files are #include'd into a single file, ext2_all.c,
> and all functions and data structures are declared static.
>
> This technique can be used in the kernel, userspace applications, and
> userspace libraries to decrease icache footprint and overall size of
> your applications.
>
> Results from 2.4.17-pre2 plus the attached patch: 1135 bytes saved in
> vmlinux, simply from making all the functions static.
> (*.orig is prior to my patch. kernel is P2 SMP-based)
> > [jgarzik@rum linux-e2all]$ ls -l vmlinux* arch/i386/boot/bzImage*
> > -rw-r--r-- 1 jgarzik jgarzik 1030259 Dec 2 06:18 arch/i386/boot/bzImage
> > -rw-r--r-- 1 jgarzik jgarzik 1030263 Dec 2 06:04 arch/i386/boot/bzImage.orig
> > -rwxr-xr-x 1 jgarzik jgarzik 2814631 Dec 2 06:18 vmlinux*
> > -rwxr-xr-x 1 jgarzik jgarzik 2815766 Dec 2 06:04 vmlinux.orig*
r

size vmlinux
and
size vmlinux.orig

would be a bit more telling whatever the reaons of the impact is.

2001-12-02 17:42:51

by Jeff Garzik

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Martin Dalecki wrote:
>
> Jeff Garzik wrote:
> >
> > I do not plan to submit this patch to Linus/Marcelo.
> >
> > This patch applies an obvious technique to the kernel: increase the
> > amount of code compiled in a single compilation unit, to increase the
> > overall knowledge the compiler has of the code, to allow for better
> > optimization and dead code removal. KDE does this, with definite
> > success, though they definitely are not the first to do this.
> >
> > Simply, all ext2 files are #include'd into a single file, ext2_all.c,
> > and all functions and data structures are declared static.
> >
> > This technique can be used in the kernel, userspace applications, and
> > userspace libraries to decrease icache footprint and overall size of
> > your applications.
> >
> > Results from 2.4.17-pre2 plus the attached patch: 1135 bytes saved in
> > vmlinux, simply from making all the functions static.
> > (*.orig is prior to my patch. kernel is P2 SMP-based)
> > > [jgarzik@rum linux-e2all]$ ls -l vmlinux* arch/i386/boot/bzImage*
> > > -rw-r--r-- 1 jgarzik jgarzik 1030259 Dec 2 06:18 arch/i386/boot/bzImage
> > > -rw-r--r-- 1 jgarzik jgarzik 1030263 Dec 2 06:04 arch/i386/boot/bzImage.orig
> > > -rwxr-xr-x 1 jgarzik jgarzik 2814631 Dec 2 06:18 vmlinux*
> > > -rwxr-xr-x 1 jgarzik jgarzik 2815766 Dec 2 06:04 vmlinux.orig*
> r
>
> size vmlinux
> and
> size vmlinux.orig
>
> would be a bit more telling whatever the reaons of the impact is.

easily done, on the latest CONFIG_FINAL patch posted to lkml:

[jgarzik@rum linux.test]$ size vmlinux.vanilla
text data bss dec hex filename
1908047 274672 353340 2536059 26b27b vmlinux.vanilla

[jgarzik@rum linux.test]$ size vmlinux
text data bss dec hex filename
1905136 273808 352860 2531804 26a1dc vmlinux

--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno

2001-12-02 21:32:00

by Andrew Morton

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Jeff Garzik wrote:
>
> Results from 2.4.17-pre2 plus the attached patch: 1135 bytes saved in
> vmlinux, simply from making all the functions static.
> (*.orig is prior to my patch. kernel is P2 SMP-based)
> > [jgarzik@rum linux-e2all]$ ls -l vmlinux* arch/i386/boot/bzImage*
> > -rw-r--r-- 1 jgarzik jgarzik 1030259 Dec 2 06:18 arch/i386/boot/bzImage
> > -rw-r--r-- 1 jgarzik jgarzik 1030263 Dec 2 06:04 arch/i386/boot/bzImage.orig
> > -rwxr-xr-x 1 jgarzik jgarzik 2814631 Dec 2 06:18 vmlinux*
> > -rwxr-xr-x 1 jgarzik jgarzik 2815766 Dec 2 06:04 vmlinux.orig*
>

but, but, but... That's on-disk size.

What does /usr/bin/size say?

And don't forget http://www.zip.com.au/~akpm/linux/2.4/2.4.17-pre1/inline.patch
which deletes 61 `inline's and save 12 kbytes. We really, really
need to examine our use of inlines. It's probable that we're
sloshing squigabytes of instructions across the external memory bus
quite unnecessarily.

-

2001-12-03 08:48:24

by Jeff Garzik

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Andrew Morton wrote:
> but, but, but... That's on-disk size.
>
> What does /usr/bin/size say?

read further down in the thread, there is /usr/bin/size savings as well


> And don't forget http://www.zip.com.au/~akpm/linux/2.4/2.4.17-pre1/inline.patch
> which deletes 61 `inline's and save 12 kbytes. We really, really
> need to examine our use of inlines.

agreed. a review of inlines has been needed for a while

--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno

2001-12-03 08:51:38

by Horst von Brand

[permalink] [raw]
Subject: Re: PATCH 2.4.17.2: make ext2 smaller

Jeff Garzik <[email protected]> said:
> This patch applies an obvious technique to the kernel: increase the
> amount of code compiled in a single compilation unit, to increase the
> overall knowledge the compiler has of the code, to allow for better
> optimization and dead code removal. KDE does this, with definite
> success, though they definitely are not the first to do this.

[...]

> Results from 2.4.17-pre2 plus the attached patch: 1135 bytes saved in
> vmlinux, simply from making all the functions static.

File size tells you nothing, it is influenced by symbol tables and
whatnot. What does size(1) say?

In any case, 1Kb out of 2Mb is 0.05%...
--
Horst von Brand [email protected]
Casilla 9G, Vin~a del Mar, Chile +56 32 672616