ext2 file system inode allocation policy

ext2 file system inode allocation policy

Post by Kristian K?hnto » Sun, 24 Mar 1996 04:00:00

I am running 1.3.77.

I just looked at the ext2_new_inode() function in
fs/ext2/ialloc.c. The comment there says

 * There are two policies for allocating an inode.  If the new inode is
 * a directory, then a forward search is made for a block group with both
 * free space and a low directory-to-inode ratio; if that fails, then of
 * the groups with above-average free space, that group with the fewest
 * directories already is chosen.
[ del del del ]

Looking at the code I find that the first strategy (find bg with
low d-i-ratio) is commented out. Furthermore the second strategy
is exactly the other way around: The code is looking for a bg
with above average free inodes and among these for the bg with
the fewest allocated blocks:

                if (!gdp) {
                        for (j = 0; j < sb->u.ext2_sb.s_groups_count; j++) {
                                tmp = get_group_desc (sb, j, &bh2);
                                if (tmp->bg_free_inodes_count &&
                                        tmp->bg_free_inodes_count >= avefreei) {
                                        if (!gdp ||
                                            (tmp->bg_free_blocks_count >
                                             gdp->bg_free_blocks_count)) {
                                                i = j;
                                                gdp = tmp;

I wonder why the first strategy is commented out (it does not
search the entire group descriptor table and should be faster).

I also wonder, which second strategy would be better: The one
described in the comment or the one implemented in the code...

Kristian Koehntopp, Wassilystrasse 30, 24113 Kiel, +49 431 688897
http://www.bundesregierung.de (Net King Kohl)