From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01F70C46467 for ; Wed, 23 Nov 2022 12:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238306AbiKWMx5 (ORCPT ); Wed, 23 Nov 2022 07:53:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237927AbiKWMvo (ORCPT ); Wed, 23 Nov 2022 07:51:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B5D85A1D; Wed, 23 Nov 2022 04:44:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83D5761CAD; Wed, 23 Nov 2022 12:44:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 310FFC433D6; Wed, 23 Nov 2022 12:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669207464; bh=Y9wZ5NENpss4gJuUy4lkrc8keKXLyrcZ8V/8CCQh9qU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWWbZX95XkmcPj2Z1Abod3jxQgParMOThsar6cVSubnWWbP6jcruoA3ZosQEORuLr PS8c7CzgSMwC+qqmAklozUAiyvnOoYLkAgPNUNl+NFdZ9pfYCVSnb0WQN9Biru8jzu 7bJGpAgT9xX8yWwGZwn0+7tY8a/pIJg84GFtVq9jL/YIX2XCjV5e1DtKuea3CHMlV+ osafrjqEn/EynV6W2O3MKkKz5VYfOF3HalPY/3OYsu1mHiG/bmoKxG2btxCEKP25C0 EueSRY0N3Z/lwZ+yQiCpHzZbjoO0Cv3tsz8k+Lpn3ohC7AWIWxwoc4663/Svl6EgEf 0r+bPBVUu7law== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mikulas Patocka , Mike Snitzer , Sasha Levin , agk@redhat.com, dm-devel@redhat.com Subject: [PATCH AUTOSEL 5.10 22/22] dm integrity: clear the journal on suspend Date: Wed, 23 Nov 2022 07:43:37 -0500 Message-Id: <20221123124339.265912-22-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221123124339.265912-1-sashal@kernel.org> References: <20221123124339.265912-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka [ Upstream commit 984bf2cc531e778e49298fdf6730e0396166aa21 ] There was a problem that a user burned a dm-integrity image on CDROM and could not activate it because it had a non-empty journal. Fix this problem by flushing the journal (done by the previous commit) and clearing the journal (done by this commit). Once the journal is cleared, dm-integrity won't attempt to replay it on the next activation. Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm-integrity.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 518116c1a716..4818b5ff0a27 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -254,6 +254,7 @@ struct dm_integrity_c { struct completion crypto_backoff; + bool wrote_to_journal; bool journal_uptodate; bool just_formatted; bool recalculate_flag; @@ -2256,6 +2257,8 @@ static void integrity_commit(struct work_struct *w) if (!commit_sections) goto release_flush_bios; + ic->wrote_to_journal = true; + i = commit_start; for (n = 0; n < commit_sections; n++) { for (j = 0; j < ic->journal_section_entries; j++) { @@ -2979,6 +2982,14 @@ static void dm_integrity_postsuspend(struct dm_target *ti) queue_work(ic->writer_wq, &ic->writer_work); drain_workqueue(ic->writer_wq); dm_integrity_flush_buffers(ic, true); + if (ic->wrote_to_journal) { + init_journal(ic, ic->free_section, + ic->journal_sections - ic->free_section, ic->commit_seq); + if (ic->free_section) { + init_journal(ic, 0, ic->free_section, + next_commit_seq(ic->commit_seq)); + } + } } if (ic->mode == 'B') { @@ -3006,6 +3017,8 @@ static void dm_integrity_resume(struct dm_target *ti) DEBUG_print("resume\n"); + ic->wrote_to_journal = false; + if (ic->provided_data_sectors != old_provided_data_sectors) { if (ic->provided_data_sectors > old_provided_data_sectors && ic->mode == 'B' && -- 2.35.1