aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-snap.c
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2009-04-02 14:55:31 -0400
committerAlasdair G Kergon <agk@redhat.com>2009-04-02 14:55:31 -0400
commit493df71c6420b211a68ae82b889c1e8a5fe701be (patch)
tree2738295190c1b3c5f72d85059aae3c96f162afa6 /drivers/md/dm-snap.c
parent7513c2a761d69d2a93f17146b3563527d3618ba0 (diff)
dm exception store: introduce registry
Move exception stores into a registry. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-snap.c')
-rw-r--r--drivers/md/dm-snap.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index dabd58e9aafc..be698f3a4ae4 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -610,8 +610,6 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
610 if (r) 610 if (r)
611 goto bad3; 611 goto bad3;
612 612
613 s->type = persistent;
614
615 s->valid = 1; 613 s->valid = 1;
616 s->active = 0; 614 s->active = 0;
617 atomic_set(&s->pending_exceptions_count, 0); 615 atomic_set(&s->pending_exceptions_count, 0);
@@ -626,19 +624,15 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
626 goto bad3; 624 goto bad3;
627 } 625 }
628 626
629 s->store.snap = s; 627 r = dm_exception_store_create(argv[2], &s->store);
630
631 if (persistent == 'P')
632 r = dm_create_persistent(&s->store);
633 else
634 r = dm_create_transient(&s->store);
635
636 if (r) { 628 if (r) {
637 ti->error = "Couldn't create exception store"; 629 ti->error = "Couldn't create exception store";
638 r = -EINVAL; 630 r = -EINVAL;
639 goto bad4; 631 goto bad4;
640 } 632 }
641 633
634 s->store->snap = s;
635
642 r = dm_kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client); 636 r = dm_kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client);
643 if (r) { 637 if (r) {
644 ti->error = "Could not create kcopyd client"; 638 ti->error = "Could not create kcopyd client";
@@ -665,7 +659,8 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
665 spin_lock_init(&s->tracked_chunk_lock); 659 spin_lock_init(&s->tracked_chunk_lock);
666 660
667 /* Metadata must only be loaded into one table at once */ 661 /* Metadata must only be loaded into one table at once */
668 r = s->store.type.read_metadata(&s->store, dm_add_exception, (void *)s); 662 r = s->store->type->read_metadata(s->store, dm_add_exception,
663 (void *)s);
669 if (r < 0) { 664 if (r < 0) {
670 ti->error = "Failed to read snapshot metadata"; 665 ti->error = "Failed to read snapshot metadata";
671 goto bad_load_and_register; 666 goto bad_load_and_register;
@@ -700,7 +695,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
700 dm_kcopyd_client_destroy(s->kcopyd_client); 695 dm_kcopyd_client_destroy(s->kcopyd_client);
701 696
702 bad5: 697 bad5:
703 s->store.type.dtr(&s->store); 698 s->store->type->dtr(s->store);
704 699
705 bad4: 700 bad4:
706 exit_exception_table(&s->pending, pending_cache); 701 exit_exception_table(&s->pending, pending_cache);
@@ -725,7 +720,7 @@ static void __free_exceptions(struct dm_snapshot *s)
725 exit_exception_table(&s->pending, pending_cache); 720 exit_exception_table(&s->pending, pending_cache);
726 exit_exception_table(&s->complete, exception_cache); 721 exit_exception_table(&s->complete, exception_cache);
727 722
728 s->store.type.dtr(&s->store); 723 s->store->type->dtr(s->store);
729} 724}
730 725
731static void snapshot_dtr(struct dm_target *ti) 726static void snapshot_dtr(struct dm_target *ti)
@@ -820,8 +815,8 @@ static void __invalidate_snapshot(struct dm_snapshot *s, int err)
820 else if (err == -ENOMEM) 815 else if (err == -ENOMEM)
821 DMERR("Invalidating snapshot: Unable to allocate exception."); 816 DMERR("Invalidating snapshot: Unable to allocate exception.");
822 817
823 if (s->store.type.drop_snapshot) 818 if (s->store->type->drop_snapshot)
824 s->store.type.drop_snapshot(&s->store); 819 s->store->type->drop_snapshot(s->store);
825 820
826 s->valid = 0; 821 s->valid = 0;
827 822
@@ -943,8 +938,8 @@ static void copy_callback(int read_err, unsigned long write_err, void *context)
943 938
944 else 939 else
945 /* Update the metadata if we are persistent */ 940 /* Update the metadata if we are persistent */
946 s->store.type.commit_exception(&s->store, &pe->e, 941 s->store->type->commit_exception(s->store, &pe->e,
947 commit_callback, pe); 942 commit_callback, pe);
948} 943}
949 944
950/* 945/*
@@ -1010,7 +1005,7 @@ __find_pending_exception(struct dm_snapshot *s,
1010 atomic_set(&pe->ref_count, 0); 1005 atomic_set(&pe->ref_count, 0);
1011 pe->started = 0; 1006 pe->started = 0;
1012 1007
1013 if (s->store.type.prepare_exception(&s->store, &pe->e)) { 1008 if (s->store->type->prepare_exception(s->store, &pe->e)) {
1014 free_pending_exception(pe); 1009 free_pending_exception(pe);
1015 return NULL; 1010 return NULL;
1016 } 1011 }
@@ -1149,11 +1144,11 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
1149 if (!snap->valid) 1144 if (!snap->valid)
1150 snprintf(result, maxlen, "Invalid"); 1145 snprintf(result, maxlen, "Invalid");
1151 else { 1146 else {
1152 if (snap->store.type.fraction_full) { 1147 if (snap->store->type->fraction_full) {
1153 sector_t numerator, denominator; 1148 sector_t numerator, denominator;
1154 snap->store.type.fraction_full(&snap->store, 1149 snap->store->type->fraction_full(snap->store,
1155 &numerator, 1150 &numerator,
1156 &denominator); 1151 &denominator);
1157 snprintf(result, maxlen, "%llu/%llu", 1152 snprintf(result, maxlen, "%llu/%llu",
1158 (unsigned long long)numerator, 1153 (unsigned long long)numerator,
1159 (unsigned long long)denominator); 1154 (unsigned long long)denominator);
@@ -1169,9 +1164,9 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
1169 * to make private copies if the output is to 1164 * to make private copies if the output is to
1170 * make sense. 1165 * make sense.
1171 */ 1166 */
1172 snprintf(result, maxlen, "%s %s %c %llu", 1167 snprintf(result, maxlen, "%s %s %s %llu",
1173 snap->origin->name, snap->cow->name, 1168 snap->origin->name, snap->cow->name,
1174 snap->type, 1169 snap->store->type->name,
1175 (unsigned long long)snap->chunk_size); 1170 (unsigned long long)snap->chunk_size);
1176 break; 1171 break;
1177 } 1172 }