From: Damien Le Moal <dlemoal@kernel.org>
To: Keith Busch <kbusch@kernel.org>, Bart Van Assche <bvanassche@acm.org>
Cc: Keith Busch <kbusch@meta.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, snitzer@kernel.org,
axboe@kernel.dk, dw@davidwei.uk, brauner@kernel.org,
Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCHv2 1/7] block: check for valid bio while splitting
Date: Thu, 14 Aug 2025 10:42:35 +0900 [thread overview]
Message-ID: <b6860c56-e91d-45c8-8d4c-05bcae97a2bb@kernel.org> (raw)
In-Reply-To: <aJz9EUxTutWLxQmk@kbusch-mbp>
On 8/14/25 6:01 AM, Keith Busch wrote:
> On Wed, Aug 13, 2025 at 01:41:49PM -0700, Bart Van Assche wrote:
>> On 8/13/25 1:06 PM, Keith Busch wrote:
>>> But I can't make that change because many scsi devices don't set the dma
>>> alignment and get the default 511 value. This is fine for the memory
>>> address offset, but the lengths sent for various inquriy commands are
>>> much smaller, like 4 and 32 byte lengths. That length wouldn't pass the
>>> dma alignment granularity, so I think the default value is far too
>>> conservative. Does the address start size need to be a different limit
>>> than minimum length? I feel like they should be the same, but maybe
>>> that's just an nvme thing.
>>
>> Hi Keith,
>>
>> Maybe I misunderstood your question. It seems to me that the SCSI core
>> sets the DMA alignment by default to four bytes. From
>> drivers/scsi/hosts.c:
>
> Thanks, I think you got my meaning.
>
> I'm using the AHCI driver. It looks like ata_scsi_dev_config() overrides
> the dma_alignment to sector_size - 1, and that pattern goes way back,
> almost 20 years ago, so maybe I can't change it.
That is probably buggy now in the sense that the scsi layer should be able to
send any command with a size not aligned to the LBA size or ATA sector (512 B)
and libata-scsi SAT should do the translation using an internal 512B aligned
command size.
What makes a mess here is that SCSI allows having a media-access command
specifying a transfer size that is not aligned on the LBA size. The transfer
will be "short" in that case, which is perfectly fine with SCSI. But ATA does
not allow that. It is all or nothing and the command size thus must always be
aligned to the LBA size.
I think that dma_alignment was abused to check that. But I think it should not
be too hard to check the alignment in libata-scsi when translating the command.
SAS HBAs should be doing something similar too. Have never exactly tested that
though, and I am afraid how many SAS HBAs will not like unaligned command to
ATA devices...
We also have the different alignment for management commands (most of which use
512B sector size) and media access commands which use the actual device LBA
size alignment.
So it is a mess :)
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2025-08-14 1:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 14:11 [PATCHv2 0/7] direct-io: even more flexible io vectors Keith Busch
2025-08-05 14:11 ` [PATCHv2 1/7] block: check for valid bio while splitting Keith Busch
2025-08-10 14:37 ` Christoph Hellwig
2025-08-10 15:39 ` Keith Busch
2025-08-10 17:14 ` Christoph Hellwig
2025-08-13 20:06 ` Keith Busch
2025-08-13 20:41 ` Bart Van Assche
2025-08-13 21:01 ` Keith Busch
2025-08-13 23:17 ` Bart Van Assche
2025-08-14 1:42 ` Damien Le Moal [this message]
2025-08-13 21:23 ` Martin K. Petersen
2025-08-13 21:52 ` Keith Busch
2025-08-18 4:49 ` Christoph Hellwig
2025-08-05 14:11 ` [PATCHv2 2/7] block: align the bio after building it Keith Busch
2025-08-06 6:07 ` Hannes Reinecke
2025-08-10 14:43 ` Christoph Hellwig
2025-08-05 14:11 ` [PATCHv2 3/7] block: simplify direct io validity check Keith Busch
2025-08-05 14:11 ` [PATCHv2 4/7] iomap: " Keith Busch
2025-08-06 6:07 ` Hannes Reinecke
2025-08-05 14:11 ` [PATCHv2 5/7] block: remove bdev_iter_is_aligned Keith Busch
2025-08-05 14:11 ` [PATCHv2 6/7] blk-integrity: use simpler alignment check Keith Busch
2025-08-05 14:11 ` [PATCHv2 7/7] iov_iter: remove iov_iter_is_aligned Keith Busch
2025-08-06 6:08 ` Hannes Reinecke
2025-08-06 3:03 ` [PATCHv2 0/7] direct-io: even more flexible io vectors Martin K. Petersen
2025-08-06 14:51 ` Christoph Hellwig
2025-08-07 23:20 ` Keith Busch
2025-08-11 10:32 ` Christoph Hellwig
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=b6860c56-e91d-45c8-8d4c-05bcae97a2bb@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=bvanassche@acm.org \
--cc=dw@davidwei.uk \
--cc=hare@suse.de \
--cc=kbusch@kernel.org \
--cc=kbusch@meta.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).