Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp628070imu; Fri, 11 Jan 2019 06:26:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN4xEX5zRNwGankjEb0u8bfzFjrll0YpoFOF48K7niJAh0AaeOOljZDf/+GmJtEwtiqEIQJc X-Received: by 2002:a63:8441:: with SMTP id k62mr13520858pgd.392.1547216811258; Fri, 11 Jan 2019 06:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547216811; cv=none; d=google.com; s=arc-20160816; b=kD2nznqlGIW94EkVg9iVlE/P8EB0gZUrDP+FqOtKCHO1YynlF+XooHJ/5y3aqBJX/5 N9xCFQIfq+fGvi5bcgCFZOJlKJsx/NY3Ydbrb3M3Y2kB9S9Ne7lejtA5jND8oKQq6mgK Oyv1h7FK/ac+0kbDovPv3WJtB7tqhfL8E8XgfUslCpGdIIZ8UMOTE6CbzVk46uTifaoN lfQA+XyeANL7hkURFyR4v1cLLhjCNBv+Ucd7cTFkjEIaHuHvcXK+SQjAPHHKHJoK8ZOZ usDX8O2NcQALCqHjWi5DRgRmSHAY7Hj0U5lxC23V/mJm5cT/THnBc0r1pCqoP8YcMRQ9 rJ+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8AJMsCur/QOcXVpysRmThfpo8+JK8tvVjjlOFaot+1U=; b=FmsXn5gyqfeaKNU1jC1bjUpLRVDQNkOVs0k3FSfRAApdpHGp5eu/c0eOMYzFBPxET2 vCr5JcY8UoOkIwIepHBW9HIAYmt530kH3S5QanlK0YvR/EWA59EiUHykhs7n+fPV16/h zrZjhpebf+3ShUONLGELd6Jai3TK7qKpRUyccBeE2YG8QPG0UNztEJyFXAkaZyMZ7roV 3inKO9SkYaTmwMFXyQdOOiuFIcEj2h0s5H4KztcXfufnQBq7uen1U2ZUc2Qbpl7o5vw3 UZXtnbgTo7WarlKFYVOLrlndeEg7HXGar2j+szKh0nkm+7PeQLP6M6jQK5OtPf1QW+zX cX6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="zMUY/eJj"; 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 u123si14992035pgb.516.2019.01.11.06.26.35; Fri, 11 Jan 2019 06:26:51 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b="zMUY/eJj"; 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 S1731798AbfAKOTY (ORCPT + 99 others); Fri, 11 Jan 2019 09:19:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:36192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731683AbfAKOTT (ORCPT ); Fri, 11 Jan 2019 09:19:19 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 538DD2177B; Fri, 11 Jan 2019 14:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547216358; bh=ezxktuBPXy+XkMrISUMKTKcZKAUUO/sN2tn/dizpP50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zMUY/eJj1SJ21Wbt/msSYNUCffURVsjIhvrpr7xGrCzzYMHT0yk0G3HGfVJgxY84L YbdwTWcelZLpBw7NWxe5aymOkPj5r0JyfbPm3WtYzBZ6d2MwBeuJLNRq/7ERwrXa2C ArqTsFPK+OrIR1GWBoCYLsNmYLHD3JykUHGtPXO8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Omar Sandoval , Jens Axboe , Sudip Mukherjee Subject: [PATCH 4.4 71/88] block: break discard submissions into the user defined size Date: Fri, 11 Jan 2019 15:08:40 +0100 Message-Id: <20190111131057.981935488@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131045.137499039@linuxfoundation.org> References: <20190111131045.137499039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Jens Axboe commit af097f5d199e2aa3ab3ef777f0716e487b8f7b08 upstream. Don't build discards bigger than what the user asked for, if the user decided to limit the size by writing to 'discard_max_bytes'. Reviewed-by: Darrick J. Wong Reviewed-by: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- block/blk-lib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -81,8 +81,14 @@ int blkdev_issue_discard(struct block_de break; } - /* Make sure bi_size doesn't overflow */ - req_sects = min_t(sector_t, nr_sects, UINT_MAX >> 9); + /* + * Issue in chunks of the user defined max discard setting, + * ensuring that bi_size doesn't overflow + */ + req_sects = min_t(sector_t, nr_sects, + q->limits.max_discard_sectors); + if (req_sects > UINT_MAX >> 9) + req_sects = UINT_MAX >> 9; /* * If splitting a request, and the next starting sector would be