aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-snap-persistent.c
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2009-01-05 22:05:19 -0500
committerAlasdair G Kergon <agk@redhat.com>2009-01-05 22:05:19 -0500
commita159c1ac5f33c6cf0f5aa3c9d1ccdc82c907ee46 (patch)
tree2cb6bfd3f376e2366f3e3820ebd07a0a86a01cfc /drivers/md/dm-snap-persistent.c
parent4db6bfe02bdc7dc5048f46dd682a94801d029adc (diff)
dm snapshot: extend exception store functions
Supply dm_add_exception as a callback to the read_metadata function. Add a status function ready for a later patch and name the functions consistently. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-snap-persistent.c')
-rw-r--r--drivers/md/dm-snap-persistent.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 57c946c69ee7..936b34e0959f 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -395,7 +395,11 @@ static void write_exception(struct pstore *ps,
395 * 'full' is filled in to indicate if the area has been 395 * 'full' is filled in to indicate if the area has been
396 * filled. 396 * filled.
397 */ 397 */
398static int insert_exceptions(struct pstore *ps, int *full) 398static int insert_exceptions(struct pstore *ps,
399 int (*callback)(void *callback_context,
400 chunk_t old, chunk_t new),
401 void *callback_context,
402 int *full)
399{ 403{
400 int r; 404 int r;
401 unsigned int i; 405 unsigned int i;
@@ -428,7 +432,7 @@ static int insert_exceptions(struct pstore *ps, int *full)
428 /* 432 /*
429 * Otherwise we add the exception to the snapshot. 433 * Otherwise we add the exception to the snapshot.
430 */ 434 */
431 r = dm_add_exception(ps->snap, de.old_chunk, de.new_chunk); 435 r = callback(callback_context, de.old_chunk, de.new_chunk);
432 if (r) 436 if (r)
433 return r; 437 return r;
434 } 438 }
@@ -436,7 +440,10 @@ static int insert_exceptions(struct pstore *ps, int *full)
436 return 0; 440 return 0;
437} 441}
438 442
439static int read_exceptions(struct pstore *ps) 443static int read_exceptions(struct pstore *ps,
444 int (*callback)(void *callback_context, chunk_t old,
445 chunk_t new),
446 void *callback_context)
440{ 447{
441 int r, full = 1; 448 int r, full = 1;
442 449
@@ -449,7 +456,7 @@ static int read_exceptions(struct pstore *ps)
449 if (r) 456 if (r)
450 return r; 457 return r;
451 458
452 r = insert_exceptions(ps, &full); 459 r = insert_exceptions(ps, callback, callback_context, &full);
453 if (r) 460 if (r)
454 return r; 461 return r;
455 } 462 }
@@ -482,7 +489,10 @@ static void persistent_destroy(struct dm_exception_store *store)
482 kfree(ps); 489 kfree(ps);
483} 490}
484 491
485static int persistent_read_metadata(struct dm_exception_store *store) 492static int persistent_read_metadata(struct dm_exception_store *store,
493 int (*callback)(void *callback_context,
494 chunk_t old, chunk_t new),
495 void *callback_context)
486{ 496{
487 int r, uninitialized_var(new_snapshot); 497 int r, uninitialized_var(new_snapshot);
488 struct pstore *ps = get_info(store); 498 struct pstore *ps = get_info(store);
@@ -540,7 +550,7 @@ static int persistent_read_metadata(struct dm_exception_store *store)
540 /* 550 /*
541 * Read the metadata. 551 * Read the metadata.
542 */ 552 */
543 r = read_exceptions(ps); 553 r = read_exceptions(ps, callback, callback_context);
544 if (r) 554 if (r)
545 return r; 555 return r;
546 } 556 }
@@ -548,8 +558,8 @@ static int persistent_read_metadata(struct dm_exception_store *store)
548 return 0; 558 return 0;
549} 559}
550 560
551static int persistent_prepare(struct dm_exception_store *store, 561static int persistent_prepare_exception(struct dm_exception_store *store,
552 struct dm_snap_exception *e) 562 struct dm_snap_exception *e)
553{ 563{
554 struct pstore *ps = get_info(store); 564 struct pstore *ps = get_info(store);
555 uint32_t stride; 565 uint32_t stride;
@@ -575,10 +585,10 @@ static int persistent_prepare(struct dm_exception_store *store,
575 return 0; 585 return 0;
576} 586}
577 587
578static void persistent_commit(struct dm_exception_store *store, 588static void persistent_commit_exception(struct dm_exception_store *store,
579 struct dm_snap_exception *e, 589 struct dm_snap_exception *e,
580 void (*callback) (void *, int success), 590 void (*callback) (void *, int success),
581 void *callback_context) 591 void *callback_context)
582{ 592{
583 unsigned int i; 593 unsigned int i;
584 struct pstore *ps = get_info(store); 594 struct pstore *ps = get_info(store);
@@ -637,7 +647,7 @@ static void persistent_commit(struct dm_exception_store *store,
637 ps->callback_count = 0; 647 ps->callback_count = 0;
638} 648}
639 649
640static void persistent_drop(struct dm_exception_store *store) 650static void persistent_drop_snapshot(struct dm_exception_store *store)
641{ 651{
642 struct pstore *ps = get_info(store); 652 struct pstore *ps = get_info(store);
643 653
@@ -675,9 +685,9 @@ int dm_create_persistent(struct dm_exception_store *store)
675 685
676 store->destroy = persistent_destroy; 686 store->destroy = persistent_destroy;
677 store->read_metadata = persistent_read_metadata; 687 store->read_metadata = persistent_read_metadata;
678 store->prepare_exception = persistent_prepare; 688 store->prepare_exception = persistent_prepare_exception;
679 store->commit_exception = persistent_commit; 689 store->commit_exception = persistent_commit_exception;
680 store->drop_snapshot = persistent_drop; 690 store->drop_snapshot = persistent_drop_snapshot;
681 store->fraction_full = persistent_fraction_full; 691 store->fraction_full = persistent_fraction_full;
682 store->context = ps; 692 store->context = ps;
683 693