* [RFC PATCH 0/2] enable sector size > PAGE_SIZE for scsi
@ 2025-12-02 2:15 sw.prabhu6
2025-12-02 2:15 ` [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE sw.prabhu6
2025-12-02 2:15 ` [PATCH 2/2] scsi: enable sector_size " sw.prabhu6
0 siblings, 2 replies; 7+ messages in thread
From: sw.prabhu6 @ 2025-12-02 2:15 UTC (permalink / raw)
To: James.Bottomley, martin.petersen, linux-scsi
Cc: linux-kernel, mcgrof, kernel, Swarna Prabhu
From: Swarna Prabhu <sw.prabhu6@gmail.com>
Hi All,
Now that block layer can support block size > PAGE_SIZE, enable the
same for scsi devices. There was one issue with write_same16 and
write_same10 command, which is fixed as a part of the series.
Testing:
1. Test suite: xfs and generic from fstest + QEMU emulated block
device(scsi and nvme)
- fstest Config for patched xfs 16k block size [xfs_reflink_16k_scsi]
TEST_DEV=/dev/sda
SCRATCH_DEV_POOL="/dev/sdb"
MKFS_OPTIONS='-f -m reflink=1,rmapbt=1, -i sparse=1, -b size=16384,
-s size=16384'
- Generic test results
Baseline: 6.18-rc5 kernel + nvme 16k logical block size
Patched: 6.18-rc5 kernel + scsi 16k logical block size
6 failures seen on generic tests and the same seen on baseline
No regressions
- XFS tests results
Baseline: 6.18-rc6 kernel + nvme16k logical block size
Patched: 6.18-rc6 kernel + sci 16k logical block size
198 failures seen on patched and baseline
No regressions
- Tests similar to above was run on 32k logical block size
No regressions seen on xfs tests.
Generic/778 (add sudden shutdown tests for multi block atomic writes
)test is failing on scsi 32k block size due to atomic write taking
too long to start, but is passing on the nvme 32k block size setup.
Since sysfs shows atomic write granularity not enforced for scsi device
it seems that XFS issues atomic writes slower. Upon increasing the
wait timeout from 10s to 40s for the first atomic write in
'start_atomic_write_and_shutdown' generic/778 seems to pass for
32k scsi sector size.
2. blktests: scsi and block layer sub tests
Baseline: tests with scsi 4k block size
Patched: tests with patched kernel + 16k scsi block size
- scsi tests - no regressions.
- block tests - Disabled block/010 and block/011
Hard to reproduce(sporadic) kernel hang seen while running
block layer tests ie at block/003 due to fio task being blocked
by a mutex held by udev event. Not seen while running it
individually.
Rootcause - block/001 stress the scsi debug devices by adding,
tearing, removing the devices in parallel that triggers udevs.
This races with fio task triggered by block/003.
Added udevadm settle and small delay between block/001 and
block/003 fixes this and using this as a temporary fix, while
we continue to evaluate. Note: block/002 being skipped.
Swarna Prabhu (2):
scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE
scsi: enable sector_size > PAGE_SIZE
drivers/scsi/scsi_debug.c | 9 ++-------
drivers/scsi/sd.c | 19 +++++++++++++------
2 files changed, 15 insertions(+), 13 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE
2025-12-02 2:15 [RFC PATCH 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
@ 2025-12-02 2:15 ` sw.prabhu6
2025-12-03 0:28 ` Bart Van Assche
2025-12-02 2:15 ` [PATCH 2/2] scsi: enable sector_size " sw.prabhu6
1 sibling, 1 reply; 7+ messages in thread
From: sw.prabhu6 @ 2025-12-02 2:15 UTC (permalink / raw)
To: James.Bottomley, martin.petersen, linux-scsi
Cc: linux-kernel, mcgrof, kernel, 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, adapt sd_set_special_bvec()
to accommodate that.
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>
---
Note: We are allocating pages of order aligned to
BLK_MAX_BLOCK_SIZE for the mempool page allocator
'sd_page_pool' all the time. This is because we only
know that a bigger sector size device is attached at
sd_probe and it might be too late to reallocate mempool
with order > 0.
drivers/scsi/sd.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 0252d3f6bed1..c3502fcba1bb 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -895,11 +895,20 @@ static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim,
static void *sd_set_special_bvec(struct request *rq, unsigned int data_len)
{
struct page *page;
+ struct scsi_device *sdp = scsi_disk(rq->q->disk)->device;
+ unsigned sector_size = sdp->sector_size;
+ unsigned int nr_pages = DIV_ROUND_UP(sector_size, PAGE_SIZE);
+ int n = 0;
page = mempool_alloc(sd_page_pool, GFP_ATOMIC);
if (!page)
return NULL;
- clear_highpage(page);
+
+ do {
+ clear_highpage(page + n);
+ n++;
+ } while (n < nr_pages);
+
bvec_set_page(&rq->special_vec, page, data_len, 0);
rq->rq_flags |= RQF_SPECIAL_PAYLOAD;
return bvec_virt(&rq->special_vec);
@@ -4368,7 +4377,7 @@ static int __init init_sd(void)
if (err)
goto err_out;
- sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, 0);
+ sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, get_order(BLK_MAX_BLOCK_SIZE));
if (!sd_page_pool) {
printk(KERN_ERR "sd: can't init discard page pool\n");
err = -ENOMEM;
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] scsi: enable sector_size > PAGE_SIZE
2025-12-02 2:15 [RFC PATCH 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
2025-12-02 2:15 ` [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE sw.prabhu6
@ 2025-12-02 2:15 ` sw.prabhu6
2025-12-03 0:30 ` Bart Van Assche
1 sibling, 1 reply; 7+ messages in thread
From: sw.prabhu6 @ 2025-12-02 2:15 UTC (permalink / raw)
To: James.Bottomley, martin.petersen, linux-scsi
Cc: linux-kernel, mcgrof, kernel, 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 sector sizes
> PAGE_SIZE in scsi and scsi_debug.
Signed-off-by: Swarna Prabhu <s.prabhu@samsung.com>
---
drivers/scsi/scsi_debug.c | 9 ++-------
drivers/scsi/sd.c | 6 ++----
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index b2ab97be5db3..b5839e62d3bb 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -8459,13 +8459,8 @@ 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 (sdebug_sector_size < 512 || sdebug_sector_size > BLK_MAX_BLOCK_SIZE ||
+ !is_power_of_2(sdebug_sector_size)) {
pr_err("invalid sector_size %d\n", sdebug_sector_size);
return -EINVAL;
}
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c3502fcba1bb..f2eac79d7263 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2889,10 +2889,8 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim,
"assuming 512.\n");
}
- if (sector_size != 512 &&
- sector_size != 1024 &&
- sector_size != 2048 &&
- sector_size != 4096) {
+ if (sector_size < 512 || sector_size > BLK_MAX_BLOCK_SIZE ||
+ !is_power_of_2(sector_size)) {
sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
sector_size);
/*
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE
2025-12-02 2:15 ` [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE sw.prabhu6
@ 2025-12-03 0:28 ` Bart Van Assche
2025-12-03 0:55 ` Swarna Prabhu
0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2025-12-03 0:28 UTC (permalink / raw)
To: sw.prabhu6, James.Bottomley, martin.petersen, linux-scsi
Cc: linux-kernel, mcgrof, kernel, Swarna Prabhu, Pankaj Raghav
On 12/1/25 4:15 PM, sw.prabhu6@gmail.com wrote:
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 0252d3f6bed1..c3502fcba1bb 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -895,11 +895,20 @@ static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim,
> static void *sd_set_special_bvec(struct request *rq, unsigned int data_len)
> {
> struct page *page;
> + struct scsi_device *sdp = scsi_disk(rq->q->disk)->device;
> + unsigned sector_size = sdp->sector_size;
> + unsigned int nr_pages = DIV_ROUND_UP(sector_size, PAGE_SIZE);
> + int n = 0;
>
> page = mempool_alloc(sd_page_pool, GFP_ATOMIC);
> if (!page)
> return NULL;
> - clear_highpage(page);
> +
> + do {
> + clear_highpage(page + n);
> + n++;
> + } while (n < nr_pages);
> +
> bvec_set_page(&rq->special_vec, page, data_len, 0);
> rq->rq_flags |= RQF_SPECIAL_PAYLOAD;
> return bvec_virt(&rq->special_vec);
> @@ -4368,7 +4377,7 @@ static int __init init_sd(void)
> if (err)
> goto err_out;
>
> - sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, 0);
> + sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, get_order(BLK_MAX_BLOCK_SIZE));
> if (!sd_page_pool) {
> printk(KERN_ERR "sd: can't init discard page pool\n");
> err = -ENOMEM;
Have the above changes been tested? I don't see any changes for this
code from drivers/scsi/sd.c:
if (sector_size != 512 &&
sector_size != 1024 &&
sector_size != 2048 &&
sector_size != 4096) {
sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
sector_size);
[ ... ]
}
Thanks,
Bart.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] scsi: enable sector_size > PAGE_SIZE
2025-12-02 2:15 ` [PATCH 2/2] scsi: enable sector_size " sw.prabhu6
@ 2025-12-03 0:30 ` Bart Van Assche
2025-12-03 0:56 ` Swarna Prabhu
0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2025-12-03 0:30 UTC (permalink / raw)
To: sw.prabhu6, James.Bottomley, martin.petersen, linux-scsi
Cc: linux-kernel, mcgrof, kernel, Swarna Prabhu
On 12/1/25 4:15 PM, sw.prabhu6@gmail.com wrote:
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index b2ab97be5db3..b5839e62d3bb 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -8459,13 +8459,8 @@ 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 (sdebug_sector_size < 512 || sdebug_sector_size > BLK_MAX_BLOCK_SIZE ||
> + !is_power_of_2(sdebug_sector_size)) {
> pr_err("invalid sector_size %d\n", sdebug_sector_size);
> return -EINVAL;
> }
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index c3502fcba1bb..f2eac79d7263 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -2889,10 +2889,8 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim,
> "assuming 512.\n");
> }
>
> - if (sector_size != 512 &&
> - sector_size != 1024 &&
> - sector_size != 2048 &&
> - sector_size != 4096) {
> + if (sector_size < 512 || sector_size > BLK_MAX_BLOCK_SIZE ||
> + !is_power_of_2(sector_size)) {
> sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
> sector_size);
> /*
Please reorganize this patch series into one patch for the scsi_debug
driver and another patch for the sd driver.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE
2025-12-03 0:28 ` Bart Van Assche
@ 2025-12-03 0:55 ` Swarna Prabhu
0 siblings, 0 replies; 7+ messages in thread
From: Swarna Prabhu @ 2025-12-03 0:55 UTC (permalink / raw)
To: Bart Van Assche
Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel,
mcgrof, kernel, Swarna Prabhu, Pankaj Raghav
On Tue, Dec 02, 2025 at 02:28:47PM -1000, Bart Van Assche wrote:
> On 12/1/25 4:15 PM, sw.prabhu6@gmail.com wrote:
> > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> > index 0252d3f6bed1..c3502fcba1bb 100644
> > --- a/drivers/scsi/sd.c
> > +++ b/drivers/scsi/sd.c
> > @@ -895,11 +895,20 @@ static void sd_config_discard(struct scsi_disk *sdkp, struct queue_limits *lim,
> > static void *sd_set_special_bvec(struct request *rq, unsigned int data_len)
> > {
> > struct page *page;
> > + struct scsi_device *sdp = scsi_disk(rq->q->disk)->device;
> > + unsigned sector_size = sdp->sector_size;
> > + unsigned int nr_pages = DIV_ROUND_UP(sector_size, PAGE_SIZE);
> > + int n = 0;
> > page = mempool_alloc(sd_page_pool, GFP_ATOMIC);
> > if (!page)
> > return NULL;
> > - clear_highpage(page);
> > +
> > + do {
> > + clear_highpage(page + n);
> > + n++;
> > + } while (n < nr_pages);
> > +
> > bvec_set_page(&rq->special_vec, page, data_len, 0);
> > rq->rq_flags |= RQF_SPECIAL_PAYLOAD;
> > return bvec_virt(&rq->special_vec);
> > @@ -4368,7 +4377,7 @@ static int __init init_sd(void)
> > if (err)
> > goto err_out;
> > - sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, 0);
> > + sd_page_pool = mempool_create_page_pool(SD_MEMPOOL_SIZE, get_order(BLK_MAX_BLOCK_SIZE));
> > if (!sd_page_pool) {
> > printk(KERN_ERR "sd: can't init discard page pool\n");
> > err = -ENOMEM;
>
> Have the above changes been tested?
Yes, the test details are included in the cover letter
Thanks
Swarna
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] scsi: enable sector_size > PAGE_SIZE
2025-12-03 0:30 ` Bart Van Assche
@ 2025-12-03 0:56 ` Swarna Prabhu
0 siblings, 0 replies; 7+ messages in thread
From: Swarna Prabhu @ 2025-12-03 0:56 UTC (permalink / raw)
To: Bart Van Assche
Cc: James.Bottomley, martin.petersen, linux-scsi, linux-kernel,
mcgrof, kernel, Swarna Prabhu
On Tue, Dec 02, 2025 at 02:30:19PM -1000, Bart Van Assche wrote:
> On 12/1/25 4:15 PM, sw.prabhu6@gmail.com wrote:
> > diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> > index b2ab97be5db3..b5839e62d3bb 100644
> > --- a/drivers/scsi/scsi_debug.c
> > +++ b/drivers/scsi/scsi_debug.c
> > @@ -8459,13 +8459,8 @@ 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 (sdebug_sector_size < 512 || sdebug_sector_size > BLK_MAX_BLOCK_SIZE ||
> > + !is_power_of_2(sdebug_sector_size)) {
> > pr_err("invalid sector_size %d\n", sdebug_sector_size);
> > return -EINVAL;
> > }
> > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> > index c3502fcba1bb..f2eac79d7263 100644
> > --- a/drivers/scsi/sd.c
> > +++ b/drivers/scsi/sd.c
> > @@ -2889,10 +2889,8 @@ sd_read_capacity(struct scsi_disk *sdkp, struct queue_limits *lim,
> > "assuming 512.\n");
> > }
> > - if (sector_size != 512 &&
> > - sector_size != 1024 &&
> > - sector_size != 2048 &&
> > - sector_size != 4096) {
> > + if (sector_size < 512 || sector_size > BLK_MAX_BLOCK_SIZE ||
> > + !is_power_of_2(sector_size)) {
> > sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
> > sector_size);
> > /*
>
> Please reorganize this patch series into one patch for the scsi_debug
> driver and another patch for the sd driver.
>
Sure, will do.
Thanks
Swarna
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-03 0:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-02 2:15 [RFC PATCH 0/2] enable sector size > PAGE_SIZE for scsi sw.prabhu6
2025-12-02 2:15 ` [PATCH 1/2] scsi: fix write_same16 and write_same10 for sector size > PAGE_SIZE sw.prabhu6
2025-12-03 0:28 ` Bart Van Assche
2025-12-03 0:55 ` Swarna Prabhu
2025-12-02 2:15 ` [PATCH 2/2] scsi: enable sector_size " sw.prabhu6
2025-12-03 0:30 ` Bart Van Assche
2025-12-03 0:56 ` Swarna Prabhu
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®