public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukas Herbolt <lukas@herbolt.com>
To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, Lukas Herbolt <lukas@herbolt.com>
Subject: [PATCH 1/1] scsi: sd: Rounddown host->opt_sectors to logical
Date: Fri, 14 Nov 2025 11:28:55 +0100	[thread overview]
Message-ID: <20251114102853.1476938-4-lukas@herbolt.com> (raw)
In-Reply-To: <20251114102853.1476938-2-lukas@herbolt.com>

The host->opt_sectors are by default 512 bytes aligned if we have 4KN SAS
disk reporting zero or smaller opt_xfer_block than the host->opt_sectors
we will end up with unaligned queue_limit->io_opt.

Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
---
 drivers/scsi/sd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 5b8668accf8e8..382474c3555c3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3787,7 +3787,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	 * an impact on performance for when the size of a request exceeds this
 	 * host limit.
 	 */
-	lim.io_opt = sdp->host->opt_sectors << SECTOR_SHIFT;
+	lim.io_opt = rounddown(lim.logical_block_size,
+			sdp->host->opt_sectors << SECTOR_SHIFT);
 	if (sd_validate_opt_xfer_size(sdkp, dev_max)) {
 		lim.io_opt = min_not_zero(lim.io_opt,
 				logical_to_bytes(sdp, sdkp->opt_xfer_blocks));
-- 
2.51.1


  reply	other threads:[~2025-11-14 10:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14 10:28 [PATCH 0/1] Fix unaligned queue_limit->io_opt on SAS and 4KN disk Lukas Herbolt
2025-11-14 10:28 ` Lukas Herbolt [this message]
2025-11-20  3:26   ` [PATCH 1/1] scsi: sd: Rounddown host->opt_sectors to logical Martin K. Petersen
2025-11-20 12:07     ` lukas
2025-11-20 16:07     ` John Garry
2025-11-21  8:34       ` lukas

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=20251114102853.1476938-4-lukas@herbolt.com \
    --to=lukas@herbolt.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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