From cc76021548ce16143ebfdced18bda82aad57cc8f Mon Sep 17 00:00:00 2001 From: Adam Hoka Date: Sun, 28 Aug 2011 08:37:19 +0000 Subject: [PATCH] dm - Add method to get inactive table size Sponsored-by: Google Summer of Code --- sys/dev/disk/dm/dm.h | 1 + sys/dev/disk/dm/dm_table.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sys/dev/disk/dm/dm.h b/sys/dev/disk/dm/dm.h index 62d563ad98..0e307e4dfd 100644 --- a/sys/dev/disk/dm/dm.h +++ b/sys/dev/disk/dm/dm.h @@ -331,6 +331,7 @@ int dm_target_snapshot_orig_upcall(dm_table_entry_t *, struct buf *); int dm_table_destroy(dm_table_head_t *, uint8_t); uint64_t dm_table_size(dm_table_head_t *); +uint64_t dm_inactive_table_size(dm_table_head_t *); dm_table_t * dm_table_get_entry(dm_table_head_t *, uint8_t); int dm_table_get_target_count(dm_table_head_t *, uint8_t); void dm_table_release(dm_table_head_t *, uint8_t s); diff --git a/sys/dev/disk/dm/dm_table.c b/sys/dev/disk/dm/dm_table.c index 38850a8fd4..f0c1f9471e 100644 --- a/sys/dev/disk/dm/dm_table.c +++ b/sys/dev/disk/dm/dm_table.c @@ -162,10 +162,10 @@ dm_table_destroy(dm_table_head_t * head, uint8_t table_id) return 0; } /* - * Return length of active table in device. + * Return length of active or inactive table in device. */ -uint64_t -dm_table_size(dm_table_head_t * head) +static uint64_t +_dm_table_size(dm_table_head_t * head, int table) { dm_table_t *tbl; dm_table_entry_t *table_en; @@ -174,7 +174,7 @@ dm_table_size(dm_table_head_t * head) length = 0; - id = dm_table_busy(head, DM_TABLE_ACTIVE); + id = dm_table_busy(head, table); /* Select active table */ tbl = &head->tables[id]; @@ -191,6 +191,19 @@ dm_table_size(dm_table_head_t * head) return length; } + +uint64_t +dm_table_size(dm_table_head_t *head) +{ + return _dm_table_size(head, DM_TABLE_ACTIVE); +} + +uint64_t +dm_inactive_table_size(dm_table_head_t *head) +{ + return _dm_table_size(head, DM_TABLE_INACTIVE); +} + /* * Return > 0 if table is at least one table entry (returns number of entries) * and return 0 if there is not. Target count returned from this function -- 2.41.0