Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1564423imm; Sun, 9 Sep 2018 04:53:50 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZilFgYKXrDlTd0LDgR7QrE6gfeCniGzgbjFxpTNPvQwbZvlFuBkaAcL60HUZ7So1PSf2KW X-Received: by 2002:a17:902:286a:: with SMTP id e97-v6mr16749182plb.340.1536494030290; Sun, 09 Sep 2018 04:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536494030; cv=none; d=google.com; s=arc-20160816; b=TSI1T51e6B3Mcb/jSNBn8THMf+gbS71Afg6z29sTL9DOpbgjYZB8Q9jmvWHC4UdGsz 3fR4C+o9AoixEZMIiSuFPxZ+k0NCjEWHhrLYecz6TiSRM+t9XJrNAeVzlMnj0ymWJfiO HJ5OVIkXEvRiJcTWMkeRHTvqrKQtKeGkJza0BqVESXNHD6UnNDC+U5ZsH16NShGfv/K8 CDfof0fgk8M57E7iJsZr2XlcNn7WK8HFCeAJwa7Yz9D2kEIAQOxmu6+5BGYmWmz9JOs3 pDlucdObndtE8g2HqdAi+7e9j/pbA95CwOPeieWnQ8aRi+TAbM1uPgxmzL+6NFxxJbBV 3aHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=WQ5e1chMCVlp1ydCMTO+48ap4gBpmLFqAgd0Ek2vsFw=; b=CZSMzd+QIzM5bKGOPAW9oJJQ4+zzaN6ANBLUngLOik6O65599k2C6IdHaUIMda1JCi RTq7WizUAKVE/ir1siakNWRHCpFL70JMq3BQFlwbticHvAQkYiKtjhnmRKKwyQFSwPss 8VyqNyeaO4e8q25kdd+1SYX0DnKU394XB3GgOH6SG1KLyq5lESmiTTpMPcqTRsueLaRz dAgcEJ7V4ptJb4Juq8AWH4mxIVJkeoA1Cx9kf2rTQFGecn1N2DA8SH43YA7QwvLIXg4M Nq+D6nrpCn9TPo0r7KUFif5g2CKn1h6fcxIOQhKoEw19+q8ukchfgSVN7XTCZVwSxwze +o/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b19-v6si14104286pfb.89.2018.09.09.04.53.31; Sun, 09 Sep 2018 04:53:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbeIIQlt (ORCPT + 99 others); Sun, 9 Sep 2018 12:41:49 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:52138 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726662AbeIIQls (ORCPT ); Sun, 9 Sep 2018 12:41:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B15126A81; Sun, 9 Sep 2018 11:52:22 +0000 (UTC) Received: from ming.t460p (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D37EC112D184; Sun, 9 Sep 2018 11:52:12 +0000 (UTC) Date: Sun, 9 Sep 2018 19:52:07 +0800 From: Ming Lei To: Xuewei Zhang Cc: "James E . J . Bottomley" , "Martin K . Petersen" , Hannes Reinecke , Christoph Hellwig , Paolo Bonzini , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Aditya Kali , tytso@mit.edu, Guenter Roeck , maze@google.com Subject: Re: [PATCH] scsi: sd: Contribute to randomness when running rotational device Message-ID: <20180909115205.GA17732@ming.t460p> References: <20180906203719.209399-1-xueweiz@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180906203719.209399-1-xueweiz@google.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sun, 09 Sep 2018 11:52:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Sun, 09 Sep 2018 11:52:22 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 06, 2018 at 01:37:19PM -0700, Xuewei Zhang wrote: > 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 > Signed-off-by: Xuewei Zhang > --- > 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 > Look reasonable, especially the disk randomness is added by SCSI itself. Reviewed-by: Ming Lei Thanks, Ming