From patchwork Mon May 7 16:13:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10384449 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 27CD860318 for ; Mon, 7 May 2018 16:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E4F126E98 for ; Mon, 7 May 2018 16:13:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 030BC28385; Mon, 7 May 2018 16:13:44 +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 931E42866F for ; Mon, 7 May 2018 16:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752432AbeEGQNn (ORCPT ); Mon, 7 May 2018 12:13:43 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:45888 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750934AbeEGQNm (ORCPT ); Mon, 7 May 2018 12:13:42 -0400 Received: by mail-io0-f194.google.com with SMTP id c9-v6so28303904iob.12 for ; Mon, 07 May 2018 09:13:42 -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=u7hV2faVFmMTZzPA9RNLe8M+UjyNR++zyI4VDHNoTqQwdz+QrVLORYhJAuaTVAlxLQ URXGWbA5y/94wf5uEIeFgm71FqkAzT2wkUluVnuyP9IS9McdsILLkEWmrFeccmfnlmcd Dvxid0djQfbZmC4oySUb8IjZwk0uly8JRy/ipaE3dCiqjzhovENwClBSML8ICRl4Kwj5 b0dbP3Omyuzrd4Tlhou6X/efbY3kTbaZwUfqcDNw0gPL9x4Hg3HqkN+f84EAYhlWFQp+ HRXIREQsuS21isGxMT/Yb7NLMRcXcFBV9+oyyBGmTaHOdPw6dfhgjI5vz+XnHx2cWXCM qSpw== 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=mXNmwptL2Yey4okb0oZ45YqB7AS7EQZJ7gmbOWUhmt0J5Le6bAZL8iDUTBLWc7+GP3 wa/EXakLRB39pbl2Fs0bXmuDRSqFrTJ0uK//FQd8iWfnwi4pf5s1859VTJjSK+Kd3J4W CqsQPsJu4XvdcndtUK7KHI8V3FRT9uthpmU0M4NgUZdeEjhYVmKwLrg2WA5pDBNW1cc8 ABaDPiG07TZyYxrJqxV5EmKviWcK2MsCmJ4wHllpOXLvabmU6mVasX0fYaCd3lSthjew dkoEb73OEoRQvitYPPaHBXDONQGWQFh23CKpQTk0UNtr3gMYya9kkS8MrVb7v1Ms5V0y RaeA== X-Gm-Message-State: ALQs6tDSZwYBbs0GdmH2fR20NmyysRcuEMKjtJylq4+ZyYuu9Dm8rvz0 udCM9j3IrDzCzZ8TDGn8NLvNkw== X-Google-Smtp-Source: AB8JxZoTZ80F1DKLCVbOxlEWFi2kNFer9x6rSg9Y1EcYUVSrqGVcVHZVe8hCO91jNVDs2tI1KwYNgQ== X-Received: by 2002:a6b:9342:: with SMTP id v63-v6mr34977128iod.76.1525709621692; Mon, 07 May 2018 09:13:41 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id q5-v6sm9003192iod.32.2018.05.07.09.13.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 May 2018 09:13:40 -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/4] block: break discard submissions into the user defined size Date: Mon, 7 May 2018 10:13:32 -0600 Message-Id: <1525709615-14395-2-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525709615-14395-1-git-send-email-axboe@kernel.dk> References: <1525709615-14395-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 Reviewed-by: Darrick J. Wong --- 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. */