From patchwork Fri Aug 12 14:27:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9277087 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 48B8F600CB for ; Fri, 12 Aug 2016 14:27:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A44928A2F for ; Fri, 12 Aug 2016 14:27:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EE0028A31; Fri, 12 Aug 2016 14:27:24 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 CD40028A2F for ; Fri, 12 Aug 2016 14:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752404AbcHLO1W (ORCPT ); Fri, 12 Aug 2016 10:27:22 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:35265 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbcHLO1V (ORCPT ); Fri, 12 Aug 2016 10:27:21 -0400 Received: by mail-pa0-f68.google.com with SMTP id cf3so1563390pad.2; Fri, 12 Aug 2016 07:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xrRhQQaSjZtlouRZGFyVvUzerWO5n62va/HDu1UBeFk=; b=nKzNvrAWOorOTjKg5AIWrYEamtsr5v/iuDg5CbUbZ5NeYxmOzaw7k+G2KqcdzX+VtT gdcJtGPxm/3C1FwPb+64EcBZhlltadDonFYktzwmW2XLKz4RQducdQUdXzc4VO4a+ibh 3zuX03A0eZR/06w5Ma+nOC1EonsvGaSchjYdUZoENO7aQJ0g04QiBXKcf50HQ63YV4Oj h1Z8ARWTtm7gOTFhnvAd6TzmvZ71V2woKRp8w7vyO9HrrRf8M2Dko5EBBKanZ2tSDa37 wyJS1T13QLc6CK8fvZlUlBPdkhVXtcQKW67igxiQeOofBUAs3OCMfAx0oGv6hTkmj64+ qbCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xrRhQQaSjZtlouRZGFyVvUzerWO5n62va/HDu1UBeFk=; b=iqa5W0TVIQ6L0WjDvp5UDmg1xzDrg+HtlSHOvER1eEgem8O/0868phZvvZ0NfCB/24 BLpKv1JAxWm2N3/wlbhXsvwKcE6Smqh1wKLX/D2LMAVrJ1yp6QGwXs9K8FRJVUIqCoDj /8h54AQhhKm0VwzJ/rioC+EdoExJx7ACsG7E9PebOv38AY9F5G88xmAAsw03Jy+RC5Be 9YtCZ0AhuVa0enpipQb8rxukgV8wbrfydlmzrk4M/rcQ8QsSs8lF+5kEzWOe9fr+9AvB fA9voU6NkfAMNOjIzpYdGf1x1ARHpnzyng1Hjzkh6F0W3Ljr27NJ+KnIAvBFGT99cQ1S qwZg== X-Gm-Message-State: AEkoousylO03jQG3W+gF5a1up304k7s7DfUIeH1hF2IwwYUaRWZ9EL2Ej/xNSsJpgasQKA== X-Received: by 10.66.54.132 with SMTP id j4mr27757628pap.110.1471012040911; Fri, 12 Aug 2016 07:27:20 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id 18sm13614816pfn.33.2016.08.12.07.27.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Aug 2016 07:27:20 -0700 (PDT) From: tom.ty89@gmail.com X-Google-Original-From: me To: tj@kernel.org, martin.petersen@oracle.com Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Tom Yan Subject: [PATCH v2 2/2] sd: check BLK_DEF_MAX_SECTORS against max_dev_sectors Date: Fri, 12 Aug 2016 22:27:04 +0800 Message-Id: <974f3a0aa9e82caf067353fd7d7119c07d7e98c1.1471011949.git.tom.ty89@gmail.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <60518e90d462d4cbb1c528914eac64e2fe124717.1471011949.git.tom.ty89@gmail.com> References: <60518e90d462d4cbb1c528914eac64e2fe124717.1471011949.git.tom.ty89@gmail.com> 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 From: Tom Yan The SCSI disk driver sets max_sectors to BLK_DEF_MAX_SECTORS when the device does not report Optimal Transfer Length. However, it checks only whether it is smaller than max_hw_sectors, but not max_dev_sectors. Signed-off-by: Tom Yan diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index d3e852a..2b6da13 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2875,8 +2875,11 @@ static int sd_revalidate_disk(struct gendisk *disk) logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) { q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); - } else + } else { rw_max = BLK_DEF_MAX_SECTORS; + /* Combine with device limits */ + rw_max = min(rw_max, q->limits.max_dev_sectors); + } /* Combine with controller limits */ q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));