Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm integrity: handle machine reboot in bitmap mode

When in bitmap mode the bitmap must be cleared when rebooting. This
commit adds the reboot hook.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Mikulas Patocka and committed by
Mike Snitzer
1f5a7759 468dfca3

+24
+24
drivers/md/dm-integrity.c
··· 15 15 #include <linux/rbtree.h> 16 16 #include <linux/delay.h> 17 17 #include <linux/random.h> 18 + #include <linux/reboot.h> 18 19 #include <crypto/hash.h> 19 20 #include <crypto/skcipher.h> 20 21 #include <linux/async_tx.h> ··· 258 257 struct alg_spec journal_mac_alg; 259 258 260 259 atomic64_t number_of_mismatches; 260 + 261 + struct notifier_block reboot_notifier; 261 262 }; 262 263 263 264 struct dm_integrity_range { ··· 2720 2717 init_journal_node(&ic->journal_tree[i]); 2721 2718 } 2722 2719 2720 + static int dm_integrity_reboot(struct notifier_block *n, unsigned long code, void *x) 2721 + { 2722 + struct dm_integrity_c *ic = container_of(n, struct dm_integrity_c, reboot_notifier); 2723 + 2724 + if (ic->mode == 'B') { 2725 + DEBUG_print("dm_integrity_reboot\n"); 2726 + cancel_delayed_work_sync(&ic->bitmap_flush_work); 2727 + queue_delayed_work(ic->commit_wq, &ic->bitmap_flush_work, 0); 2728 + flush_workqueue(ic->commit_wq); 2729 + } 2730 + 2731 + return NOTIFY_DONE; 2732 + } 2733 + 2723 2734 static void dm_integrity_postsuspend(struct dm_target *ti) 2724 2735 { 2725 2736 struct dm_integrity_c *ic = (struct dm_integrity_c *)ti->private; 2726 2737 int r; 2738 + 2739 + WARN_ON(unregister_reboot_notifier(&ic->reboot_notifier)); 2727 2740 2728 2741 del_timer_sync(&ic->autocommit_timer); 2729 2742 ··· 2848 2829 recalc_write_super(ic); 2849 2830 } 2850 2831 } 2832 + 2833 + ic->reboot_notifier.notifier_call = dm_integrity_reboot; 2834 + ic->reboot_notifier.next = NULL; 2835 + ic->reboot_notifier.priority = INT_MAX - 1; /* be notified after md and before hardware drivers */ 2836 + WARN_ON(register_reboot_notifier(&ic->reboot_notifier)); 2851 2837 } 2852 2838 2853 2839 static void dm_integrity_status(struct dm_target *ti, status_type_t type,