nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 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 00050 #ifdef HAVE_CONFIG_H 00051 #include "config.h" 00052 #endif 00053 00054 #ifdef _SOLARIS 00055 #include "solaris_port.h" 00056 #endif 00057 00058 #include <stdio.h> 00059 #include <string.h> 00060 #include <pthread.h> 00061 #include <fcntl.h> 00062 #include <sys/file.h> /* for having FNDELAY */ 00063 #include "HashData.h" 00064 #include "HashTable.h" 00065 #include "log.h" 00066 #include "ganesha_rpc.h" 00067 #include "nfs23.h" 00068 #include "nfs4.h" 00069 #include "mount.h" 00070 #include "nfs_core.h" 00071 #include "cache_inode.h" 00072 #include "nfs_exports.h" 00073 #include "nfs_creds.h" 00074 #include "nfs_proto_functions.h" 00075 #include "nfs_tools.h" 00076 #include "nfs_proto_tools.h" 00077 #include "nfs_stat.h" 00078 00092 void nfs_stat_update(nfs_stat_type_t type, 00093 nfs_request_stat_t * pstat_req, struct svc_req *preq, 00094 nfs_request_latency_stat_t * lstat_req) 00095 { 00096 nfs_request_stat_item_t *pitem = NULL; 00097 int up_counter = 1; 00098 00099 /* Don't increase counters when updating await time. */ 00100 if(lstat_req->type == AWAIT_TIME) 00101 { 00102 up_counter = 0; 00103 } 00104 00105 if(preq->rq_prog == nfs_param.core_param.program[P_NFS]) 00106 { 00107 switch (preq->rq_vers) 00108 { 00109 case NFS_V2: 00110 pitem = &pstat_req->stat_req_nfs2[preq->rq_proc]; 00111 if(up_counter) 00112 pstat_req->nb_nfs2_req += 1; 00113 break; 00114 00115 case NFS_V3: 00116 pitem = &pstat_req->stat_req_nfs3[preq->rq_proc]; 00117 if(up_counter) 00118 pstat_req->nb_nfs3_req += 1; 00119 break; 00120 00121 case NFS_V4: 00122 pitem = &pstat_req->stat_req_nfs4[preq->rq_proc]; 00123 if(up_counter) 00124 pstat_req->nb_nfs4_req += 1; 00125 00126 break; 00127 00128 default: 00129 /* Bad vers ? */ 00130 LogCrit(COMPONENT_DISPATCH, 00131 "IMPLEMENTATION ERROR: /!\\ | you should never step here file %s, line %d", 00132 __FILE__, __LINE__); 00133 return; 00134 } 00135 } 00136 else if(preq->rq_prog == nfs_param.core_param.program[P_MNT]) 00137 { 00138 switch (preq->rq_vers) 00139 { 00140 case MOUNT_V1: 00141 pitem = &pstat_req->stat_req_mnt1[preq->rq_proc]; 00142 if(up_counter) 00143 pstat_req->nb_mnt1_req += 1; 00144 break; 00145 00146 case MOUNT_V3: 00147 pitem = &pstat_req->stat_req_mnt3[preq->rq_proc]; 00148 if(up_counter) 00149 pstat_req->nb_mnt3_req += 1; 00150 break; 00151 00152 default: 00153 /* Bad vers ? */ 00154 LogCrit(COMPONENT_DISPATCH, 00155 "IMPLEMENTATION ERROR: /!\\ | you should never step here file %s, line %d", 00156 __FILE__, __LINE__); 00157 return; 00158 } 00159 } 00160 #ifdef _USE_NLM 00161 else if(preq->rq_prog == nfs_param.core_param.program[P_NLM]) 00162 { 00163 switch (preq->rq_vers) 00164 { 00165 case NLM4_VERS: 00166 pitem = &pstat_req->stat_req_nlm4[preq->rq_proc]; 00167 if(up_counter) 00168 pstat_req->nb_nlm4_req += 1; 00169 break; 00170 default: 00171 /* Bad vers ? */ 00172 LogCrit(COMPONENT_DISPATCH, 00173 "IMPLEMENTATION ERROR: /!\\ | you should never step here file %s, line %d", 00174 __FILE__, __LINE__); 00175 return; 00176 } 00177 } 00178 #endif 00179 #ifdef _USE_RQUOTA 00180 else if(preq->rq_prog == nfs_param.core_param.program[P_RQUOTA]) 00181 { 00182 switch (preq->rq_vers) 00183 { 00184 case RQUOTAVERS: 00185 pitem = &pstat_req->stat_req_rquota1[preq->rq_proc]; 00186 if(up_counter) 00187 pstat_req->nb_rquota1_req += 1; 00188 break; 00189 case EXT_RQUOTAVERS: 00190 pitem = &pstat_req->stat_req_rquota2[preq->rq_proc]; 00191 if(up_counter) 00192 pstat_req->nb_rquota2_req += 1; 00193 break; 00194 default: 00195 /* Bad vers ? */ 00196 LogCrit(COMPONENT_DISPATCH, 00197 "IMPLEMENTATION ERROR: /!\\ | you should never step here file %s, line %d", 00198 __FILE__, __LINE__); 00199 return; 00200 } 00201 00202 } 00203 #endif 00204 else 00205 { 00206 /* Bad program ? */ 00207 LogCrit(COMPONENT_DISPATCH, 00208 "IMPLEMENTATION ERROR: /!\\ | you should never step here file %s, line %d", 00209 __FILE__, __LINE__); 00210 return; 00211 } 00212 00213 if(up_counter) 00214 pitem->total += 1; 00215 00216 if(lstat_req->type == SVC_TIME) 00217 { 00218 /* Set the initial value of latencies */ 00219 if(pitem->tot_latency == 0) 00220 { 00221 pitem->max_latency = lstat_req->latency; 00222 pitem->min_latency = lstat_req->latency; 00223 } 00224 00225 /* Update total, min and max latency */ 00226 pitem->tot_latency += lstat_req->latency; 00227 if(lstat_req->latency > pitem->max_latency) 00228 { 00229 pitem->max_latency = lstat_req->latency; 00230 } 00231 else if(lstat_req->latency < pitem->min_latency) 00232 { 00233 pitem->min_latency = lstat_req->latency; 00234 } 00235 } 00236 else if(lstat_req->type == AWAIT_TIME) 00237 { 00238 pitem->tot_await_time += lstat_req->latency; 00239 } 00240 00241 switch (type) 00242 { 00243 case GANESHA_STAT_SUCCESS: 00244 if(up_counter) 00245 pitem->success += 1; 00246 break; 00247 00248 case GANESHA_STAT_DROP: 00249 if(up_counter) 00250 pitem->dropped += 1; 00251 break; 00252 00253 default: 00254 /* Bad type ? */ 00255 LogCrit(COMPONENT_DISPATCH, 00256 "IMPLEMENTATION ERROR: /!\\ | you should never step here file %s, line %u", 00257 __FILE__, __LINE__); 00258 break; 00259 } 00260 00261 return; 00262 00263 } /* nfs_stat_update */