diff options
| author | Kaushal M <kaushal@redhat.com> | 2012-01-01 15:59:28 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2012-01-27 04:20:04 -0800 | 
| commit | 623919a78a7faac30d1f0df5793681da2c449e32 (patch) | |
| tree | ee213fa96ebf5feb938babf36c34cb7c8d5f6a24 /libglusterfs/src/inode.c | |
| parent | a078235dbede380ca695251e86a1502ca131d816 (diff) | |
cli: Extend "volume status" with statedump info
This patch enhances and extends the "volume status" command with information
obtained from the statedump of the bricks of volumes.
Adds new status types : clients, inode, fd, mem, callpool
The new syntax of "volume status" is,
 #gluster volume status [all|{<volname> [<brickname>]
                         [misc-details|clients|inode|fd|mem|callpool]}]
Change-Id: I8d019718465bbc3de727653a839de7238f45da5c
BUG: 765495
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.com/2637
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Diffstat (limited to 'libglusterfs/src/inode.c')
| -rw-r--r-- | libglusterfs/src/inode.c | 96 | 
1 files changed, 96 insertions, 0 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index c23f0f0e545..4685ec8d255 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -1637,3 +1637,99 @@ inode_table_dump (inode_table_t *itable, char *prefix)          pthread_mutex_unlock(&itable->lock);  } + +void +inode_dump_to_dict (inode_t *inode, char *prefix, dict_t *dict) +{ +        int             ret = -1; +        char            key[GF_DUMP_MAX_BUF_LEN] = {0,}; + +        ret = TRY_LOCK (&inode->lock); +        if (ret) +                return; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.gfid", prefix); +        ret = dict_set_str (dict, key, gf_strdup (uuid_utoa (inode->gfid))); +        if (ret) +                goto out; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.nlookup", prefix); +        ret = dict_set_uint64 (dict, key, inode->nlookup); +        if (ret) +                goto out; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.ref", prefix); +        ret = dict_set_uint32 (dict, key, inode->ref); +        if (ret) +                goto out; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.ia_type", prefix); +        ret = dict_set_int32 (dict, key, inode->ia_type); + +out: +        UNLOCK (&inode->lock); +        return; +} + +void +inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict) +{ +        char            key[GF_DUMP_MAX_BUF_LEN] = {0,}; +        int             ret = 0; +        inode_t         *inode = NULL; +        int             count = 0; + +        ret = pthread_mutex_trylock (&itable->lock); +        if (ret) +                return; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.itable.active_size", prefix); +        ret = dict_set_uint32 (dict, key, itable->active_size); +        if (ret) +                goto out; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.itable.lru_size", prefix); +        ret = dict_set_uint32 (dict, key, itable->lru_size); +        if (ret) +                goto out; + +        memset (key, 0, sizeof (key)); +        snprintf (key, sizeof (key), "%s.itable.purge_size", prefix); +        ret = dict_set_uint32 (dict, key, itable->purge_size); +        if (ret) +                goto out; + +        list_for_each_entry (inode, &itable->active, list) { +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "%s.itable.active%d", prefix, +                          count++); +                inode_dump_to_dict (inode, key, dict); +        } +        count = 0; + +        list_for_each_entry (inode, &itable->lru, list) { +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "%s.itable.lru%d", prefix, +                          count++); +                inode_dump_to_dict (inode, key, dict); +        } +        count = 0; + +        list_for_each_entry (inode, &itable->purge, list) { +                memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "%s.itable.purge%d", prefix, +                          count++); +                inode_dump_to_dict (inode, key, dict); +        } + +out: +        pthread_mutex_unlock (&itable->lock); + +        return; +}  | 
