From patchwork Tue Aug 30 16:54:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Grover X-Patchwork-Id: 9305685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E719360865 for ; Tue, 30 Aug 2016 16:54:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D773628C5E for ; Tue, 30 Aug 2016 16:54:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC0C628CD8; Tue, 30 Aug 2016 16:54:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2736D28C9D for ; Tue, 30 Aug 2016 16:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758286AbcH3QyL (ORCPT ); Tue, 30 Aug 2016 12:54:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56360 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758225AbcH3QyI (ORCPT ); Tue, 30 Aug 2016 12:54:08 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D24DC05681A; Tue, 30 Aug 2016 16:54:07 +0000 (UTC) Received: from [10.3.116.110] (ovpn-116-110.phx2.redhat.com [10.3.116.110]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7UGs60P031814; Tue, 30 Aug 2016 12:54:06 -0400 To: "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-scsi , target-devel From: Andy Grover Subject: Should queue_max_hw_sectors() always be <= max_dev_sectors? Organization: Red Hat Message-ID: <202d350b-0e59-1a10-4b65-3563f0afa084@redhat.com> Date: Tue, 30 Aug 2016 09:54:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 30 Aug 2016 16:54:07 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: ...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 --- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 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); }