From patchwork Fri Apr 19 16:42:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 238079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 93F822C0225 for ; Sat, 20 Apr 2013 03:57:36 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTEPL-0002xV-U2; Fri, 19 Apr 2013 16:43:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTEOQ-0002KR-P9; Fri, 19 Apr 2013 16:42:34 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UTEON-0002Jx-4V for linux-mtd@lists.infradead.org; Fri, 19 Apr 2013 16:42:32 +0000 Received: by mail-pa0-f41.google.com with SMTP id kx10so520255pab.0 for ; Fri, 19 Apr 2013 09:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=Sd5xTFIY9AkR1W0q7/c1gUZDJKonZ/7z/ZOzyweFGLw=; b=XxBNBJxlE/fSYiHxnEnrfnGXVe7kDvZQ5YHhtfMgGMu1ysU+feYbjmhmoI68K0y0GW 4ek5/jwxqLeasIQtuwu8lmuHFMOw0/ptBAgaw5ar6k6EBjlXLN63hxVGmerAPGSScrpH PKg9rC5RL7P4TJemUY/Rd1L3Jp83cOHuBnidSur49Qa4ksTMIiAFuTlTbQZj3TFaju1z NRvJiba+Lg3Xt2KQr6GByV19Aodw9+7cho2AMKUfDVSNz5beXTRxXEW4iBiYliJPrCvU qU5JMJxe+gDqaiSiHYHIdYbxGQ43usFvK4JBU9xksUuc5DkjntHWRtxymcQDb4rCZ5Da Ow/g== X-Received: by 10.68.91.131 with SMTP id ce3mr20417726pbb.46.1366389748468; Fri, 19 Apr 2013 09:42:28 -0700 (PDT) Received: from linkinjeon-Aspire-One-522.kornet ([121.143.184.70]) by mx.google.com with ESMTPS id iy2sm13931736pbb.31.2013.04.19.09.42.25 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Apr 2013 09:42:28 -0700 (PDT) From: Namjae Jeon To: dwmw2@infradead.org, axboe@kernel.dk, shli@kernel.org, Paul.Clements@steeleye.com, npiggin@kernel.dk, neilb@suse.de, cjb@laptop.org, adrian.hunter@intel.com, James.Bottomley@HansenPartnership.com, JBottomley@parallels.com Subject: [PATCH v2 8/9] dm thin: use generic helper to set max_discard_sectors Date: Sat, 20 Apr 2013 01:42:20 +0900 Message-Id: <1366389740-19587-1-git-send-email-linkinjeon@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130419_124231_350104_6B333B57 X-CRM114-Status: GOOD ( 10.89 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.41 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (linkinjeon[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: nbd-general@lists.sourceforge.net, Namjae Jeon , Vivek Trivedi , linux-scsi@vger.kernel.org, Namjae Jeon , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, jcmvbkbc@gmail.com, linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Namjae Jeon It is better to use blk_queue_max_discard_sectors helper function to set max_discard_sectors as it checks max_discard_sectors upper limit UINT_MAX >> 9 similar issue was reported for mmc in below link https://lkml.org/lkml/2013/4/1/292 If multiple discard requests get merged, merged discard request's size exceeds 4GB, there is possibility that merged discard request's __data_len field may overflow. This patch fixes this issue. Signed-off-by: Namjae Jeon Signed-off-by: Vivek Trivedi --- drivers/md/dm-thin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 905b75f..237295a 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -2513,7 +2513,8 @@ static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits) struct pool *pool = pt->pool; struct queue_limits *data_limits; - limits->max_discard_sectors = pool->sectors_per_block; + blk_queue_max_discard_sectors(bdev_get_queue(pt->data_dev->bdev), + pool->sectors_per_block); /* * discard_granularity is just a hint, and not enforced.