aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2009-12-10 18:52:11 -0500
committerAlasdair G Kergon <agk@redhat.com>2009-12-10 18:52:11 -0500
commit985903bb3a6d98623360ab6c855417f638840029 (patch)
tree64e7582e0b7827aa318c4fe1c497ebc541d9ce8b /drivers
parent3510cb94ff7b04b016bd22bfee913e2c1c05c066 (diff)
dm snapshot: add allocated metadata to snapshot status
Add number of sectors used by metadata to the end of the snapshot's status line. Renamed dm_exception_store_type's 'fraction_full' to 'usage'. Renamed arguments to be clearer about what is being returned. Also added 'metadata_sectors'. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-exception-store.h6
-rw-r--r--drivers/md/dm-snap-persistent.c23
-rw-r--r--drivers/md/dm-snap-transient.c15
-rw-r--r--drivers/md/dm-snap.c21
4 files changed, 41 insertions, 24 deletions
diff --git a/drivers/md/dm-exception-store.h b/drivers/md/dm-exception-store.h
index 92749696e359..366c8b1fca37 100644
--- a/drivers/md/dm-exception-store.h
+++ b/drivers/md/dm-exception-store.h
@@ -86,9 +86,9 @@ struct dm_exception_store_type {
86 /* 86 /*
87 * Return how full the snapshot is. 87 * Return how full the snapshot is.
88 */ 88 */
89 void (*fraction_full) (struct dm_exception_store *store, 89 void (*usage) (struct dm_exception_store *store,
90 sector_t *numerator, 90 sector_t *total_sectors, sector_t *sectors_allocated,
91 sector_t *denominator); 91 sector_t *metadata_sectors);
92 92
93 /* For internal device-mapper use only. */ 93 /* For internal device-mapper use only. */
94 struct list_head list; 94 struct list_head list;
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 24b8acd1be83..767065f6c5f3 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -489,11 +489,22 @@ static struct pstore *get_info(struct dm_exception_store *store)
489 return (struct pstore *) store->context; 489 return (struct pstore *) store->context;
490} 490}
491 491
492static void persistent_fraction_full(struct dm_exception_store *store, 492static void persistent_usage(struct dm_exception_store *store,
493 sector_t *numerator, sector_t *denominator) 493 sector_t *total_sectors,
494 sector_t *sectors_allocated,
495 sector_t *metadata_sectors)
494{ 496{
495 *numerator = get_info(store)->next_free * store->chunk_size; 497 struct pstore *ps = get_info(store);
496 *denominator = get_dev_size(store->cow->bdev); 498
499 *sectors_allocated = ps->next_free * store->chunk_size;
500 *total_sectors = get_dev_size(store->cow->bdev);
501
502 /*
503 * First chunk is the fixed header.
504 * Then there are (ps->current_area + 1) metadata chunks, each one
505 * separated from the next by ps->exceptions_per_area data chunks.
506 */
507 *metadata_sectors = (ps->current_area + 2) * store->chunk_size;
497} 508}
498 509
499static void persistent_dtr(struct dm_exception_store *store) 510static void persistent_dtr(struct dm_exception_store *store)
@@ -738,7 +749,7 @@ static struct dm_exception_store_type _persistent_type = {
738 .prepare_exception = persistent_prepare_exception, 749 .prepare_exception = persistent_prepare_exception,
739 .commit_exception = persistent_commit_exception, 750 .commit_exception = persistent_commit_exception,
740 .drop_snapshot = persistent_drop_snapshot, 751 .drop_snapshot = persistent_drop_snapshot,
741 .fraction_full = persistent_fraction_full, 752 .usage = persistent_usage,
742 .status = persistent_status, 753 .status = persistent_status,
743}; 754};
744 755
@@ -751,7 +762,7 @@ static struct dm_exception_store_type _persistent_compat_type = {
751 .prepare_exception = persistent_prepare_exception, 762 .prepare_exception = persistent_prepare_exception,
752 .commit_exception = persistent_commit_exception, 763 .commit_exception = persistent_commit_exception,
753 .drop_snapshot = persistent_drop_snapshot, 764 .drop_snapshot = persistent_drop_snapshot,
754 .fraction_full = persistent_fraction_full, 765 .usage = persistent_usage,
755 .status = persistent_status, 766 .status = persistent_status,
756}; 767};
757 768
diff --git a/drivers/md/dm-snap-transient.c b/drivers/md/dm-snap-transient.c
index 267801b34ff6..245a50c7337e 100644
--- a/drivers/md/dm-snap-transient.c
+++ b/drivers/md/dm-snap-transient.c
@@ -59,11 +59,14 @@ static void transient_commit_exception(struct dm_exception_store *store,
59 callback(callback_context, 1); 59 callback(callback_context, 1);
60} 60}
61 61
62static void transient_fraction_full(struct dm_exception_store *store, 62static void transient_usage(struct dm_exception_store *store,
63 sector_t *numerator, sector_t *denominator) 63 sector_t *total_sectors,
64 sector_t *sectors_allocated,
65 sector_t *metadata_sectors)
64{ 66{
65 *numerator = ((struct transient_c *) store->context)->next_free; 67 *sectors_allocated = ((struct transient_c *) store->context)->next_free;
66 *denominator = get_dev_size(store->cow->bdev); 68 *total_sectors = get_dev_size(store->cow->bdev);
69 *metadata_sectors = 0;
67} 70}
68 71
69static int transient_ctr(struct dm_exception_store *store, 72static int transient_ctr(struct dm_exception_store *store,
@@ -106,7 +109,7 @@ static struct dm_exception_store_type _transient_type = {
106 .read_metadata = transient_read_metadata, 109 .read_metadata = transient_read_metadata,
107 .prepare_exception = transient_prepare_exception, 110 .prepare_exception = transient_prepare_exception,
108 .commit_exception = transient_commit_exception, 111 .commit_exception = transient_commit_exception,
109 .fraction_full = transient_fraction_full, 112 .usage = transient_usage,
110 .status = transient_status, 113 .status = transient_status,
111}; 114};
112 115
@@ -118,7 +121,7 @@ static struct dm_exception_store_type _transient_compat_type = {
118 .read_metadata = transient_read_metadata, 121 .read_metadata = transient_read_metadata,
119 .prepare_exception = transient_prepare_exception, 122 .prepare_exception = transient_prepare_exception,
120 .commit_exception = transient_commit_exception, 123 .commit_exception = transient_commit_exception,
121 .fraction_full = transient_fraction_full, 124 .usage = transient_usage,
122 .status = transient_status, 125 .status = transient_status,
123}; 126};
124 127
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index cb4c2c3a43f0..8bd77cbd7e45 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1174,14 +1174,17 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
1174 if (!snap->valid) 1174 if (!snap->valid)
1175 DMEMIT("Invalid"); 1175 DMEMIT("Invalid");
1176 else { 1176 else {
1177 if (snap->store->type->fraction_full) { 1177 if (snap->store->type->usage) {
1178 sector_t numerator, denominator; 1178 sector_t total_sectors, sectors_allocated,
1179 snap->store->type->fraction_full(snap->store, 1179 metadata_sectors;
1180 &numerator, 1180 snap->store->type->usage(snap->store,
1181 &denominator); 1181 &total_sectors,
1182 DMEMIT("%llu/%llu", 1182 &sectors_allocated,
1183 (unsigned long long)numerator, 1183 &metadata_sectors);
1184 (unsigned long long)denominator); 1184 DMEMIT("%llu/%llu %llu",
1185 (unsigned long long)sectors_allocated,
1186 (unsigned long long)total_sectors,
1187 (unsigned long long)metadata_sectors);
1185 } 1188 }
1186 else 1189 else
1187 DMEMIT("Unknown"); 1190 DMEMIT("Unknown");
@@ -1462,7 +1465,7 @@ static struct target_type origin_target = {
1462 1465
1463static struct target_type snapshot_target = { 1466static struct target_type snapshot_target = {
1464 .name = "snapshot", 1467 .name = "snapshot",
1465 .version = {1, 7, 0}, 1468 .version = {1, 8, 0},
1466 .module = THIS_MODULE, 1469 .module = THIS_MODULE,
1467 .ctr = snapshot_ctr, 1470 .ctr = snapshot_ctr,
1468 .dtr = snapshot_dtr, 1471 .dtr = snapshot_dtr,