From patchwork Sat Apr 13 13:39:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 2440651 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 50030DFB78 for ; Sat, 13 Apr 2013 13:39:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753764Ab3DMNjO (ORCPT ); Sat, 13 Apr 2013 09:39:14 -0400 Received: from mail-da0-f51.google.com ([209.85.210.51]:57090 "EHLO mail-da0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753494Ab3DMNjM (ORCPT ); Sat, 13 Apr 2013 09:39:12 -0400 Received: by mail-da0-f51.google.com with SMTP id g27so1489150dan.38 for ; Sat, 13 Apr 2013 06:39:11 -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=mnGOJywvQlS/4GoKo+YvpbK3i8schnHlZgWA+3uFKbQ=; b=xGE8M9zFiZUuqQ6AVUOtO8hCfB+7po7M1BMwcCC6zoM/2advkmNVJn4wuV99zIWUOk QnRhMppYeivreDUjx06JAO1k4cTJgkyhZ1yBUHEPVul/daE2y0q6jkXWA0ofY5Q1q6jr u5dzIbSnWVEh6QKS+QV9wQBy8V1TMtzyzySvHD92IQXraH89bZfZQNzhDk8ZUwEYg9WK hKcqgDSxiwooTGLdwxJknyI1Eo9P27t49/XuSuGWoIUJppNK8p07Kl5vzUzRnnfR2kVJ w8VSxY5jQg9B/t7479rIGtDMF9336I+Rfnia77p41lKGNeyUhpMzr0ZgTLFg682r9noW wehg== X-Received: by 10.66.196.68 with SMTP id ik4mr20754148pac.105.1365860351405; Sat, 13 Apr 2013 06:39:11 -0700 (PDT) Received: from linkinjeon-Aspire-One-522.kornet ([121.143.184.70]) by mx.google.com with ESMTPS id li15sm13922023pab.2.2013.04.13.06.39.06 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Apr 2013 06:39:11 -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 Cc: 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, Namjae Jeon , Namjae Jeon , Vivek Trivedi Subject: [PATCH 4/8] loop: use generic helper to set max_discard_sectors Date: Sat, 13 Apr 2013 22:39:00 +0900 Message-Id: <1365860340-21329-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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index b2955b3..21f3233 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -806,7 +806,7 @@ static void loop_config_discard(struct loop_device *lo) lo->lo_encrypt_key_size) { q->limits.discard_granularity = 0; q->limits.discard_alignment = 0; - q->limits.max_discard_sectors = 0; + blk_queue_max_discard_sectors(q, 0); q->limits.discard_zeroes_data = 0; queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); return; @@ -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); }