Re: [Ext2-devel] ext2/ialloc.c cleanup

Andreas Dilger
2001-11-08T22:45:01Z

On Nov 08, 2001 17:16 -0500, Alexander Viro wrote:
> + get_random_bytes(&group, sizeof(group));
> + goto fallback;

Little chance that 0 <= group < ngroups. Even so, value is unused, AFAICS.

> +fallback:
> + for (i = 0; i < ngroups; i++) {
> + group = (parent_cg + i) % ngroups;
> + cg = ext2_get_group_desc (sb, group, &bh);
> + if (!cg || !cg->bg_free_inodes_count)
> + continue;
> + if (le16_to_cpu(cg->bg_free_inodes_count) >= avefreei)
> + goto found;
> + }
> +
> + return -1;

> diff -urN S14/include/linux/ext2_fs_sb.h S14-ext2/include/linux/ext2_fs_sb.h
> --- S14/include/linux/ext2_fs_sb.h Fri Feb 16 21:29:52 2001
> +++ S14-ext2/include/linux/ext2_fs_sb.h Thu Nov 8 15:28:34 2001
> @@ -56,6 +56,8 @@
> int s_desc_per_block_bits;
> int s_inode_size;
> int s_first_ino;
> + unsigned long s_dir_count;
> + u8 *debts;
> };

I had thought a couple of times it may be useful to have an in-memory list
of group descriptors, each with a pointer to the on-disk struct, like
ext2_sb points to s_es.

Cheers, Andreas
--
Andreas Dilger