From: sashiko-bot@kernel.org
To: "Phil Pemberton" <philpem@philpem.me.uk>
Cc: dlemoal@kernel.org, linux-scsi@vger.kernel.org,
cassel@kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH v9 04/11] scsi: sr: initialize logical block size before registering the disk
Date: Tue, 06 Oct 2026 23:53:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-162536@kernel.org> (raw)
In-Reply-To: <20261006234202.1139018-5-philpem@philpem.me.uk>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: sr: physical_block_size permanently stuck at 2048 after hot-plugging 512-byte media
--
commit e4bcc9c7bb99e2ad5359e3deb3e003674d2e6c22
Author: Phil Pemberton <philpem@philpem.me.uk>
scsi: sr: initialize logical block size before registering the disk
This commit updates the logical block size of the request queue to match
the driver's default sector size (2048 bytes) if the drive is empty during
probe. This attempts to prevent mismatched block sizes when reading from
media inserted later.
> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
> index c36c54ecd354b..268f15a4fdb88 100644
> --- a/drivers/scsi/sr.c
> +++ b/drivers/scsi/sr.c
[ ... ]
> @@ -701,6 +702,16 @@ static int sr_probe(struct scsi_device *sdev)
> if (error)
> goto unregister_cdrom;
>
> + /* If no medium was ready, match the queue to the driver's guess. */
> + if (queue_logical_block_size(sdev->request_queue) != sdev->sector_size) {
> + lim = queue_limits_start_update(sdev->request_queue);
> + lim.logical_block_size = sdev->sector_size;
> + error = queue_limits_commit_update_frozen(sdev->request_queue,
> + &lim);
> + if (error)
> + goto unregister_cdrom;
> + }
> +
[Severity: High]
Does this logic introduce a regression where physical_block_size becomes
permanently stuck at 2048 when a 512-byte medium is inserted later?
If a drive is empty during sr_probe(), this code promotes the
logical_block_size to 2048. Because the block layer one-way promotes
physical_block_size to match logical_block_size, blk_validate_limits()
will automatically latch physical_block_size to 2048:
block/blk-settings.c:blk_validate_limits() {
...
if (lim->physical_block_size < lim->logical_block_size) {
lim->physical_block_size = lim->logical_block_size;
...
}
When a 512-byte medium is later hot-plugged, sr_revalidate_disk() shrinks
logical_block_size back to 512:
drivers/scsi/sr.c:sr_revalidate_disk() {
...
lim = queue_limits_start_update(q);
lim.logical_block_size = sector_size;
lim.features |= BLK_FEAT_ROTATIONAL;
return queue_limits_commit_update_frozen(q, &lim);
...
}
However, blk_validate_limits() never automatically shrinks
physical_block_size. Could this leave physical_block_size and io_min
permanently at 2048, continuing to cause mismatched block size issues?
> error = device_add_disk(&sdev->sdev_gendev, disk, NULL);
> if (error)
> goto unregister_cdrom;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261006234202.1139018-1-philpem@philpem.me.uk?part=4
next prev parent reply other threads:[~2026-10-06 23:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 23:41 [PATCH v9 00/11] ata: add multi-LUN support for ATAPI devices Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 01/11] ata: libata-core: pin SCSI devices during port detach Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 02/11] ata: libata-zpodd: reference SCSI devices in PM callbacks Phil Pemberton
2026-10-06 23:59 ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 03/11] scsi: scsi_devinfo: preserve full-width quirk identifiers Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 04/11] scsi: sr: initialize logical block size before registering the disk Phil Pemberton
2026-10-06 23:53 ` sashiko-bot [this message]
2026-10-06 23:41 ` [PATCH v9 05/11] scsi: sr: retry unfinished media revalidation on the next open Phil Pemberton
2026-10-06 23:52 ` sashiko-bot
2026-10-06 23:41 ` [PATCH v9 06/11] ata: libata-scsi: add atapi_max_lun module parameter Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 07/11] ata: libata-scsi: convert dev->sdev to per-LUN array Phil Pemberton
2026-10-06 23:58 ` sashiko-bot
2026-10-07 2:38 ` Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 08/11] ata: libata-scsi: route non-zero LUN commands for multi-LUN ATAPI Phil Pemberton
2026-10-06 23:41 ` [PATCH v9 09/11] scsi: add BLIST_NO_LUN_1F blacklist flag Phil Pemberton
2026-10-06 23:42 ` [PATCH v9 10/11] ata: libata-scsi: probe additional LUNs for multi-LUN ATAPI devices Phil Pemberton
2026-10-06 23:42 ` [PATCH v9 11/11] scsi: scsi_devinfo: add COMPAQ PD-1 multi-LUN ATAPI device quirk Phil Pemberton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-162536@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=philpem@philpem.me.uk \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox