dm-integrity.c (7fc2e47f40dd77ab1fcbda6db89614a0173d89c7) | dm-integrity.c (adc0daad366b62ca1bce3e2958a40b0b71a8b8b3) |
---|---|
1/* 2 * Copyright (C) 2016-2017 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2016-2017 Milan Broz 4 * Copyright (C) 2016-2017 Mikulas Patocka 5 * 6 * This file is released under the GPL. 7 */ 8 --- 187 unchanged lines hidden (view full) --- 196 unsigned initial_sectors; 197 unsigned metadata_run; 198 __s8 log2_metadata_run; 199 __u8 log2_buffer_sectors; 200 __u8 sectors_per_block; 201 __u8 log2_blocks_per_bitmap_bit; 202 203 unsigned char mode; | 1/* 2 * Copyright (C) 2016-2017 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2016-2017 Milan Broz 4 * Copyright (C) 2016-2017 Mikulas Patocka 5 * 6 * This file is released under the GPL. 7 */ 8 --- 187 unchanged lines hidden (view full) --- 196 unsigned initial_sectors; 197 unsigned metadata_run; 198 __s8 log2_metadata_run; 199 __u8 log2_buffer_sectors; 200 __u8 sectors_per_block; 201 __u8 log2_blocks_per_bitmap_bit; 202 203 unsigned char mode; |
204 int suspending; | |
205 206 int failed; 207 208 struct crypto_shash *internal_hash; 209 | 204 205 int failed; 206 207 struct crypto_shash *internal_hash; 208 |
209 struct dm_target *ti; 210 |
|
210 /* these variables are locked with endio_wait.lock */ 211 struct rb_root in_progress; 212 struct list_head wait_list; 213 wait_queue_head_t endio_wait; 214 struct workqueue_struct *wait_wq; 215 struct workqueue_struct *offload_wq; 216 217 unsigned char commit_seq; --- 2093 unchanged lines hidden (view full) --- 2311static void integrity_writer(struct work_struct *w) 2312{ 2313 struct dm_integrity_c *ic = container_of(w, struct dm_integrity_c, writer_work); 2314 unsigned write_start, write_sections; 2315 2316 unsigned prev_free_sectors; 2317 2318 /* the following test is not needed, but it tests the replay code */ | 211 /* these variables are locked with endio_wait.lock */ 212 struct rb_root in_progress; 213 struct list_head wait_list; 214 wait_queue_head_t endio_wait; 215 struct workqueue_struct *wait_wq; 216 struct workqueue_struct *offload_wq; 217 218 unsigned char commit_seq; --- 2093 unchanged lines hidden (view full) --- 2312static void integrity_writer(struct work_struct *w) 2313{ 2314 struct dm_integrity_c *ic = container_of(w, struct dm_integrity_c, writer_work); 2315 unsigned write_start, write_sections; 2316 2317 unsigned prev_free_sectors; 2318 2319 /* the following test is not needed, but it tests the replay code */ |
2319 if (READ_ONCE(ic->suspending) && !ic->meta_dev) | 2320 if (unlikely(dm_suspended(ic->ti)) && !ic->meta_dev) |
2320 return; 2321 2322 spin_lock_irq(&ic->endio_wait.lock); 2323 write_start = ic->committed_section; 2324 write_sections = ic->n_committed_sections; 2325 spin_unlock_irq(&ic->endio_wait.lock); 2326 2327 if (!write_sections) --- 44 unchanged lines hidden (view full) --- 2372 unsigned super_counter = 0; 2373 2374 DEBUG_print("start recalculation... (position %llx)\n", le64_to_cpu(ic->sb->recalc_sector)); 2375 2376 spin_lock_irq(&ic->endio_wait.lock); 2377 2378next_chunk: 2379 | 2321 return; 2322 2323 spin_lock_irq(&ic->endio_wait.lock); 2324 write_start = ic->committed_section; 2325 write_sections = ic->n_committed_sections; 2326 spin_unlock_irq(&ic->endio_wait.lock); 2327 2328 if (!write_sections) --- 44 unchanged lines hidden (view full) --- 2373 unsigned super_counter = 0; 2374 2375 DEBUG_print("start recalculation... (position %llx)\n", le64_to_cpu(ic->sb->recalc_sector)); 2376 2377 spin_lock_irq(&ic->endio_wait.lock); 2378 2379next_chunk: 2380 |
2380 if (unlikely(READ_ONCE(ic->suspending))) | 2381 if (unlikely(dm_suspended(ic->ti))) |
2381 goto unlock_ret; 2382 2383 range.logical_sector = le64_to_cpu(ic->sb->recalc_sector); 2384 if (unlikely(range.logical_sector >= ic->provided_data_sectors)) { 2385 if (ic->mode == 'B') { 2386 DEBUG_print("queue_delayed_work: bitmap_flush_work\n"); 2387 queue_delayed_work(ic->commit_wq, &ic->bitmap_flush_work, 0); 2388 } --- 411 unchanged lines hidden (view full) --- 2800{ 2801 struct dm_integrity_c *ic = (struct dm_integrity_c *)ti->private; 2802 int r; 2803 2804 WARN_ON(unregister_reboot_notifier(&ic->reboot_notifier)); 2805 2806 del_timer_sync(&ic->autocommit_timer); 2807 | 2382 goto unlock_ret; 2383 2384 range.logical_sector = le64_to_cpu(ic->sb->recalc_sector); 2385 if (unlikely(range.logical_sector >= ic->provided_data_sectors)) { 2386 if (ic->mode == 'B') { 2387 DEBUG_print("queue_delayed_work: bitmap_flush_work\n"); 2388 queue_delayed_work(ic->commit_wq, &ic->bitmap_flush_work, 0); 2389 } --- 411 unchanged lines hidden (view full) --- 2801{ 2802 struct dm_integrity_c *ic = (struct dm_integrity_c *)ti->private; 2803 int r; 2804 2805 WARN_ON(unregister_reboot_notifier(&ic->reboot_notifier)); 2806 2807 del_timer_sync(&ic->autocommit_timer); 2808 |
2808 WRITE_ONCE(ic->suspending, 1); 2809 | |
2810 if (ic->recalc_wq) 2811 drain_workqueue(ic->recalc_wq); 2812 2813 if (ic->mode == 'B') 2814 cancel_delayed_work_sync(&ic->bitmap_flush_work); 2815 2816 queue_work(ic->commit_wq, &ic->commit_work); 2817 drain_workqueue(ic->commit_wq); --- 12 unchanged lines hidden (view full) --- 2830 init_journal(ic, 0, ic->journal_sections, 0); 2831 ic->sb->flags &= ~cpu_to_le32(SB_FLAG_DIRTY_BITMAP); 2832 r = sync_rw_sb(ic, REQ_OP_WRITE, REQ_FUA); 2833 if (unlikely(r)) 2834 dm_integrity_io_error(ic, "writing superblock", r); 2835#endif 2836 } 2837 | 2809 if (ic->recalc_wq) 2810 drain_workqueue(ic->recalc_wq); 2811 2812 if (ic->mode == 'B') 2813 cancel_delayed_work_sync(&ic->bitmap_flush_work); 2814 2815 queue_work(ic->commit_wq, &ic->commit_work); 2816 drain_workqueue(ic->commit_wq); --- 12 unchanged lines hidden (view full) --- 2829 init_journal(ic, 0, ic->journal_sections, 0); 2830 ic->sb->flags &= ~cpu_to_le32(SB_FLAG_DIRTY_BITMAP); 2831 r = sync_rw_sb(ic, REQ_OP_WRITE, REQ_FUA); 2832 if (unlikely(r)) 2833 dm_integrity_io_error(ic, "writing superblock", r); 2834#endif 2835 } 2836 |
2838 WRITE_ONCE(ic->suspending, 0); 2839 | |
2840 BUG_ON(!RB_EMPTY_ROOT(&ic->in_progress)); 2841 2842 ic->journal_uptodate = true; 2843} 2844 2845static void dm_integrity_resume(struct dm_target *ti) 2846{ 2847 struct dm_integrity_c *ic = (struct dm_integrity_c *)ti->private; --- 778 unchanged lines hidden (view full) --- 3626 3627 ic = kzalloc(sizeof(struct dm_integrity_c), GFP_KERNEL); 3628 if (!ic) { 3629 ti->error = "Cannot allocate integrity context"; 3630 return -ENOMEM; 3631 } 3632 ti->private = ic; 3633 ti->per_io_data_size = sizeof(struct dm_integrity_io); | 2837 BUG_ON(!RB_EMPTY_ROOT(&ic->in_progress)); 2838 2839 ic->journal_uptodate = true; 2840} 2841 2842static void dm_integrity_resume(struct dm_target *ti) 2843{ 2844 struct dm_integrity_c *ic = (struct dm_integrity_c *)ti->private; --- 778 unchanged lines hidden (view full) --- 3623 3624 ic = kzalloc(sizeof(struct dm_integrity_c), GFP_KERNEL); 3625 if (!ic) { 3626 ti->error = "Cannot allocate integrity context"; 3627 return -ENOMEM; 3628 } 3629 ti->private = ic; 3630 ti->per_io_data_size = sizeof(struct dm_integrity_io); |
3631 ic->ti = ti; |
|
3634 3635 ic->in_progress = RB_ROOT; 3636 INIT_LIST_HEAD(&ic->wait_list); 3637 init_waitqueue_head(&ic->endio_wait); 3638 bio_list_init(&ic->flush_bio_list); 3639 init_waitqueue_head(&ic->copy_to_journal_wait); 3640 init_completion(&ic->crypto_backoff); 3641 atomic64_set(&ic->number_of_mismatches, 0); --- 624 unchanged lines hidden --- | 3632 3633 ic->in_progress = RB_ROOT; 3634 INIT_LIST_HEAD(&ic->wait_list); 3635 init_waitqueue_head(&ic->endio_wait); 3636 bio_list_init(&ic->flush_bio_list); 3637 init_waitqueue_head(&ic->copy_to_journal_wait); 3638 init_completion(&ic->crypto_backoff); 3639 atomic64_set(&ic->number_of_mismatches, 0); --- 624 unchanged lines hidden --- |