From: chenxiang <chenxiang66@hisilicon.com>
To: <axboe@kernel.dk>, <tj@kernel.org>, <martin.petersen@oracle.com>
Cc: <linux-ide@vger.kernel.org>, <linux-scsi@vger.kernel.org>,
<linuxarm@openeuler.org>, <linuxarm@huawei.com>,
Xiang Chen <chenxiang66@hisilicon.com>
Subject: [PATCH] libata: configure max sectors properly
Date: Wed, 26 May 2021 09:34:22 +0800 [thread overview]
Message-ID: <1621992862-114264-1-git-send-email-chenxiang66@hisilicon.com> (raw)
From: Xiang Chen <chenxiang66@hisilicon.com>
Max sectors of limitations for scsi host can be set through
scsi_host_template->max_sectors in scsi driver. But we find that max
sectors may exceed scsi_host_template->max_sectors for SATA disk even
if we set it. We find that it may be overwrote in some scsi drivers
(which calls the callback slave_configure and also calls function
ata_scsi_dev_config in it). The invoking relationship is as follows:
scsi_probe_and_add_lun
...
scsi_alloc_sdev
scsi_mq_alloc_queue
...
__scsi_init_queue
blk_queue_max_hw_sectors(q, shost->max_sectors) //max_sectors coming from sht->max_sectors
scsi_change_queue_depth
scsi_sysfs_device_initialize
shost->hostt->slave_alloc()
xxx_salve_configure
...
ata_scsi_dev_config
blk_queue_max_hw_sectors(q, dev->max_sectors) //max_sectors is overwrote by dev->max_sectors
To avoid the issue, set q->limits.max_sectors with the minimum value between
dev->max_sectors and q->limits.max_sectors.
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
---
drivers/ata/libata-scsi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 48b8934..fb7b243 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1026,12 +1026,15 @@ EXPORT_SYMBOL_GPL(ata_scsi_dma_need_drain);
int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)
{
struct request_queue *q = sdev->request_queue;
+ unsigned int max_sectors;
if (!ata_id_has_unload(dev->id))
dev->flags |= ATA_DFLAG_NO_UNLOAD;
/* configure max sectors */
- blk_queue_max_hw_sectors(q, dev->max_sectors);
+ max_sectors = min_t(unsigned int, dev->max_sectors,
+ q->limits.max_sectors);
+ blk_queue_max_hw_sectors(q, max_sectors);
if (dev->class == ATA_DEV_ATAPI) {
sdev->sector_size = ATA_SECT_SIZE;
--
2.8.1
next reply other threads:[~2021-05-26 1:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 1:34 chenxiang [this message]
2021-05-26 2:48 ` [PATCH] libata: configure max sectors properly Martin K. Petersen
2021-05-31 14:19 ` [libata] 2c76f9f255: stress-ng.copy-file.ops_per_sec -25.9% regression kernel test robot
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=1621992862-114264-1-git-send-email-chenxiang66@hisilicon.com \
--to=chenxiang66@hisilicon.com \
--cc=axboe@kernel.dk \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=linuxarm@openeuler.org \
--cc=martin.petersen@oracle.com \
--cc=tj@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).