This is a note to let you know that I've just added the patch titled

    dm integrity: clear the journal on suspend

to the 6.0-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dm-integrity-clear-the-journal-on-suspend.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <sta...@vger.kernel.org> know about it.



commit e2db1c738c2945f7e1f867459a32db110527dc48
Author: Mikulas Patocka <mpato...@redhat.com>
Date:   Tue Nov 15 12:51:50 2022 -0500

    dm integrity: clear the journal on suspend
    
    [ 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 <mpato...@redhat.com>
    Signed-off-by: Mike Snitzer <snit...@kernel.org>
    Signed-off-by: Sasha Levin <sas...@kernel.org>

diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index f26a6cd09e0c..e97e9f97456d 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -263,6 +263,7 @@ struct dm_integrity_c {
 
        struct completion crypto_backoff;
 
+       bool wrote_to_journal;
        bool journal_uptodate;
        bool just_formatted;
        bool recalculate_flag;
@@ -2375,6 +2376,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++) {
@@ -3100,6 +3103,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') {
@@ -3127,6 +3138,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' &&

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel

Reply via email to