From patchwork Thu May 3 15:20:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10378645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04D0560353 for ; Thu, 3 May 2018 15:21:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E60EC292EB for ; Thu, 3 May 2018 15:21:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E091A2928D; Thu, 3 May 2018 15:21:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D56229352 for ; Thu, 3 May 2018 15:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751279AbeECPUu (ORCPT ); Thu, 3 May 2018 11:20:50 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:38951 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbeECPUs (ORCPT ); Thu, 3 May 2018 11:20:48 -0400 Received: by mail-io0-f194.google.com with SMTP id r9-v6so22078262iod.6 for ; Thu, 03 May 2018 08:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XbcY1XqgZkIdlObRQolVv0nLxn/SB85q8p7M8nXdfTI=; b=egisyHVnsis/kugcewxGfPDlaom6agv8d1+GbhpZfuqXb3h+trcqirrCTEuZbbn9Lj IKwvyKxFVVag1aZG+4BlmXA1cv3ZWstm0Co4yXYPRI6dV9WBsKh1xswqOjGfQSsxLkjr eHd1U2NamNv34kuaomrDQNImiOcNNHjyhbqWzl78plHHoqc/io2n8MCjMaOn03DK9GRC EpG7o6Qg8+fvn7zpqmk6j662lnQtnJSBw4Feyr4sqxCJNAjDAfHGfzbhFqmpuuUi46Xv NxZp7ua9Pyh85YslJFbFt7Qgfssl6g3q4EZ+9IhY4zhTPcrghIhF59h276Z4zjkNHZ6f rOiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XbcY1XqgZkIdlObRQolVv0nLxn/SB85q8p7M8nXdfTI=; b=CLwJkZFTZ+er2lvsxZPwHqpm7pBT5Z+FgUaEOMjzM3TD2PaAsPI1xKeyW7dBBcvJCb hZvUdyJprO3aveljwIC0z0Ga3Fjpl+GQW/xJqtLHujBs5WhC9qyrBN77XUcjURY79Coj R6aM71Om2+gWHjXwJGwwk1wl0ckMgctYZTzyszklSUXFi+9dnkta6RoXeFgQXWrO0tll elHrHr/zSijx1IBv++TCKUixpY/8B291u8laLhs0w6zz+NbYlgShdL3pVnS3gCIlxJCK 3RVuYWbPKeSE41RCzsB5zPowSQ7cNMziUVHbglIh8+k5DO7rK9CVGyrbhVCSYNHuCYQz E3Lg== X-Gm-Message-State: ALQs6tB9Kqe3qam6CHjGbzM1tM0bDmTn+IBFpG9D5DVYTDM/LfvziLS7 f9uKGzHiUITMTDfMBz4FvGa+OA== X-Google-Smtp-Source: AB8JxZq7cRiPDgYNiNytGx0i3VYWUTV2uqlrmEThKL53kYQxNKJxNlnzTUsX3dK9VruqKomTQadw4g== X-Received: by 2002:a6b:ca83:: with SMTP id a125-v6mr15517792iog.111.1525360848222; Thu, 03 May 2018 08:20:48 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id 10-v6sm4860537ite.28.2018.05.03.08.20.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 May 2018 08:20:47 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org, linux-xfs@vger.kernel.org Cc: dchinner@redhat.com, hch@lst.de, Jens Axboe Subject: [PATCH 1/3] block: break discard submissions into the user defined size Date: Thu, 3 May 2018 09:20:41 -0600 Message-Id: <1525360843-6504-2-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525360843-6504-1-git-send-email-axboe@kernel.dk> References: <1525360843-6504-1-git-send-email-axboe@kernel.dk> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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'. Signed-off-by: Jens Axboe --- block/blk-lib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index a676084d4740..7417d617091b 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -62,10 +62,11 @@ 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 */ + req_sects = min_t(sector_t, nr_sects, + q->limits.max_discard_sectors); - /** + /* * If splitting a request, and the next starting sector would be * misaligned, stop the discard at the previous aligned sector. */