From patchwork Fri Apr 19 16:41: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: 2466401 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 04D6B3FD8C for ; Fri, 19 Apr 2013 16:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030974Ab3DSQlL (ORCPT ); Fri, 19 Apr 2013 12:41:11 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:53300 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967882Ab3DSQlI (ORCPT ); Fri, 19 Apr 2013 12:41:08 -0400 Received: by mail-pd0-f173.google.com with SMTP id v14so2346892pde.4 for ; Fri, 19 Apr 2013 09:41:07 -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=kTS/9YfSk0W4wDu6HWqREM2Bx9CbK35LMxHeHvTLYQw=; b=NdT5yCJIaTIhudC8w2ruNc/ZGay6Yxi1PO2ykR8U7rgCdd+nwAoG4Q7x1DT/slMdNI //WYEaop8dxZrfw+gzbeBzM4TN4HdJN5UKnyKGcChj7r9kZFiO4cMGG7dm8Vd28hJYNG QOYr4v12KqEMU1m0AGJEg9n+qfrY7UBvIRwTNoAzWUJ4G6MnjH53ORL8N2uDIdIOokwk KxHFhuUje9IcGl0lUKo0uEf/gyqV4KKH8cINpkFWFrtd7aUBE2+mB0ryqculriw/Pjs7 uOFAfJ/sjmQnA/id6MiznOlhbUsA2ter+mURt8rbnqzU8rSyRKA9mzCVi4n1tt4iDTCB nzZQ== X-Received: by 10.66.154.164 with SMTP id vp4mr344055pab.89.1366389667654; Fri, 19 Apr 2013 09:41:07 -0700 (PDT) Received: from linkinjeon-Aspire-One-522.kornet ([121.143.184.70]) by mx.google.com with ESMTPS id bs3sm13921095pbb.36.2013.04.19.09.41.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Apr 2013 09:41:07 -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 3/9] sd: use generic helper to set max_discard_sectors Date: Sat, 20 Apr 2013 01:41:00 +0900 Message-Id: <1366389660-19417-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/scsi/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 7992635..93c26b3 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -632,7 +632,8 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) break; } - q->limits.max_discard_sectors = max_blocks * (logical_block_size >> 9); + blk_queue_max_discard_sectors(q, + max_blocks * (logical_block_size >> 9)); queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); }