Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp348896pxu; Thu, 7 Jan 2021 06:40:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkMeOVQ0YlVmdd9BqXHKZEGucWYlJxxSqI0P1B1KIfLV0h04BHTOvn7w/veS0HTe11cvUa X-Received: by 2002:a17:906:971a:: with SMTP id k26mr6684743ejx.279.1610030422026; Thu, 07 Jan 2021 06:40:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610030422; cv=none; d=google.com; s=arc-20160816; b=mArKotycPoZj2NGr1QRCFfoEk/1Ft9qsuRg8wZ8UkS8J83jjA27v1HLjSgFCF47EdF G7+KZhNCk2uRNgc2vk02B+IY4FTF+m7NNyMiwSmKAxsSsdwetrElvVEToorxMRb5QI3v 3pqWQ0Xf4xOr9x1BCdjEAQx12so1Qb6t740xLj22dBKJO5OsAH3CsRz13zyjjgJovAQW RoBUaJ2XgKz+1E3reSKppRb2BgxccY+I/yZ015OWX2b8Rf+un5mhidicwtZWQ+3oewY0 jgx3qeRziTPvXuepr4S9bynlPjxCBbYRsPLi90uWEN9qLf4TDdcgXWuywO4Fnt+PozEV XtKQ== 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=oaPSNVSL99bzn0wMv/obQOOxjWYWgMNVmzciy4pa6j0=; b=vJccuIflp+ncMXLdTFOG8kX9DM8hy6Cj9UY0KYO5KmsA4LGqfybt4rg4tZfI7oBIlo mcHUDcKrCSi0oq4zpi9cxhwC1HDIkchT7GL1PuJCO+4glsJd0j4SnMJNb9XDA1BhLZ1L aG4iBCAH3/7//D/5qJnbp80Cg51JUT17Zrs+DX2XvoKy5X+VKOTCDIFRvQTr+Nv9n76A SsaxfzxPe5VXbMu0xODeNGZ8pTkMXnqkkFFu2x1jphEfg0ONpKevduPsOL9nUBj0vfV1 teY65TgiLCPi/CvBXFNzrR7LfHJZJ36AgL73Ymw+YjUujKy2ynpxfB9w2xB9+QfwphkW BaEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="A4y/GaOQ"; 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 r9si2345644ejb.246.2021.01.07.06.39.57; Thu, 07 Jan 2021 06:40:22 -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="A4y/GaOQ"; 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 S1729915AbhAGOiP (ORCPT + 99 others); Thu, 7 Jan 2021 09:38:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:45562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728983AbhAGObw (ORCPT ); Thu, 7 Jan 2021 09:31:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 738C3233A0; Thu, 7 Jan 2021 14:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610029869; bh=hLKRlzV9HJgJF3/Ryhk2CejgBYqdQ8YDfA/XwtsyKRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4y/GaOQJnlS8FISkDkUvCO27759GxmB2btPHxS9DD6El3wgbLqL8OKV7kBQgYt0h az0t+G7luNQhU6t1RgxiEbcC69XtZzxhJerKLr776+l1K1PSqIwQ9cPGgxEFKX+UFn XCVg5Y92Wgvy8AZajvI5/uQ/6dMbNhEIjaI9G1i0= 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 4.14 25/29] dm verity: skip verity work if I/O error when system is shutting down Date: Thu, 7 Jan 2021 15:31:40 +0100 Message-Id: <20210107143056.558164713@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210107143052.973437064@linuxfoundation.org> References: <20210107143052.973437064@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 e705799976c2c..2dae30713eb3d 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -551,6 +551,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. */ @@ -578,7 +587,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