From: "Theodore Ts'o" <tytso@mit.edu>
To: linux-kernel@vger.kernel.org
Subject: [RFC] Slimming down struct inode
Date: Fri, 09 Jun 2006 19:50:08 -0400 [thread overview]
Message-ID: <E1Foqjw-00010e-Ln@candygram.thunk.org> (raw)
Since Linus has been complaining about how awful ext3's in-core inodes
are, and given that 70% of the space used by ext3's in-core inode is
coming from the include/linux/fs.h's struct inode structure, I decided
it would be good to see how we might be able to slim it down. Slimming
down struct inode has the added benefit that it will help all
filesystems, so this is generic goodness. Furthermore, depending on
which features you have compiled into the kernel, even slimming struct
inode by 12 bytes could result being able to pack more objects per page
in the slab cache.
So without further ado, here are some ideas of ways that we can slim
down struct inode:
1) Move i_blksize (optimal size for I/O, reported by the stat system
call). Is there any reason why this needs to be per-inode, instead
of per-filesystem?
2) Move i_blkbits (blocksize for doing direct I/O in bits) to struct
super. Again, why is this per-inode?
3) Move i_pipe, i_bdev, and i_cdev into a union. An inode cannot
simultaneously be a pipe, block device, and character device at the
same time.
4) i_state and i_flags are both 4-byte longs, but they only need to be
2-byte shorts, and could be placed next to each other.
5) Nuke i_cindex. This is only used by ieee1394's
ieee_file_to_instance. There must be another place where we can
store this --- say, in a ieee1394-specific field in struct file? Or
maybe it can be derived some other way, but to chew up 4 bytes in
i_cindex for all inodes just for ieee1394's benefit seems like the
Wrong Thing(tm).
6) Separate out those elements which are only used if the inode is open
into a separate data structure (call it "struct inode_state" for
the sake of argument):
i_flock, i_mapping, i_data, i_dnotify_mask, i_dnotify,
inotify_watches, inotify_sem, i_state, dirtied_when,
i_size_seqcount, i_mutex, i_alloc_sem
This is the motherload. Moving these fields out to a separate
structure which is only allocated for inodes which are open will save
a huge amount of memory. But, of course, sweeping through all of the
code which uses these variables to move them would be a major code
change. (We can do it initially with #define magic, but we will need
to audit the code paths to see if it's always to safe to assume that
inode is open before dereferencing the i_state pointer, or whether we
need to check to see if it is valid first.)
The first four I think are fairly non-contentious, but it's worth
checking to see if anybody knows if there are filesystems for which the
block size changes on a per-inode basis (I hope not!). There's a very
trivial way of fixing #5 by simply moving i_cindex into struct file, but
it may be possible to fix the ieee1394 layer so it doesn't need it at
all.
#6 is going to be the hard one, since it will involving touching the
largest amount of code. But of course, the payoff will be quite big as
well. Of course, memory is pretty cheap these days, which is probably
why we've ignored it until Linus started kvetching about the size of
ext3's in-core inodes.... and when I looked into it, most of it wasn't
even ext3's fault. :-)
What do people think? Is it worth putting together patches to do some
or all of the above?
- Ted
next reply other threads:[~2006-06-09 23:50 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-09 23:50 Theodore Ts'o [this message]
2006-06-10 0:24 ` Bernd Eckenfels
2006-06-10 1:27 ` Al Viro
2006-06-10 1:56 ` Theodore Tso
2006-06-10 6:24 ` Stefan Richter
2006-06-10 10:48 ` Jan Engelhardt
2006-06-10 15:04 ` Jeff Garzik
2006-06-13 4:35 ` Nathan Scott
2006-06-13 4:32 ` Nathan Scott
2006-06-13 14:00 ` Avi Kivity
2006-06-13 17:44 ` Theodore Tso
2006-06-13 18:08 ` Avi Kivity
2006-06-13 20:10 ` Jan Engelhardt
2006-06-13 20:25 ` Avi Kivity
2006-06-13 22:41 ` Nathan Scott
2006-06-14 10:29 ` Nikita Danilov
2006-06-14 21:50 ` Nathan Scott
2006-06-15 5:49 ` Theodore Tso
2006-06-15 7:01 ` Nathan Scott
2006-06-15 8:46 ` Brian F. G. Bidulock
2006-06-15 10:20 ` Nathan Scott
2006-06-14 23:27 ` Jan Engelhardt
2006-06-15 10:09 ` Nikita Danilov
2006-06-10 11:03 ` Tomasz Torcz
2006-06-10 15:06 ` Jeff Garzik
2006-06-15 0:16 ` Brian F. G. Bidulock
2006-06-15 4:43 ` Theodore Tso
2006-06-15 8:27 ` Brian F. G. Bidulock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Foqjw-00010e-Ln@candygram.thunk.org \
--to=tytso@mit.edu \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®