Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8271350imu; Fri, 28 Dec 2018 14:13:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN6JM+m7xcV3lnP+F+fitkiB3X9JOpLMaTDiRGGKRlSl99TWxjJZb6iA1VkQpKAGdVz0DCyw X-Received: by 2002:a17:902:8e8b:: with SMTP id bg11mr29548259plb.332.1546035196597; Fri, 28 Dec 2018 14:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546035196; cv=none; d=google.com; s=arc-20160816; b=mhytkyIlguH4qmNxE46yEeeY404QTPnAtW61Qyi1HKvqG4JrFFPpb5WXtxvwDTBWdt K1xrDehnkFpycMXknJsruhGdRQRwUHsiLlOZBaMRYl0oNRGD0rNU+hkhfOPqJS/fpGzu eURuPvopmbVADKrYEvm/+8+1uVnSNOnWj2zpaey6mC9Q/Kbm3ssbwn30dm2vUyzB3BDE ah+Dq6uwotXagH/Q41M0f4BIBlsAWYDcjd9cJj06/FHJrQzH3RcIfbiN0BMY1xgH1XWs 9Ze5gHN+4i83rBqa19ZCepTY5S1VpRvmp6cSL0ZD7Wd754ok8drVbNMktqqmvPCSOaFT iKyg== 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=wN0X93hOx5qWozAxrw3to2cLSNi9aIDk3RzDcGOufMA=; b=hz1POTC/ns8k2+Wd70VgmN18ytcmHlkCm/2bdczktFedW3rCM40E4tSzTzKx6+qoeF R4zhaA4Z3HHU5ovKHrepvyXguHuGD9nCtyX6Kaf2k1W8Yy0GHHlioezWElsTJIVHy9p2 IJnAj6wkf+jd2t2PwOZe70PCJuLAgvhkuiyJLqtvcWZ+coCKOQjBc1CB2ZVS9g+ZqLsF doj6k4UW2xh7dof9XrNwXtJDUImfvH2v3mi3HyQYJbh1WYIJgZ6GIYlv8NpmKFVjQ+XE 1sdkHhVxXed3tk3uYat7OfIxLBA5mB1C1hgQtC6m9gGEcqyVuABO7fj2Eg9ZrqN8LFes rPuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HqwCU2p7; 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 l23si35647388pgh.533.2018.12.28.14.13.01; Fri, 28 Dec 2018 14:13:16 -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=HqwCU2p7; 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 S1732883AbeL1MRP (ORCPT + 99 others); Fri, 28 Dec 2018 07:17:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:36284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732872AbeL1MRM (ORCPT ); Fri, 28 Dec 2018 07:17:12 -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 77D6B2087F; Fri, 28 Dec 2018 12:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545999432; bh=xLo+A00IV1UQgq4LU/ithV4VkCjTMXLgRB4wVtrpfAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HqwCU2p7IJ501VK8BNBeX4Vlo8yIPVIK8SrNzcbcdyHPTwPXO50U/ZurND3ljbAEP jnCU+cwYbcnUg4So9TtXhAlxdawZJJ6UEaUJ1z/qcWBJDMc54n1eBNdKQAl5siqrWV QlMk4v0gYu1m/bZhxIGPszkF3VvfxrxzI3S00S2c= 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 , Sasha Levin Subject: [PATCH 4.9 01/22] block: break discard submissions into the user defined size Date: Fri, 28 Dec 2018 12:52:38 +0100 Message-Id: <20181228113126.222869065@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181228113126.144310132@linuxfoundation.org> References: <20181228113126.144310132@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit af097f5d199e2aa3ab3ef777f0716e487b8f7b08 ] 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: Sasha Levin --- block/blk-lib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 46fe9248410d..d8b89c58af3d 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -63,10 +63,16 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, unsigned int req_sects; sector_t end_sect, tmp; - /* 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 * misaligned, stop the discard at the previous aligned sector. */ -- 2.19.1