dm-raid1.c (255e2646496fcbf836a3dfe1b535692f09f11b45) | dm-raid1.c (a4a82ce3d24d4409143a7b7b980072ada6e20b2a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2003 Sistina Software Limited. 4 * Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5 * 6 * This file is released under the GPL. 7 */ 8 --- 19 unchanged lines hidden (view full) --- 28 29#define DM_RAID1_HANDLE_ERRORS 0x01 30#define DM_RAID1_KEEP_LOG 0x02 31#define errors_handled(p) ((p)->features & DM_RAID1_HANDLE_ERRORS) 32#define keep_log(p) ((p)->features & DM_RAID1_KEEP_LOG) 33 34static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped); 35 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2003 Sistina Software Limited. 4 * Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5 * 6 * This file is released under the GPL. 7 */ 8 --- 19 unchanged lines hidden (view full) --- 28 29#define DM_RAID1_HANDLE_ERRORS 0x01 30#define DM_RAID1_KEEP_LOG 0x02 31#define errors_handled(p) ((p)->features & DM_RAID1_HANDLE_ERRORS) 32#define keep_log(p) ((p)->features & DM_RAID1_KEEP_LOG) 33 34static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped); 35 |
36/*----------------------------------------------------------------- | 36/* 37 *--------------------------------------------------------------- |
37 * Mirror set structures. | 38 * Mirror set structures. |
38 *---------------------------------------------------------------*/ | 39 *--------------------------------------------------------------- 40 */ |
39enum dm_raid1_error { 40 DM_RAID1_WRITE_ERROR, 41 DM_RAID1_FLUSH_ERROR, 42 DM_RAID1_SYNC_ERROR, 43 DM_RAID1_READ_ERROR 44}; 45 46struct mirror { --- 234 unchanged lines hidden (view full) --- 281 fail_mirror(ms->mirror + i, 282 DM_RAID1_FLUSH_ERROR); 283 return -EIO; 284 } 285 286 return 0; 287} 288 | 41enum dm_raid1_error { 42 DM_RAID1_WRITE_ERROR, 43 DM_RAID1_FLUSH_ERROR, 44 DM_RAID1_SYNC_ERROR, 45 DM_RAID1_READ_ERROR 46}; 47 48struct mirror { --- 234 unchanged lines hidden (view full) --- 283 fail_mirror(ms->mirror + i, 284 DM_RAID1_FLUSH_ERROR); 285 return -EIO; 286 } 287 288 return 0; 289} 290 |
289/*----------------------------------------------------------------- | 291/* 292 *--------------------------------------------------------------- |
290 * Recovery. 291 * 292 * When a mirror is first activated we may find that some regions 293 * are in the no-sync state. We have to recover these by 294 * recopying from the default mirror to all the others. | 293 * Recovery. 294 * 295 * When a mirror is first activated we may find that some regions 296 * are in the no-sync state. We have to recover these by 297 * recopying from the default mirror to all the others. |
295 *---------------------------------------------------------------*/ | 298 *--------------------------------------------------------------- 299 */ |
296static void recovery_complete(int read_err, unsigned long write_err, 297 void *context) 298{ 299 struct dm_region *reg = context; 300 struct mirror_set *ms = dm_rh_region_context(reg); 301 int m, bit = 0; 302 303 if (read_err) { --- 100 unchanged lines hidden (view full) --- 404 (log->type->get_sync_count(log) == ms->nr_regions)) { 405 /* the sync is complete */ 406 dm_table_event(ms->ti->table); 407 ms->in_sync = 1; 408 reset_ms_flags(ms); 409 } 410} 411 | 300static void recovery_complete(int read_err, unsigned long write_err, 301 void *context) 302{ 303 struct dm_region *reg = context; 304 struct mirror_set *ms = dm_rh_region_context(reg); 305 int m, bit = 0; 306 307 if (read_err) { --- 100 unchanged lines hidden (view full) --- 408 (log->type->get_sync_count(log) == ms->nr_regions)) { 409 /* the sync is complete */ 410 dm_table_event(ms->ti->table); 411 ms->in_sync = 1; 412 reset_ms_flags(ms); 413 } 414} 415 |
412/*----------------------------------------------------------------- | 416/* 417 *--------------------------------------------------------------- |
413 * Reads | 418 * Reads |
414 *---------------------------------------------------------------*/ | 419 *--------------------------------------------------------------- 420 */ |
415static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector) 416{ 417 struct mirror *m = get_default_mirror(ms); 418 419 do { 420 if (likely(!atomic_read(&m->error_count))) 421 return m; 422 --- 71 unchanged lines hidden (view full) --- 494 495 /* 496 * Hold bio until the suspend is complete. 497 */ 498 bio_list_add(&ms->holds, bio); 499 spin_unlock_irq(&ms->lock); 500} 501 | 421static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector) 422{ 423 struct mirror *m = get_default_mirror(ms); 424 425 do { 426 if (likely(!atomic_read(&m->error_count))) 427 return m; 428 --- 71 unchanged lines hidden (view full) --- 500 501 /* 502 * Hold bio until the suspend is complete. 503 */ 504 bio_list_add(&ms->holds, bio); 505 spin_unlock_irq(&ms->lock); 506} 507 |
502/*----------------------------------------------------------------- | 508/* 509 *--------------------------------------------------------------- |
503 * Reads | 510 * Reads |
504 *---------------------------------------------------------------*/ | 511 *--------------------------------------------------------------- 512 */ |
505static void read_callback(unsigned long error, void *context) 506{ 507 struct bio *bio = context; 508 struct mirror *m; 509 510 m = bio_get_m(bio); 511 bio_set_m(bio, NULL); 512 --- 62 unchanged lines hidden (view full) --- 575 576 if (likely(m)) 577 read_async_bio(m, bio); 578 else 579 bio_io_error(bio); 580 } 581} 582 | 513static void read_callback(unsigned long error, void *context) 514{ 515 struct bio *bio = context; 516 struct mirror *m; 517 518 m = bio_get_m(bio); 519 bio_set_m(bio, NULL); 520 --- 62 unchanged lines hidden (view full) --- 583 584 if (likely(m)) 585 read_async_bio(m, bio); 586 else 587 bio_io_error(bio); 588 } 589} 590 |
583/*----------------------------------------------------------------- | 591/* 592 *--------------------------------------------------------------------- |
584 * Writes. 585 * 586 * We do different things with the write io depending on the 587 * state of the region that it's in: 588 * 589 * SYNC: increment pending, use kcopyd to write to *all* mirrors 590 * RECOVERING: delay the io until recovery completes 591 * NOSYNC: increment pending, just write to the default mirror | 593 * Writes. 594 * 595 * We do different things with the write io depending on the 596 * state of the region that it's in: 597 * 598 * SYNC: increment pending, use kcopyd to write to *all* mirrors 599 * RECOVERING: delay the io until recovery completes 600 * NOSYNC: increment pending, just write to the default mirror |
592 *---------------------------------------------------------------*/ 593 594 | 601 *--------------------------------------------------------------------- 602 */ |
595static void write_callback(unsigned long error, void *context) 596{ 597 unsigned int i; 598 struct bio *bio = (struct bio *) context; 599 struct mirror_set *ms; 600 int should_wake = 0; 601 unsigned long flags; 602 --- 235 unchanged lines hidden (view full) --- 838static void trigger_event(struct work_struct *work) 839{ 840 struct mirror_set *ms = 841 container_of(work, struct mirror_set, trigger_event); 842 843 dm_table_event(ms->ti->table); 844} 845 | 603static void write_callback(unsigned long error, void *context) 604{ 605 unsigned int i; 606 struct bio *bio = (struct bio *) context; 607 struct mirror_set *ms; 608 int should_wake = 0; 609 unsigned long flags; 610 --- 235 unchanged lines hidden (view full) --- 846static void trigger_event(struct work_struct *work) 847{ 848 struct mirror_set *ms = 849 container_of(work, struct mirror_set, trigger_event); 850 851 dm_table_event(ms->ti->table); 852} 853 |
846/*----------------------------------------------------------------- | 854/* 855 *--------------------------------------------------------------- |
847 * kmirrord | 856 * kmirrord |
848 *---------------------------------------------------------------*/ | 857 *--------------------------------------------------------------- 858 */ |
849static void do_mirror(struct work_struct *work) 850{ 851 struct mirror_set *ms = container_of(work, struct mirror_set, 852 kmirrord_work); 853 struct bio_list reads, writes, failures; 854 unsigned long flags; 855 856 spin_lock_irqsave(&ms->lock, flags); --- 7 unchanged lines hidden (view full) --- 864 865 dm_rh_update_states(ms->rh, errors_handled(ms)); 866 do_recovery(ms); 867 do_reads(ms, &reads); 868 do_writes(ms, &writes); 869 do_failures(ms, &failures); 870} 871 | 859static void do_mirror(struct work_struct *work) 860{ 861 struct mirror_set *ms = container_of(work, struct mirror_set, 862 kmirrord_work); 863 struct bio_list reads, writes, failures; 864 unsigned long flags; 865 866 spin_lock_irqsave(&ms->lock, flags); --- 7 unchanged lines hidden (view full) --- 874 875 dm_rh_update_states(ms->rh, errors_handled(ms)); 876 do_recovery(ms); 877 do_reads(ms, &reads); 878 do_writes(ms, &writes); 879 do_failures(ms, &failures); 880} 881 |
872/*----------------------------------------------------------------- | 882/* 883 *--------------------------------------------------------------- |
873 * Target functions | 884 * Target functions |
874 *---------------------------------------------------------------*/ | 885 *--------------------------------------------------------------- 886 */ |
875static struct mirror_set *alloc_context(unsigned int nr_mirrors, 876 uint32_t region_size, 877 struct dm_target *ti, 878 struct dm_dirty_log *dl) 879{ 880 struct mirror_set *ms = 881 kzalloc(struct_size(ms, mirror, nr_mirrors), GFP_KERNEL); 882 --- 631 unchanged lines hidden --- | 887static struct mirror_set *alloc_context(unsigned int nr_mirrors, 888 uint32_t region_size, 889 struct dm_target *ti, 890 struct dm_dirty_log *dl) 891{ 892 struct mirror_set *ms = 893 kzalloc(struct_size(ms, mirror, nr_mirrors), GFP_KERNEL); 894 --- 631 unchanged lines hidden --- |