* [PATCH] dm snapshot: add allocated metadata to snapshot status
@ 2009-10-08 15:54 Mike Snitzer
2009-10-09 11:45 ` Alasdair G Kergon
0 siblings, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2009-10-08 15:54 UTC (permalink / raw)
To: dm-devel
Add metadata usage to the end of the snapshot's status output.
Renamed dm_exception_store_type's 'fraction_full' to 'usage'. Renamed
arguments to be clearer about what is being returned. Also added
'metadata_allocated'.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-exception-store.h | 6 +++---
drivers/md/dm-snap-persistent.c | 15 +++++++++------
drivers/md/dm-snap-transient.c | 14 ++++++++------
drivers/md/dm-snap.c | 17 +++++++++--------
4 files changed, 29 insertions(+), 23 deletions(-)
Index: linux-2.6/drivers/md/dm-exception-store.h
===================================================================
--- linux-2.6.orig/drivers/md/dm-exception-store.h
+++ linux-2.6/drivers/md/dm-exception-store.h
@@ -86,9 +86,9 @@ struct dm_exception_store_type {
/*
* Return how full the snapshot is.
*/
- void (*fraction_full) (struct dm_exception_store *store,
- sector_t *numerator,
- sector_t *denominator);
+ void (*usage) (struct dm_exception_store *store,
+ sector_t *total, sector_t *total_allocated,
+ sector_t *metadata_allocated);
/* For internal device-mapper use only. */
struct list_head list;
Index: linux-2.6/drivers/md/dm-snap-persistent.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-snap-persistent.c
+++ linux-2.6/drivers/md/dm-snap-persistent.c
@@ -489,11 +489,14 @@ static struct pstore *get_info(struct dm
return (struct pstore *) store->context;
}
-static void persistent_fraction_full(struct dm_exception_store *store,
- sector_t *numerator, sector_t *denominator)
+static void persistent_usage(struct dm_exception_store *store,
+ sector_t *total, sector_t *total_allocated,
+ sector_t *metadata_allocated)
{
- *numerator = get_info(store)->next_free * store->chunk_size;
- *denominator = get_dev_size(store->cow->bdev);
+ struct pstore *ps = get_info(store);
+ *total_allocated = ps->next_free * store->chunk_size;
+ *total = get_dev_size(store->cow->bdev);
+ *metadata_allocated = (ps->current_area + 2) * store->chunk_size;
}
static void persistent_dtr(struct dm_exception_store *store)
@@ -738,7 +741,7 @@ static struct dm_exception_store_type _p
.prepare_exception = persistent_prepare_exception,
.commit_exception = persistent_commit_exception,
.drop_snapshot = persistent_drop_snapshot,
- .fraction_full = persistent_fraction_full,
+ .usage = persistent_usage,
.status = persistent_status,
};
@@ -751,7 +754,7 @@ static struct dm_exception_store_type _p
.prepare_exception = persistent_prepare_exception,
.commit_exception = persistent_commit_exception,
.drop_snapshot = persistent_drop_snapshot,
- .fraction_full = persistent_fraction_full,
+ .usage = persistent_usage,
.status = persistent_status,
};
Index: linux-2.6/drivers/md/dm-snap-transient.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-snap-transient.c
+++ linux-2.6/drivers/md/dm-snap-transient.c
@@ -59,11 +59,13 @@ static void transient_commit_exception(s
callback(callback_context, 1);
}
-static void transient_fraction_full(struct dm_exception_store *store,
- sector_t *numerator, sector_t *denominator)
+static void transient_usage(struct dm_exception_store *store,
+ sector_t *total, sector_t *total_allocated,
+ sector_t *metadata_allocated)
{
- *numerator = ((struct transient_c *) store->context)->next_free;
- *denominator = get_dev_size(store->cow->bdev);
+ *total_allocated = ((struct transient_c *) store->context)->next_free;
+ *total = get_dev_size(store->cow->bdev);
+ *metadata_allocated = 0;
}
static int transient_ctr(struct dm_exception_store *store,
@@ -106,7 +108,7 @@ static struct dm_exception_store_type _t
.read_metadata = transient_read_metadata,
.prepare_exception = transient_prepare_exception,
.commit_exception = transient_commit_exception,
- .fraction_full = transient_fraction_full,
+ .usage = transient_usage,
.status = transient_status,
};
@@ -118,7 +120,7 @@ static struct dm_exception_store_type _t
.read_metadata = transient_read_metadata,
.prepare_exception = transient_prepare_exception,
.commit_exception = transient_commit_exception,
- .fraction_full = transient_fraction_full,
+ .usage = transient_usage,
.status = transient_status,
};
Index: linux-2.6/drivers/md/dm-snap.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-snap.c
+++ linux-2.6/drivers/md/dm-snap.c
@@ -1171,14 +1171,15 @@ static int snapshot_status(struct dm_tar
if (!snap->valid)
DMEMIT("Invalid");
else {
- if (snap->store->type->fraction_full) {
- sector_t numerator, denominator;
- snap->store->type->fraction_full(snap->store,
- &numerator,
- &denominator);
- DMEMIT("%llu/%llu",
- (unsigned long long)numerator,
- (unsigned long long)denominator);
+ if (snap->store->type->usage) {
+ sector_t total, total_allocated, metadata_allocated;
+ snap->store->type->usage(snap->store,
+ &total, &total_allocated,
+ &metadata_allocated);
+ DMEMIT("%llu/%llu %llu",
+ (unsigned long long)total_allocated,
+ (unsigned long long)total,
+ (unsigned long long)metadata_allocated);
}
else
DMEMIT("Unknown");
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] dm snapshot: add allocated metadata to snapshot status
2009-10-08 15:54 [PATCH] dm snapshot: add allocated metadata to snapshot status Mike Snitzer
@ 2009-10-09 11:45 ` Alasdair G Kergon
2009-10-09 12:04 ` Alasdair G Kergon
0 siblings, 1 reply; 5+ messages in thread
From: Alasdair G Kergon @ 2009-10-09 11:45 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel
I'm thinking a formula more like:
((current_area - 2) / (exceptions_per_area + 1) + 3
for the number of metadata chunks.
(Untested.)
Try it - then write to the origin one chunk at a time and check the output.
(Add 'current_area' to the status line while you are testing it.)
Alasdair
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm snapshot: add allocated metadata to snapshot status
2009-10-09 11:45 ` Alasdair G Kergon
@ 2009-10-09 12:04 ` Alasdair G Kergon
2009-10-09 12:07 ` Alasdair G Kergon
0 siblings, 1 reply; 5+ messages in thread
From: Alasdair G Kergon @ 2009-10-09 12:04 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel
On Fri, Oct 09, 2009 at 12:45:09PM +0100, Alasdair G Kergon wrote:
> I'm thinking a formula more like:
> ((current_area - 2) / (exceptions_per_area + 1) + 3
> for the number of metadata chunks.
But no - current_area already takes account of the factor (exceptions_per_area
+ 1).
So just current_area + 3?
(The first is 0, plus 2 for the header.)
Alasdair
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] dm snapshot: add allocated metadata to snapshot status
2009-10-09 12:04 ` Alasdair G Kergon
@ 2009-10-09 12:07 ` Alasdair G Kergon
2009-10-09 12:52 ` Mike Snitzer
0 siblings, 1 reply; 5+ messages in thread
From: Alasdair G Kergon @ 2009-10-09 12:07 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel
On Fri, Oct 09, 2009 at 01:04:00PM +0100, Alasdair G Kergon wrote:
> So just current_area + 3?
> (The first is 0, plus 2 for the header.)
But the header is only 1 not 2 chunks, so finally I agree, current_area + 2.
We really should get this documented...
Alasdair
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: dm snapshot: add allocated metadata to snapshot status
2009-10-09 12:07 ` Alasdair G Kergon
@ 2009-10-09 12:52 ` Mike Snitzer
0 siblings, 0 replies; 5+ messages in thread
From: Mike Snitzer @ 2009-10-09 12:52 UTC (permalink / raw)
To: Alasdair G Kergon; +Cc: dm-devel
On Fri, Oct 09 2009 at 8:07am -0400,
Alasdair G Kergon <agk@redhat.com> wrote:
> On Fri, Oct 09, 2009 at 01:04:00PM +0100, Alasdair G Kergon wrote:
> > So just current_area + 3?
> > (The first is 0, plus 2 for the header.)
>
> But the header is only 1 not 2 chunks, so finally I agree, current_area + 2.
>
> We really should get this documented...
:) I see you've taken care of it in your editing tree.
Thanks,
Mike
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-10-09 12:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08 15:54 [PATCH] dm snapshot: add allocated metadata to snapshot status Mike Snitzer
2009-10-09 11:45 ` Alasdair G Kergon
2009-10-09 12:04 ` Alasdair G Kergon
2009-10-09 12:07 ` Alasdair G Kergon
2009-10-09 12:52 ` Mike Snitzer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.