From: Dexuan Cui <decui@microsoft.com>
To: John Garry <john.garry@huawei.com>,
KY Srinivasan <kys@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
"wei.liu@kernel.org" <wei.liu@kernel.org>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
"ming.lei@redhat.com" <ming.lei@redhat.com>,
"bvanassche@acm.org" <bvanassche@acm.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
Long Li <longli@microsoft.com>,
Michael Kelley <mikelley@microsoft.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH v2] scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma()
Date: Thu, 7 Oct 2021 22:52:03 +0000 [thread overview]
Message-ID: <BYAPR21MB127049F258715B6F33D1B2B0BFB19@BYAPR21MB1270.namprd21.prod.outlook.com> (raw)
In-Reply-To: <8fe3959d-9462-64f6-53d8-ef7036ec0545@huawei.com>
> From: John Garry <john.garry@huawei.com>
> Sent: Thursday, October 7, 2021 2:42 PM
>
> On 07/10/2021 18:49, Dexuan Cui wrote:
> > After commit ea2f0f77538c, a 416-CPU VM running on Hyper-V hangs during
> > boot because scsi_add_host_with_dma() sets shost->cmd_per_lun to a
> > negative number (the below numbers may differ in different kernel versions):
> > in drivers/scsi/storvsc_drv.c, storvsc_drv_init() sets
> > 'max_outstanding_req_per_channel' to 352, and storvsc_probe() sets
> > 'max_sub_channels' to (416 - 1) / 4 = 103 and sets scsi_driver.can_queue to
> > 352 * (103 + 1) * (100 - 10) / 100 = 32947, which exceeds SHRT_MAX.
>
> I think that you just need to mention that if can_queue exceeds
> SHRT_MAX, then there is a data truncation issue.
I just hoped the explanation how the too big 'can_queue' value is generated is helpful.
OK, I think I can change the commit log to:
After commit ea2f0f77538c, a 416-CPU VM running on Hyper-V hangs during
boot because the hv_storvsc driver sets scsi_driver.can_queue to an "int"
value that exceeds SHRT_MAX, and hence scsi_add_host_with_dma() sets
shost->cmd_per_lun to a negative "short" number.
Use min_t(int, ...) to fix the issue.
> It looks ok, I'd just like to test it a bit more.
>
> Thanks,
> John
Thanks! I'll post v3 with the above commit log, and I look forward to your review/test.
> > v2 directly fixes the scsi core change instead as Michael Kelley and
> > John Garry suggested (refer to the above link).
>
> To be fair, it was Michael's suggestion
Yeah. Michael always gives good suggstions when reviewing patches. :-)
next prev parent reply other threads:[~2021-10-07 22:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 17:49 [PATCH v2] scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma() Dexuan Cui
2021-10-07 18:10 ` Haiyang Zhang
2021-10-07 21:41 ` John Garry
2021-10-07 22:52 ` Dexuan Cui [this message]
2021-10-08 3:19 ` Ming Lei
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=BYAPR21MB127049F258715B6F33D1B2B0BFB19@BYAPR21MB1270.namprd21.prod.outlook.com \
--to=decui@microsoft.com \
--cc=bvanassche@acm.org \
--cc=haiyangz@microsoft.com \
--cc=jejb@linux.ibm.com \
--cc=john.garry@huawei.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=martin.petersen@oracle.com \
--cc=mikelley@microsoft.com \
--cc=ming.lei@redhat.com \
--cc=stable@vger.kernel.org \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@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).