Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2969653imm; Sun, 1 Jul 2018 09:23:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcr5g75Al7+Q12W+mKVDuL/gbo4N3TRnTivCnMHkoWfBTZDaAclUP9mY5J4OccNrAgY4BHM X-Received: by 2002:a62:4141:: with SMTP id o62-v6mr21985759pfa.111.1530462211376; Sun, 01 Jul 2018 09:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530462211; cv=none; d=google.com; s=arc-20160816; b=P4iWqjRGnUXB+/ozEpJy7UNgSXzs5lK2VTPghu4PrMubCVNOj/Wz4ZsMTdk7WKFxjn oqLZJFs2ypMvQksSEueXxM/PXREGcQuEJbc76y3R7a4UhZf5uEjjEqV6NERkVgld4ig7 +iXhB24FRmVgitBV6dFp+CGWodEhVInfwV8Tfem5WrLQseKluDEaVwg+msxM4W8Ujgzu mbN9e1ydiVIvkPIIzyUfcDhlNbrFI1IULHjUOF94XGrrESi3BFbBQl3pTh87WK+gqssb gu9ZSw94gtlq0qIj27968fGWFsuV37qeti2z3PwRybwB4TLEtyb32pnRMRreTfZKYEVv z8dQ== 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=gyM8czIVrLV3CXY+dL/GKBznaePY2/tmSQXK5wFEaLA=; b=ILa/ot89l+dx4PReDoX8xgI/PPrQzK3pj3VOglfVwrIycuAcE5g0Zlb6COOOD8mN0U I69fwOOmTRQAzlC+kOsTd7DFTodz4/HIz3H/huitjIAEwCpzXuxHIGH3KtIjWRwfQRSq ZPr4QBOEh1pmozqXw/zyuEh+KsEaQ+EORvNP/4E93ySaUsK21VLFDdsQWoAE0DFRE/UZ mLqykqUU6ocTFBGCDV0Z0osm9akIYtPfVIoz7C0rcJLmtU/Wm2fUE6U0RaqFAE4GC2Nx /e4qYJPLxH9mz7ugXPSfLkv2mMgWOdWKrcsArCc29LxDZW1hoTaUKAJzw7BHBflzBmFX GtfQ== 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 t1-v6si13647450plo.241.2018.07.01.09.23.17; Sun, 01 Jul 2018 09:23:31 -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 S964996AbeGAQTp (ORCPT + 99 others); Sun, 1 Jul 2018 12:19:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33244 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964978AbeGAQTj (ORCPT ); Sun, 1 Jul 2018 12:19:39 -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 A794A49B; Sun, 1 Jul 2018 16:19:38 +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.4 102/105] block: Fix transfer when chunk sectors exceeds max Date: Sun, 1 Jul 2018 18:02:52 +0200 Message-Id: <20180701153156.786175755@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153149.382300170@linuxfoundation.org> References: <20180701153149.382300170@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.4-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 @@ -882,8 +882,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)