nfs-ganesha 1.4

nfs_stat.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Copyright CEA/DAM/DIF  (2008)
00005  * contributeur : Philippe DENIEL   philippe.deniel@cea.fr
00006  *                Thomas LEIBOVICI  thomas.leibovici@cea.fr
00007  *
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 3 of the License, or (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  * 
00023  * ---------------------------------------
00024  */
00025 
00038 #ifndef _NFS_STAT_H
00039 #define _NFS_STAT_H
00040 
00041 #include <unistd.h>
00042 #include <sys/types.h>
00043 #include <sys/param.h>
00044 #include <time.h>
00045 #include <pthread.h>
00046 #include "ganesha_rpc.h"
00047 #include "LRU_List.h"
00048 #include "HashData.h"
00049 #include "HashTable.h"
00050 #include "fsal.h"
00051 #include "cache_inode.h"
00052 
00053 #define NFS_V2_NB_COMMAND 18
00054 extern char *nfsv2_function_names[];
00055 
00056 #define NFS_V3_NB_COMMAND 22
00057 extern char *nfsv3_function_names[];
00058 
00059 #define NFS_V4_NB_COMMAND 2
00060 extern char *nfsv4_function_names[];
00061 
00062 #define MNT_V1_NB_COMMAND 6
00063 #define MNT_V3_NB_COMMAND 6
00064 extern char *mnt_function_names[];
00065 
00066 #define RQUOTA_NB_COMMAND 5
00067 extern char *rquota_functions_names[];
00068 
00069 #define NFS_V40_NB_OPERATION 39
00070 #define NFS_V41_NB_OPERATION 58
00071 
00072 #define ERR_STAT_NO_ERROR 0
00073 #define ERR_STAT_ERROR    1
00074 
00075 typedef enum nfs_stat_type__
00076 { GANESHA_STAT_SUCCESS = 0,
00077   GANESHA_STAT_DROP = 1
00078 } nfs_stat_type_t;
00079 
00080 /* we support only upto NLMPROC4_UNLOCK */
00081 #define NLM_V4_NB_OPERATION 5
00082 
00083 typedef struct nfs_op_stat_item__
00084 {
00085   unsigned int total;
00086   unsigned int success;
00087   unsigned int failed;
00088 } nfs_op_stat_item_t;
00089 
00090 typedef struct nfs_request_stat_item__
00091 {
00092   unsigned int total;
00093   unsigned int success;
00094   unsigned int dropped;
00095   unsigned int tot_latency;
00096   unsigned int min_latency;
00097   unsigned int max_latency;
00098   unsigned int tot_await_time;
00099 } nfs_request_stat_item_t;
00100 
00101 typedef struct nfs_request_stat__
00102 {
00103   unsigned int nb_mnt1_req;
00104   unsigned int nb_mnt3_req;
00105   unsigned int nb_nfs2_req;
00106   unsigned int nb_nfs3_req;
00107   unsigned int nb_nfs4_req;
00108   unsigned int nb_nfs40_op;
00109   unsigned int nb_nfs41_op;
00110   unsigned int nb_nlm4_req;
00111   unsigned int nb_rquota1_req;
00112   unsigned int nb_rquota2_req;
00113   nfs_request_stat_item_t stat_req_mnt1[MNT_V1_NB_COMMAND];
00114   nfs_request_stat_item_t stat_req_mnt3[MNT_V3_NB_COMMAND];
00115   nfs_request_stat_item_t stat_req_nfs2[NFS_V2_NB_COMMAND];
00116   nfs_request_stat_item_t stat_req_nfs3[NFS_V3_NB_COMMAND];
00117   nfs_request_stat_item_t stat_req_nfs4[NFS_V4_NB_COMMAND];
00118   nfs_op_stat_item_t stat_op_nfs40[NFS_V40_NB_OPERATION];
00119   nfs_op_stat_item_t stat_op_nfs41[NFS_V41_NB_OPERATION];
00120   nfs_request_stat_item_t stat_req_nlm4[NLM_V4_NB_OPERATION];
00121   nfs_request_stat_item_t stat_req_rquota1[RQUOTA_NB_COMMAND];
00122   nfs_request_stat_item_t stat_req_rquota2[RQUOTA_NB_COMMAND];
00123 } nfs_request_stat_t;
00124 
00125 typedef enum
00126 {
00127   SVC_TIME = 0,
00128   AWAIT_TIME
00129 } nfs_stat_latency_type_t;
00130 
00131 typedef struct nfs_request_latency_stat__
00132 {
00133   nfs_stat_latency_type_t type;
00134   unsigned int latency;
00135 } nfs_request_latency_stat_t;
00136 
00137 typedef enum
00138 {
00139   PER_SERVER = 0,
00140   PER_SERVER_DETAIL,
00141   PER_SHARE,
00142   PER_SHARE_DETAIL,
00143   PER_CLIENT,
00144   PER_CLIENTSHARE
00145 } nfs_stat_client_req_type_t;
00146 
00147 typedef struct
00148 {
00149   int nfs_version;
00150   nfs_stat_client_req_type_t stat_type;
00151   char client_name[1024];
00152   char share_path[1024];
00153 } nfs_stat_client_req_t;
00154 
00155 typedef struct nfs_worker_stat__
00156 {
00157   unsigned int nb_total_req;
00158   unsigned int nb_udp_req;
00159   unsigned int nb_tcp_req;
00160   nfs_request_stat_t stat_req;
00161 
00162   time_t last_stat_update;
00163   fsal_statistics_t fsal_stats;
00164 } nfs_worker_stat_t;
00165 
00166 void nfs_stat_update(nfs_stat_type_t type,
00167                      nfs_request_stat_t * pstat_req, struct svc_req *preq,
00168                      nfs_request_latency_stat_t * lstat_req);
00169 
00170 void set_min_latency(nfs_request_stat_item_t *cur_stat, unsigned int val);
00171 
00172 void set_max_latency(nfs_request_stat_item_t *cur_stat, unsigned int val);
00173 
00174 struct timeval time_diff(struct timeval time_from, struct timeval time_to);
00175 
00176 #endif                          /* _NFS_STAT_H */