scsi: scsi_debug: Disallow zone sizes that are not powers of 2
authorDamien Le Moal <damien.lemoal@wdc.com>
Thu, 7 May 2020 02:35:26 +0000 (11:35 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 8 May 2020 00:45:02 +0000 (20:45 -0400)
commit108e36f0d8bf91839613d8053a6d1354965801b0
tree6791e13e7771e7189956788ea3819c4650238ca3
parent64e14ece07004f0bf434fe7aad4a6d6411b1d9b6
scsi: scsi_debug: Disallow zone sizes that are not powers of 2

Allowing a non-power-of-2 zone size forces the use of direct division
operations of 64-bit sector values to obtain a zone number or number of
zones. Doing so without using do_div() leads to compilation errors on
32-bit architectures.

Devices with a zone size that is not a power of 2 do not exist today so
allowing their emulation is of limited interest as the sd driver will not
support them anyway. To fix this compilation error, instead of using
do_div() for sector values divisions, simply disallow zone size values that
are not a power of 2.

[mkp: commit desc]

Link: https://lore.kernel.org/r/20200507023526.221574-1-damien.lemoal@wdc.com
Fixes: 98e0a689868c ("scsi: scsi_debug: Add zone_size_mb module parameter")
Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_debug.c