Minor nits, from my changes to this same function:
1) please replace use of "i" for best block group in find_cg_*, to
something better like "group", just for clarity.
2) in find_cg_*, when you fail the quadratic search, the linear search
should skip groups that were previously checked in the quadratic search,
with slight changes to both loops:
start = dir->u.ext2_i.i_block_group;
/* Use quadratic hash to find group with a free inode */
for (j = 1; j < count; j <<= 1) {
group = start + j;
if (group >= count)
group -= count;
cg = ext2_get_group_desc(sb, group, &bh);
if (cg && le16_to_cpu(cg->bg_free_inodes_count))
goto found;
}
/* That failed: try linear search for a free inode
* skipping groups we checked in the previous loop.
*/
for (j = 3; j < count; j++) {
if ((j & (j - 1)) == 0)
continue;
group = start + j;
if (group > count)
group -= count;
cg = ext2_get_group_desc(sb, group, &bh);
if (cg && le16_to_cpu(cg->bg_free_inodes_count))
goto found;
}
3) I know that "cylinder groups" were used in old FFS/whatever implementation,
but all of the ext2 code/documentation refers to these as block groups.
Can you stick with that for ext2 (e.g. gdp, not cg; bg_foo, not cg_foo)?
4) sbi can be gotten by "EXT2_SB(sb)".
Cheers, Andreas
-- Andreas Dilger http://sourceforge.net/projects/ext2resize/ http://www-mddsp.enel.ucalgary.ca/People/adilger/- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/