From patchwork Tue Mar 25 23:48:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 3891371 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 694FBBF540 for ; Tue, 25 Mar 2014 23:49:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACA1B201BC for ; Tue, 25 Mar 2014 23:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6567200CC for ; Tue, 25 Mar 2014 23:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754027AbaCYXtN (ORCPT ); Tue, 25 Mar 2014 19:49:13 -0400 Received: from mail-ob0-f202.google.com ([209.85.214.202]:45134 "EHLO mail-ob0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751291AbaCYXtM (ORCPT ); Tue, 25 Mar 2014 19:49:12 -0400 Received: by mail-ob0-f202.google.com with SMTP id wo20so268626obc.5 for ; Tue, 25 Mar 2014 16:49:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e1zLnaqTNAWZAidNp+QCDDi9wbcPWaoLgYH3EZDcwRw=; b=dCuqJKtBQbHy7i36Aij3IFOlIRFK4sxetJzTqQLaPDKXjSltYhhF2w2w9p5xUgtx0Y FUASfxKX+qptSLTJWYT8hrZRwVeF2Iop4GyDkNr8NVq8cMnSQPAtGaDXZe4x6l5rgZvx JUmiX5Ix5ZiJVzCHu0LtNw31tazXEpfUl0V6qWopweP2HTUYpyr+EQo4SYCdMqCnm3S7 Xth5KY5Nbtid3uSsr1KdHg8bkvyRpr9dSSXxvDkPFYXN8BueXAXLjEAHghsA2VGFyqNW dlRlITlMSVvcKWb2D09MqL5MRwyoOdHGmYuAtKMzm55Yzuadn/AW9ojvmNYVjMGwpVwF 1bcA== X-Gm-Message-State: ALoCoQn/lB+af207gtQwsIugNPCFRRUE8Oc543FX6e22lgPV6DauuZ1k8eRoH13GEFs2AvOPyIzIgOjfOyThqoj7vvxkRh1jBBG5O3sI2158kEmR+blXUskCcxWbYhachOdNLE+HKxsEqU1L+PdR1bkQ3VvFBpvpENhq6ACp1DYVtWNIJDfMt1Hgr96oeKUkvuGxBkIGiNV/BEgiVlN+8rKgd490Ireo+A== X-Received: by 10.42.123.139 with SMTP id s11mr24959299icr.15.1395791351619; Tue, 25 Mar 2014 16:49:11 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id x22si2474368yhd.5.2014.03.25.16.49.11 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Mar 2014 16:49:11 -0700 (PDT) Received: from gwendal.mtv.corp.google.com (gwendal.mtv.corp.google.com [172.22.72.115]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 7160931C241; Tue, 25 Mar 2014 16:49:11 -0700 (PDT) Received: by gwendal.mtv.corp.google.com (Postfix, from userid 60833) id 233EB14192E; Tue, 25 Mar 2014 16:49:11 -0700 (PDT) From: Gwendal Grignou To: axboe@kernel.dk, ulf.hansson@linaro.org Cc: linux-mtd@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Gwendal Grignou Subject: [PATCH 2/4] Limit max_discard_sectors to UINT_MAX>>9 Date: Tue, 25 Mar 2014 16:48:24 -0700 Message-Id: <1395791307-23727-3-git-send-email-gwendal@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1395791307-23727-1-git-send-email-gwendal@chromium.org> References: <1395791307-23727-1-git-send-email-gwendal@chromium.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP max_discard_sectors can not be larger than UINT_MAX>>9, otherwise, there is a risk that discard requests would be merged into a request larger than 4GB. Signed-off-by: Gwendal Grignou --- block/blk-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 9b5b561..67bb0e7 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -64,7 +64,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, * Ensure that max_discard_sectors is of the proper * granularity, so that requests stay aligned after a split. */ - max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9); + max_discard_sectors = q->limits.max_discard_sectors; max_discard_sectors -= max_discard_sectors % granularity; if (unlikely(!max_discard_sectors)) { /* Avoid infinite loop below. Being cautious never hurts. */