Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2991391imm; Sun, 1 Jul 2018 09:52:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFcMKFRSwYNd8YvGGbr3kJsCuvOqxQ95AHvCAAkO+Cf0MQK1eow1wr0uZo6ECOVR8LtoDY X-Received: by 2002:a62:d646:: with SMTP id r67-v6mr11804905pfg.130.1530463936265; Sun, 01 Jul 2018 09:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530463936; cv=none; d=google.com; s=arc-20160816; b=osrvayEZwbjiNnpH75GTFZFVQYGkZ99th/oC70stz0NOdy0NRTyho/TYVAM4HIebnl V2CzU/k4cYn+oA4VYM02fSWQ60yAxBWpOdH4hydQltVhuQBH0ryCttafZ0OyTAzu5ooi e0qJW6iZ1oQ5K+ai40tLPNz0DAi5nuaNDP0pFNcidFRYpfvwIYDnhVB47RXKXlGu/vJC Hw6bJCXsGYksHC7aXpYpIjNJ3T+nVfVHAQgW6pn/mm4wcaWcVE4zrQAkOlvXvAXPXJFy sn+o9goEsJyUTJYjY75dvzoXtgx2g4aGICdbcRLU4cxa6k6H4rDOYWaI5caGuBbRi0at RGUA== 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=TAx846i8u8C+rIcWCMqd20KyxekaZd3auKGbRuDMoVk=; b=uYkdfwOR+jftn953sEAoOm6RvazBHDbdyE4cTYl0wfdMs9YBB1HlqJ1s/j6MUt7NL3 v7ucB1hQNBGHBBOC0Y4jYyB0rmvlX5z8j5MygGODFIjLH7xp6nKBHwuLX25O2ERa5UO3 HsthSXzhbsUSOvMgkaMV6/lT1tsoHREwdf9NQxcWgDFSLrVYtYvAq4veiOlGNJQpJWtb OzFBY16V+3ljxyYDamrAskk/CscFS0fnnGnAc1Z0PDGn1WOnL7WmVAr2nPuKw9jhNPPO ZL92rSsSwcsHTvpDQP3s6THBAxIuVRHHwWsKAKMEtUQyT/9C1u9fmgNlNwCd/eZQIoYk qvWA== 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 r3-v6si12603687pgo.606.2018.07.01.09.52.02; Sun, 01 Jul 2018 09:52:16 -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 S1032414AbeGAQq3 (ORCPT + 99 others); Sun, 1 Jul 2018 12:46:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38414 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032271AbeGAQqY (ORCPT ); Sun, 1 Jul 2018 12:46:24 -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 BA97DA73; Sun, 1 Jul 2018 16:46:23 +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 4.17 212/220] block: Fix transfer when chunk sectors exceeds max Date: Sun, 1 Jul 2018 18:23:56 +0200 Message-Id: <20180701160917.011058475@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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 4.17-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 @@ -1124,8 +1124,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,