Change snapshot status line to how full it is as a fraction. [Alasdair Kergon] --- diff/drivers/md/dm-exception-store.c 2003-04-17 17:43:53.000000000 +0100 +++ source/drivers/md/dm-exception-store.c 2003-04-17 17:54:12.000000000 +0100 @@ -427,11 +427,11 @@ return (struct pstore *) store->context; } -static int persistent_percentfull(struct exception_store *store) +static void persistent_fraction_full(struct exception_store *store, + sector_t *numerator, sector_t *denominator) { - struct pstore *ps = get_info(store); - return (ps->next_free * store->snap->chunk_size * 100) / - get_dev_size(store->snap->cow->dev); + *numerator = get_info(store)->next_free * store->snap->chunk_size - 1; + *denominator = get_dev_size(store->snap->cow->dev); } static void persistent_destroy(struct exception_store *store) @@ -625,10 +625,10 @@ store->prepare_exception = persistent_prepare; store->commit_exception = persistent_commit; store->drop_snapshot = persistent_drop; - store->percent_full = persistent_percentfull; + store->fraction_full = persistent_fraction_full; store->context = ps; - return r; + return 0; bad: if (ps) { @@ -678,10 +678,11 @@ callback(callback_context, 1); } -static int transient_percentfull(struct exception_store *store) +static void transient_fraction_full(struct exception_store *store, + sector_t *numerator, sector_t *denominator) { - struct transient_c *tc = (struct transient_c *) store->context; - return (tc->next_free * 100) / get_dev_size(store->snap->cow->dev); + *numerator = ((struct transient_c *) store->context)->next_free; + *denominator = get_dev_size(store->snap->cow->dev); } int dm_create_transient(struct exception_store *store, @@ -693,7 +694,7 @@ store->destroy = transient_destroy; store->prepare_exception = transient_prepare; store->commit_exception = transient_commit; - store->percent_full = transient_percentfull; + store->fraction_full = transient_fraction_full; store->snap = s; tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL); --- diff/drivers/md/dm-snapshot.c 2003-04-17 17:43:53.000000000 +0100 +++ source/drivers/md/dm-snapshot.c 2003-04-17 17:54:12.000000000 +0100 @@ -650,8 +650,13 @@ DMDEBUG("Exception completed successfully."); /* Notify any interested parties */ - if (s->store.percent_full) { - int pc = s->store.percent_full(&s->store); + if (s->store.fraction_full) { + int pc; + sector_t numerator, denominator; + + s->store.fraction_full(&s->store, &numerator, + &denominator); + pc = numerator * 100 / denominator; if (pc >= s->last_percent + WAKE_UP_PERCENT) { dm_table_event(s->table); @@ -947,12 +952,18 @@ if (!snap->valid) snprintf(result, maxlen, "Invalid"); else { - if (snap->store.percent_full) - snprintf(result, maxlen, "%d%%", - snap->store.percent_full(&snap-> - store)); - else + if (!snap->store.fraction_full) snprintf(result, maxlen, "Unknown"); + + else { + sector_t numerator, denominator; + snap->store.fraction_full(&snap->store, + &numerator, + &denominator); + snprintf(result, maxlen, + SECTOR_FORMAT "/" SECTOR_FORMAT, + numerator, denominator); + } } break; --- diff/drivers/md/dm-snapshot.h 2003-04-17 17:52:15.000000000 +0100 +++ source/drivers/md/dm-snapshot.h 2003-04-17 17:54:12.000000000 +0100 @@ -66,9 +66,11 @@ void (*drop_snapshot) (struct exception_store *store); /* - * Return the %age full of the snapshot + * Return how full the snapshot is. */ - int (*percent_full) (struct exception_store *store); + void (*fraction_full) (struct exception_store *store, + sector_t *numerator, + sector_t *denominator); struct dm_snapshot *snap; void *context;