Skip to content

Commit 83e32a5

Browse files
Xuewei Zhangmartinkpetersen
authored andcommitted
scsi: sd: Contribute to randomness when running rotational device
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 b5b6e8c ("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> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Maciej Żenczykowski <maze@google.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent adad633 commit 83e32a5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/scsi/sd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,9 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
29592959
if (rot == 1) {
29602960
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
29612961
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
2962+
} else {
2963+
blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
2964+
blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
29622965
}
29632966

29642967
if (sdkp->device->type == TYPE_ZBC) {

0 commit comments

Comments
 (0)