diff options
author | Mike Snitzer <snitzer@redhat.com> | 2014-10-04 12:55:32 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-10-04 12:55:32 -0400 |
commit | b277da0a8a594308e17881f4926879bd5fca2a2d (patch) | |
tree | 1af7df6ade218a4b246dd43a0771701a672c6cb8 | |
parent | 7b7b7f7e024460cb7d77f8f96b6eb1a8803f94d9 (diff) |
block: disable entropy contributions for nonrot devices
Clear QUEUE_FLAG_ADD_RANDOM in all block drivers that set
QUEUE_FLAG_NONROT.
Historically, all block devices have automatically made entropy
contributions. But as previously stated in commit e2e1a148 ("block: add
sysfs knob for turning off disk entropy contributions"):
- On SSD disks, the completion times aren't as random as they
are for rotational drives. So it's questionable whether they
should contribute to the random pool in the first place.
- Calling add_disk_randomness() has a lot of overhead.
There are more reliable sources for randomness than non-rotational block
devices. From a security perspective it is better to err on the side of
caution than to allow entropy contributions from unreliable "random"
sources.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/block/mtip32xx/mtip32xx.c | 1 | ||||
-rw-r--r-- | drivers/block/nbd.c | 1 | ||||
-rw-r--r-- | drivers/block/null_blk.c | 1 | ||||
-rw-r--r-- | drivers/block/nvme-core.c | 1 | ||||
-rw-r--r-- | drivers/block/rsxx/dev.c | 1 | ||||
-rw-r--r-- | drivers/block/skd_main.c | 1 | ||||
-rw-r--r-- | drivers/block/zram/zram_drv.c | 1 | ||||
-rw-r--r-- | drivers/ide/ide-disk.c | 4 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 1 | ||||
-rw-r--r-- | drivers/mmc/card/queue.c | 1 | ||||
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 1 | ||||
-rw-r--r-- | drivers/s390/block/scm_blk.c | 1 | ||||
-rw-r--r-- | drivers/s390/block/xpram.c | 1 | ||||
-rw-r--r-- | drivers/scsi/sd.c | 4 |
14 files changed, 18 insertions, 2 deletions
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index db1e9560d8a7..936f8c160e46 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c | |||
@@ -3952,6 +3952,7 @@ skip_create_disk: | |||
3952 | 3952 | ||
3953 | /* Set device limits. */ | 3953 | /* Set device limits. */ |
3954 | set_bit(QUEUE_FLAG_NONROT, &dd->queue->queue_flags); | 3954 | set_bit(QUEUE_FLAG_NONROT, &dd->queue->queue_flags); |
3955 | clear_bit(QUEUE_FLAG_ADD_RANDOM, &dd->queue->queue_flags); | ||
3955 | blk_queue_max_segments(dd->queue, MTIP_MAX_SG); | 3956 | blk_queue_max_segments(dd->queue, MTIP_MAX_SG); |
3956 | blk_queue_physical_block_size(dd->queue, 4096); | 3957 | blk_queue_physical_block_size(dd->queue, 4096); |
3957 | blk_queue_max_hw_sectors(dd->queue, 0xffff); | 3958 | blk_queue_max_hw_sectors(dd->queue, 0xffff); |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index fb31b8ee4372..4bc2a5cb9935 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -847,6 +847,7 @@ static int __init nbd_init(void) | |||
847 | * Tell the block layer that we are not a rotational device | 847 | * Tell the block layer that we are not a rotational device |
848 | */ | 848 | */ |
849 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue); | 849 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue); |
850 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, disk->queue); | ||
850 | disk->queue->limits.discard_granularity = 512; | 851 | disk->queue->limits.discard_granularity = 512; |
851 | disk->queue->limits.max_discard_sectors = UINT_MAX; | 852 | disk->queue->limits.max_discard_sectors = UINT_MAX; |
852 | disk->queue->limits.discard_zeroes_data = 0; | 853 | disk->queue->limits.discard_zeroes_data = 0; |
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index a3b042c4d448..b0d94b6973ab 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c | |||
@@ -507,6 +507,7 @@ static int null_add_dev(void) | |||
507 | 507 | ||
508 | nullb->q->queuedata = nullb; | 508 | nullb->q->queuedata = nullb; |
509 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q); | 509 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q); |
510 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q); | ||
510 | 511 | ||
511 | disk = nullb->disk = alloc_disk_node(1, home_node); | 512 | disk = nullb->disk = alloc_disk_node(1, home_node); |
512 | if (!disk) | 513 | if (!disk) |
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 02351e217165..e2bb8afbeae5 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
@@ -1916,6 +1916,7 @@ static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid, | |||
1916 | ns->queue->queue_flags = QUEUE_FLAG_DEFAULT; | 1916 | ns->queue->queue_flags = QUEUE_FLAG_DEFAULT; |
1917 | queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue); | 1917 | queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue); |
1918 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue); | 1918 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue); |
1919 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, ns->queue); | ||
1919 | blk_queue_make_request(ns->queue, nvme_make_request); | 1920 | blk_queue_make_request(ns->queue, nvme_make_request); |
1920 | ns->dev = dev; | 1921 | ns->dev = dev; |
1921 | ns->queue->queuedata = ns; | 1922 | ns->queue->queuedata = ns; |
diff --git a/drivers/block/rsxx/dev.c b/drivers/block/rsxx/dev.c index 2839d37e5af7..40ee7705df63 100644 --- a/drivers/block/rsxx/dev.c +++ b/drivers/block/rsxx/dev.c | |||
@@ -307,6 +307,7 @@ int rsxx_setup_dev(struct rsxx_cardinfo *card) | |||
307 | blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); | 307 | blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); |
308 | 308 | ||
309 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, card->queue); | 309 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, card->queue); |
310 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, card->queue); | ||
310 | if (rsxx_discard_supported(card)) { | 311 | if (rsxx_discard_supported(card)) { |
311 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, card->queue); | 312 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, card->queue); |
312 | blk_queue_max_discard_sectors(card->queue, | 313 | blk_queue_max_discard_sectors(card->queue, |
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 8fcdcfb4b472..1e46eb2305c0 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c | |||
@@ -4426,6 +4426,7 @@ static int skd_cons_disk(struct skd_device *skdev) | |||
4426 | q->limits.discard_zeroes_data = 1; | 4426 | q->limits.discard_zeroes_data = 1; |
4427 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); | 4427 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); |
4428 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); | 4428 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); |
4429 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q); | ||
4429 | 4430 | ||
4430 | spin_lock_irqsave(&skdev->lock, flags); | 4431 | spin_lock_irqsave(&skdev->lock, flags); |
4431 | pr_debug("%s:%s:%d stopping %s queue\n", | 4432 | pr_debug("%s:%s:%d stopping %s queue\n", |
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index dfa4024c448a..6dd2cef5b865 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -925,6 +925,7 @@ static int create_device(struct zram *zram, int device_id) | |||
925 | set_capacity(zram->disk, 0); | 925 | set_capacity(zram->disk, 0); |
926 | /* zram devices sort of resembles non-rotational disks */ | 926 | /* zram devices sort of resembles non-rotational disks */ |
927 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); | 927 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); |
928 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue); | ||
928 | /* | 929 | /* |
929 | * To ensure that we always get PAGE_SIZE aligned | 930 | * To ensure that we always get PAGE_SIZE aligned |
930 | * and n*PAGE_SIZED sized I/O requests. | 931 | * and n*PAGE_SIZED sized I/O requests. |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index ee880382e3bc..56b9708894a5 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -685,8 +685,10 @@ static void ide_disk_setup(ide_drive_t *drive) | |||
685 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, | 685 | printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, |
686 | queue_max_sectors(q) / 2); | 686 | queue_max_sectors(q) / 2); |
687 | 687 | ||
688 | if (ata_id_is_ssd(id)) | 688 | if (ata_id_is_ssd(id)) { |
689 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); | 689 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); |
690 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q); | ||
691 | } | ||
690 | 692 | ||
691 | /* calculate drive capacity, and select LBA if possible */ | 693 | /* calculate drive capacity, and select LBA if possible */ |
692 | ide_disk_get_capacity(drive); | 694 | ide_disk_get_capacity(drive); |
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index d4713d098a39..4dd2bb7167f0 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -842,6 +842,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size, | |||
842 | q->limits.logical_block_size = block_size; | 842 | q->limits.logical_block_size = block_size; |
843 | q->limits.physical_block_size = block_size; | 843 | q->limits.physical_block_size = block_size; |
844 | set_bit(QUEUE_FLAG_NONROT, &d->disk->queue->queue_flags); | 844 | set_bit(QUEUE_FLAG_NONROT, &d->disk->queue->queue_flags); |
845 | clear_bit(QUEUE_FLAG_ADD_RANDOM, &d->disk->queue->queue_flags); | ||
845 | set_bit(QUEUE_FLAG_DISCARD, &d->disk->queue->queue_flags); | 846 | set_bit(QUEUE_FLAG_DISCARD, &d->disk->queue->queue_flags); |
846 | 847 | ||
847 | blk_queue_flush(q, REQ_FLUSH|REQ_FUA); | 848 | blk_queue_flush(q, REQ_FLUSH|REQ_FUA); |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 3e049c13429c..c19bfc1e565a 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
@@ -210,6 +210,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, | |||
210 | 210 | ||
211 | blk_queue_prep_rq(mq->queue, mmc_prep_request); | 211 | blk_queue_prep_rq(mq->queue, mmc_prep_request); |
212 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue); | 212 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue); |
213 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, mq->queue); | ||
213 | if (mmc_can_erase(card)) | 214 | if (mmc_can_erase(card)) |
214 | mmc_queue_setup_discard(mq->queue, card); | 215 | mmc_queue_setup_discard(mq->queue, card); |
215 | 216 | ||
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 43e30992a369..d08229eb44d8 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -417,6 +417,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
417 | blk_queue_logical_block_size(new->rq, tr->blksize); | 417 | blk_queue_logical_block_size(new->rq, tr->blksize); |
418 | 418 | ||
419 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, new->rq); | 419 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, new->rq); |
420 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, new->rq); | ||
420 | 421 | ||
421 | if (tr->discard) { | 422 | if (tr->discard) { |
422 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq); | 423 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq); |
diff --git a/drivers/s390/block/scm_blk.c b/drivers/s390/block/scm_blk.c index 76bed1743db1..56046ab39629 100644 --- a/drivers/s390/block/scm_blk.c +++ b/drivers/s390/block/scm_blk.c | |||
@@ -386,6 +386,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev) | |||
386 | blk_queue_max_hw_sectors(rq, nr_max_blk << 3); /* 8 * 512 = blk_size */ | 386 | blk_queue_max_hw_sectors(rq, nr_max_blk << 3); /* 8 * 512 = blk_size */ |
387 | blk_queue_max_segments(rq, nr_max_blk); | 387 | blk_queue_max_segments(rq, nr_max_blk); |
388 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, rq); | 388 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, rq); |
389 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, rq); | ||
389 | scm_blk_dev_cluster_setup(bdev); | 390 | scm_blk_dev_cluster_setup(bdev); |
390 | 391 | ||
391 | bdev->gendisk = alloc_disk(SCM_NR_PARTS); | 392 | bdev->gendisk = alloc_disk(SCM_NR_PARTS); |
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index 6969d39f1e2e..9e0de9c9a6fc 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c | |||
@@ -346,6 +346,7 @@ static int __init xpram_setup_blkdev(void) | |||
346 | goto out; | 346 | goto out; |
347 | } | 347 | } |
348 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, xpram_queues[i]); | 348 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, xpram_queues[i]); |
349 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, xpram_queues[i]); | ||
349 | blk_queue_make_request(xpram_queues[i], xpram_make_request); | 350 | blk_queue_make_request(xpram_queues[i], xpram_make_request); |
350 | blk_queue_logical_block_size(xpram_queues[i], 4096); | 351 | blk_queue_logical_block_size(xpram_queues[i], 4096); |
351 | } | 352 | } |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 2c2041ca4b70..fe67f5c107a2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -2660,8 +2660,10 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) | |||
2660 | 2660 | ||
2661 | rot = get_unaligned_be16(&buffer[4]); | 2661 | rot = get_unaligned_be16(&buffer[4]); |
2662 | 2662 | ||
2663 | if (rot == 1) | 2663 | if (rot == 1) { |
2664 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue); | 2664 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue); |
2665 | queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, sdkp->disk->queue); | ||
2666 | } | ||
2665 | 2667 | ||
2666 | out: | 2668 | out: |
2667 | kfree(buffer); | 2669 | kfree(buffer); |