[PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE

sw.prabhu6@gmail.com posted 2 patches 1 month, 1 week ago
[PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
Posted by sw.prabhu6@gmail.com 1 month, 1 week ago
From: Swarna Prabhu <s.prabhu@samsung.com>

Now that block layer can support block size > PAGE_SIZE
and the issue with WRITE_SAME(16) and WRITE_SAME(10) are
fixed for sector sizes > PAGE_SIZE, enable sdebug_sector_size
> PAGE_SIZE in scsi_debug.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Swarna Prabhu <s.prabhu@samsung.com>
---
 drivers/scsi/scsi_debug.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index c947655db518..4c6feee87f05 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -8495,13 +8495,7 @@ static int __init scsi_debug_init(void)
 	} else if (sdebug_ndelay > 0)
 		sdebug_jdelay = JDELAY_OVERRIDDEN;
 
-	switch (sdebug_sector_size) {
-	case  512:
-	case 1024:
-	case 2048:
-	case 4096:
-		break;
-	default:
+	if (blk_validate_block_size(sdebug_sector_size)) {
 		pr_err("invalid sector_size %d\n", sdebug_sector_size);
 		return -EINVAL;
 	}
-- 
2.39.5
Re: [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
Posted by John Garry 1 month ago
On 19/02/2026 04:37, sw.prabhu6@gmail.com wrote:
> From: Swarna Prabhu <s.prabhu@samsung.com>
> 
> Now that block layer can support block size > PAGE_SIZE
> and the issue with WRITE_SAME(16) and WRITE_SAME(10) are
> fixed for sector sizes > PAGE_SIZE, enable sdebug_sector_size
>> PAGE_SIZE in scsi_debug.
> 

Surely the sd driver or block layer should be catching non-compliant HW, 
right?

The scsi_debug driver should minic HW, and there is nothing in any SCSI 
specs which mentions that the sector size needs to be limited to 64KB or 
the like - am I correct? The useful thing about scsi_debug is that we 
can pretend to be broken* HW and see if the upper layers catch it.

*broken for Linux or non-compliant wrt spec

> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Swarna Prabhu <s.prabhu@samsung.com>
> ---
>   drivers/scsi/scsi_debug.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index c947655db518..4c6feee87f05 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -8495,13 +8495,7 @@ static int __init scsi_debug_init(void)
>   	} else if (sdebug_ndelay > 0)
>   		sdebug_jdelay = JDELAY_OVERRIDDEN;
>   
> -	switch (sdebug_sector_size) {
> -	case  512:
> -	case 1024:
> -	case 2048:
> -	case 4096:
> -		break;
> -	default:
> +	if (blk_validate_block_size(sdebug_sector_size)) {
>   		pr_err("invalid sector_size %d\n", sdebug_sector_size);
>   		return -EINVAL;
>   	}
Re: [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
Posted by Swarna Prabhu 1 month ago
On Fri, Feb 27, 2026 at 08:35:32AM +0000, John Garry wrote:
> On 19/02/2026 04:37, sw.prabhu6@gmail.com wrote:
> > From: Swarna Prabhu <s.prabhu@samsung.com>
> > 
> > Now that block layer can support block size > PAGE_SIZE
> > and the issue with WRITE_SAME(16) and WRITE_SAME(10) are
> > fixed for sector sizes > PAGE_SIZE, enable sdebug_sector_size
> > > PAGE_SIZE in scsi_debug.
> > 
> 
> Surely the sd driver or block layer should be catching non-compliant HW,
> right?

Yes, the sd driver and block layer will catch any non compliant HW.
> 
> The scsi_debug driver should minic HW, and there is nothing in any SCSI
> specs which mentions that the sector size needs to be limited to 64KB or the
> like - am I correct? The useful thing about scsi_debug is that we can
> pretend to be broken* HW and see if the upper layers catch it.
> 
> *broken for Linux or non-compliant wrt spec
>

As you pointed, the SCSI spec doesn't restrict the sector size to be
limited to 64 KiB. Earlier block layer had limitations on block size
upto PAGE_SIZE. With that limitation being addressed and sd driver
change, sd driver and block layer can handle large block sizes
correctly. By allowing large sector size on scsi debug we allow 
emulation of spec compliant HW. 

Thanks
Swarna

> > Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> > Signed-off-by: Swarna Prabhu <s.prabhu@samsung.com>
> > ---
> >   drivers/scsi/scsi_debug.c | 8 +-------
> >   1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> > index c947655db518..4c6feee87f05 100644
> > --- a/drivers/scsi/scsi_debug.c
> > +++ b/drivers/scsi/scsi_debug.c
> > @@ -8495,13 +8495,7 @@ static int __init scsi_debug_init(void)
> >   	} else if (sdebug_ndelay > 0)
> >   		sdebug_jdelay = JDELAY_OVERRIDDEN;
> > -	switch (sdebug_sector_size) {
> > -	case  512:
> > -	case 1024:
> > -	case 2048:
> > -	case 4096:
> > -		break;
> > -	default:
> > +	if (blk_validate_block_size(sdebug_sector_size)) {
> >   		pr_err("invalid sector_size %d\n", sdebug_sector_size);
> >   		return -EINVAL;
> >   	}
>
Re: [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
Posted by John Garry 1 month ago
On 02/03/2026 12:27, Swarna Prabhu wrote:
>>>> PAGE_SIZE in scsi_debug.
>> Surely the sd driver or block layer should be catching non-compliant HW,
>> right?
> Yes, the sd driver and block layer will catch any non compliant HW.
>> The scsi_debug driver should minic HW, and there is nothing in any SCSI
>> specs which mentions that the sector size needs to be limited to 64KB or the
>> like - am I correct? The useful thing about scsi_debug is that we can
>> pretend to be broken* HW and see if the upper layers catch it.
>>
>> *broken for Linux or non-compliant wrt spec
>>
> As you pointed, the SCSI spec doesn't restrict the sector size to be
> limited to 64 KiB. Earlier block layer had limitations on block size
> upto PAGE_SIZE. With that limitation being addressed and sd driver
> change, sd driver and block layer can handle large block sizes
> correctly. By allowing large sector size on scsi debug we allow
> emulation of spec compliant HW.

Sure, so is there any reason to have those checks in scsi_debug at all? 
Would removing them break that driver and be unsafe?

Thanks,
John

> 
>>> Reviewed-by: Damien Le Moal<dlemoal@kernel.org>
>>> Signed-off-by: Swarna Prabhu<s.prabhu@samsung.com>
>>> ---
>>>    drivers/scsi/scsi_debug.c | 8 +-------
>>>    1 file changed, 1 insertion(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
>>> index c947655db518..4c6feee87f05 100644
>>> --- a/drivers/scsi/scsi_debug.c
>>> +++ b/drivers/scsi/scsi_debug.c
>>> @@ -8495,13 +8495,7 @@ static int __init scsi_debug_init(void)
>>>    	} else if (sdebug_ndelay > 0)
>>>    		sdebug_jdelay = JDELAY_OVERRIDDEN;
>>> -	switch (sdebug_sector_size) {
>>> -	case  512:
>>> -	case 1024:
>>> -	case 2048:
>>> -	case 4096:
>>> -		break;
>>> -	default:
>>> +	if (blk_validate_block_size(sdebug_sector_size)) {
>>>    		pr_err("invalid sector_size %d\n", sdebug_sector_size);
>>>    		return -EINVAL;