From: Andy Grover <agrover@redhat.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-block@vger.kernel.org,
linux-scsi <linux-scsi@vger.kernel.org>,
target-devel <target-devel@vger.kernel.org>
Subject: Should queue_max_hw_sectors() always be <= max_dev_sectors?
Date: Tue, 30 Aug 2016 09:54:05 -0700 [thread overview]
Message-ID: <202d350b-0e59-1a10-4b65-3563f0afa084@redhat.com> (raw)
Hi Martin, (you're the last person to touch this? :)
If I create a local SCSI device using LIO's loopback fabric, and backed
by a file, /sys/block/sda/queue/max_hw_sectors_kb reports 32767. This
reflects the loopback scsi_host_template reporting 65536 max_sectors,
but that's the "controller" -- the actual device reports via the Block
Limits VPD of supporting a max size of 16384 512-byte blocks.
Therefore, using max_hw_sectors_kb will give a wrong impression for what
the max data size that can be issued to the device is -- 32767KiB
instead of 8192KiB. Should max_hw_sectors_kb be reported as the lesser
of max_hw_sectors and max_dev_sectors? Something like:
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1196,7 +1196,7 @@ static inline unsigned int
queue_max_sectors(struct request_queue *q)
static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
{
- return q->limits.max_hw_sectors;
+ return min_not_zero(q->limits.max_hw_sectors,
q->limits.max_dev_sectors);
}
...because limits.max_hw_sectors internally seems to be just the
controller limit, but what users of queue_max_hw_sectors (including
sysfs) really want is the lesser of limits.max_hw_sectors and
limits.max_dev_sectors.
BTW the docs say:
max_hw_sectors_kb (RO)
----------------------
This is the maximum number of kilobytes supported in a single data transfer.
Thanks -- Regards -- Andy
next reply other threads:[~2016-08-30 16:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-30 16:54 Andy Grover [this message]
2016-08-31 2:11 ` Should queue_max_hw_sectors() always be <= max_dev_sectors? Jens Axboe
2016-08-31 2:15 ` Martin K. Petersen
2016-08-31 2:36 ` Jens Axboe
2016-08-31 4:11 ` Martin K. Petersen
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=202d350b-0e59-1a10-4b65-3563f0afa084@redhat.com \
--to=agrover@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.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