Re: lots and lots of disks again

Christoph Hellwig
2004-02-10T13:39:39Z

On Tue, Feb 10, 2004 at 12:26:58PM +0100, Kurt Garloff wrote:
> +/* sd_index_bits array size / disks
> + * 32 / 256
> + * 4096 / 32768
> + * 32768 / 262144
> + */
> +#ifdef CONFIG_EMBEDDED
> +# define SD_DISKS 256
> +#else
> +# define SD_DISKS 32768 // we can raise this to 262144 if needed
> +#endif

Umm, using CONFIG_EMBEDDED doesn't mean no config option - it just mean
another config option which no-one would think of changing the number of
support scsi disks.

Really, any solution that requires huge static allocations is wrong. The
bitmap either needs to be replaced with a saner algorithm or dynamic
allocation and reallocation on growth.

> }
>
> +static int inv_sd_major(int major)
> +{
> + switch (major) {
> + case SCSI_DISK0_MAJOR:
> + return 0;
> + case SCSI_DISK1_MAJOR ... SCSI_DISK7_MAJOR:
> + return major + 1 - SCSI_DISK1_MAJOR;
> + case SCSI_DISK8_MAJOR ... SCSI_DISK15_MAJOR:
> + return major + 8 - SCSI_DISK8_MAJOR;
> + default:
> + BUG();
> + return 0; /* shut up gcc */
> + }
> +}
> +
> +unsigned int dev_to_sd_nr(unsigned int dev) {
> + return ((dev >> 4) & 15) | (inv_sd_major(dev >> 20) << 4) |
> + (dev & 0x3ff00);
> +}
> +unsigned int dev_to_sd_part(unsigned int dev) {
> + return (dev & 15) | ((dev >> 14) & 0x30);
> +}
> +

Maybe I missed something but this seems completely unused?

Also please follow the coding style guidelines, that is opening brace
for functions on the next line and non-exported functions always static.