public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Xuewei Zhang <xueweiz@google.com>
To: "James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Ming Lei <ming.lei@redhat.com>, Hannes Reinecke <hare@suse.de>,
	Christoph Hellwig <hch@lst.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Aditya Kali <adityakali@google.com>,
	tytso@mit.edu, Guenter Roeck <groeck@chromium.org>,
	maze@google.com, Xuewei Zhang <xueweiz@google.com>
Subject: [PATCH] scsi: sd: Contribute to randomness when running rotational device
Date: Thu,  6 Sep 2018 13:37:19 -0700	[thread overview]
Message-ID: <20180906203719.209399-1-xueweiz@google.com> (raw)

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

             reply	other threads:[~2018-09-06 20:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 20:37 Xuewei Zhang [this message]
2018-09-06 22:27 ` [PATCH] scsi: sd: Contribute to randomness when running rotational device 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180906203719.209399-1-xueweiz@google.com \
    --to=xueweiz@google.com \
    --cc=adityakali@google.com \
    --cc=groeck@chromium.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=maze@google.com \
    --cc=ming.lei@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox