summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/blk-settings.c2
-rw-r--r--include/linux/blkdev.h5
2 files changed, 7 insertions, 0 deletions
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)