Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13952615pxu; Mon, 4 Jan 2021 08:50:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8W9Q7ea/9aUYD7M8Ed2b5bH/XchEMQmf6k9cvz6Q/1kyPuNUQoAM3Y22TAruM4Sg4GHjO X-Received: by 2002:a17:906:e093:: with SMTP id gh19mr67569627ejb.510.1609779041005; Mon, 04 Jan 2021 08:50:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609779040; cv=none; d=google.com; s=arc-20160816; b=yaY8nkJjnQksgg2r3TYOzjJ9U5EY6vtkdsszJxq+xeQwCj/TFdq5FzMYz90BJCmOWY W2vmj6+ZTHJpBn+xj6/O6cmXz8OKpSVhAol8WIhuQTgv/EK/X2YAD7qLrCbj8OL/OtYM fXep7XNFuJS/ZKgqb94ZG9XMhPq6uwBLY10AoVHPZIG2fONb5Tu4ZztUhZlGhVnCe9/+ EmZcbQpUy0GwVj2oPitJRhpDKbg9hBGVyyFGJnI3Be4f3Q0oiUz6OnV/76mAlWccVKsJ RHIC6Vn19vN9dUtJDNSyDUD49NgdQ6JsIVXsGKiB/ej1tpYfaEf02YXxKZbyAheq81Ci bm4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZhjUNZR6xrRXZ4fC9Qwig4QCR8aduypF8GwAY9rFSNA=; b=XUbZ4QcvkbyeJ8tuIvqWytDbl2BWCVzeG3nsyt7FGfwAgeofG038v6RZKjNsGrEivJ SIBE7RUziRj8NXog+wCF9Nc9kCnNnh7cIrNS3Br6x7o4mmBndx6goi4WtGleytPNALZx AbzqHx+JdluLZrjHSF/H1ERI9HFEfaKFOD+EDwOwo3F7DJ/3xyISWLWFHv6rR3r0F7vO /lKiAAMGqJsYHB0EV6z1M/KQUhkPsllvTFbE0P50fh7PLxe3Cz1L6+OS0WuFp/yCPPC0 q6EeQpplju2yuf5uFO/sHUZyRDM0dARe0HeE8m5SHx8mFT8UEpyoMHz2YR0+WMtWsWHS mdHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pqt+bhvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si32286939edx.350.2021.01.04.08.50.17; Mon, 04 Jan 2021 08:50:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pqt+bhvO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728672AbhADQBt (ORCPT + 99 others); Mon, 4 Jan 2021 11:01:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:39138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728661AbhADQBr (ORCPT ); Mon, 4 Jan 2021 11:01:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC09D22516; Mon, 4 Jan 2021 16:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609776067; bh=61+iNcBDie/n0PCMCDmOO2PTfNTL/z08B+iuTNZh3GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pqt+bhvOJq+KOV0gtFxgOtiTpMCMS9An3rb6BCDwRZGKWTV2Miaru1EN/Th8cfhz0 +gYqXfjKVTwmn/BCH3JSCzF05/Q8dG+MBQj7fpA7s7Bl6lqE8yk4ivAknqCgQG4wY8 MiBps+eVws9ZQB8gqcGJIWwiyteYS5Xy4aLRZ4fA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hyeongseok Kim , Sami Tolvanen , Mike Snitzer , Sasha Levin Subject: [PATCH 5.4 47/47] dm verity: skip verity work if I/O error when system is shutting down Date: Mon, 4 Jan 2021 16:57:46 +0100 Message-Id: <20210104155708.006308878@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210104155705.740576914@linuxfoundation.org> References: <20210104155705.740576914@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hyeongseok Kim [ Upstream commit 252bd1256396cebc6fc3526127fdb0b317601318 ] If emergency system shutdown is called, like by thermal shutdown, a dm device could be alive when the block device couldn't process I/O requests anymore. In this state, the handling of I/O errors by new dm I/O requests or by those already in-flight can lead to a verity corruption state, which is a misjudgment. So, skip verity work in response to I/O error when system is shutting down. Signed-off-by: Hyeongseok Kim Reviewed-by: Sami Tolvanen Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm-verity-target.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 4fb33e7562c52..2aeb922e2365c 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -533,6 +533,15 @@ static int verity_verify_io(struct dm_verity_io *io) return 0; } +/* + * Skip verity work in response to I/O error when system is shutting down. + */ +static inline bool verity_is_system_shutting_down(void) +{ + return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF + || system_state == SYSTEM_RESTART; +} + /* * End one "io" structure with a given error. */ @@ -560,7 +569,8 @@ static void verity_end_io(struct bio *bio) { struct dm_verity_io *io = bio->bi_private; - if (bio->bi_status && !verity_fec_is_enabled(io->v)) { + if (bio->bi_status && + (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { verity_finish_io(io, bio->bi_status); return; } -- 2.27.0