Re: [PATCH] Large Block device patch part 3/4

From: Andreas Dilger (adilger@clusterfs.com)
Date: Thu Oct 03 2002 - 01:01:03 EST


On Oct 03, 2002 15:20 +1000, peterc@gelato.unsw.edu.au wrote:
> diff -Nru a/drivers/block/cciss.c b/drivers/block/cciss.c
> --- a/drivers/block/cciss.c Thu Oct 3 15:06:13 2002
> +++ b/drivers/block/cciss.c Thu Oct 3 15:06:13 2002
> @@ -405,7 +405,7 @@
> } else {
> driver_geo.heads = 0xff;
> driver_geo.sectors = 0x3f;
> - driver_geo.cylinders = hba[ctlr]->drv[dsk].nr_blocks / (0xff*0x3f);
> + driver_geo.cylinders = (int)hba[ctlr]->drv[dsk].nr_blocks / (0xff*0x3f);
> }
> driver_geo.start= get_start_sect(inode->i_bdev);
> if (copy_to_user((void *) arg, &driver_geo,

Wouldn't this be better off as:

    driver_geo.cylinders = (int)(hba[ctlr]->drv[dsk].nr_blocks / (0xff*0x3f));

> diff -Nru a/drivers/md/linear.c b/drivers/md/linear.c
> --- a/drivers/md/linear.c Thu Oct 3 15:06:13 2002
> +++ b/drivers/md/linear.c Thu Oct 3 15:06:13 2002
> @@ -72,10 +72,12 @@
> goto out;
> }
>
> - nb_zone = conf->nr_zones =
> - md_size[mdidx(mddev)] / conf->smallest->size +
> - ((md_size[mdidx(mddev)] % conf->smallest->size) ? 1 : 0);
> -
> + {
> + sector_t sz = md_size[mdidx(mddev)];
> + unsigned round = sector_div(sz, conf->smallest->size);
> + nb_zone = conf->nr_zones = sz + (round ? 1 : 0);
> + }
> +
> conf->hash_table = kmalloc (sizeof (struct linear_hash) * nb_zone,
> GFP_KERNEL);
> if (!conf->hash_table)

Something like the following should work for most cases (i.e. as long as
an individual device isn't larger than 2TB):

        round = do_div(sz, conf->smallest_size);

> printk("raid0 : conf->smallest->size is %ld blocks.\n", conf->smallest->size);
> nb_zone = md_size[mdidx(mddev)]/conf->smallest->size +
> - (md_size[mdidx(mddev)] % conf->smallest->size ? 1 : 0);
> - printk("raid0 : nb_zone is %ld.\n", nb_zone);
> + (md_size[mdidx(mddev)] % conf->smallest->size ? 1 : 0);
> + printk("raid0 : nb_zone is %d.\n", nb_zone);

Don't we need something similar here also?

Cheers, Andreas

--
Andreas Dilger
http://www-mddsp.enel.ucalgary.ca/People/adilger/
http://sourceforge.net/projects/ext2resize/

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



This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:37 EST