Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2480351imj; Mon, 18 Feb 2019 06:45:35 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibb0PvcAsaJAud6ER/9cFb0UQkTPPZ58UA72dbvtdBWeKeJ1QER3IENsUSqbz7xdx907LKX X-Received: by 2002:a17:902:9683:: with SMTP id n3mr26082732plp.333.1550501135169; Mon, 18 Feb 2019 06:45:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550501135; cv=none; d=google.com; s=arc-20160816; b=EljrtbpHrP7hfXAXV52mw42sRIhkJC4bhsvKDCCXrWUcRokchxyo13BxeJEvtPvTX0 sSZepb8XnrhJS8gsOZwcWdtvh5MYQ9dEz/kMcfgmeQ5xZLUdwo17kuzhxA7vvDV1ykJI 0PeXYySkQtEG0/fixOyKMvRio/ueh/Lup7NkHJoooFtK2NBXIgDSnUx+F9JKTo7txUvr 4tac6Rr9xiWM3O+r2+MiNaQFr+ONz95qiUrT9lk6wOkHZCT8mYacMYtcF3KTUCohhRT6 l/exP+JZ+MJlFZUWqi1PZIc/KrF4DQMvmechtCP1FFPi5XaVlHjQu6fby9fLaq261hhn 7q9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qShIEHD9EW9QTg92qu9oiSH5BRvVjAuJmAu+DboUJbc=; b=UzzJZgKnrnFTUAQ4saUvsuhTYn9y3MkvZTSmIfKFmWfqCY+gI2AWZqOsCQ/tyFOm/K /O7oNp9ELETM159Ljs4bE7Xv1SkTi6rRsNx+HdbXLQVJMiiTQGy5MsBDECYjCj+SBQtg Wcj/YDE672tqmVutgOkMWaphJuks2Y2WnouqlTyfBN600+rAYxTvCeOIPUhQ7Hrf9eSV iaP3wrjpuP0c8vib2yp6irnlJZyMOfLBjlu6F08uC3d+WzviDESq+5Rdytve0GY36C/T kgDPlrABLcSB6CfUvLknDXjig8mynUBDGHv5SPpgT8BQARYYgYSqFQesJXwB3Tu3mKD8 YHcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ITkbfjzX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23si12739737pgu.151.2019.02.18.06.45.19; Mon, 18 Feb 2019 06:45:35 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=ITkbfjzX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731027AbfBRNsl (ORCPT + 99 others); Mon, 18 Feb 2019 08:48:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:55482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731886AbfBRNsi (ORCPT ); Mon, 18 Feb 2019 08:48:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9AECA21906; Mon, 18 Feb 2019 13:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550497717; bh=z30Ifm7jdW5LEFSmgxp0ZjlVb9Jx681Ika63tGrtR2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ITkbfjzXF6fJ+U7XwdOMCsL+pVProRrAMaGDqfZrHpwMVdcmOFb/8L09pllB8O2kL Equ2x4LEPk2HZFAZfBMd3QIOA68zyLlGk9t2UgbEjW+qkHpLpS5x/jCtpAKArOiAdQ KV3Pi6BjWsCC0DPZfXdZbQa1pFU7Nx9oIO4GWAmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikael Pettersson , James Bottomley , Jens Axboe , Xuewei Zhang , "Martin K. Petersen" Subject: [PATCH 4.20 80/92] scsi: sd: fix entropy gathering for most rotational disks Date: Mon, 18 Feb 2019 14:43:23 +0100 Message-Id: <20190218133502.587537434@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133454.668268457@linuxfoundation.org> References: <20190218133454.668268457@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Bottomley commit e4a056987c86f402f1286e050b1dee3f4ce7c7eb upstream. The problem is that the default for MQ is not to gather entropy, whereas the default for the legacy queue was always to gather it. The original attempt to fix entropy gathering for rotational disks under MQ added an else branch in sd_read_block_characteristics(). Unfortunately, the entire check isn't reached if the device has no characteristics VPD page. Since this page was only introduced in SBC-3 and its optional anyway, most less expensive rotational disks don't have one, meaning they all stopped gathering entropy when we made MQ the default. In a wholly unrelated change, openssl and openssh won't function until the random number generator is initialised, meaning lots of people have been seeing large delays before they could log into systems with default MQ kernels due to this lack of entropy, because it now can take tens of minutes to initialise the kernel random number generator. The fix is to set the non-rotational and add-randomness flags unconditionally early on in the disk initialization path, so they can be reset only if the device actually reports being non-rotational via the VPD page. Reported-by: Mikael Pettersson Fixes: 83e32a591077 ("scsi: sd: Contribute to randomness when running rotational device") Cc: stable@vger.kernel.org Signed-off-by: James Bottomley Reviewed-by: Jens Axboe Reviewed-by: Xuewei Zhang Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/sd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2960,9 +2960,6 @@ static void sd_read_block_characteristic 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) { @@ -3099,6 +3096,15 @@ static int sd_revalidate_disk(struct gen if (sdkp->media_present) { sd_read_capacity(sdkp, buffer); + /* + * set the default to rotational. All non-rotational devices + * support the block characteristics VPD page, which will + * cause this to be updated correctly and any device which + * doesn't support it should be treated as rotational. + */ + blk_queue_flag_clear(QUEUE_FLAG_NONROT, q); + blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q); + if (scsi_device_supports_vpd(sdp)) { sd_read_block_provisioning(sdkp); sd_read_block_limits(sdkp);