mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi
@ 2026-02-19  4:37 sw.prabhu6
  2026-02-19  4:37 ` [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver sw.prabhu6
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: sw.prabhu6 @ 2026-02-19  4:37 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen, linux-scsi
  Cc: linux-kernel, mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu

From: Swarna Prabhu <sw.prabhu6@gmail.com>

Hi All,

This is v4 series sent based on the review comments received on v3 [1].
This patchset enables sector sizes > PAGE_SIZE for
sd driver and scsi_debug driver since block layer can support block
size > PAGE_SIZE. There was one issue with write_same16 and write_same10
command, which is fixed as a part of the series.

Changes since v2:
 - Added reviewed by tag for scsi sd driver and scsi_debug patch.
 - Modified the helper function name used for safe creation and destruction
   of the large page mempool.
 - No functional changes.

Thanks to Damien for review.

Testing:
Testing results are same as v3 since no functional changes introduced in v4.

Link to v3: https://lore.kernel.org/all/20260214011829.508272-1-sw.prabhu6@gmail.com/ [1]

Swarna Prabhu (2):
  scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver
  scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE

 drivers/scsi/scsi_debug.c |  8 +---
 drivers/scsi/sd.c         | 80 +++++++++++++++++++++++++++++++++------
 2 files changed, 69 insertions(+), 19 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver
  2026-02-19  4:37 [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
@ 2026-02-19  4:37 ` sw.prabhu6
  2026-03-01  1:49   ` Martin K. Petersen
  2026-02-19  4:37 ` [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE sw.prabhu6
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: sw.prabhu6 @ 2026-02-19  4:37 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen, linux-scsi
  Cc: linux-kernel, mcgrof, pankaj.raghav, bvanassche, dlemoal,
	Swarna Prabhu, Swarna Prabhu, Pankaj Raghav

From: Swarna Prabhu <sw.prabhu6@gmail.com>

The WRITE SAME(16) and WRITE SAME(10) scsi commands uses
a page from a dedicated mempool('sd_page_pool') for its
payload. This pool was initialized to allocate single
pages, which was sufficient as long as the device sector
size did not exceed the PAGE_SIZE.

Given that block layer now supports block size upto
64K ie beyond PAGE_SIZE, initialize large page pool in
'sd_probe()' if a higher sector device is attached ensuring
atomicity. Adapt 'sd_set_special_bvec()' to use large page
pool when a higher sector size device is attached. Hence
enable sector sizes > PAGE_SIZE in scsi sd driver.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Swarna Prabhu <s.prabhu@samsung.com>
Co-developed-by: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 drivers/scsi/sd.c | 80 ++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 68 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index d76996d6cbc9..ce09239c18cb 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -107,8 +107,11 @@ static void sd_config_write_same(struct scsi_disk *sdkp,
 static void  sd_revalidate_disk(struct gendisk *);
 
 static DEFINE_IDA(sd_index_ida);
+static DEFINE_MUTEX(sd_mutex_lock);
 
 static mempool_t *sd_page_pool;
+static mempool_t *sd_large_page_pool;
+static atomic_t sd_large_page_pool_users = ATOMIC_INIT(0);
 static struct lock_class_key sd_bio_compl_lkclass;
 
 static const char *sd_cache_types[] = {
@@ -116,6 +119,33 @@ static const char *sd_cache_types[] = {
 	"write back, no read (daft)"
 };
 
+static int sd_large_pool_create(void)
+{
+	mutex_lock(&sd_mutex_lock);
+	if (!sd_large_page_pool) {
+		sd_large_page_pool = mempool_create_page_pool(
+			SD_MEMPOOL_SIZE, get_order(BLK_MAX_BLOCK_SIZE));
+		if (!sd_large_page_pool) {
+			printk(KERN_ERR "sd: can't create large page mempool\n");
+			mutex_unlock(&sd_mutex_lock);
+			return -ENOMEM;
+		}
+	}
+	atomic_inc(&sd_large_page_pool_users);
+	mutex_unlock(&sd_mutex_lock);
+	return 0;
+}
+
+static void sd_large_pool_destroy(void)
+{
+	mutex_lock(&sd_mutex_lock);
+	if (atomic_dec_and_test(&sd_large_page_pool_users)) {
+		mempool_destroy(sd_large_page_pool);
+		sd_large_page_pool = NULL;
+	}
+	mutex_unlock(&sd_mutex_lock);
+}
+
 static void sd_disable_discard(struct scsi_disk *sdkp)
 {
 	sdkp->provisioning_mode = SD_LBP_DISABLE;
@@ -928,14 +958,24 @@ static unsigned char sd_setup_protect_cmnd(struct scsi_cmnd *scmd,
 	return protect;
 }
 
-static void *sd_set_special_bvec(struct request *rq, unsigned int data_len)
+static void *sd_set_special_bvec(struct scsi_cmnd *cmd, unsigned int data_len)
 {
 	struct page *page;
+	struct request *rq = scsi_cmd_to_rq(cmd);
+	struct scsi_device *sdp = cmd->device;
+	unsigned sector_size = sdp->sector_size;
+	unsigned int nr_pages = DIV_ROUND_UP(sector_size, PAGE_SIZE);
+	int n;
 
-	page = mempool_alloc(sd_page_pool, GFP_ATOMIC);
+	if (sector_size > PAGE_SIZE)
+		page = mempool_alloc(sd_large_page_pool, GFP_ATOMIC);
+	else
+		page = mempool_alloc(sd_page_pool, GFP_ATOMIC);
 	if (!page)
 		return NULL;
-	clear_highpage(page);
+
+	for (n = 0; n < nr_pages; n++)
+		clear_highpage(page + n);
 	bvec_set_page(&rq->special_vec, page, data_len, 0);
 	rq->rq_flags |= RQF_SPECIAL_PAYLOAD;
 	return bvec_virt(&rq->special_vec);
@@ -951,7 +991,7 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)
 	unsigned int data_len = 24;
 	char *buf;
 
-	buf = sd_set_special_bvec(rq, data_len);
+	buf = sd_set_special_bvec(cmd, data_len);
 	if (!buf)
 		return BLK_STS_RESOURCE;
 
@@ -1040,7 +1080,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,
 	u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
 	u32 data_len = sdp->sector_size;
 
-	if (!sd_set_special_bvec(rq, data_len))
+	if (!sd_set_special_bvec(cmd, data_len))
 		return BLK_STS_RESOURCE;
 
 	cmd->cmd_len = 16;
@@ -1067,7 +1107,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
 	u32 nr_blocks = sectors_to_logical(sdp, blk_rq_sectors(rq));
 	u32 data_len = sdp->sector_size;
 
-	if (!sd_set_special_bvec(rq, data_len))
+	if (!sd_set_special_bvec(cmd, data_len))
 		return BLK_STS_RESOURCE;
 
 	cmd->cmd_len = 10;
@@ -1513,9 +1553,15 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
 static void sd_uninit_command(struct scsi_cmnd *SCpnt)
 {
 	struct request *rq = scsi_cmd_to_rq(SCpnt);
+	struct scsi_device *sdp = SCpnt->device;
+	unsigned sector_size = sdp->sector_size;
 
-	if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
-		mempool_free(rq->special_vec.bv_page, sd_page_pool);
+	if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) {
+		if (sector_size > PAGE_SIZE)
+			mempool_free(rq->special_vec.bv_page, sd_large_page_pool);
+		else
+			mempool_free(rq->special_vec.bv_page, sd_page_pool);
+	}
 }
 
 static bool sd_need_revalidate(struct gendisk *disk, struct scsi_disk *sdkp)
@@ -2912,10 +2958,7 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim,
 			  "Sector size 0 reported, assuming 512.\n");
 	}
 
-	if (sector_size != 512 &&
-	    sector_size != 1024 &&
-	    sector_size != 2048 &&
-	    sector_size != 4096) {
+	if (blk_validate_block_size(sector_size)) {
 		sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
 			  sector_size);
 		/*
@@ -4043,6 +4086,12 @@ static int sd_probe(struct scsi_device *sdp)
 	sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
 
 	sd_revalidate_disk(gd);
+	if (sdp->sector_size > PAGE_SIZE) {
+		if (sd_large_pool_create()) {
+			error = -ENOMEM;
+			goto out_free_index;
+		}
+	}
 
 	if (sdp->removable) {
 		gd->flags |= GENHD_FL_REMOVABLE;
@@ -4060,6 +4109,8 @@ static int sd_probe(struct scsi_device *sdp)
 	if (error) {
 		device_unregister(&sdkp->disk_dev);
 		put_disk(gd);
+		if (sdp->sector_size > PAGE_SIZE)
+			sd_large_pool_destroy();
 		goto out;
 	}
 
@@ -4212,6 +4263,9 @@ static void sd_remove(struct scsi_device *sdp)
 		sd_shutdown(sdp);
 
 	put_disk(sdkp->disk);
+
+	if (sdp->sector_size > PAGE_SIZE)
+		sd_large_pool_destroy();
 }
 
 static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime)
@@ -4435,6 +4489,8 @@ static void __exit exit_sd(void)
 
 	scsi_unregister_driver(&sd_template);
 	mempool_destroy(sd_page_pool);
+	if (sd_large_page_pool)
+		mempool_destroy(sd_large_page_pool);
 
 	class_unregister(&sd_disk_class);
 
-- 
2.39.5


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
  2026-02-19  4:37 [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
  2026-02-19  4:37 ` [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver sw.prabhu6
@ 2026-02-19  4:37 ` sw.prabhu6
  2026-02-27  8:35   ` John Garry
  2026-02-27  3:09 ` [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi Swarna Prabhu
  2026-03-11  2:06 ` (subset) " Martin K. Petersen
  3 siblings, 1 reply; 11+ messages in thread
From: sw.prabhu6 @ 2026-02-19  4:37 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen, linux-scsi
  Cc: linux-kernel, mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi
  2026-02-19  4:37 [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
  2026-02-19  4:37 ` [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver sw.prabhu6
  2026-02-19  4:37 ` [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE sw.prabhu6
@ 2026-02-27  3:09 ` Swarna Prabhu
  2026-03-11  2:06 ` (subset) " Martin K. Petersen
  3 siblings, 0 replies; 11+ messages in thread
From: Swarna Prabhu @ 2026-02-27  3:09 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen
  Cc: linux-kernel, mcgrof, pankaj.raghav, bvanassche, dlemoal, linux-scsi

On Wed, Feb 18, 2026 at 08:37:40PM -0800, sw.prabhu6@gmail.com wrote:
> From: Swarna Prabhu <sw.prabhu6@gmail.com>
> 
> Hi All,
> 
> This is v4 series sent based on the review comments received on v3 [1].
> This patchset enables sector sizes > PAGE_SIZE for
> sd driver and scsi_debug driver since block layer can support block
> size > PAGE_SIZE. There was one issue with write_same16 and write_same10
> command, which is fixed as a part of the series.
> 
> Changes since v2:
>  - Added reviewed by tag for scsi sd driver and scsi_debug patch.
>  - Modified the helper function name used for safe creation and destruction
>    of the large page mempool.
>  - No functional changes.
> 
> Thanks to Damien for review.
> 
> Testing:
> Testing results are same as v3 since no functional changes introduced in v4.
> 
> Link to v3: https://lore.kernel.org/all/20260214011829.508272-1-sw.prabhu6@gmail.com/ [1]
> 
> Swarna Prabhu (2):
>   scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver
>   scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
> 
>  drivers/scsi/scsi_debug.c |  8 +---
>  drivers/scsi/sd.c         | 80 +++++++++++++++++++++++++++++++++------
>  2 files changed, 69 insertions(+), 19 deletions(-)
> 
> -- 
> 2.39.5
>

Gentle ping. 

Just wanted to make sure it didn't get lost. 

Please let me know if any updates are needed.

Thank you, 
Swarna Prabhu

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
  2026-02-19  4:37 ` [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE sw.prabhu6
@ 2026-02-27  8:35   ` John Garry
  2026-03-02 12:27     ` Swarna Prabhu
  0 siblings, 1 reply; 11+ messages in thread
From: John Garry @ 2026-02-27  8:35 UTC (permalink / raw)
  To: sw.prabhu6, James.Bottomley, martin.petersen, linux-scsi
  Cc: linux-kernel, mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu

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;
>   	}


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver
  2026-02-19  4:37 ` [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver sw.prabhu6
@ 2026-03-01  1:49   ` Martin K. Petersen
  0 siblings, 0 replies; 11+ messages in thread
From: Martin K. Petersen @ 2026-03-01  1:49 UTC (permalink / raw)
  To: sw.prabhu6
  Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel,
	mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu,
	Pankaj Raghav


> The WRITE SAME(16) and WRITE SAME(10) scsi commands uses a page from a
> dedicated mempool('sd_page_pool') for its payload. This pool was
> initialized to allocate single pages, which was sufficient as long as
> the device sector size did not exceed the PAGE_SIZE.

Applied to 7.1/scsi-staging, thanks!

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
  2026-02-27  8:35   ` John Garry
@ 2026-03-02 12:27     ` Swarna Prabhu
  2026-03-02 12:37       ` John Garry
  0 siblings, 1 reply; 11+ messages in thread
From: Swarna Prabhu @ 2026-03-02 12:27 UTC (permalink / raw)
  To: John Garry
  Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel,
	mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu

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;
> >   	}
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
  2026-03-02 12:27     ` Swarna Prabhu
@ 2026-03-02 12:37       ` John Garry
  0 siblings, 0 replies; 11+ messages in thread
From: John Garry @ 2026-03-02 12:37 UTC (permalink / raw)
  To: Swarna Prabhu
  Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel,
	mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu

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;


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: (subset) [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi
  2026-02-19  4:37 [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
                   ` (2 preceding siblings ...)
  2026-02-27  3:09 ` [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi Swarna Prabhu
@ 2026-03-11  2:06 ` Martin K. Petersen
  3 siblings, 0 replies; 11+ messages in thread
From: Martin K. Petersen @ 2026-03-11  2:06 UTC (permalink / raw)
  To: James.Bottomley, linux-scsi, sw.prabhu6
  Cc: Martin K . Petersen, linux-kernel, mcgrof, pankaj.raghav,
	bvanassche, dlemoal

On Wed, 18 Feb 2026 20:37:40 -0800, sw.prabhu6@gmail.com wrote:

> This is v4 series sent based on the review comments received on v3 [1].
> This patchset enables sector sizes > PAGE_SIZE for
> sd driver and scsi_debug driver since block layer can support block
> size > PAGE_SIZE. There was one issue with write_same16 and write_same10
> command, which is fixed as a part of the series.
> 
> Changes since v2:
>  - Added reviewed by tag for scsi sd driver and scsi_debug patch.
>  - Modified the helper function name used for safe creation and destruction
>    of the large page mempool.
>  - No functional changes.
> 
> [...]

Applied to 7.1/scsi-queue, thanks!

[1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver
      https://git.kernel.org/mkp/scsi/c/7179e626b76e

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
  2026-02-11  1:50 [PATCH v2 " sw.prabhu6
@ 2026-02-11  1:50 ` sw.prabhu6
  0 siblings, 0 replies; 11+ messages in thread
From: sw.prabhu6 @ 2026-02-11  1:50 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen, linux-scsi
  Cc: linux-kernel, mcgrof, pankaj.raghav, bvanassche, dlemoal, Swarna Prabhu

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.

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 c5085e6d2e75..91f42b7e68aa 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -8508,13 +8508,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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE
  2025-12-10  1:41 [v1 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
@ 2025-12-10  1:41 ` sw.prabhu6
  0 siblings, 0 replies; 11+ messages in thread
From: sw.prabhu6 @ 2025-12-10  1:41 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen, linux-scsi
  Cc: bvanassche, linux-kernel, mcgrof, kernel, dlemoal, Swarna Prabhu,
	Swarna Prabhu

From: Swarna Prabhu <sw.prabhu6@gmail.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.

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 b2ab97be5db3..2348976b3f70 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -8459,13 +8459,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.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-03-11  2:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-19  4:37 [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
2026-02-19  4:37 ` [PATCH 1/2] scsi: sd: enable sector size > PAGE_SIZE in scsi sd driver sw.prabhu6
2026-03-01  1:49   ` Martin K. Petersen
2026-02-19  4:37 ` [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE sw.prabhu6
2026-02-27  8:35   ` John Garry
2026-03-02 12:27     ` Swarna Prabhu
2026-03-02 12:37       ` John Garry
2026-02-27  3:09 ` [PATCH v4 0/2] enable sector size > PAGE_SIZE for scsi Swarna Prabhu
2026-03-11  2:06 ` (subset) " Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2026-02-11  1:50 [PATCH v2 " sw.prabhu6
2026-02-11  1:50 ` [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE sw.prabhu6
2025-12-10  1:41 [v1 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
2025-12-10  1:41 ` [PATCH 2/2] scsi: scsi_debug: enable sdebug_sector_size > PAGE_SIZE sw.prabhu6

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®