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

Andreas Dilger (adilger@turbolabs.com)
Thu, 8 Nov 2001 15:43:12 -0700


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
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/