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>
This commit is contained in:
parent
3510cb94ff
commit
985903bb3a
@ -86,9 +86,9 @@ struct dm_exception_store_type {
|
|||||||
/*
|
/*
|
||||||
* Return how full the snapshot is.
|
* Return how full the snapshot is.
|
||||||
*/
|
*/
|
||||||
void (*fraction_full) (struct dm_exception_store *store,
|
void (*usage) (struct dm_exception_store *store,
|
||||||
sector_t *numerator,
|
sector_t *total_sectors, sector_t *sectors_allocated,
|
||||||
sector_t *denominator);
|
sector_t *metadata_sectors);
|
||||||
|
|
||||||
/* For internal device-mapper use only. */
|
/* For internal device-mapper use only. */
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
@ -489,11 +489,22 @@ static struct pstore *get_info(struct dm_exception_store *store)
|
|||||||
return (struct pstore *) store->context;
|
return (struct pstore *) store->context;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void persistent_fraction_full(struct dm_exception_store *store,
|
static void persistent_usage(struct dm_exception_store *store,
|
||||||
sector_t *numerator, sector_t *denominator)
|
sector_t *total_sectors,
|
||||||
|
sector_t *sectors_allocated,
|
||||||
|
sector_t *metadata_sectors)
|
||||||
{
|
{
|
||||||
*numerator = get_info(store)->next_free * store->chunk_size;
|
struct pstore *ps = get_info(store);
|
||||||
*denominator = get_dev_size(store->cow->bdev);
|
|
||||||
|
*sectors_allocated = ps->next_free * store->chunk_size;
|
||||||
|
*total_sectors = get_dev_size(store->cow->bdev);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First chunk is the fixed header.
|
||||||
|
* Then there are (ps->current_area + 1) metadata chunks, each one
|
||||||
|
* separated from the next by ps->exceptions_per_area data chunks.
|
||||||
|
*/
|
||||||
|
*metadata_sectors = (ps->current_area + 2) * store->chunk_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void persistent_dtr(struct dm_exception_store *store)
|
static void persistent_dtr(struct dm_exception_store *store)
|
||||||
@ -738,7 +749,7 @@ static struct dm_exception_store_type _persistent_type = {
|
|||||||
.prepare_exception = persistent_prepare_exception,
|
.prepare_exception = persistent_prepare_exception,
|
||||||
.commit_exception = persistent_commit_exception,
|
.commit_exception = persistent_commit_exception,
|
||||||
.drop_snapshot = persistent_drop_snapshot,
|
.drop_snapshot = persistent_drop_snapshot,
|
||||||
.fraction_full = persistent_fraction_full,
|
.usage = persistent_usage,
|
||||||
.status = persistent_status,
|
.status = persistent_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -751,7 +762,7 @@ static struct dm_exception_store_type _persistent_compat_type = {
|
|||||||
.prepare_exception = persistent_prepare_exception,
|
.prepare_exception = persistent_prepare_exception,
|
||||||
.commit_exception = persistent_commit_exception,
|
.commit_exception = persistent_commit_exception,
|
||||||
.drop_snapshot = persistent_drop_snapshot,
|
.drop_snapshot = persistent_drop_snapshot,
|
||||||
.fraction_full = persistent_fraction_full,
|
.usage = persistent_usage,
|
||||||
.status = persistent_status,
|
.status = persistent_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,11 +59,14 @@ static void transient_commit_exception(struct dm_exception_store *store,
|
|||||||
callback(callback_context, 1);
|
callback(callback_context, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transient_fraction_full(struct dm_exception_store *store,
|
static void transient_usage(struct dm_exception_store *store,
|
||||||
sector_t *numerator, sector_t *denominator)
|
sector_t *total_sectors,
|
||||||
|
sector_t *sectors_allocated,
|
||||||
|
sector_t *metadata_sectors)
|
||||||
{
|
{
|
||||||
*numerator = ((struct transient_c *) store->context)->next_free;
|
*sectors_allocated = ((struct transient_c *) store->context)->next_free;
|
||||||
*denominator = get_dev_size(store->cow->bdev);
|
*total_sectors = get_dev_size(store->cow->bdev);
|
||||||
|
*metadata_sectors = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int transient_ctr(struct dm_exception_store *store,
|
static int transient_ctr(struct dm_exception_store *store,
|
||||||
@ -106,7 +109,7 @@ static struct dm_exception_store_type _transient_type = {
|
|||||||
.read_metadata = transient_read_metadata,
|
.read_metadata = transient_read_metadata,
|
||||||
.prepare_exception = transient_prepare_exception,
|
.prepare_exception = transient_prepare_exception,
|
||||||
.commit_exception = transient_commit_exception,
|
.commit_exception = transient_commit_exception,
|
||||||
.fraction_full = transient_fraction_full,
|
.usage = transient_usage,
|
||||||
.status = transient_status,
|
.status = transient_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,7 +121,7 @@ static struct dm_exception_store_type _transient_compat_type = {
|
|||||||
.read_metadata = transient_read_metadata,
|
.read_metadata = transient_read_metadata,
|
||||||
.prepare_exception = transient_prepare_exception,
|
.prepare_exception = transient_prepare_exception,
|
||||||
.commit_exception = transient_commit_exception,
|
.commit_exception = transient_commit_exception,
|
||||||
.fraction_full = transient_fraction_full,
|
.usage = transient_usage,
|
||||||
.status = transient_status,
|
.status = transient_status,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1174,14 +1174,17 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
|
|||||||
if (!snap->valid)
|
if (!snap->valid)
|
||||||
DMEMIT("Invalid");
|
DMEMIT("Invalid");
|
||||||
else {
|
else {
|
||||||
if (snap->store->type->fraction_full) {
|
if (snap->store->type->usage) {
|
||||||
sector_t numerator, denominator;
|
sector_t total_sectors, sectors_allocated,
|
||||||
snap->store->type->fraction_full(snap->store,
|
metadata_sectors;
|
||||||
&numerator,
|
snap->store->type->usage(snap->store,
|
||||||
&denominator);
|
&total_sectors,
|
||||||
DMEMIT("%llu/%llu",
|
§ors_allocated,
|
||||||
(unsigned long long)numerator,
|
&metadata_sectors);
|
||||||
(unsigned long long)denominator);
|
DMEMIT("%llu/%llu %llu",
|
||||||
|
(unsigned long long)sectors_allocated,
|
||||||
|
(unsigned long long)total_sectors,
|
||||||
|
(unsigned long long)metadata_sectors);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DMEMIT("Unknown");
|
DMEMIT("Unknown");
|
||||||
@ -1462,7 +1465,7 @@ static struct target_type origin_target = {
|
|||||||
|
|
||||||
static struct target_type snapshot_target = {
|
static struct target_type snapshot_target = {
|
||||||
.name = "snapshot",
|
.name = "snapshot",
|
||||||
.version = {1, 7, 0},
|
.version = {1, 8, 0},
|
||||||
.module = THIS_MODULE,
|
.module = THIS_MODULE,
|
||||||
.ctr = snapshot_ctr,
|
.ctr = snapshot_ctr,
|
||||||
.dtr = snapshot_dtr,
|
.dtr = snapshot_dtr,
|
||||||
|
Loading…
Reference in New Issue
Block a user