Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
Cc: James.Bottomley@HansenPartnership.com, ahuang12@lenovo.com,
	axboe@kernel.dk, hch@lst.de, ionut_n2001@yahoo.com,
	john.g.garry@oracle.com, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, m.szyprowski@samsung.com,
	martin.petersen@oracle.com, robin.murphy@arm.com,
	sunlightlinux@gmail.com
Subject: Re: [PATCH v4] scsi: sas: skip opt_sectors when DMA reports no real optimization hint
Date: Fri, 20 Mar 2026 05:49:10 +0900	[thread overview]
Message-ID: <c6aa3d0b-e815-4b73-8677-d8dd2fe1d5ff@kernel.org> (raw)
In-Reply-To: <20260319204333.17432-1-ionut.nechita@windriver.com>

On 3/20/26 05:43, Ionut Nechita (Wind River) wrote:
> On Wed, 19 Mar 2026 11:07:00 +0000, Damien Le Moal wrote:
>> Why return 0 ? This is a valid case, so this should get through the
>> alignment below.
> 
> Hi Damien,
> 
> Thanks for the review.
> 
> The opt == max case is specifically the bug this patch fixes.
> 
> When the IOMMU is disabled or in passthrough mode and no DMA ops
> provide an opt_mapping_size callback, dma_opt_mapping_size() falls
> back to min(SIZE_MAX, dma_max_mapping_size()), which equals
> dma_max_mapping_size().  So opt == max.
> 
> If we let that value through, rounddown_pow_of_two() produces a
> huge power-of-two, and min_t() caps it at max_sectors (32767).
> That gives opt_sectors = 32767, which is exactly the bogus value
> that breaks mkfs.xfs:
> 
>   swidth = 16773120 / 4096 = 4095
>   sunit  = 8192 / 4096     = 2
>   4095 % 2 != 0  ->  "SB stripe unit sanity check failed"
> 
> The key insight (from Robin Murphy's v1 review) is that when no
> backend provides a real optimization constraint, the DMA core
> returns the largest efficient size == the largest size.  That is
> correct DMA semantics, but it means opt == max signals "no
> preference", not "the optimal size happens to equal the maximum".
> 
> Returning 0 in that case means "no preference", which leaves
> opt_sectors at 0 and lets the disk's own geometry (or lack
> thereof) determine the I/O size.

Thanks for re-explaining this.

The code needs to have all this explanation as comment so that we do not trip on
this again.

> 
> Regarding the Cc list: noted, I will trim it for v5 if needed.
> 
> Thanks,
> Ionut


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-03-19 20:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19  8:39 [PATCH v4 0/1] scsi: sas: fix mkfs.xfs failure due to bogus optimal_io_size Ionut Nechita (Wind River)
2026-03-19  8:39 ` [PATCH v4] scsi: sas: skip opt_sectors when DMA reports no real optimization hint Ionut Nechita (Wind River)
2026-03-19 11:06   ` Damien Le Moal
2026-03-19 11:07   ` Damien Le Moal
2026-03-19 20:43     ` Ionut Nechita (Wind River)
2026-03-19 20:49       ` Damien Le Moal [this message]
2026-03-19 21:04       ` James Bottomley

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=c6aa3d0b-e815-4b73-8677-d8dd2fe1d5ff@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=ahuang12@lenovo.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=ionut.nechita@windriver.com \
    --cc=ionut_n2001@yahoo.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=martin.petersen@oracle.com \
    --cc=robin.murphy@arm.com \
    --cc=sunlightlinux@gmail.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