Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13954929pxu; Mon, 4 Jan 2021 08:54:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxs+LQheTlVcmjnRTLDIy2lOYz/PCg4JuE9w4HzSzeWr6xjk4EpX2Zhh4DtJ9V7VNbwDdeo X-Received: by 2002:a17:906:1488:: with SMTP id x8mr54976332ejc.124.1609779292420; Mon, 04 Jan 2021 08:54:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609779292; cv=none; d=google.com; s=arc-20160816; b=Vvytij5WNRH7mb5Km/6xhYQVHmQttXOUJ4rJFdXdrRlQdJziICQhQbNsbN3n/nJ5WE p0QIf/1L96r4qFo137SL0Mnkpm/lCeyN7w3tmy8yIVRS+a9zxtOXO8bAeTQUt9T1WWxT 68u8OcHO0NxR7xPn4WLve6npWDM2+IKyk/h4cfaTo/DHbQbSCNdc1j/FGUZ/Uml+rTOH lakhg2QrsM/ET+pnmsn53gdFrmBBmDbJsM3P5YzBCUVEqoHHxMIb+uC+CPNmdrDYlKin SrJN3yIhTk/UCynjDsEseD9mJ+fmpZLI1xsvZ3dVHnHvp7pV2V5IOABDQ1CbIB5rWML5 PYXw== 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=1AnTraZ3aPr1m5EgzPFEmOtvMF6Eg8W7fqqmpRdmGAw=; b=cvqjNfDWWxgocN+/hTYhgJQd0Pc/4bhGbiz+Cz3SypWF1wXBqMi8udoMJCy2NnogC2 HkoIylu84rRwga+g1EjleiQdOAx9ac4ynaJKSJ8ED5fVEo6Xl+2sKHAzLlWAWl1sD4mP JW6bCvu1iPYce/UM3gTDXvp8MAwCTXjs5r9JegAI8OawQxgfPDgE5A43WvVbIIcSs/KR EIkYwB/XYWIBHkfv+B4daD1Ui+HxgA/AUvHmy3tZe50Bh3s5eQeNxspcBPn4Dtw9c859 zFNar0gvHBdsGznuY+md3JNltEeYrP59YaV+pOe9PbeYhpsklCWR48Bz26EcbDdmxarc 9tGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RPRhoN+6; 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 hq7si28889873ejc.539.2021.01.04.08.54.28; Mon, 04 Jan 2021 08:54:52 -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=RPRhoN+6; 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 S1728420AbhADQDw (ORCPT + 99 others); Mon, 4 Jan 2021 11:03:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:41380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbhADQDt (ORCPT ); Mon, 4 Jan 2021 11:03:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8A5C822507; Mon, 4 Jan 2021 16:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609776189; bh=KWk5pWbTEHZ6TTGGZbFPEBpBo6ewhVXlMbkXg2F/BRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RPRhoN+6iZwxwBczB+iU87PtDBERsJknPoOyIK/6d8GfG5IMiMdG94ji/hvMUS/lH CHVzy7FPZqKnqrfVxQBsdvwe/+/Du4E41nxr4g5cjJGRg6WCI6Hbl0d9vAf6IBEAB7 efmVVrmWlb1VtUg5cH+ic9RjQb4jcfiC26drw3+M= 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.10 61/63] dm verity: skip verity work if I/O error when system is shutting down Date: Mon, 4 Jan 2021 16:57:54 +0100 Message-Id: <20210104155711.761767339@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210104155708.800470590@linuxfoundation.org> References: <20210104155708.800470590@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 f74982dcbea0d..6b8e5bdd8526d 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -537,6 +537,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. */ @@ -564,7 +573,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