Skip to content

Commit 984bf2c

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm integrity: clear the journal on suspend
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 <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 5e5dab5 commit 984bf2c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/md/dm-integrity.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ struct dm_integrity_c {
263263

264264
struct completion crypto_backoff;
265265

266+
bool wrote_to_journal;
266267
bool journal_uptodate;
267268
bool just_formatted;
268269
bool recalculate_flag;
@@ -2375,6 +2376,8 @@ static void integrity_commit(struct work_struct *w)
23752376
if (!commit_sections)
23762377
goto release_flush_bios;
23772378

2379+
ic->wrote_to_journal = true;
2380+
23782381
i = commit_start;
23792382
for (n = 0; n < commit_sections; n++) {
23802383
for (j = 0; j < ic->journal_section_entries; j++) {
@@ -3100,6 +3103,14 @@ static void dm_integrity_postsuspend(struct dm_target *ti)
31003103
queue_work(ic->writer_wq, &ic->writer_work);
31013104
drain_workqueue(ic->writer_wq);
31023105
dm_integrity_flush_buffers(ic, true);
3106+
if (ic->wrote_to_journal) {
3107+
init_journal(ic, ic->free_section,
3108+
ic->journal_sections - ic->free_section, ic->commit_seq);
3109+
if (ic->free_section) {
3110+
init_journal(ic, 0, ic->free_section,
3111+
next_commit_seq(ic->commit_seq));
3112+
}
3113+
}
31033114
}
31043115

31053116
if (ic->mode == 'B') {
@@ -3127,6 +3138,8 @@ static void dm_integrity_resume(struct dm_target *ti)
31273138

31283139
DEBUG_print("resume\n");
31293140

3141+
ic->wrote_to_journal = false;
3142+
31303143
if (ic->provided_data_sectors != old_provided_data_sectors) {
31313144
if (ic->provided_data_sectors > old_provided_data_sectors &&
31323145
ic->mode == 'B' &&

0 commit comments

Comments
 (0)