diff options
Diffstat (limited to 'drivers/md/dm-snap.c')
-rw-r--r-- | drivers/md/dm-snap.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index b0ce2ce82278..0821a2b68a73 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | #define SNAPSHOT_PAGES 256 | 40 | #define SNAPSHOT_PAGES 256 |
41 | 41 | ||
42 | struct workqueue_struct *ksnapd; | 42 | static struct workqueue_struct *ksnapd; |
43 | static void flush_queued_bios(struct work_struct *work); | 43 | static void flush_queued_bios(struct work_struct *work); |
44 | 44 | ||
45 | struct pending_exception { | 45 | struct pending_exception { |
@@ -564,6 +564,17 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
564 | return r; | 564 | return r; |
565 | } | 565 | } |
566 | 566 | ||
567 | static void __free_exceptions(struct dm_snapshot *s) | ||
568 | { | ||
569 | kcopyd_client_destroy(s->kcopyd_client); | ||
570 | s->kcopyd_client = NULL; | ||
571 | |||
572 | exit_exception_table(&s->pending, pending_cache); | ||
573 | exit_exception_table(&s->complete, exception_cache); | ||
574 | |||
575 | s->store.destroy(&s->store); | ||
576 | } | ||
577 | |||
567 | static void snapshot_dtr(struct dm_target *ti) | 578 | static void snapshot_dtr(struct dm_target *ti) |
568 | { | 579 | { |
569 | struct dm_snapshot *s = (struct dm_snapshot *) ti->private; | 580 | struct dm_snapshot *s = (struct dm_snapshot *) ti->private; |
@@ -574,13 +585,7 @@ static void snapshot_dtr(struct dm_target *ti) | |||
574 | /* After this returns there can be no new kcopyd jobs. */ | 585 | /* After this returns there can be no new kcopyd jobs. */ |
575 | unregister_snapshot(s); | 586 | unregister_snapshot(s); |
576 | 587 | ||
577 | kcopyd_client_destroy(s->kcopyd_client); | 588 | __free_exceptions(s); |
578 | |||
579 | exit_exception_table(&s->pending, pending_cache); | ||
580 | exit_exception_table(&s->complete, exception_cache); | ||
581 | |||
582 | /* Deallocate memory used */ | ||
583 | s->store.destroy(&s->store); | ||
584 | 589 | ||
585 | dm_put_device(ti, s->origin); | 590 | dm_put_device(ti, s->origin); |
586 | dm_put_device(ti, s->cow); | 591 | dm_put_device(ti, s->cow); |
@@ -868,7 +873,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, | |||
868 | { | 873 | { |
869 | struct exception *e; | 874 | struct exception *e; |
870 | struct dm_snapshot *s = (struct dm_snapshot *) ti->private; | 875 | struct dm_snapshot *s = (struct dm_snapshot *) ti->private; |
871 | int r = 1; | 876 | int r = DM_MAPIO_REMAPPED; |
872 | chunk_t chunk; | 877 | chunk_t chunk; |
873 | struct pending_exception *pe = NULL; | 878 | struct pending_exception *pe = NULL; |
874 | 879 | ||
@@ -914,7 +919,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, | |||
914 | remap_exception(s, &pe->e, bio); | 919 | remap_exception(s, &pe->e, bio); |
915 | bio_list_add(&pe->snapshot_bios, bio); | 920 | bio_list_add(&pe->snapshot_bios, bio); |
916 | 921 | ||
917 | r = 0; | 922 | r = DM_MAPIO_SUBMITTED; |
918 | 923 | ||
919 | if (!pe->started) { | 924 | if (!pe->started) { |
920 | /* this is protected by snap->lock */ | 925 | /* this is protected by snap->lock */ |
@@ -992,7 +997,7 @@ static int snapshot_status(struct dm_target *ti, status_type_t type, | |||
992 | *---------------------------------------------------------------*/ | 997 | *---------------------------------------------------------------*/ |
993 | static int __origin_write(struct list_head *snapshots, struct bio *bio) | 998 | static int __origin_write(struct list_head *snapshots, struct bio *bio) |
994 | { | 999 | { |
995 | int r = 1, first = 0; | 1000 | int r = DM_MAPIO_REMAPPED, first = 0; |
996 | struct dm_snapshot *snap; | 1001 | struct dm_snapshot *snap; |
997 | struct exception *e; | 1002 | struct exception *e; |
998 | struct pending_exception *pe, *next_pe, *primary_pe = NULL; | 1003 | struct pending_exception *pe, *next_pe, *primary_pe = NULL; |
@@ -1050,7 +1055,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio) | |||
1050 | 1055 | ||
1051 | bio_list_add(&primary_pe->origin_bios, bio); | 1056 | bio_list_add(&primary_pe->origin_bios, bio); |
1052 | 1057 | ||
1053 | r = 0; | 1058 | r = DM_MAPIO_SUBMITTED; |
1054 | } | 1059 | } |
1055 | 1060 | ||
1056 | if (!pe->primary_pe) { | 1061 | if (!pe->primary_pe) { |
@@ -1099,7 +1104,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio) | |||
1099 | static int do_origin(struct dm_dev *origin, struct bio *bio) | 1104 | static int do_origin(struct dm_dev *origin, struct bio *bio) |
1100 | { | 1105 | { |
1101 | struct origin *o; | 1106 | struct origin *o; |
1102 | int r = 1; | 1107 | int r = DM_MAPIO_REMAPPED; |
1103 | 1108 | ||
1104 | down_read(&_origins_lock); | 1109 | down_read(&_origins_lock); |
1105 | o = __lookup_origin(origin->bdev); | 1110 | o = __lookup_origin(origin->bdev); |
@@ -1156,7 +1161,7 @@ static int origin_map(struct dm_target *ti, struct bio *bio, | |||
1156 | return -EOPNOTSUPP; | 1161 | return -EOPNOTSUPP; |
1157 | 1162 | ||
1158 | /* Only tell snapshots if this is a write */ | 1163 | /* Only tell snapshots if this is a write */ |
1159 | return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : 1; | 1164 | return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED; |
1160 | } | 1165 | } |
1161 | 1166 | ||
1162 | #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r)) | 1167 | #define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r)) |