From patchwork Wed Dec 16 22:53:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Martin K. Petersen" X-Patchwork-Id: 7866581 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0468F9F54F for ; Wed, 16 Dec 2015 22:54:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 115B0203A5 for ; Wed, 16 Dec 2015 22:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B141203E6 for ; Wed, 16 Dec 2015 22:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755088AbbLPWyG (ORCPT ); Wed, 16 Dec 2015 17:54:06 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:17612 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755205AbbLPWyE (ORCPT ); Wed, 16 Dec 2015 17:54:04 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tBGMs3tv001384 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Dec 2015 22:54:04 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id tBGMs3Z2017209 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 16 Dec 2015 22:54:03 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id tBGMs3dK008929; Wed, 16 Dec 2015 22:54:03 GMT Received: from mellowmood.mkp.net (/10.156.108.201) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 Dec 2015 14:54:02 -0800 From: "Martin K. Petersen" To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org Cc: "Martin K. Petersen" Subject: [PATCH 3/3] block: Export max_dev_sectors_kb in sysfs Date: Wed, 16 Dec 2015 17:53:53 -0500 Message-Id: <1450306433-20166-3-git-send-email-martin.petersen@oracle.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1450306433-20166-1-git-send-email-martin.petersen@oracle.com> References: <1450306433-20166-1-git-send-email-martin.petersen@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some storage devices report a maximum transfer length which indicates the maximum size of an I/O request that the device can process. This limit is enforced in combination with the controller's max_hw_sectors and DMA constraints to ensure that we do not issue a command too big for the device. Export the max_dev_sectors_kb queue limit in sysfs and update the documentation accordingly. Signed-off-by: Martin K. Petersen Reviewed-by: Ewan D. Milne --- Documentation/ABI/testing/sysfs-block | 9 +++++++++ Documentation/block/queue-sysfs.txt | 11 +++++++++-- block/blk-settings.c | 4 +++- block/blk-sysfs.c | 13 +++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block index 71d184dbb70d..4f284d38c085 100644 --- a/Documentation/ABI/testing/sysfs-block +++ b/Documentation/ABI/testing/sysfs-block @@ -235,3 +235,12 @@ Description: write_same_max_bytes is 0, write same is not supported by the device. +What: /sys/block//queue/max_dev_sectors_kb +Date: December 2015 +Contact: Martin K. Petersen +Description: + Some storage devices report the maximum size that the + device can process in a single READ or WRITE + request. This limit is used in combination with + constraints set by the controller driver to limit the + size of filesystem requests. diff --git a/Documentation/block/queue-sysfs.txt b/Documentation/block/queue-sysfs.txt index e5d914845be6..a078995f3eae 100644 --- a/Documentation/block/queue-sysfs.txt +++ b/Documentation/block/queue-sysfs.txt @@ -55,9 +55,15 @@ logical_block_size (RO) ----------------------- This is the logcal block size of the device, in bytes. +max_dev_sectors_kb (R) +---------------------- +This is the maximum number of kilobytes supported by the storage device +for a READ or WRITE request. + max_hw_sectors_kb (RO) ---------------------- -This is the maximum number of kilobytes supported in a single data transfer. +This is the maximum number of kilobytes supported by the storage +controller in a single data transfer. max_integrity_segments (RO) --------------------------- @@ -68,7 +74,8 @@ max_sectors_kb (RW) ------------------- This is the maximum number of kilobytes that the block layer will allow for a filesystem request. Must be smaller than or equal to the maximum -size allowed by the hardware. +size allowed by the storage controller (max_hw_sectors_kb) and the +maximum size allowed by the storage device (max_dev_sectors_kb). max_segments (RO) ----------------- diff --git a/block/blk-settings.c b/block/blk-settings.c index dd4973583978..362b0179c86a 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -232,7 +232,9 @@ EXPORT_SYMBOL(blk_queue_bounce_limit); * max_sectors is a soft limit imposed by the block layer for * filesystem type requests. This value can be overridden on a * per-device basis in /sys/block//queue/max_sectors_kb. - * The soft limit can not exceed max_hw_sectors. + * + * The soft limit's lower bound is the page cache size and it can not + * exceed neither max_hw_sectors, nor max_dev_sectors. **/ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors) { diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index e140cc487ce1..c289f9f6dcd9 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -225,6 +225,13 @@ static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page) return queue_var_show(max_hw_sectors_kb, (page)); } +static ssize_t queue_max_dev_sectors_show(struct request_queue *q, char *page) +{ + int max_dev_sectors_kb = q->limits.max_dev_sectors >> 1; + + return queue_var_show(max_dev_sectors_kb, (page)); +} + #define QUEUE_SYSFS_BIT_FNS(name, flag, neg) \ static ssize_t \ queue_show_##name(struct request_queue *q, char *page) \ @@ -371,6 +378,11 @@ static struct queue_sysfs_entry queue_max_hw_sectors_entry = { .show = queue_max_hw_sectors_show, }; +static struct queue_sysfs_entry queue_max_dev_sectors_entry = { + .attr = {.name = "max_dev_sectors_kb", .mode = S_IRUGO }, + .show = queue_max_dev_sectors_show, +}; + static struct queue_sysfs_entry queue_max_segments_entry = { .attr = {.name = "max_segments", .mode = S_IRUGO }, .show = queue_max_segments_show, @@ -483,6 +495,7 @@ static struct attribute *default_attrs[] = { &queue_requests_entry.attr, &queue_ra_entry.attr, &queue_max_hw_sectors_entry.attr, + &queue_max_dev_sectors_entry.attr, &queue_max_sectors_entry.attr, &queue_max_segments_entry.attr, &queue_max_integrity_segments_entry.attr,