X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ovsdb%2Fovsdb.c;h=6b53f4a32878b20cc9ef5e070132a37eaf3e131b;hb=22eb07cd9b1200678d25ca4ffe43fd3b670cc42e;hp=584433c7f7df5182e94fd4d74cc628e73ce7be45;hpb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;p=sliver-openvswitch.git diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c index 584433c7f..6b53f4a32 100644 --- a/ovsdb/ovsdb.c +++ b/ovsdb/ovsdb.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009, 2010, 2011 Nicira, Inc. +/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include "ovsdb-error.h" #include "ovsdb-parser.h" #include "ovsdb-types.h" +#include "simap.h" #include "table.h" #include "transaction.h" @@ -384,6 +385,25 @@ ovsdb_destroy(struct ovsdb *db) } } +/* Adds some memory usage statistics for 'db' into 'usage', for use with + * memory_report(). */ +void +ovsdb_get_memory_usage(const struct ovsdb *db, struct simap *usage) +{ + const struct shash_node *node; + unsigned int cells = 0; + + SHASH_FOR_EACH (node, &db->tables) { + const struct ovsdb_table *table = node->data; + unsigned int n_columns = shash_count(&table->schema->columns); + unsigned int n_rows = hmap_count(&table->rows); + + cells += n_rows * n_columns; + } + + simap_increase(usage, "cells", cells); +} + struct ovsdb_table * ovsdb_get_table(const struct ovsdb *db, const char *name) {