Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2974927imm; Sun, 1 Jul 2018 09:30:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfDyrIe0FDUrQSfthcexKHAK3YZ6ZYjFMC8hZ00fPqNGNbRKav9YR+vo8423d6EbfTFoCkM X-Received: by 2002:a62:93d4:: with SMTP id r81-v6mr4889153pfk.55.1530462625398; Sun, 01 Jul 2018 09:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530462625; cv=none; d=google.com; s=arc-20160816; b=G5x2XquuhKgwT9qC3gacqzj/vaeDfAnUPBA7JavgvFnV0g4Vw3evGPwX1ev9dlASqN 6ia4F0ktdmSVaQbf53SSTN0HWN8C0aMx7huvcpuj3T6VO6Xii1ANuCMYL86konkb+Vdt Zhv3DaiSK6T6nbq7qn9AUiJZ94cPFSbzEVZPzZrqmLdkwbr8mlZq8PHiI8rjR9vAoqS3 g6uzPyDWmSW1Zj4Ec74dPxiTMp24khKbiXYKA05swrAg52Ew1NqxmESqDmY4f3AnmYFn MMiLaJZ0Gc6c8/EvBBJHsecB75ZrqDosAFdl5RptNfLtC7Xfsyak8E7dhL3j/NuCWEbJ Pl4w== 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=Ax7NCnYPnBHEjphTdS2F/d0b7jIyOUfKLORhEUEl5ZE=; b=x4gs7TZVaja4XQsF82b1ys6ivdqhifItyUMrXeuOsdUttnv/Wy+zvA+8tpsikoaNet 1OeFBZB4mpR2l+JxxrvAWhXIQ1E05fMqw0CJiZ6GQqJV9tGIZqtGr08lyxjmY1C/K04v w716vE2nF+YNHrk4QsjE4h0Ffe7iwzbaTsyJcBUhGrAqFGCR9xVWDBJTH+Xub0qOM3ef xi1QKyDdvYWBusdf+7OmIXrOCEtxo0oewkYMkxIe3eyTqj8UL1ElK9VFCsShkltqSx8Q tRjFVR/0JA3fCFIgiqq8L5Jkf0dhWVniItJ6UpI3xviLK8JOWGZMBkq2F/ABnm58haM2 MOag== 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 n5-v6si14390873plk.352.2018.07.01.09.30.10; Sun, 01 Jul 2018 09:30:25 -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 S965762AbeGAQ2v (ORCPT + 99 others); Sun, 1 Jul 2018 12:28:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34382 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965745AbeGAQ2s (ORCPT ); Sun, 1 Jul 2018 12:28:48 -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 74C3C92B; Sun, 1 Jul 2018 16:28:47 +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.9 099/101] block: Fix transfer when chunk sectors exceeds max Date: Sun, 1 Jul 2018 18:22:25 +0200 Message-Id: <20180701160801.109042949@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -901,8 +901,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,