Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753229AbbGNSug (ORCPT ); Tue, 14 Jul 2015 14:50:36 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:21240 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752238AbbGNSue (ORCPT ); Tue, 14 Jul 2015 14:50:34 -0400 From: Jens Axboe To: CC: , , Jens Axboe Subject: [PATCH 3/3] block: by default, limit maximum discard size to 64MB Date: Tue, 14 Jul 2015 12:48:23 -0600 Message-ID: <1436899703-31966-4-git-send-email-axboe@fb.com> X-Mailer: git-send-email 2.4.1.168.g1ea28e1 In-Reply-To: <1436899703-31966-1-git-send-email-axboe@fb.com> References: <1436899703-31966-1-git-send-email-axboe@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-07-14_08:2015-07-14,2015-07-14,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1943 Lines: 52 Lots of devices exhibit very high latencies for big discards, hurting reads and writes. By default, limit the max discard we will build to 64MB. This value has shown good results across a number of devices. This will potentially hurt discard throughput, from a provisioning point of view (when the user does mkfs.xfs, for instance, and mkfs issues a full device discard). If that becomes an issue, we could have different behavior for provisioning vs runtime discards. Signed-off-by: Jens Axboe --- block/blk-settings.c | 2 ++ include/linux/blkdev.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index b38d8d723276..b98d26fcbf81 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -306,6 +306,8 @@ void blk_queue_max_discard_sectors(struct request_queue *q, { q->limits.max_hw_discard_sectors = max_discard_sectors; q->limits.max_discard_sectors = max_discard_sectors; + if (q->limits.max_discard_sectors > BLK_DISCARD_MAX_SECTORS) + q->limits.max_discard_sectors = BLK_DISCARD_MAX_SECTORS; } EXPORT_SYMBOL(blk_queue_max_discard_sectors); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 243f29e779ec..3a01b16397c4 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1141,6 +1141,11 @@ enum blk_default_limits { BLK_SAFE_MAX_SECTORS = 255, BLK_MAX_SEGMENT_SIZE = 65536, BLK_SEG_BOUNDARY_MASK = 0xFFFFFFFFUL, + + /* + * Default to max 64MB of discards, to keep latencies in check + */ + BLK_DISCARD_MAX_SECTORS = (64 * 1024 * 1024UL) >> 9, }; #define blkdev_entry_to_request(entry) list_entry((entry), struct request, queuelist) -- 2.4.1.168.g1ea28e1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/