nfs-ganesha 1.4

nfs_ip_stats.h

Go to the documentation of this file.
00001 #ifndef _NFS_IP_STATS_H
00002 #define _NFS_IP_STATS_H
00003 
00004 #include <sys/types.h>
00005 #include <sys/param.h>
00006 
00007 #include "ganesha_rpc.h"
00008 #include <dirent.h>             /* for having MAXNAMLEN */
00009 #include <netdb.h>              /* for having MAXHOSTNAMELEN */
00010 #include "HashData.h"
00011 #include "HashTable.h"
00012 
00013 /* IP/name cache error */
00014 #define IP_NAME_SUCCESS             0
00015 #define IP_NAME_INSERT_MALLOC_ERROR 1
00016 #define IP_NAME_NOT_FOUND           2
00017 #define IP_NAME_NETDB_ERROR         3
00018 
00019 /* IP/stats cache error */
00020 #define IP_STATS_SUCCESS             0
00021 #define IP_STATS_INSERT_MALLOC_ERROR 1
00022 #define IP_STATS_NOT_FOUND           2
00023 #define IP_STATS_NETDB_ERROR         3
00024 
00025 #define IP_NAME_PREALLOC_SIZE      200
00026 
00027 /* NFS IPaddr cache entry structure */
00028 typedef struct nfs_ip_name__
00029 {
00030   time_t timestamp;
00031   char hostname[MAXHOSTNAMELEN];
00032 } nfs_ip_name_t;
00033 
00034 typedef struct nfs_ip_stats__
00035 {
00036   unsigned int nb_call;
00037   unsigned int nb_req_nfs2;
00038   unsigned int nb_req_nfs3;
00039   unsigned int nb_req_nfs4;
00040   unsigned int nb_req_mnt1;
00041   unsigned int nb_req_mnt3;
00042   unsigned int req_mnt1[MNT_V1_NB_COMMAND];
00043   unsigned int req_mnt3[MNT_V3_NB_COMMAND];
00044   unsigned int req_nfs2[NFS_V2_NB_COMMAND];
00045   unsigned int req_nfs3[NFS_V3_NB_COMMAND];
00046 } nfs_ip_stats_t;
00047 
00048 int nfs_ip_name_get(sockaddr_t *ipaddr, char *hostname);
00049 int nfs_ip_name_add(sockaddr_t *ipaddr, char *hostname);
00050 int nfs_ip_name_remove(sockaddr_t *ipaddr);
00051 
00052 int nfs_ip_stats_add(hash_table_t * ht_ip_stats,
00053                      sockaddr_t * ipaddr, pool_t *ip_stats_pool);
00054 
00055 int nfs_ip_stats_incr(hash_table_t * ht_ip_stats,
00056                       sockaddr_t * ipaddr,
00057                       unsigned int nfs_prog,
00058                       unsigned int mnt_prog, struct svc_req *ptr_req);
00059 
00060 int nfs_ip_stats_get(hash_table_t * ht_ip_stats,
00061                      sockaddr_t * ipaddr, nfs_ip_stats_t ** pnfs_ip_stats);
00062 
00063 int nfs_ip_stats_remove(hash_table_t * ht_ip_stats,
00064                         sockaddr_t * ipaddr, pool_t *ip_stats_pool);
00065 void nfs_ip_stats_dump(hash_table_t ** ht_ip_stats,
00066                        unsigned int nb_worker, char *path_stat);
00067 
00068 void nfs_ip_name_get_stats(hash_stat_t * phstat);
00069 int nfs_ip_name_populate(char *path);
00070 
00071 int display_ip_name_key(hash_buffer_t * pbuff, char *str);
00072 int display_ip_name_val(hash_buffer_t * pbuff, char *str);
00073 int compare_ip_name(hash_buffer_t * buff1, hash_buffer_t * buff2);
00074 uint64_t ip_name_rbt_hash_func(hash_parameter_t * p_hparam,
00075                                hash_buffer_t * buffclef);
00076 uint32_t ip_name_value_hash_func(hash_parameter_t * p_hparam,
00077                                  hash_buffer_t * buffclef);
00078 
00079 int display_ip_stats_key(hash_buffer_t * pbuff, char *str);
00080 int display_ip_stats_val(hash_buffer_t * pbuff, char *str);
00081 int compare_ip_stats(hash_buffer_t * buff1, hash_buffer_t * buff2);
00082 uint64_t ip_stats_rbt_hash_func(hash_parameter_t * p_hparam,
00083                                          hash_buffer_t * buffclef);
00084 uint32_t ip_stats_value_hash_func(hash_parameter_t * p_hparam,
00085                                   hash_buffer_t * buffclef);
00086 
00087 #endif