From patchwork Fri Aug 12 11:56:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Yan X-Patchwork-Id: 9276847 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 A418660231 for ; Fri, 12 Aug 2016 11:56:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95164289B1 for ; Fri, 12 Aug 2016 11:56:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89D13289B4; Fri, 12 Aug 2016 11:56:22 +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 3AD0F289B1 for ; Fri, 12 Aug 2016 11:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752629AbcHLL4T (ORCPT ); Fri, 12 Aug 2016 07:56:19 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33915 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752175AbcHLL4S (ORCPT ); Fri, 12 Aug 2016 07:56:18 -0400 Received: by mail-pf0-f195.google.com with SMTP id g202so1466050pfb.1; Fri, 12 Aug 2016 04:56:18 -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=KnZzzChohhOu5qktAV8yLv+OaBuvcoxVY8vYOhFARBc=; b=uaLmjh466U8F6lUNs69lC92uS4QFVIuoc9N2E3qgf2BSBkFznuMfrURZo3jCof8eEE +BLgw+rDsQzzJzUovqk6CSYj8ZQQ3hPGAgiN4TAfzrb2U0KQP9QrnlWyqBSEJN67xzv6 gO+Zm5FHyndceTCw8aW/7/AAWs8XqDMMYo+u8EG73yiCa/FqiH7D+vyQysrh5fQ8XOjB oCg8zpNLWOAgnu2j6b13XFwFxQjMXfoBsDK2txAqhQpWDQ1g+50WXxcT2OYEoflEWISk ISXSu1LkV681KDcPKrl7+AxQvEQXrsOAgfAWXDfGlfZq4rnlsA8UoqsXEf7Wq2KdNZ+G Dp4Q== 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=KnZzzChohhOu5qktAV8yLv+OaBuvcoxVY8vYOhFARBc=; b=Fqqj/ndd1dJNTY4uVNd9/M7hnzWHCIo2j3zcHXR/os2izDm4UH3THbSVA0s/Ii3CnI u05mPRIAITaiEUhbjfuJ2kcsy5VAYhRaN6PGj40lDXJAh+EdV62uP2fJ4ZBlE2hexDAL SoQnIzKZ6oFgLHSHniZVuDz/nDO5JrBk/NvxL2D7bpmJiIfjxZT/2PuUXfRrIotDhsGs bsPN9LPzPAGwWjUVsFLVnb5G3kdJ4ZcMFSizuQCI7HkANOoiBOqGYUJm7qideDxR4wbZ MzLUoMT2QF42VQaPnLxV+AZDl2bqBvuui4u/CjTri1O+h0GNr/ycV9HBAs9vPULutMGd vD0g== X-Gm-Message-State: AEkoout3zlsLWs5l8wPH1M6l/E45M3Flq9UP1uCuyrhbhw+VTzCSF8hZL66vnpn7zuNdtw== X-Received: by 10.98.157.12 with SMTP id i12mr26523549pfd.164.1471002977609; Fri, 12 Aug 2016 04:56:17 -0700 (PDT) Received: from localhost.localdomain ([2404:c805:e00:4700:ae22:bff:fe29:e60c]) by smtp.gmail.com with ESMTPSA id l128sm12601008pfl.21.2016.08.12.04.56.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Aug 2016 04:56:17 -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 2/2] sd: check BLK_DEF_MAX_SECTORS against max_dev_sectors Date: Fri, 12 Aug 2016 19:56:07 +0800 Message-Id: <0bc2e9a09870610a48e0033a0370941ad549ba6b.1471002480.git.tom.ty89@gmail.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <911c68378b91bf275a4bbed5717b4639641d7029.1471002480.git.tom.ty89@gmail.com> References: <911c68378b91bf275a4bbed5717b4639641d7029.1471002480.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_sector 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));