All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: Contribute to randomness when running rotational device
@ 2018-09-06 20:37 Xuewei Zhang
  2018-09-06 22:27 ` Bart Van Assche
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Xuewei Zhang @ 2018-09-06 20:37 UTC (permalink / raw)
  To: James E . J . Bottomley, Martin K . Petersen, Ming Lei,
	Hannes Reinecke, Christoph Hellwig
  Cc: Paolo Bonzini, linux-scsi, linux-kernel, Aditya Kali, tytso,
	Guenter Roeck, maze, Xuewei Zhang

Currently a scsi device won't contribute to kernel randomness when it
uses blk-mq. Since we commonly use scsi on rotational device with
blk-mq, it make sense to keep contributing to kernel randomness in these
cases. This is especially important for virtual machines.

commit b5b6e8c8d3b4 ("scsi: virtio_scsi: fix IO hang caused by automatic
irq vector affinity") made all virtio-scsi device to use blk-mq, which
does not contribute to randomness today. So for a virtual machine only
having virtio-scsi disk (which is common), it will simple stop getting
randomness from its disks in today's implementation.

With this patch, if the above VM has rotational virtio-scsi device, then
it can still benefit from the entropy generated from the disk.

Reported-by: Xuewei Zhang <xueweiz@google.com>
Signed-off-by: Xuewei Zhang <xueweiz@google.com>
---
 drivers/scsi/sd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b79b366a94f7..5e4f10d28065 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2959,6 +2959,9 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
 	if (rot == 1) {
 		blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
 		blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
+	} else {
+		blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
+		blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
 	}
 
 	if (sdkp->device->type == TYPE_ZBC) {
-- 
2.19.0.rc2.392.g5ba43deb5a-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-17  6:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 20:37 [PATCH] scsi: sd: Contribute to randomness when running rotational device Xuewei Zhang
2018-09-06 22:27 ` Bart Van Assche
2018-09-06 22:42   ` Theodore Y. Ts'o
2018-09-06 23:03     ` Xuewei Zhang
2018-09-08  4:06       ` Bart Van Assche
2018-09-09 11:52 ` Ming Lei
2018-09-14  5:05   ` Maciej Żenczykowski
2018-09-17  6:58 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.