From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>,
dlemoal@kernel.org
Cc: 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: Thu, 19 Mar 2026 17:04:01 -0400 [thread overview]
Message-ID: <bd3120c2cddce94182354b71c90c693ea9c7cb62.camel@HansenPartnership.com> (raw)
In-Reply-To: <20260319204333.17432-1-ionut.nechita@windriver.com>
On Thu, 2026-03-19 at 22:43 +0200, 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"
So if max_sectors is usually 32767 and this breaks xfs why the final
line:
> + return min_t(unsigned int, opt >> SECTOR_SHIFT,
> max_sectors);
because there are surely situations where the above max_sectors
(32767) comes back as the minimum or are you assuming opt >>
SECTOR_SHIFT is always less than max_sectors, in which case there's no
need for min_t?
Additionally, I note that the new AI code review:
https://sashiko.dev/#/patchset/20260319083954.21056-1-ionut.nechita%40windriver.com
Worries that if opt comes back as its don't care zero value then
rounddown_pow_of_2(opt) returns a bogus value.
Regards,
James
prev parent reply other threads:[~2026-03-19 21:04 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
2026-03-19 21:04 ` James Bottomley [this message]
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=bd3120c2cddce94182354b71c90c693ea9c7cb62.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=ahuang12@lenovo.com \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--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
all inboxes | Powered by JetHome®