nfs-ganesha 1.4

nfs_dupreq.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 License
00011  * as published by the Free Software Foundation; either version 3 of
00012  * the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * 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
00022  * 02110-1301 USA
00023  *
00024  * ---------------------------------------
00025  */
00026 
00036 #ifndef _NFS_DUPREQ_H
00037 #define _NFS_DUPREQ_H
00038 
00039 #ifdef _SOLARIS
00040 #ifndef _USE_SNMP
00041 typedef unsigned long u_long;
00042 #endif
00043 #endif                          /* _SOLARIS */
00044 
00045 #include "ganesha_rpc.h"
00046 #include "HashData.h"
00047 #include "HashTable.h"
00048 #include "nfs_core.h"
00049 #include "nfs23.h"
00050 #include "nfs4.h"
00051 #include "fsal.h"
00052 #include "nfs_tools.h"
00053 
00054 typedef struct dupreq_key__
00055 {
00056   /* Each NFS request is identified by the client by an xid.
00057    * The same xids can be recycled by the same client or used
00058    * by different clients ... it's too weak to make the dup req
00059    * cache useful. */
00060   long xid;
00061 
00062   /* The IP and port are also used to identify duplicate requests.
00063    * This is much much stronger. */
00064   sockaddr_t addr;
00065 
00066   /* In very rare cases, ip/port/xid is not enough. In databases
00067    * and other specific applications this may be a greater concern.
00068    * In those cases a checksum of the first 200 bytes of the request
00069    * should be used */
00070   int checksum;
00071 } dupreq_key_t;
00072 
00073 typedef struct dupreq_entry__
00074 {
00075   long xid;
00076   sockaddr_t addr;
00077   int checksum;
00078   int ipproto ;
00079 
00080   pthread_mutex_t dupreq_mutex;
00081   int processing; /* if currently being processed, this should be = 1 */
00082 
00083   nfs_res_t res_nfs;
00084   u_long rq_prog;               /* service program number        */
00085   u_long rq_vers;               /* service protocol version      */
00086   u_long rq_proc;
00087   time_t timestamp;
00088 } dupreq_entry_t;
00089 
00090 int compare_req(hash_buffer_t *buff1, hash_buffer_t *buff2);
00091 int print_entry_dupreq(LRU_data_t data, char *str);
00092 int clean_entry_dupreq(LRU_entry_t *pentry, void *addparam);
00093 int nfs_dupreq_gc_function(LRU_entry_t *pentry, void *addparam);
00094 
00095 nfs_res_t nfs_dupreq_get(struct svc_req *req, int *pstatus);
00096 int nfs_dupreq_delete(struct svc_req *req);
00097 int nfs_dupreq_add_not_finished(struct svc_req *req, nfs_res_t *res_nfs);
00098 
00099 int nfs_dupreq_finish(struct svc_req *req, nfs_res_t *p_res_nfs,
00100                       LRU_list_t *lru_dupreq);
00101 
00102 uint32_t dupreq_value_hash_func(hash_parameter_t *p_hparam,
00103                                      hash_buffer_t *buffclef);
00104 uint64_t dupreq_rbt_hash_func(hash_parameter_t *p_hparam, hash_buffer_t *buffclef);
00105 void nfs_dupreq_get_stats(hash_stat_t *phstat_udp, hash_stat_t *phstat_tcp ) ;
00106 
00107 typedef enum dupreq_status
00108 {
00109     DUPREQ_SUCCESS = 0,
00110     DUPREQ_INSERT_MALLOC_ERROR,
00111     DUPREQ_NOT_FOUND,
00112     DUPREQ_BEING_PROCESSED,
00113     DUPREQ_ALREADY_EXISTS,
00114 } dupreq_status_t;
00115 
00116 #endif                          /* _NFS_DUPREQ_H */