Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3074543imm; Sun, 1 Jul 2018 11:39:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzh+85HozTdivzq0aR0AyYOu0l6OtdI/YEfh7D4Xo0W2rAsbqoUqrICGG6ky1xQvRbXy7x X-Received: by 2002:a17:902:4424:: with SMTP id k33-v6mr22956919pld.242.1530470367093; Sun, 01 Jul 2018 11:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530470367; cv=none; d=google.com; s=arc-20160816; b=sQcsJLboRegxbQ9bJdl8k3xSGTJtjEJ2yxQ5Kn8/MLvMMvnsqMeRidIgiDz3jlh1// xp3kSAUCZBdDVnKuT1jlKGusyB+uyT2fcSkU46Y2hvPHWdsNvJGhNOgKBLkDhjiSaMuQ R5xBBmwCWMlS/gBx/GFS4EAayXQ7W+UaBAHXf8p49MvayR1s0aq+7GRQvW4uz0Qd+lO5 Og8Ng6dYkc1MKGeLaSW9yQ2MgZtYHyZid9EZp0S5gZ2Lm5u9rhf4B/3YuATeoepDebt6 cONr6tdD+tLZoH4lcGFDbgE9PZVwA1to8SF4G6INcf7T7A0VkKMxqDDkbzYSAZD3TZex AlxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=W+/SC1/rlUCOnnaI14YlElZCSEsAHEju9Ex5Uc5v5sw=; b=TJyjMWHD0gvruQffb25hCLuINgHEO9KbKTLeL4wUlVulpAF7e2RPKZE3Tu5mvCxYhb XJDfGhcry4/JprZ4IjnHmfmO8Zk7r490SPXFe47VvtYMo7S8VG8wkitUgbknmWtjCbaS kKt67pdCZlrU+lZYop4b9iQ7x+dFXQLjOlnG3EW6J/Uj7yK8+ym4ogZOV5SObcydfA2x 4Q2Ew4WSHlSJdvu8K820ZtrB96cdwY4kLg2yJdl1/nOq0mcISoMZfk5KOBmkr5D4O/QJ 9eQQusOv9tkgipsXjzV1gBYE8kekW9FDP2ByqsOssYzTe4fmNjBFrFmlb4bSx3eC5kY3 mufQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1-v6si14591479pld.40.2018.07.01.11.39.12; Sun, 01 Jul 2018 11:39:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932287AbeGAQOt (ORCPT + 99 others); Sun, 1 Jul 2018 12:14:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60408 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752898AbeGAQOo (ORCPT ); Sun, 1 Jul 2018 12:14:44 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7A6FF86A; Sun, 1 Jul 2018 16:14:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jitendra Bhivare , "Martin K. Petersen" , Keith Busch , Jens Axboe Subject: [PATCH 3.18 84/85] block: Fix transfer when chunk sectors exceeds max Date: Sun, 1 Jul 2018 18:02:42 +0200 Message-Id: <20180701153125.708892298@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153122.365061142@linuxfoundation.org> References: <20180701153122.365061142@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Keith Busch commit 15bfd21fbc5d35834b9ea383dc458a1f0c9e3434 upstream. A device may have boundary restrictions where the number of sectors between boundaries exceeds its max transfer size. In this case, we need to cap the max size to the smaller of the two limits. Reported-by: Jitendra Bhivare Tested-by: Jitendra Bhivare Cc: Reviewed-by: Martin K. Petersen Signed-off-by: Keith Busch Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- include/linux/blkdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -919,8 +919,8 @@ static inline unsigned int blk_max_size_ if (!q->limits.chunk_sectors) return q->limits.max_sectors; - return q->limits.chunk_sectors - - (offset & (q->limits.chunk_sectors - 1)); + return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors - + (offset & (q->limits.chunk_sectors - 1)))); } static inline unsigned int blk_rq_get_max_sectors(struct request *rq)