Patchwork [PATCHv2,7/7] mtd: Raise limit on block device minor numbers

login
register
mail settings
Submitter Ben Hutchings
Date Jan. 12, 2010, 11:10 p.m.
Message ID <1263337846.3011.28.camel@achroite.uk.solarflarecom.com>
Download mbox | patch
Permalink /patch/42777/
State New, archived
Headers show

Comments

Ben Hutchings - Jan. 12, 2010, 11:10 p.m.
add_mtd_blktrans_dev() imposes a maximum of 257 devices per block
translator.  This was presumably meant to prevent overflow back in the
days of 8-bit minor numbers.  Since we now have 20-bit minor numbers
and can have more than 32 MTDs, change the maximum to MINORMASK.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/mtd/mtd_blkdevs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Ben Hutchings - Jan. 14, 2010, 7:19 p.m.
On Tue, 2010-01-12 at 23:10 +0000, Ben Hutchings wrote:
> add_mtd_blktrans_dev() imposes a maximum of 257 devices per block
> translator.  This was presumably meant to prevent overflow back in the
> days of 8-bit minor numbers.  Since we now have 20-bit minor numbers
> and can have more than 32 MTDs, change the maximum to MINORMASK.
> 
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
> ---
>  drivers/mtd/mtd_blkdevs.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
> index 85a52b3..5e88b49 100644
> --- a/drivers/mtd/mtd_blkdevs.c
> +++ b/drivers/mtd/mtd_blkdevs.c
> @@ -242,7 +242,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
>  	if (new->devnum == -1)
>  		new->devnum = last_devnum+1;
>  
> -	if ((new->devnum << tr->part_bits) > 256) {
> +	if ((new->devnum << tr->part_bits) > MINORMASK) {

Actually this still has a boundary error.  I think the correct condition
is:

	new->devnum > (MINORMASK >> tr->part_bits)

Ben.

>  		return -EBUSY;
>  	}
>  
> -- 
> 1.5.5
>

Patch

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 85a52b3..5e88b49 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -242,7 +242,7 @@  int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	if (new->devnum == -1)
 		new->devnum = last_devnum+1;
 
-	if ((new->devnum << tr->part_bits) > 256) {
+	if ((new->devnum << tr->part_bits) > MINORMASK) {
 		return -EBUSY;
 	}