[dm-devel] [PATCH RFC 09/10] dm-dedup: status function
Vasily Tarasov
tarasov at vasily.name
Thu Apr 17 20:48:15 UTC 2014
The status function prints various statistics about a deduplication
target instance.
Signed-off-by: Vasily Tarasov <tarasov at vasily.name>
---
drivers/md/dm-dedup-target.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/drivers/md/dm-dedup-target.c b/drivers/md/dm-dedup-target.c
index 3b3b9ca..b5ba8a5 100644
--- a/drivers/md/dm-dedup-target.c
+++ b/drivers/md/dm-dedup-target.c
@@ -682,6 +682,39 @@ static void dm_dedup_dtr_fn(struct dm_target *ti)
kfree(dc);
}
+static void dm_dedup_status_fn(struct dm_target *ti, status_type_t status_type,
+ unsigned status_flags, char *result, unsigned maxlen)
+{
+ struct dedup_config *dc = ti->private;
+ uint64_t data_total_block_count;
+ uint64_t data_used_block_count;
+ uint64_t data_free_block_count;
+ uint64_t data_actual_block_count;
+ int sz = 0;
+
+ switch (status_type) {
+ case STATUSTYPE_INFO:
+ case STATUSTYPE_TABLE:
+ data_used_block_count = dc->physical_block_counter;
+ data_actual_block_count = dc->logical_block_counter;
+ data_total_block_count = dc->pblocks;
+
+ data_free_block_count =
+ data_total_block_count - data_used_block_count;
+
+ DMEMIT("%llu %llu %llu %llu",
+ data_total_block_count, data_free_block_count,
+ data_used_block_count, data_actual_block_count);
+
+ DMEMIT("%u %s %s", dc->block_size,
+ dc->data_dev->name, dc->metadata_dev->name);
+
+ DMEMIT("%llu %llu %llu %llu %llu %llu",
+ dc->writes, dc->uniqwrites, dc->dupwrites,
+ dc->reads_on_writes, dc->overwrites, dc->newwrites);
+ }
+}
+
static int dm_dedup_endio_fn(struct dm_target *ti, struct bio *bio, int error)
{
if (error || bio_data_dir(bio) != READ)
@@ -699,6 +732,7 @@ static struct target_type dm_dedup_target = {
.dtr = dm_dedup_dtr_fn,
.map = dm_dedup_map_fn,
.end_io = dm_dedup_endio_fn,
+ .status = dm_dedup_status_fn,
};
static int __init dm_dedup_init(void)
--
1.7.1
More information about the dm-devel
mailing list