From patchwork Fri Apr 19 16:41:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 2466391 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 703903FD8C for ; Fri, 19 Apr 2013 16:43:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030996Ab3DSQlt (ORCPT ); Fri, 19 Apr 2013 12:41:49 -0400 Received: from mail-da0-f50.google.com ([209.85.210.50]:47324 "EHLO mail-da0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030985Ab3DSQls (ORCPT ); Fri, 19 Apr 2013 12:41:48 -0400 Received: by mail-da0-f50.google.com with SMTP id a4so537379dad.37 for ; Fri, 19 Apr 2013 09:41:47 -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=AF1mJ9X0Bv6WCIb2uIkg1holvn3mmhYN7O7cYe9jBaI=; b=OnZQzlnrToGfSthaPNThBlC0EwQS+F5KsWmkA/vwzW/uyiiQZpWs0BeQQj1CF1gD74 dmj3H4DYjLpPrJRIGcTeYUVNYRMeN6ndjYQdmV7IJkd2oL4mUynrgzJ9ZNiEPJQufzg7 us4LRFLwSbJ++WhD1tx8oA5UJW9gQAMXrts3iR+Llauplvw+mN18m31P/9pyU/wgV9y0 ObyYSWXQLg9fglIcO6srF5qXdLR1O3nxqCurpBDHxeZj1t/7hP2Rpb7wqCUgPZthr23C eKPdewS44Ws5eF+4bekyHCyvmt5fUV7WmhUH0O198QCVApKl3Wy6NqPInJTfjMWGry14 7XjA== X-Received: by 10.67.3.2 with SMTP id bs2mr403083pad.132.1366389707766; Fri, 19 Apr 2013 09:41:47 -0700 (PDT) Received: from linkinjeon-Aspire-One-522.kornet ([121.143.184.70]) by mx.google.com with ESMTPS id aj2sm13983489pbc.1.2013.04.19.09.41.44 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Apr 2013 09:41:47 -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 Cc: linux-scsi@vger.kernel.org, linux-mtd@lists.infradead.org, nbd-general@lists.sourceforge.net, linux-raid@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, jcmvbkbc@gmail.com, Namjae Jeon , Namjae Jeon , Vivek Trivedi Subject: [PATCH v2 5/9] loop: use generic helper to set max_discard_sectors Date: Sat, 20 Apr 2013 01:41:39 +0900 Message-Id: <1366389699-19485-1-git-send-email-linkinjeon@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index b2955b3..aedc341 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -814,7 +814,7 @@ static void loop_config_discard(struct loop_device *lo) q->limits.discard_granularity = inode->i_sb->s_blocksize; q->limits.discard_alignment = 0; - q->limits.max_discard_sectors = UINT_MAX >> 9; + blk_queue_max_discard_sectors(q, UINT_MAX >> 9); q->limits.discard_zeroes_data = 1; queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); }